@namera-ai/cli 0.1.3 → 0.1.4
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/commands/index.mjs +21 -0
- package/dist/commands/index.mjs.map +1 -0
- package/dist/commands/keystore/create.mjs +74 -0
- package/dist/commands/keystore/create.mjs.map +1 -0
- package/dist/commands/keystore/decrypt.mjs +71 -0
- package/dist/commands/keystore/decrypt.mjs.map +1 -0
- package/dist/commands/keystore/import.mjs +84 -0
- package/dist/commands/keystore/import.mjs.map +1 -0
- package/dist/commands/keystore/index.mjs +28 -0
- package/dist/commands/keystore/index.mjs.map +1 -0
- package/dist/commands/keystore/info.mjs +62 -0
- package/dist/commands/keystore/info.mjs.map +1 -0
- package/dist/commands/keystore/list.mjs +46 -0
- package/dist/commands/keystore/list.mjs.map +1 -0
- package/dist/commands/keystore/remove.mjs +51 -0
- package/dist/commands/keystore/remove.mjs.map +1 -0
- package/dist/commands/mcp/index.mjs +13 -0
- package/dist/commands/mcp/index.mjs.map +1 -0
- package/dist/commands/mcp/start.mjs +82 -0
- package/dist/commands/mcp/start.mjs.map +1 -0
- package/dist/commands/schema/index.mjs +53 -0
- package/dist/commands/schema/index.mjs.map +1 -0
- package/dist/commands/session-key/create/index.mjs +87 -0
- package/dist/commands/session-key/create/index.mjs.map +1 -0
- package/dist/commands/session-key/create/prompts/base.mjs +52 -0
- package/dist/commands/session-key/create/prompts/base.mjs.map +1 -0
- package/dist/commands/session-key/create/prompts/call.mjs +85 -0
- package/dist/commands/session-key/create/prompts/call.mjs.map +1 -0
- package/dist/commands/session-key/create/prompts/common.mjs +27 -0
- package/dist/commands/session-key/create/prompts/common.mjs.map +1 -0
- package/dist/commands/session-key/create/prompts/gas.mjs +19 -0
- package/dist/commands/session-key/create/prompts/gas.mjs.map +1 -0
- package/dist/commands/session-key/create/prompts/index.mjs +44 -0
- package/dist/commands/session-key/create/prompts/index.mjs.map +1 -0
- package/dist/commands/session-key/create/prompts/rate-limit.mjs +40 -0
- package/dist/commands/session-key/create/prompts/rate-limit.mjs.map +1 -0
- package/dist/commands/session-key/create/prompts/signature-caller.mjs +26 -0
- package/dist/commands/session-key/create/prompts/signature-caller.mjs.map +1 -0
- package/dist/commands/session-key/create/prompts/timestamp.mjs +32 -0
- package/dist/commands/session-key/create/prompts/timestamp.mjs.map +1 -0
- package/dist/commands/session-key/index.mjs +26 -0
- package/dist/commands/session-key/index.mjs.map +1 -0
- package/dist/commands/session-key/info.mjs +64 -0
- package/dist/commands/session-key/info.mjs.map +1 -0
- package/dist/commands/session-key/list.mjs +54 -0
- package/dist/commands/session-key/list.mjs.map +1 -0
- package/dist/commands/session-key/remove.mjs +51 -0
- package/dist/commands/session-key/remove.mjs.map +1 -0
- package/dist/commands/session-key/status.mjs +64 -0
- package/dist/commands/session-key/status.mjs.map +1 -0
- package/dist/commands/smart-account/create.mjs +94 -0
- package/dist/commands/smart-account/create.mjs.map +1 -0
- package/dist/commands/smart-account/import.mjs +45 -0
- package/dist/commands/smart-account/import.mjs.map +1 -0
- package/dist/commands/smart-account/index.mjs +30 -0
- package/dist/commands/smart-account/index.mjs.map +1 -0
- package/dist/commands/smart-account/info.mjs +66 -0
- package/dist/commands/smart-account/info.mjs.map +1 -0
- package/dist/commands/smart-account/list.mjs +48 -0
- package/dist/commands/smart-account/list.mjs.map +1 -0
- package/dist/commands/smart-account/remove.mjs +54 -0
- package/dist/commands/smart-account/remove.mjs.map +1 -0
- package/dist/commands/smart-account/status.mjs +63 -0
- package/dist/commands/smart-account/status.mjs.map +1 -0
- package/dist/dto/index.mjs +6 -0
- package/dist/dto/keystore.mjs +44 -0
- package/dist/dto/keystore.mjs.map +1 -0
- package/dist/dto/mcp.mjs +13 -0
- package/dist/dto/mcp.mjs.map +1 -0
- package/dist/dto/session-key.mjs +54 -0
- package/dist/dto/session-key.mjs.map +1 -0
- package/dist/dto/smart-account.mjs +45 -0
- package/dist/dto/smart-account.mjs.map +1 -0
- package/dist/flags/global.mjs +29 -0
- package/dist/flags/global.mjs.map +1 -0
- package/dist/flags/shared.mjs +11 -0
- package/dist/flags/shared.mjs.map +1 -0
- package/dist/helpers/humanize.mjs +153 -0
- package/dist/helpers/humanize.mjs.map +1 -0
- package/dist/helpers/paths.mjs +31 -0
- package/dist/helpers/paths.mjs.map +1 -0
- package/dist/helpers/policy.mjs +89 -0
- package/dist/helpers/policy.mjs.map +1 -0
- package/dist/helpers/pretty.mjs +71 -0
- package/dist/helpers/pretty.mjs.map +1 -0
- package/dist/index.mjs +15 -3264
- package/dist/index.mjs.map +1 -1
- package/dist/layers/config.mjs +124 -0
- package/dist/layers/config.mjs.map +1 -0
- package/dist/layers/index.mjs +11 -0
- package/dist/layers/keystore.mjs +225 -0
- package/dist/layers/keystore.mjs.map +1 -0
- package/dist/layers/mcp-context.mjs +8 -0
- package/dist/layers/mcp-context.mjs.map +1 -0
- package/dist/layers/mcp.mjs +31 -0
- package/dist/layers/mcp.mjs.map +1 -0
- package/dist/layers/output.mjs +21 -0
- package/dist/layers/output.mjs.map +1 -0
- package/dist/layers/prompt.mjs +78 -0
- package/dist/layers/prompt.mjs.map +1 -0
- package/dist/layers/session-key.mjs +218 -0
- package/dist/layers/session-key.mjs.map +1 -0
- package/dist/layers/smart-account.mjs +175 -0
- package/dist/layers/smart-account.mjs.map +1 -0
- package/dist/layers/web3.mjs +83 -0
- package/dist/layers/web3.mjs.map +1 -0
- package/dist/mcp/helpers/common.mjs +9 -0
- package/dist/mcp/helpers/common.mjs.map +1 -0
- package/dist/mcp/helpers/index.mjs +4 -0
- package/dist/mcp/helpers/session-key.mjs +129 -0
- package/dist/mcp/helpers/session-key.mjs.map +1 -0
- package/dist/mcp/index.mjs +43 -0
- package/dist/mcp/index.mjs.map +1 -0
- package/dist/mcp/mcp.mjs +15 -0
- package/dist/mcp/mcp.mjs.map +1 -0
- package/dist/mcp/tools/account/address.mjs +20 -0
- package/dist/mcp/tools/account/address.mjs.map +1 -0
- package/dist/mcp/tools/account/get-balance.mjs +54 -0
- package/dist/mcp/tools/account/get-balance.mjs.map +1 -0
- package/dist/mcp/tools/account/index.mjs +15 -0
- package/dist/mcp/tools/account/index.mjs.map +1 -0
- package/dist/mcp/tools/read/index.mjs +11 -0
- package/dist/mcp/tools/read/index.mjs.map +1 -0
- package/dist/mcp/tools/read/read-contract.mjs +49 -0
- package/dist/mcp/tools/read/read-contract.mjs.map +1 -0
- package/dist/mcp/tools/transaction/execute-transaction.mjs +38 -0
- package/dist/mcp/tools/transaction/execute-transaction.mjs.map +1 -0
- package/dist/mcp/tools/transaction/index.mjs +15 -0
- package/dist/mcp/tools/transaction/index.mjs.map +1 -0
- package/dist/mcp/tools/transaction/native-transfer.mjs +59 -0
- package/dist/mcp/tools/transaction/native-transfer.mjs.map +1 -0
- package/dist/schema/chain.mjs +124 -0
- package/dist/schema/chain.mjs.map +1 -0
- package/dist/schema/common.mjs +29 -0
- package/dist/schema/common.mjs.map +1 -0
- package/dist/schema/index.mjs +5 -0
- package/dist/schema/policy.mjs +114 -0
- package/dist/schema/policy.mjs.map +1 -0
- package/dist/schema/tx.mjs +19 -0
- package/dist/schema/tx.mjs.map +1 -0
- package/dist/types/index.mjs +11 -0
- package/dist/types/index.mjs.map +1 -0
- package/package.json +10 -11
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { keystoreCommands } from "./keystore/index.mjs";
|
|
3
|
+
import { mcpCommands } from "./mcp/index.mjs";
|
|
4
|
+
import { schemaCommand } from "./schema/index.mjs";
|
|
5
|
+
import { sessionKeyCommands } from "./session-key/index.mjs";
|
|
6
|
+
import { smartAccountCommands } from "./smart-account/index.mjs";
|
|
7
|
+
//#region src/commands/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* Root CLI command set.
|
|
10
|
+
*/
|
|
11
|
+
const commands = [
|
|
12
|
+
keystoreCommands,
|
|
13
|
+
smartAccountCommands,
|
|
14
|
+
sessionKeyCommands,
|
|
15
|
+
mcpCommands,
|
|
16
|
+
schemaCommand
|
|
17
|
+
];
|
|
18
|
+
//#endregion
|
|
19
|
+
export { commands };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/commands/index.ts"],"sourcesContent":["import { keystoreCommands } from \"./keystore\";\nimport { mcpCommands } from \"./mcp\";\nimport { schemaCommand } from \"./schema\";\nimport { sessionKeyCommands } from \"./session-key\";\nimport { smartAccountCommands } from \"./smart-account\";\n\n/**\n * Root CLI command set.\n */\nexport const commands = [\n keystoreCommands,\n smartAccountCommands,\n sessionKeyCommands,\n mcpCommands,\n schemaCommand,\n] as const;\n"],"mappings":";;;;;;;;;;AASA,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { CreateKeystoreParams } from "../../dto/keystore.mjs";
|
|
3
|
+
import "../../dto/index.mjs";
|
|
4
|
+
import { getGlobalFlags } from "../../flags/global.mjs";
|
|
5
|
+
import { PromptManager } from "../../layers/prompt.mjs";
|
|
6
|
+
import { KeystoreManager } from "../../layers/keystore.mjs";
|
|
7
|
+
import { OutputFormatter } from "../../layers/output.mjs";
|
|
8
|
+
import "../../layers/index.mjs";
|
|
9
|
+
import { Console, Effect, Redacted, Schema } from "effect";
|
|
10
|
+
import { Command, Flag } from "effect/unstable/cli";
|
|
11
|
+
//#region src/commands/keystore/create.ts
|
|
12
|
+
const createKeystoreHandler = (flagAlias, flagPassword) => Effect.gen(function* () {
|
|
13
|
+
const promptManager = yield* PromptManager;
|
|
14
|
+
const keystoreManager = yield* KeystoreManager;
|
|
15
|
+
const outputFormatter = yield* OutputFormatter;
|
|
16
|
+
const globalFlags = yield* getGlobalFlags();
|
|
17
|
+
let params;
|
|
18
|
+
if (globalFlags.params._tag === "Some") params = Schema.decodeUnknownSync(Schema.fromJsonString(CreateKeystoreParams))(globalFlags.params.value);
|
|
19
|
+
else {
|
|
20
|
+
let alias;
|
|
21
|
+
let password;
|
|
22
|
+
if (flagAlias._tag === "Some") alias = flagAlias.value;
|
|
23
|
+
else alias = yield* promptManager.aliasPrompt({
|
|
24
|
+
aliasType: "new",
|
|
25
|
+
message: "Enter alias for keystore:",
|
|
26
|
+
type: "keystore"
|
|
27
|
+
});
|
|
28
|
+
if (flagPassword._tag === "Some") password = flagPassword.value;
|
|
29
|
+
else password = yield* promptManager.passwordPrompt({ message: "Enter password for keystore:" });
|
|
30
|
+
params = {
|
|
31
|
+
alias,
|
|
32
|
+
password: Redacted.value(password)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const res = yield* keystoreManager.createKeystore(params);
|
|
36
|
+
const data = {
|
|
37
|
+
address: res.data.address,
|
|
38
|
+
alias: res.alias,
|
|
39
|
+
path: res.path
|
|
40
|
+
};
|
|
41
|
+
if (globalFlags.quiet) return;
|
|
42
|
+
const output = yield* outputFormatter.format(data, globalFlags.out);
|
|
43
|
+
yield* Console.log(output);
|
|
44
|
+
});
|
|
45
|
+
const alias = Flag.string("alias").pipe(Flag.withDescription("The alias of the keystore to create"), Flag.withAlias("a"), Flag.optional);
|
|
46
|
+
const password = Flag.redacted("password").pipe(Flag.withDescription("The password to encrypt the keystore with"), Flag.withAlias("p"), Flag.optional);
|
|
47
|
+
/**
|
|
48
|
+
* Command that creates a new keystore and stores it locally.
|
|
49
|
+
*/
|
|
50
|
+
const createKeystoreCommand = Command.make("create", {
|
|
51
|
+
alias,
|
|
52
|
+
password
|
|
53
|
+
}, ({ alias, password }) => createKeystoreHandler(alias, password)).pipe(Command.withAlias("c"), Command.withDescription("Creates a random keypair and stores it as keystore"), Command.withExamples([
|
|
54
|
+
{
|
|
55
|
+
command: "namera keystore create -a my-wallet",
|
|
56
|
+
description: "Creates a new keystore with alias 'my-wallet'"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
command: "namera keystore create --alias my-wallet --password my-password",
|
|
60
|
+
description: "Creates a new keystore with alias 'my-wallet' and password 'my-password'"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
command: `namera keystore create --params '{"alias":"my-wallet","password":"my-password"}'`,
|
|
64
|
+
description: "Creates a new keystore with json params"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
command: "namera schema keystore.create",
|
|
68
|
+
description: "Get the schema for the create command"
|
|
69
|
+
}
|
|
70
|
+
]));
|
|
71
|
+
//#endregion
|
|
72
|
+
export { createKeystoreCommand };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=create.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.mjs","names":["PromptManager.PromptManager","KeystoreManager.KeystoreManager","OutputFormatter.OutputFormatter"],"sources":["../../../src/commands/keystore/create.ts"],"sourcesContent":["import { Console, Effect, type Option, Redacted, Schema } from \"effect\";\nimport { Command, Flag } from \"effect/unstable/cli\";\n\nimport { CreateKeystoreParams } from \"@/dto\";\nimport { getGlobalFlags } from \"@/flags/global\";\nimport { KeystoreManager, OutputFormatter, PromptManager } from \"@/layers\";\n\nconst createKeystoreHandler = (\n flagAlias: Option.Option<string>,\n flagPassword: Option.Option<Redacted.Redacted<string>>,\n) =>\n Effect.gen(function* () {\n const promptManager = yield* PromptManager.PromptManager;\n const keystoreManager = yield* KeystoreManager.KeystoreManager;\n const outputFormatter = yield* OutputFormatter.OutputFormatter;\n const globalFlags = yield* getGlobalFlags();\n\n let params: CreateKeystoreParams;\n\n if (globalFlags.params._tag === \"Some\") {\n params = Schema.decodeUnknownSync(\n Schema.fromJsonString(CreateKeystoreParams),\n )(globalFlags.params.value);\n } else {\n let alias: string;\n let password: Redacted.Redacted<string>;\n\n if (flagAlias._tag === \"Some\") {\n alias = flagAlias.value;\n } else {\n alias = yield* promptManager.aliasPrompt({\n aliasType: \"new\",\n message: \"Enter alias for keystore:\",\n type: \"keystore\",\n });\n }\n\n if (flagPassword._tag === \"Some\") {\n password = flagPassword.value;\n } else {\n password = yield* promptManager.passwordPrompt({\n message: \"Enter password for keystore:\",\n });\n }\n\n params = { alias, password: Redacted.value(password) };\n }\n\n const res = yield* keystoreManager.createKeystore(params);\n\n const data = {\n address: res.data.address,\n alias: res.alias,\n path: res.path,\n };\n\n if (globalFlags.quiet) return;\n\n const output = yield* outputFormatter.format(data, globalFlags.out);\n yield* Console.log(output);\n });\n\nconst alias = Flag.string(\"alias\").pipe(\n Flag.withDescription(\"The alias of the keystore to create\"),\n Flag.withAlias(\"a\"),\n Flag.optional,\n);\n\nconst password = Flag.redacted(\"password\").pipe(\n Flag.withDescription(\"The password to encrypt the keystore with\"),\n Flag.withAlias(\"p\"),\n Flag.optional,\n);\n\n/**\n * Command that creates a new keystore and stores it locally.\n */\nexport const createKeystoreCommand = Command.make(\n \"create\",\n { alias, password },\n ({ alias, password }) => createKeystoreHandler(alias, password),\n).pipe(\n Command.withAlias(\"c\"),\n Command.withDescription(\"Creates a random keypair and stores it as keystore\"),\n Command.withExamples([\n {\n command: \"namera keystore create -a my-wallet\",\n description: \"Creates a new keystore with alias 'my-wallet'\",\n },\n {\n command:\n \"namera keystore create --alias my-wallet --password my-password\",\n description:\n \"Creates a new keystore with alias 'my-wallet' and password 'my-password'\",\n },\n {\n command: `namera keystore create --params '{\"alias\":\"my-wallet\",\"password\":\"my-password\"}'`,\n description: \"Creates a new keystore with json params\",\n },\n {\n command: \"namera schema keystore.create\",\n description: \"Get the schema for the create command\",\n },\n ]),\n);\n"],"mappings":";;;;;;;;;;;AAOA,MAAM,yBACJ,WACA,iBAEA,OAAO,IAAI,aAAa;CACtB,MAAM,gBAAgB,OAAOA;CAC7B,MAAM,kBAAkB,OAAOC;CAC/B,MAAM,kBAAkB,OAAOC;CAC/B,MAAM,cAAc,OAAO,gBAAgB;CAE3C,IAAI;AAEJ,KAAI,YAAY,OAAO,SAAS,OAC9B,UAAS,OAAO,kBACd,OAAO,eAAe,qBAAqB,CAC5C,CAAC,YAAY,OAAO,MAAM;MACtB;EACL,IAAI;EACJ,IAAI;AAEJ,MAAI,UAAU,SAAS,OACrB,SAAQ,UAAU;MAElB,SAAQ,OAAO,cAAc,YAAY;GACvC,WAAW;GACX,SAAS;GACT,MAAM;GACP,CAAC;AAGJ,MAAI,aAAa,SAAS,OACxB,YAAW,aAAa;MAExB,YAAW,OAAO,cAAc,eAAe,EAC7C,SAAS,gCACV,CAAC;AAGJ,WAAS;GAAE;GAAO,UAAU,SAAS,MAAM,SAAS;GAAE;;CAGxD,MAAM,MAAM,OAAO,gBAAgB,eAAe,OAAO;CAEzD,MAAM,OAAO;EACX,SAAS,IAAI,KAAK;EAClB,OAAO,IAAI;EACX,MAAM,IAAI;EACX;AAED,KAAI,YAAY,MAAO;CAEvB,MAAM,SAAS,OAAO,gBAAgB,OAAO,MAAM,YAAY,IAAI;AACnE,QAAO,QAAQ,IAAI,OAAO;EAC1B;AAEJ,MAAM,QAAQ,KAAK,OAAO,QAAQ,CAAC,KACjC,KAAK,gBAAgB,sCAAsC,EAC3D,KAAK,UAAU,IAAI,EACnB,KAAK,SACN;AAED,MAAM,WAAW,KAAK,SAAS,WAAW,CAAC,KACzC,KAAK,gBAAgB,4CAA4C,EACjE,KAAK,UAAU,IAAI,EACnB,KAAK,SACN;;;;AAKD,MAAa,wBAAwB,QAAQ,KAC3C,UACA;CAAE;CAAO;CAAU,GAClB,EAAE,OAAO,eAAe,sBAAsB,OAAO,SAAS,CAChE,CAAC,KACA,QAAQ,UAAU,IAAI,EACtB,QAAQ,gBAAgB,qDAAqD,EAC7E,QAAQ,aAAa;CACnB;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SACE;EACF,aACE;EACH;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { DecryptKeystoreParams } from "../../dto/keystore.mjs";
|
|
3
|
+
import "../../dto/index.mjs";
|
|
4
|
+
import { getGlobalFlags } from "../../flags/global.mjs";
|
|
5
|
+
import { PromptManager } from "../../layers/prompt.mjs";
|
|
6
|
+
import { KeystoreManager } from "../../layers/keystore.mjs";
|
|
7
|
+
import { OutputFormatter } from "../../layers/output.mjs";
|
|
8
|
+
import "../../layers/index.mjs";
|
|
9
|
+
import { Console, Effect, Redacted, Schema } from "effect";
|
|
10
|
+
import { Command, Flag } from "effect/unstable/cli";
|
|
11
|
+
//#region src/commands/keystore/decrypt.ts
|
|
12
|
+
const handler = (flagAlias, flagPassword) => Effect.gen(function* () {
|
|
13
|
+
const keystoreManager = yield* KeystoreManager;
|
|
14
|
+
const promptManager = yield* PromptManager;
|
|
15
|
+
const outputFormatter = yield* OutputFormatter;
|
|
16
|
+
const globalFlags = yield* getGlobalFlags();
|
|
17
|
+
let params;
|
|
18
|
+
if (globalFlags.params._tag === "Some") params = Schema.decodeUnknownSync(Schema.fromJsonString(DecryptKeystoreParams))(globalFlags.params.value);
|
|
19
|
+
else {
|
|
20
|
+
let alias;
|
|
21
|
+
let password;
|
|
22
|
+
if (flagAlias._tag === "Some") alias = flagAlias.value;
|
|
23
|
+
else alias = (yield* keystoreManager.selectKeystore({ message: "Select keystore:" })).alias;
|
|
24
|
+
if (flagPassword._tag === "Some") password = flagPassword.value;
|
|
25
|
+
else password = yield* promptManager.passwordPrompt({ message: "Enter password for keystore:" });
|
|
26
|
+
params = {
|
|
27
|
+
alias,
|
|
28
|
+
password: Redacted.value(password)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const res = yield* keystoreManager.decryptKeystore(params);
|
|
32
|
+
const data = {
|
|
33
|
+
alias: res.alias,
|
|
34
|
+
address: res.address,
|
|
35
|
+
publicKey: res.publicKey,
|
|
36
|
+
privateKey: Redacted.value(res.privateKey)
|
|
37
|
+
};
|
|
38
|
+
if (globalFlags.quiet) return;
|
|
39
|
+
const output = yield* outputFormatter.format(data, globalFlags.out);
|
|
40
|
+
yield* Console.log(output);
|
|
41
|
+
});
|
|
42
|
+
const alias = Flag.string("alias").pipe(Flag.withDescription("The alias of the keystore to decrypt"), Flag.withAlias("a"), Flag.optional);
|
|
43
|
+
const password = Flag.redacted("password").pipe(Flag.withDescription("The password to decrypt the keystore with"), Flag.withAlias("p"), Flag.optional);
|
|
44
|
+
/**
|
|
45
|
+
* Command that decrypts a keystore and prints key material.
|
|
46
|
+
*/
|
|
47
|
+
const decryptKeystoreCommand = Command.make("decrypt", {
|
|
48
|
+
alias,
|
|
49
|
+
password
|
|
50
|
+
}, ({ alias, password }) => handler(alias, password)).pipe(Command.withAlias("d"), Command.withDescription("Decrypt a keystore to get the private key"), Command.withExamples([
|
|
51
|
+
{
|
|
52
|
+
command: "namera keystore decrypt",
|
|
53
|
+
description: "Decrypt a keystore with alias and password prompts"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
command: "namera keystore decrypt --alias my-wallet --password my-password",
|
|
57
|
+
description: "Decrypt a keystore with alias and password"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
command: `namera keystore decrypt --params '{"alias":"my-wallet","password":"my-password"}'`,
|
|
61
|
+
description: "Decrypt a keystore with json params"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
command: "namera schema keystore.decrypt",
|
|
65
|
+
description: "Get the schema for the decrypt command"
|
|
66
|
+
}
|
|
67
|
+
]));
|
|
68
|
+
//#endregion
|
|
69
|
+
export { decryptKeystoreCommand };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=decrypt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decrypt.mjs","names":["KeystoreManager.KeystoreManager","PromptManager.PromptManager","OutputFormatter.OutputFormatter"],"sources":["../../../src/commands/keystore/decrypt.ts"],"sourcesContent":["import { Console, Effect, type Option, Redacted, Schema } from \"effect\";\nimport { Command, Flag } from \"effect/unstable/cli\";\n\nimport { DecryptKeystoreParams } from \"@/dto\";\nimport { getGlobalFlags } from \"@/flags/global\";\nimport { KeystoreManager, OutputFormatter, PromptManager } from \"@/layers\";\n\nconst handler = (\n flagAlias: Option.Option<string>,\n flagPassword: Option.Option<Redacted.Redacted<string>>,\n) =>\n Effect.gen(function* () {\n const keystoreManager = yield* KeystoreManager.KeystoreManager;\n const promptManager = yield* PromptManager.PromptManager;\n const outputFormatter = yield* OutputFormatter.OutputFormatter;\n\n const globalFlags = yield* getGlobalFlags();\n\n let params: DecryptKeystoreParams;\n\n if (globalFlags.params._tag === \"Some\") {\n params = Schema.decodeUnknownSync(\n Schema.fromJsonString(DecryptKeystoreParams),\n )(globalFlags.params.value);\n } else {\n let alias: string;\n let password: Redacted.Redacted<string>;\n\n if (flagAlias._tag === \"Some\") {\n alias = flagAlias.value;\n } else {\n const res = yield* keystoreManager.selectKeystore({\n message: \"Select keystore:\",\n });\n alias = res.alias;\n }\n\n if (flagPassword._tag === \"Some\") {\n password = flagPassword.value;\n } else {\n password = yield* promptManager.passwordPrompt({\n message: \"Enter password for keystore:\",\n });\n }\n\n params = { alias, password: Redacted.value(password) };\n }\n\n const res = yield* keystoreManager.decryptKeystore(params);\n\n const data = {\n alias: res.alias,\n address: res.address,\n publicKey: res.publicKey,\n privateKey: Redacted.value(res.privateKey),\n };\n\n if (globalFlags.quiet) return;\n const output = yield* outputFormatter.format(data, globalFlags.out);\n yield* Console.log(output);\n });\n\nconst alias = Flag.string(\"alias\").pipe(\n Flag.withDescription(\"The alias of the keystore to decrypt\"),\n Flag.withAlias(\"a\"),\n Flag.optional,\n);\n\nconst password = Flag.redacted(\"password\").pipe(\n Flag.withDescription(\"The password to decrypt the keystore with\"),\n Flag.withAlias(\"p\"),\n Flag.optional,\n);\n\n/**\n * Command that decrypts a keystore and prints key material.\n */\nexport const decryptKeystoreCommand = Command.make(\n \"decrypt\",\n { alias, password },\n ({ alias, password }) => handler(alias, password),\n).pipe(\n Command.withAlias(\"d\"),\n Command.withDescription(\"Decrypt a keystore to get the private key\"),\n Command.withExamples([\n {\n command: \"namera keystore decrypt\",\n description: \"Decrypt a keystore with alias and password prompts\",\n },\n {\n command:\n \"namera keystore decrypt --alias my-wallet --password my-password\",\n description: \"Decrypt a keystore with alias and password\",\n },\n {\n command: `namera keystore decrypt --params '{\"alias\":\"my-wallet\",\"password\":\"my-password\"}'`,\n description: \"Decrypt a keystore with json params\",\n },\n {\n command: \"namera schema keystore.decrypt\",\n description: \"Get the schema for the decrypt command\",\n },\n ]),\n);\n"],"mappings":";;;;;;;;;;;AAOA,MAAM,WACJ,WACA,iBAEA,OAAO,IAAI,aAAa;CACtB,MAAM,kBAAkB,OAAOA;CAC/B,MAAM,gBAAgB,OAAOC;CAC7B,MAAM,kBAAkB,OAAOC;CAE/B,MAAM,cAAc,OAAO,gBAAgB;CAE3C,IAAI;AAEJ,KAAI,YAAY,OAAO,SAAS,OAC9B,UAAS,OAAO,kBACd,OAAO,eAAe,sBAAsB,CAC7C,CAAC,YAAY,OAAO,MAAM;MACtB;EACL,IAAI;EACJ,IAAI;AAEJ,MAAI,UAAU,SAAS,OACrB,SAAQ,UAAU;MAKlB,UAAQ,OAHW,gBAAgB,eAAe,EAChD,SAAS,oBACV,CAAC,EACU;AAGd,MAAI,aAAa,SAAS,OACxB,YAAW,aAAa;MAExB,YAAW,OAAO,cAAc,eAAe,EAC7C,SAAS,gCACV,CAAC;AAGJ,WAAS;GAAE;GAAO,UAAU,SAAS,MAAM,SAAS;GAAE;;CAGxD,MAAM,MAAM,OAAO,gBAAgB,gBAAgB,OAAO;CAE1D,MAAM,OAAO;EACX,OAAO,IAAI;EACX,SAAS,IAAI;EACb,WAAW,IAAI;EACf,YAAY,SAAS,MAAM,IAAI,WAAW;EAC3C;AAED,KAAI,YAAY,MAAO;CACvB,MAAM,SAAS,OAAO,gBAAgB,OAAO,MAAM,YAAY,IAAI;AACnE,QAAO,QAAQ,IAAI,OAAO;EAC1B;AAEJ,MAAM,QAAQ,KAAK,OAAO,QAAQ,CAAC,KACjC,KAAK,gBAAgB,uCAAuC,EAC5D,KAAK,UAAU,IAAI,EACnB,KAAK,SACN;AAED,MAAM,WAAW,KAAK,SAAS,WAAW,CAAC,KACzC,KAAK,gBAAgB,4CAA4C,EACjE,KAAK,UAAU,IAAI,EACnB,KAAK,SACN;;;;AAKD,MAAa,yBAAyB,QAAQ,KAC5C,WACA;CAAE;CAAO;CAAU,GAClB,EAAE,OAAO,eAAe,QAAQ,OAAO,SAAS,CAClD,CAAC,KACA,QAAQ,UAAU,IAAI,EACtB,QAAQ,gBAAgB,4CAA4C,EACpE,QAAQ,aAAa;CACnB;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SACE;EACF,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { ImportKeystoreParams } from "../../dto/keystore.mjs";
|
|
3
|
+
import "../../dto/index.mjs";
|
|
4
|
+
import { getGlobalFlags } from "../../flags/global.mjs";
|
|
5
|
+
import { PromptManager } from "../../layers/prompt.mjs";
|
|
6
|
+
import { KeystoreManager } from "../../layers/keystore.mjs";
|
|
7
|
+
import { OutputFormatter } from "../../layers/output.mjs";
|
|
8
|
+
import "../../layers/index.mjs";
|
|
9
|
+
import { Console, Effect, Redacted, Schema } from "effect";
|
|
10
|
+
import { Command, Flag } from "effect/unstable/cli";
|
|
11
|
+
//#region src/commands/keystore/import.ts
|
|
12
|
+
const handler = (flagAlias, flagPassword, flagPrivateKey) => Effect.gen(function* () {
|
|
13
|
+
const keystoreManager = yield* KeystoreManager;
|
|
14
|
+
const promptManager = yield* PromptManager;
|
|
15
|
+
const outputFormatter = yield* OutputFormatter;
|
|
16
|
+
const globalFlags = yield* getGlobalFlags();
|
|
17
|
+
let params;
|
|
18
|
+
if (globalFlags.params._tag === "Some") params = Schema.decodeUnknownSync(Schema.fromJsonString(ImportKeystoreParams))(globalFlags.params.value);
|
|
19
|
+
else {
|
|
20
|
+
let alias;
|
|
21
|
+
let password;
|
|
22
|
+
let privateKey;
|
|
23
|
+
if (flagAlias._tag === "Some") alias = flagAlias.value;
|
|
24
|
+
else alias = yield* promptManager.aliasPrompt({
|
|
25
|
+
aliasType: "new",
|
|
26
|
+
message: "Enter alias for keystore:",
|
|
27
|
+
type: "keystore"
|
|
28
|
+
});
|
|
29
|
+
if (flagPassword._tag === "Some") password = flagPassword.value;
|
|
30
|
+
else password = yield* promptManager.passwordPrompt({ message: "Enter password for keystore:" });
|
|
31
|
+
if (flagPrivateKey._tag === "Some") privateKey = flagPrivateKey.value;
|
|
32
|
+
else privateKey = yield* promptManager.hexPrompt({
|
|
33
|
+
redacted: true,
|
|
34
|
+
length: 32,
|
|
35
|
+
message: "Enter private key:"
|
|
36
|
+
});
|
|
37
|
+
params = {
|
|
38
|
+
alias,
|
|
39
|
+
password: Redacted.value(password),
|
|
40
|
+
privateKey: Redacted.value(privateKey)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const res = yield* keystoreManager.importKeystore(params);
|
|
44
|
+
const data = {
|
|
45
|
+
alias: res.alias,
|
|
46
|
+
address: res.data.address,
|
|
47
|
+
path: res.path
|
|
48
|
+
};
|
|
49
|
+
if (globalFlags.quiet) return;
|
|
50
|
+
const output = yield* outputFormatter.format(data, globalFlags.out);
|
|
51
|
+
yield* Console.log(output);
|
|
52
|
+
});
|
|
53
|
+
const alias = Flag.string("alias").pipe(Flag.withDescription("The alias of the keystore to import"), Flag.withAlias("a"), Flag.optional);
|
|
54
|
+
const privateKey = Flag.redacted("private-key").pipe(Flag.withDescription("The private key of the keystore to import"), Flag.optional);
|
|
55
|
+
const password = Flag.redacted("password").pipe(Flag.withDescription("The password to encrypt the keystore with"), Flag.withAlias("p"), Flag.optional);
|
|
56
|
+
/**
|
|
57
|
+
* Command that imports a keystore from a private key.
|
|
58
|
+
*/
|
|
59
|
+
const importKeystoreCommand = Command.make("import", {
|
|
60
|
+
alias,
|
|
61
|
+
privateKey,
|
|
62
|
+
password
|
|
63
|
+
}, ({ alias, password, privateKey }) => handler(alias, password, privateKey)).pipe(Command.withAlias("i"), Command.withDescription("Import a keystore from a private key"), Command.withExamples([
|
|
64
|
+
{
|
|
65
|
+
command: "namera keystore import",
|
|
66
|
+
description: "Import a keystore with interactive prompts"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
command: "namera keystore import --alias my-wallet",
|
|
70
|
+
description: "Import a keystore with alias 'my-wallet'"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
command: "namera keystore import -a my-wallet -p my-password --private-key 0x1234567890abcdef",
|
|
74
|
+
description: "Import a keystore with alias 'my-wallet', password 'my-password', and private key '0x1234567890abcdef'"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
command: "namera schema keystore.import",
|
|
78
|
+
description: "Get the schema for the import command"
|
|
79
|
+
}
|
|
80
|
+
]));
|
|
81
|
+
//#endregion
|
|
82
|
+
export { importKeystoreCommand };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=import.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.mjs","names":["KeystoreManager.KeystoreManager","PromptManager.PromptManager","OutputFormatter.OutputFormatter"],"sources":["../../../src/commands/keystore/import.ts"],"sourcesContent":["import { Console, Effect, type Option, Redacted, Schema } from \"effect\";\nimport { Command, Flag } from \"effect/unstable/cli\";\n\nimport { ImportKeystoreParams } from \"@/dto\";\nimport { getGlobalFlags } from \"@/flags/global\";\nimport { KeystoreManager, OutputFormatter, PromptManager } from \"@/layers\";\n\nconst handler = (\n flagAlias: Option.Option<string>,\n flagPassword: Option.Option<Redacted.Redacted<string>>,\n flagPrivateKey: Option.Option<Redacted.Redacted<string>>,\n) =>\n Effect.gen(function* () {\n const keystoreManager = yield* KeystoreManager.KeystoreManager;\n const promptManager = yield* PromptManager.PromptManager;\n const outputFormatter = yield* OutputFormatter.OutputFormatter;\n\n const globalFlags = yield* getGlobalFlags();\n\n let params: ImportKeystoreParams;\n\n if (globalFlags.params._tag === \"Some\") {\n params = Schema.decodeUnknownSync(\n Schema.fromJsonString(ImportKeystoreParams),\n )(globalFlags.params.value);\n } else {\n let alias: string;\n let password: Redacted.Redacted<string>;\n let privateKey: Redacted.Redacted<string>;\n\n if (flagAlias._tag === \"Some\") {\n alias = flagAlias.value;\n } else {\n const res = yield* promptManager.aliasPrompt({\n aliasType: \"new\",\n message: \"Enter alias for keystore:\",\n type: \"keystore\",\n });\n alias = res;\n }\n\n if (flagPassword._tag === \"Some\") {\n password = flagPassword.value;\n } else {\n password = yield* promptManager.passwordPrompt({\n message: \"Enter password for keystore:\",\n });\n }\n\n if (flagPrivateKey._tag === \"Some\") {\n privateKey = flagPrivateKey.value;\n } else {\n privateKey = yield* promptManager.hexPrompt({\n redacted: true,\n length: 32,\n message: \"Enter private key:\",\n });\n }\n\n params = {\n alias,\n password: Redacted.value(password),\n privateKey: Redacted.value(privateKey),\n };\n }\n\n const res = yield* keystoreManager.importKeystore(params);\n\n const data = {\n alias: res.alias,\n address: res.data.address,\n path: res.path,\n };\n\n if (globalFlags.quiet) return;\n\n const output = yield* outputFormatter.format(data, globalFlags.out);\n yield* Console.log(output);\n });\n\nconst alias = Flag.string(\"alias\").pipe(\n Flag.withDescription(\"The alias of the keystore to import\"),\n Flag.withAlias(\"a\"),\n Flag.optional,\n);\n\nconst privateKey = Flag.redacted(\"private-key\").pipe(\n Flag.withDescription(\"The private key of the keystore to import\"),\n Flag.optional,\n);\n\nconst password = Flag.redacted(\"password\").pipe(\n Flag.withDescription(\"The password to encrypt the keystore with\"),\n Flag.withAlias(\"p\"),\n Flag.optional,\n);\n\n/**\n * Command that imports a keystore from a private key.\n */\nexport const importKeystoreCommand = Command.make(\n \"import\",\n { alias, privateKey, password },\n ({ alias, password, privateKey }) => handler(alias, password, privateKey),\n).pipe(\n Command.withAlias(\"i\"),\n Command.withDescription(\"Import a keystore from a private key\"),\n Command.withExamples([\n {\n command: \"namera keystore import\",\n description: \"Import a keystore with interactive prompts\",\n },\n {\n command: \"namera keystore import --alias my-wallet\",\n description: \"Import a keystore with alias 'my-wallet'\",\n },\n {\n command:\n \"namera keystore import -a my-wallet -p my-password --private-key 0x1234567890abcdef\",\n description:\n \"Import a keystore with alias 'my-wallet', password 'my-password', and private key '0x1234567890abcdef'\",\n },\n {\n command: \"namera schema keystore.import\",\n description: \"Get the schema for the import command\",\n },\n ]),\n);\n"],"mappings":";;;;;;;;;;;AAOA,MAAM,WACJ,WACA,cACA,mBAEA,OAAO,IAAI,aAAa;CACtB,MAAM,kBAAkB,OAAOA;CAC/B,MAAM,gBAAgB,OAAOC;CAC7B,MAAM,kBAAkB,OAAOC;CAE/B,MAAM,cAAc,OAAO,gBAAgB;CAE3C,IAAI;AAEJ,KAAI,YAAY,OAAO,SAAS,OAC9B,UAAS,OAAO,kBACd,OAAO,eAAe,qBAAqB,CAC5C,CAAC,YAAY,OAAO,MAAM;MACtB;EACL,IAAI;EACJ,IAAI;EACJ,IAAI;AAEJ,MAAI,UAAU,SAAS,OACrB,SAAQ,UAAU;MAOlB,SAAQ,OALW,cAAc,YAAY;GAC3C,WAAW;GACX,SAAS;GACT,MAAM;GACP,CAAC;AAIJ,MAAI,aAAa,SAAS,OACxB,YAAW,aAAa;MAExB,YAAW,OAAO,cAAc,eAAe,EAC7C,SAAS,gCACV,CAAC;AAGJ,MAAI,eAAe,SAAS,OAC1B,cAAa,eAAe;MAE5B,cAAa,OAAO,cAAc,UAAU;GAC1C,UAAU;GACV,QAAQ;GACR,SAAS;GACV,CAAC;AAGJ,WAAS;GACP;GACA,UAAU,SAAS,MAAM,SAAS;GAClC,YAAY,SAAS,MAAM,WAAW;GACvC;;CAGH,MAAM,MAAM,OAAO,gBAAgB,eAAe,OAAO;CAEzD,MAAM,OAAO;EACX,OAAO,IAAI;EACX,SAAS,IAAI,KAAK;EAClB,MAAM,IAAI;EACX;AAED,KAAI,YAAY,MAAO;CAEvB,MAAM,SAAS,OAAO,gBAAgB,OAAO,MAAM,YAAY,IAAI;AACnE,QAAO,QAAQ,IAAI,OAAO;EAC1B;AAEJ,MAAM,QAAQ,KAAK,OAAO,QAAQ,CAAC,KACjC,KAAK,gBAAgB,sCAAsC,EAC3D,KAAK,UAAU,IAAI,EACnB,KAAK,SACN;AAED,MAAM,aAAa,KAAK,SAAS,cAAc,CAAC,KAC9C,KAAK,gBAAgB,4CAA4C,EACjE,KAAK,SACN;AAED,MAAM,WAAW,KAAK,SAAS,WAAW,CAAC,KACzC,KAAK,gBAAgB,4CAA4C,EACjE,KAAK,UAAU,IAAI,EACnB,KAAK,SACN;;;;AAKD,MAAa,wBAAwB,QAAQ,KAC3C,UACA;CAAE;CAAO;CAAY;CAAU,GAC9B,EAAE,OAAO,UAAU,iBAAiB,QAAQ,OAAO,UAAU,WAAW,CAC1E,CAAC,KACA,QAAQ,UAAU,IAAI,EACtB,QAAQ,gBAAgB,uCAAuC,EAC/D,QAAQ,aAAa;CACnB;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SACE;EACF,aACE;EACH;CACD;EACE,SAAS;EACT,aAAa;EACd;CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createKeystoreCommand } from "./create.mjs";
|
|
3
|
+
import { decryptKeystoreCommand } from "./decrypt.mjs";
|
|
4
|
+
import { importKeystoreCommand } from "./import.mjs";
|
|
5
|
+
import { getKeystoreInfoCommand } from "./info.mjs";
|
|
6
|
+
import { listKeystoresCommand } from "./list.mjs";
|
|
7
|
+
import { removeKeystoreCommand } from "./remove.mjs";
|
|
8
|
+
import { Effect } from "effect";
|
|
9
|
+
import { CliError, Command } from "effect/unstable/cli";
|
|
10
|
+
//#region src/commands/keystore/index.ts
|
|
11
|
+
/**
|
|
12
|
+
* Command group for keystore-related operations.
|
|
13
|
+
*/
|
|
14
|
+
const keystoreCommands = Command.make("keystore", {}, () => Effect.fail(new CliError.ShowHelp({
|
|
15
|
+
commandPath: ["namera", "keystore"],
|
|
16
|
+
errors: []
|
|
17
|
+
}))).pipe(Command.withDescription("Keystore management utilities."), Command.withAlias("k"), Command.withSubcommands([
|
|
18
|
+
createKeystoreCommand,
|
|
19
|
+
listKeystoresCommand,
|
|
20
|
+
getKeystoreInfoCommand,
|
|
21
|
+
decryptKeystoreCommand,
|
|
22
|
+
importKeystoreCommand,
|
|
23
|
+
removeKeystoreCommand
|
|
24
|
+
]));
|
|
25
|
+
//#endregion
|
|
26
|
+
export { keystoreCommands };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/commands/keystore/index.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { CliError, Command } from \"effect/unstable/cli\";\n\nimport { createKeystoreCommand } from \"./create\";\nimport { decryptKeystoreCommand } from \"./decrypt\";\nimport { importKeystoreCommand } from \"./import\";\nimport { getKeystoreInfoCommand } from \"./info\";\nimport { listKeystoresCommand } from \"./list\";\nimport { removeKeystoreCommand } from \"./remove\";\n\n/**\n * Command group for keystore-related operations.\n */\nexport const keystoreCommands = Command.make(\"keystore\", {}, () =>\n Effect.fail(\n new CliError.ShowHelp({\n commandPath: [\"namera\", \"keystore\"],\n errors: [],\n }),\n ),\n).pipe(\n Command.withDescription(\"Keystore management utilities.\"),\n Command.withAlias(\"k\"),\n Command.withSubcommands([\n createKeystoreCommand,\n listKeystoresCommand,\n getKeystoreInfoCommand,\n decryptKeystoreCommand,\n importKeystoreCommand,\n removeKeystoreCommand,\n ]),\n);\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,mBAAmB,QAAQ,KAAK,YAAY,EAAE,QACzD,OAAO,KACL,IAAI,SAAS,SAAS;CACpB,aAAa,CAAC,UAAU,WAAW;CACnC,QAAQ,EAAE;CACX,CAAC,CACH,CACF,CAAC,KACA,QAAQ,gBAAgB,iCAAiC,EACzD,QAAQ,UAAU,IAAI,EACtB,QAAQ,gBAAgB;CACtB;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,CACH"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { GetKeystoreParams } from "../../dto/keystore.mjs";
|
|
3
|
+
import "../../dto/index.mjs";
|
|
4
|
+
import { getGlobalFlags } from "../../flags/global.mjs";
|
|
5
|
+
import { KeystoreManager } from "../../layers/keystore.mjs";
|
|
6
|
+
import { OutputFormatter } from "../../layers/output.mjs";
|
|
7
|
+
import "../../layers/index.mjs";
|
|
8
|
+
import { Console, Effect, Schema } from "effect";
|
|
9
|
+
import { Command, Flag } from "effect/unstable/cli";
|
|
10
|
+
//#region src/commands/keystore/info.ts
|
|
11
|
+
const getKeystoreInfoHandler = (flagAlias) => Effect.gen(function* () {
|
|
12
|
+
const keystoreManager = yield* KeystoreManager;
|
|
13
|
+
const outputFormatter = yield* OutputFormatter;
|
|
14
|
+
const globalFlags = yield* getGlobalFlags();
|
|
15
|
+
let params;
|
|
16
|
+
if (globalFlags.params._tag === "Some") params = Schema.decodeUnknownSync(Schema.fromJsonString(GetKeystoreParams))(globalFlags.params.value);
|
|
17
|
+
else {
|
|
18
|
+
let alias;
|
|
19
|
+
if (flagAlias._tag === "Some") alias = flagAlias.value;
|
|
20
|
+
else alias = (yield* keystoreManager.selectKeystore({ message: "Select keystore:" })).alias;
|
|
21
|
+
params = { alias };
|
|
22
|
+
}
|
|
23
|
+
const res = yield* keystoreManager.getKeystore(params);
|
|
24
|
+
const data = {
|
|
25
|
+
alias: res.alias,
|
|
26
|
+
address: res.data.address,
|
|
27
|
+
path: res.path
|
|
28
|
+
};
|
|
29
|
+
if (globalFlags.quiet) return;
|
|
30
|
+
const output = yield* outputFormatter.format(data, globalFlags.out);
|
|
31
|
+
yield* Console.log(output);
|
|
32
|
+
});
|
|
33
|
+
const alias = Flag.string("alias").pipe(Flag.withDescription("The alias of the keystore to retrieve"), Flag.withAlias("a"), Flag.optional);
|
|
34
|
+
/**
|
|
35
|
+
* Command that returns metadata for a keystore.
|
|
36
|
+
*/
|
|
37
|
+
const getKeystoreInfoCommand = Command.make("info", { alias }, ({ alias }) => getKeystoreInfoHandler(alias)).pipe(Command.withDescription("Get information about a keystore"), Command.withExamples([
|
|
38
|
+
{
|
|
39
|
+
command: "namera keystore info",
|
|
40
|
+
description: "Get information about a keystore with alias prompt"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
command: "namera keystore info --alias my-wallet",
|
|
44
|
+
description: "Get information about a keystore with alias 'my-wallet'"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
command: `namera keystore info --params '{"alias":"my-wallet"}'`,
|
|
48
|
+
description: "Get information about a keystore with json params"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
command: "namera keystore info --alias my-wallet --output json",
|
|
52
|
+
description: "Get information about a keystore in json format"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
command: "namera schema keystore.info",
|
|
56
|
+
description: "Get the schema for the info command"
|
|
57
|
+
}
|
|
58
|
+
]));
|
|
59
|
+
//#endregion
|
|
60
|
+
export { getKeystoreInfoCommand };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=info.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.mjs","names":["KeystoreManager.KeystoreManager","OutputFormatter.OutputFormatter"],"sources":["../../../src/commands/keystore/info.ts"],"sourcesContent":["import { Console, Effect, type Option, Schema } from \"effect\";\nimport { Command, Flag } from \"effect/unstable/cli\";\n\nimport { GetKeystoreParams } from \"@/dto\";\nimport { getGlobalFlags } from \"@/flags/global\";\nimport { KeystoreManager, OutputFormatter } from \"@/layers\";\n\nconst getKeystoreInfoHandler = (flagAlias: Option.Option<string>) =>\n Effect.gen(function* () {\n const keystoreManager = yield* KeystoreManager.KeystoreManager;\n const outputFormatter = yield* OutputFormatter.OutputFormatter;\n\n const globalFlags = yield* getGlobalFlags();\n\n let params: GetKeystoreParams;\n\n if (globalFlags.params._tag === \"Some\") {\n params = Schema.decodeUnknownSync(\n Schema.fromJsonString(GetKeystoreParams),\n )(globalFlags.params.value);\n } else {\n let alias: string;\n\n if (flagAlias._tag === \"Some\") {\n alias = flagAlias.value;\n } else {\n const res = yield* keystoreManager.selectKeystore({\n message: \"Select keystore:\",\n });\n alias = res.alias;\n }\n\n params = { alias };\n }\n\n const res = yield* keystoreManager.getKeystore(params);\n\n const data = {\n alias: res.alias,\n address: res.data.address,\n path: res.path,\n };\n\n if (globalFlags.quiet) return;\n\n const output = yield* outputFormatter.format(data, globalFlags.out);\n yield* Console.log(output);\n });\n\nconst alias = Flag.string(\"alias\").pipe(\n Flag.withDescription(\"The alias of the keystore to retrieve\"),\n Flag.withAlias(\"a\"),\n Flag.optional,\n);\n\n/**\n * Command that returns metadata for a keystore.\n */\nexport const getKeystoreInfoCommand = Command.make(\n \"info\",\n { alias },\n ({ alias }) => getKeystoreInfoHandler(alias),\n).pipe(\n Command.withDescription(\"Get information about a keystore\"),\n Command.withExamples([\n {\n command: \"namera keystore info\",\n description: \"Get information about a keystore with alias prompt\",\n },\n {\n command: \"namera keystore info --alias my-wallet\",\n description: \"Get information about a keystore with alias 'my-wallet'\",\n },\n {\n command: `namera keystore info --params '{\"alias\":\"my-wallet\"}'`,\n description: \"Get information about a keystore with json params\",\n },\n {\n command: \"namera keystore info --alias my-wallet --output json\",\n description: \"Get information about a keystore in json format\",\n },\n {\n command: \"namera schema keystore.info\",\n description: \"Get the schema for the info command\",\n },\n ]),\n);\n"],"mappings":";;;;;;;;;;AAOA,MAAM,0BAA0B,cAC9B,OAAO,IAAI,aAAa;CACtB,MAAM,kBAAkB,OAAOA;CAC/B,MAAM,kBAAkB,OAAOC;CAE/B,MAAM,cAAc,OAAO,gBAAgB;CAE3C,IAAI;AAEJ,KAAI,YAAY,OAAO,SAAS,OAC9B,UAAS,OAAO,kBACd,OAAO,eAAe,kBAAkB,CACzC,CAAC,YAAY,OAAO,MAAM;MACtB;EACL,IAAI;AAEJ,MAAI,UAAU,SAAS,OACrB,SAAQ,UAAU;MAKlB,UAAQ,OAHW,gBAAgB,eAAe,EAChD,SAAS,oBACV,CAAC,EACU;AAGd,WAAS,EAAE,OAAO;;CAGpB,MAAM,MAAM,OAAO,gBAAgB,YAAY,OAAO;CAEtD,MAAM,OAAO;EACX,OAAO,IAAI;EACX,SAAS,IAAI,KAAK;EAClB,MAAM,IAAI;EACX;AAED,KAAI,YAAY,MAAO;CAEvB,MAAM,SAAS,OAAO,gBAAgB,OAAO,MAAM,YAAY,IAAI;AACnE,QAAO,QAAQ,IAAI,OAAO;EAC1B;AAEJ,MAAM,QAAQ,KAAK,OAAO,QAAQ,CAAC,KACjC,KAAK,gBAAgB,wCAAwC,EAC7D,KAAK,UAAU,IAAI,EACnB,KAAK,SACN;;;;AAKD,MAAa,yBAAyB,QAAQ,KAC5C,QACA,EAAE,OAAO,GACR,EAAE,YAAY,uBAAuB,MAAM,CAC7C,CAAC,KACA,QAAQ,gBAAgB,mCAAmC,EAC3D,QAAQ,aAAa;CACnB;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { getGlobalFlags } from "../../flags/global.mjs";
|
|
3
|
+
import { KeystoreManager } from "../../layers/keystore.mjs";
|
|
4
|
+
import { OutputFormatter } from "../../layers/output.mjs";
|
|
5
|
+
import "../../layers/index.mjs";
|
|
6
|
+
import { Console, Effect } from "effect";
|
|
7
|
+
import { Command } from "effect/unstable/cli";
|
|
8
|
+
//#region src/commands/keystore/list.ts
|
|
9
|
+
const listKeystoreHandler = () => Effect.gen(function* () {
|
|
10
|
+
const keystoreManager = yield* KeystoreManager;
|
|
11
|
+
const outputFormatter = yield* OutputFormatter;
|
|
12
|
+
const globalFlags = yield* getGlobalFlags();
|
|
13
|
+
const data = (yield* keystoreManager.listKeystores()).map((k) => ({
|
|
14
|
+
alias: k.alias,
|
|
15
|
+
address: k.data.address,
|
|
16
|
+
path: k.path
|
|
17
|
+
}));
|
|
18
|
+
if (globalFlags.quiet) return;
|
|
19
|
+
const output = yield* outputFormatter.format(data, globalFlags.out);
|
|
20
|
+
yield* Console.log(output);
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Command that lists all stored keystores.
|
|
24
|
+
*/
|
|
25
|
+
const listKeystoresCommand = Command.make("list", {}, () => listKeystoreHandler()).pipe(Command.withAlias("ls"), Command.withDescription("List all keystores"), Command.withExamples([
|
|
26
|
+
{
|
|
27
|
+
command: "namera keystore list",
|
|
28
|
+
description: "List all keystores"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
command: "namera keystore list --output json",
|
|
32
|
+
description: "List all keystores in json format"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
command: "namera keystore list --output ndjson",
|
|
36
|
+
description: "List all keystores in ndjson format"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
command: "namera schema keystore.list",
|
|
40
|
+
description: "Get the schema for the list command"
|
|
41
|
+
}
|
|
42
|
+
]));
|
|
43
|
+
//#endregion
|
|
44
|
+
export { listKeystoresCommand };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=list.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.mjs","names":["KeystoreManager.KeystoreManager","OutputFormatter.OutputFormatter"],"sources":["../../../src/commands/keystore/list.ts"],"sourcesContent":["import { Console, Effect } from \"effect\";\nimport { Command } from \"effect/unstable/cli\";\n\nimport { getGlobalFlags } from \"@/flags/global\";\nimport { KeystoreManager, OutputFormatter } from \"@/layers\";\n\nconst listKeystoreHandler = () =>\n Effect.gen(function* () {\n const keystoreManager = yield* KeystoreManager.KeystoreManager;\n const outputFormatter = yield* OutputFormatter.OutputFormatter;\n const globalFlags = yield* getGlobalFlags();\n\n const res = yield* keystoreManager.listKeystores();\n\n const data = res.map((k) => ({\n alias: k.alias,\n address: k.data.address,\n path: k.path,\n }));\n\n if (globalFlags.quiet) return;\n\n const output = yield* outputFormatter.format(data, globalFlags.out);\n yield* Console.log(output);\n });\n\n/**\n * Command that lists all stored keystores.\n */\nexport const listKeystoresCommand = Command.make(\"list\", {}, () =>\n listKeystoreHandler(),\n).pipe(\n Command.withAlias(\"ls\"),\n Command.withDescription(\"List all keystores\"),\n Command.withExamples([\n {\n command: \"namera keystore list\",\n description: \"List all keystores\",\n },\n {\n command: \"namera keystore list --output json\",\n description: \"List all keystores in json format\",\n },\n {\n command: \"namera keystore list --output ndjson\",\n description: \"List all keystores in ndjson format\",\n },\n {\n command: \"namera schema keystore.list\",\n description: \"Get the schema for the list command\",\n },\n ]),\n);\n"],"mappings":";;;;;;;;AAMA,MAAM,4BACJ,OAAO,IAAI,aAAa;CACtB,MAAM,kBAAkB,OAAOA;CAC/B,MAAM,kBAAkB,OAAOC;CAC/B,MAAM,cAAc,OAAO,gBAAgB;CAI3C,MAAM,QAAO,OAFM,gBAAgB,eAAe,EAEjC,KAAK,OAAO;EAC3B,OAAO,EAAE;EACT,SAAS,EAAE,KAAK;EAChB,MAAM,EAAE;EACT,EAAE;AAEH,KAAI,YAAY,MAAO;CAEvB,MAAM,SAAS,OAAO,gBAAgB,OAAO,MAAM,YAAY,IAAI;AACnE,QAAO,QAAQ,IAAI,OAAO;EAC1B;;;;AAKJ,MAAa,uBAAuB,QAAQ,KAAK,QAAQ,EAAE,QACzD,qBAAqB,CACtB,CAAC,KACA,QAAQ,UAAU,KAAK,EACvB,QAAQ,gBAAgB,qBAAqB,EAC7C,QAAQ,aAAa;CACnB;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { RemoveKeystoreParams } from "../../dto/keystore.mjs";
|
|
3
|
+
import "../../dto/index.mjs";
|
|
4
|
+
import { getGlobalFlags } from "../../flags/global.mjs";
|
|
5
|
+
import { KeystoreManager } from "../../layers/keystore.mjs";
|
|
6
|
+
import { OutputFormatter } from "../../layers/output.mjs";
|
|
7
|
+
import "../../layers/index.mjs";
|
|
8
|
+
import { Console, Effect, Schema } from "effect";
|
|
9
|
+
import { Command, Flag } from "effect/unstable/cli";
|
|
10
|
+
//#region src/commands/keystore/remove.ts
|
|
11
|
+
const handler = (flagAlias) => Effect.gen(function* () {
|
|
12
|
+
const keystoreManager = yield* KeystoreManager;
|
|
13
|
+
const outputFormatter = yield* OutputFormatter;
|
|
14
|
+
const globalFlags = yield* getGlobalFlags();
|
|
15
|
+
let params;
|
|
16
|
+
if (globalFlags.params._tag === "Some") params = Schema.decodeUnknownSync(Schema.fromJsonString(RemoveKeystoreParams))(globalFlags.params.value);
|
|
17
|
+
else {
|
|
18
|
+
let alias;
|
|
19
|
+
if (flagAlias._tag === "Some") alias = flagAlias.value;
|
|
20
|
+
else alias = (yield* keystoreManager.selectKeystore({ message: "Select keystore:" })).alias;
|
|
21
|
+
params = { alias };
|
|
22
|
+
}
|
|
23
|
+
yield* keystoreManager.removeKeystore(params);
|
|
24
|
+
const data = { success: true };
|
|
25
|
+
if (globalFlags.quiet) return;
|
|
26
|
+
const output = yield* outputFormatter.format(data, globalFlags.out);
|
|
27
|
+
yield* Console.log(output);
|
|
28
|
+
});
|
|
29
|
+
const alias = Flag.string("alias").pipe(Flag.withDescription("The alias of the keystore to remove"), Flag.withAlias("a"), Flag.optional);
|
|
30
|
+
const removeKeystoreCommand = Command.make("remove", { alias }, ({ alias }) => handler(alias)).pipe(Command.withAlias("rm"), Command.withDescription("Remove a keystore"), Command.withExamples([
|
|
31
|
+
{
|
|
32
|
+
command: "namera keystore remove",
|
|
33
|
+
description: "Remove a keystore with alias prompt"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
command: "namera keystore remove --alias my-wallet",
|
|
37
|
+
description: "Remove a keystore with alias 'my-wallet'"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
command: `namera keystore remove --params '{"alias":"my-wallet"}'`,
|
|
41
|
+
description: "Remove a keystore with json params"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
command: "namera schema keystore.remove",
|
|
45
|
+
description: "Get the schema for the remove command"
|
|
46
|
+
}
|
|
47
|
+
]));
|
|
48
|
+
//#endregion
|
|
49
|
+
export { removeKeystoreCommand };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=remove.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.mjs","names":["KeystoreManager.KeystoreManager","OutputFormatter.OutputFormatter"],"sources":["../../../src/commands/keystore/remove.ts"],"sourcesContent":["import { Console, Effect, type Option, Schema } from \"effect\";\nimport { Command, Flag } from \"effect/unstable/cli\";\n\nimport { RemoveKeystoreParams } from \"@/dto\";\nimport { getGlobalFlags } from \"@/flags/global\";\nimport { KeystoreManager, OutputFormatter } from \"@/layers\";\n\nconst handler = (flagAlias: Option.Option<string>) =>\n Effect.gen(function* () {\n const keystoreManager = yield* KeystoreManager.KeystoreManager;\n const outputFormatter = yield* OutputFormatter.OutputFormatter;\n const globalFlags = yield* getGlobalFlags();\n\n let params: RemoveKeystoreParams;\n\n if (globalFlags.params._tag === \"Some\") {\n params = Schema.decodeUnknownSync(\n Schema.fromJsonString(RemoveKeystoreParams),\n )(globalFlags.params.value);\n } else {\n let alias: string;\n\n if (flagAlias._tag === \"Some\") {\n alias = flagAlias.value;\n } else {\n const res = yield* keystoreManager.selectKeystore({\n message: \"Select keystore:\",\n });\n alias = res.alias;\n }\n\n params = { alias };\n }\n\n yield* keystoreManager.removeKeystore(params);\n\n const data = { success: true };\n\n if (globalFlags.quiet) return;\n const output = yield* outputFormatter.format(data, globalFlags.out);\n yield* Console.log(output);\n });\n\nconst alias = Flag.string(\"alias\").pipe(\n Flag.withDescription(\"The alias of the keystore to remove\"),\n Flag.withAlias(\"a\"),\n Flag.optional,\n);\n\nexport const removeKeystoreCommand = Command.make(\n \"remove\",\n { alias },\n ({ alias }) => handler(alias),\n).pipe(\n Command.withAlias(\"rm\"),\n Command.withDescription(\"Remove a keystore\"),\n Command.withExamples([\n {\n command: \"namera keystore remove\",\n description: \"Remove a keystore with alias prompt\",\n },\n {\n command: \"namera keystore remove --alias my-wallet\",\n description: \"Remove a keystore with alias 'my-wallet'\",\n },\n {\n command: `namera keystore remove --params '{\"alias\":\"my-wallet\"}'`,\n description: \"Remove a keystore with json params\",\n },\n {\n command: \"namera schema keystore.remove\",\n description: \"Get the schema for the remove command\",\n },\n ]),\n);\n"],"mappings":";;;;;;;;;;AAOA,MAAM,WAAW,cACf,OAAO,IAAI,aAAa;CACtB,MAAM,kBAAkB,OAAOA;CAC/B,MAAM,kBAAkB,OAAOC;CAC/B,MAAM,cAAc,OAAO,gBAAgB;CAE3C,IAAI;AAEJ,KAAI,YAAY,OAAO,SAAS,OAC9B,UAAS,OAAO,kBACd,OAAO,eAAe,qBAAqB,CAC5C,CAAC,YAAY,OAAO,MAAM;MACtB;EACL,IAAI;AAEJ,MAAI,UAAU,SAAS,OACrB,SAAQ,UAAU;MAKlB,UAAQ,OAHW,gBAAgB,eAAe,EAChD,SAAS,oBACV,CAAC,EACU;AAGd,WAAS,EAAE,OAAO;;AAGpB,QAAO,gBAAgB,eAAe,OAAO;CAE7C,MAAM,OAAO,EAAE,SAAS,MAAM;AAE9B,KAAI,YAAY,MAAO;CACvB,MAAM,SAAS,OAAO,gBAAgB,OAAO,MAAM,YAAY,IAAI;AACnE,QAAO,QAAQ,IAAI,OAAO;EAC1B;AAEJ,MAAM,QAAQ,KAAK,OAAO,QAAQ,CAAC,KACjC,KAAK,gBAAgB,sCAAsC,EAC3D,KAAK,UAAU,IAAI,EACnB,KAAK,SACN;AAED,MAAa,wBAAwB,QAAQ,KAC3C,UACA,EAAE,OAAO,GACR,EAAE,YAAY,QAAQ,MAAM,CAC9B,CAAC,KACA,QAAQ,UAAU,KAAK,EACvB,QAAQ,gBAAgB,oBAAoB,EAC5C,QAAQ,aAAa;CACnB;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACD;EACE,SAAS;EACT,aAAa;EACd;CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { startMcpCommand } from "./start.mjs";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { CliError, Command } from "effect/unstable/cli";
|
|
5
|
+
//#region src/commands/mcp/index.ts
|
|
6
|
+
const mcpCommands = Command.make("mcp", {}, () => Effect.fail(new CliError.ShowHelp({
|
|
7
|
+
commandPath: ["namera", "mcp"],
|
|
8
|
+
errors: []
|
|
9
|
+
}))).pipe(Command.withDescription("Start and manage the Namera MCP server"), Command.withSubcommands([startMcpCommand]));
|
|
10
|
+
//#endregion
|
|
11
|
+
export { mcpCommands };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/commands/mcp/index.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { CliError, Command } from \"effect/unstable/cli\";\n\nimport { startMcpCommand } from \"./start\";\n\nexport const mcpCommands = Command.make(\"mcp\", {}, () =>\n Effect.fail(\n new CliError.ShowHelp({\n commandPath: [\"namera\", \"mcp\"],\n errors: [],\n }),\n ),\n).pipe(\n Command.withDescription(\"Start and manage the Namera MCP server\"),\n Command.withSubcommands([startMcpCommand]),\n);\n"],"mappings":";;;;;AAKA,MAAa,cAAc,QAAQ,KAAK,OAAO,EAAE,QAC/C,OAAO,KACL,IAAI,SAAS,SAAS;CACpB,aAAa,CAAC,UAAU,MAAM;CAC9B,QAAQ,EAAE;CACX,CAAC,CACH,CACF,CAAC,KACA,QAAQ,gBAAgB,yCAAyC,EACjE,QAAQ,gBAAgB,CAAC,gBAAgB,CAAC,CAC3C"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StartMcpServerParams } from "../../dto/mcp.mjs";
|
|
3
|
+
import { getGlobalFlags } from "../../flags/global.mjs";
|
|
4
|
+
import { SmartAccountManager } from "../../layers/smart-account.mjs";
|
|
5
|
+
import { SessionKeyManager } from "../../layers/session-key.mjs";
|
|
6
|
+
import { McpManager } from "../../layers/mcp.mjs";
|
|
7
|
+
import "../../layers/index.mjs";
|
|
8
|
+
import { Effect, Redacted, Schema } from "effect";
|
|
9
|
+
import { Command, Flag } from "effect/unstable/cli";
|
|
10
|
+
//#region src/commands/mcp/start.ts
|
|
11
|
+
const handler = (flagSmartAccount, flagSessionKeys, flagTransport, flagPort) => Effect.gen(function* () {
|
|
12
|
+
const smartAccountManager = yield* SmartAccountManager;
|
|
13
|
+
const sessionKeyManager = yield* SessionKeyManager;
|
|
14
|
+
const mcpManager = yield* McpManager;
|
|
15
|
+
const globalFlags = yield* getGlobalFlags();
|
|
16
|
+
let params;
|
|
17
|
+
if (globalFlags.params._tag === "Some") params = Schema.decodeUnknownSync(Schema.fromJsonString(StartMcpServerParams))(globalFlags.params.value);
|
|
18
|
+
else {
|
|
19
|
+
let smartAccountAlias;
|
|
20
|
+
let sessionKeys = {};
|
|
21
|
+
let transport;
|
|
22
|
+
let port;
|
|
23
|
+
if (flagSmartAccount._tag === "Some") smartAccountAlias = flagSmartAccount.value;
|
|
24
|
+
else smartAccountAlias = (yield* smartAccountManager.selectSmartAccount({ message: "Select smart account to use for the MCP server" })).alias;
|
|
25
|
+
if (flagSessionKeys._tag === "Some") sessionKeys = flagSessionKeys.value;
|
|
26
|
+
else {
|
|
27
|
+
const keys = yield* sessionKeyManager.multiSelectSessionKeys({
|
|
28
|
+
message: "Select session keys to use for the MCP server",
|
|
29
|
+
smartAccount: smartAccountAlias
|
|
30
|
+
});
|
|
31
|
+
for (const key of keys) {
|
|
32
|
+
const pass = yield* sessionKeyManager.getSessionKeyPassword({
|
|
33
|
+
alias: key.alias,
|
|
34
|
+
message: `Enter password for session key ${key.alias}:`
|
|
35
|
+
});
|
|
36
|
+
sessionKeys[key.alias] = Redacted.value(pass);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (flagTransport._tag === "Some") transport = flagTransport.value;
|
|
40
|
+
else transport = "stdio";
|
|
41
|
+
if (flagPort._tag === "Some") port = flagPort.value;
|
|
42
|
+
else port = 8080;
|
|
43
|
+
params = {
|
|
44
|
+
smartAccountAlias,
|
|
45
|
+
sessionKeys,
|
|
46
|
+
transport,
|
|
47
|
+
port
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
yield* mcpManager.startMcpServer(params);
|
|
51
|
+
});
|
|
52
|
+
const smartAccount = Flag.string("smart-account").pipe(Flag.withAlias("sa"), Flag.optional, Flag.withDescription("The smart account alias to use for the MCP server"));
|
|
53
|
+
const sessionKeys = Flag.keyValuePair("session-key").pipe(Flag.withAlias("sk"), Flag.optional, Flag.withDescription("The session key aliases, password pairs to use for the MCP server"));
|
|
54
|
+
const transport = Flag.choice("transport", ["stdio", "http"]).pipe(Flag.withAlias("t"), Flag.optional, Flag.withDescription("The transport to use for the MCP server"));
|
|
55
|
+
const port = Flag.integer("port").pipe(Flag.withAlias("p"), Flag.optional, Flag.withDescription("The port to use for the MCP server when using http transport"));
|
|
56
|
+
const startMcpCommand = Command.make("start", {
|
|
57
|
+
smartAccount,
|
|
58
|
+
sessionKeys,
|
|
59
|
+
transport,
|
|
60
|
+
port
|
|
61
|
+
}, ({ smartAccount, sessionKeys, transport, port }) => handler(smartAccount, sessionKeys, transport, port)).pipe(Command.withAlias("s"), Command.withDescription("Starts the local MCP server."), Command.withExamples([
|
|
62
|
+
{
|
|
63
|
+
command: "namera mcp start --smart-account my-smart --session-key my-key=my-password",
|
|
64
|
+
description: "Starts the local MCP server with a single session key and the default transport"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
command: "namera mcp start --smart-account my-smart --session-key my-key=my-password --transport http --port 8080",
|
|
68
|
+
description: "Starts the local MCP server with a single session key and http transport on port 8080"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
command: "namera mcp start --smart-account my-smart --session-key my-key=my-password --session-key my-other-key=my-other-password",
|
|
72
|
+
description: "Starts the local MCP server with multiple session keys and the default transport"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
command: "namera schema mcp.start",
|
|
76
|
+
description: "Get the schema for the start command"
|
|
77
|
+
}
|
|
78
|
+
]));
|
|
79
|
+
//#endregion
|
|
80
|
+
export { startMcpCommand };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=start.mjs.map
|