feat: script for getting key material (#4829)
### Description Corresponding info on how to use this efficiently, PSA will follow https://www.notion.so/hyperlanexyz/Runbook-83c755f2652943289cf98cd1309487a8?pvs=4#1366d35200d68056b827e9e6115f3ea2 - Prints the private key in a subshell but not in a normal tty - Intended to encourage healthier key habits that don't write keys to the filesystem, as described in the first step of https://discord.com/channels/935678348330434570/1296491706417549413/1301158531667595265 ### Drive-by changes - groups some key related scripts ### Related issues <!-- - Fixes #[issue number here] --> ### Backward compatibility <!-- Are these changes backward compatible? Are there any infrastructure implications, e.g. changes that would prohibit deploying older commits using this infra tooling? Yes/No --> ### Testing <!-- What kind of testing have these changes undergone? None/Manual/Unit Tests -->pull/4873/head
parent
0cd65c5715
commit
85dc14d827
@ -1,6 +1,5 @@ |
|||||||
import { createAgentKeysIfNotExists } from '../src/agents/key-utils.js'; |
import { createAgentKeysIfNotExists } from '../../src/agents/key-utils.js'; |
||||||
|
import { getAgentConfigsBasedOnArgs } from '../agent-utils.js'; |
||||||
import { getAgentConfigsBasedOnArgs } from './agent-utils.js'; |
|
||||||
|
|
||||||
async function main() { |
async function main() { |
||||||
const { agentConfig } = await getAgentConfigsBasedOnArgs(); |
const { agentConfig } = await getAgentConfigsBasedOnArgs(); |
@ -1,6 +1,5 @@ |
|||||||
import { deleteAgentKeys } from '../src/agents/key-utils.js'; |
import { deleteAgentKeys } from '../../src/agents/key-utils.js'; |
||||||
|
import { getAgentConfigsBasedOnArgs } from '../agent-utils.js'; |
||||||
import { getAgentConfigsBasedOnArgs } from './agent-utils.js'; |
|
||||||
|
|
||||||
async function main() { |
async function main() { |
||||||
const { agentConfig } = await getAgentConfigsBasedOnArgs(); |
const { agentConfig } = await getAgentConfigsBasedOnArgs(); |
@ -1,7 +1,6 @@ |
|||||||
import { getAllCloudAgentKeys } from '../src/agents/key-utils.js'; |
import { getAllCloudAgentKeys } from '../../src/agents/key-utils.js'; |
||||||
|
import { getArgs, withContext, withProtocol } from '../agent-utils.js'; |
||||||
import { getArgs, withContext, withProtocol } from './agent-utils.js'; |
import { getConfigsBasedOnArgs } from '../core-utils.js'; |
||||||
import { getConfigsBasedOnArgs } from './core-utils.js'; |
|
||||||
|
|
||||||
async function main() { |
async function main() { |
||||||
const argv = await withProtocol(withContext(getArgs())).argv; |
const argv = await withProtocol(withContext(getArgs())).argv; |
@ -0,0 +1,38 @@ |
|||||||
|
import { getCloudAgentKey } from '../../src/agents/key-utils.js'; |
||||||
|
import { |
||||||
|
getArgs, |
||||||
|
withAgentRole, |
||||||
|
withContext, |
||||||
|
withProtocol, |
||||||
|
} from '../agent-utils.js'; |
||||||
|
import { getConfigsBasedOnArgs } from '../core-utils.js'; |
||||||
|
|
||||||
|
async function main() { |
||||||
|
const argv = await withAgentRole(withContext(getArgs())).argv; |
||||||
|
|
||||||
|
const { agentConfig } = await getConfigsBasedOnArgs(argv); |
||||||
|
|
||||||
|
// As a (very rudimentary) security precaution, we don't print the private key directly to
|
||||||
|
// the console if this script is ran directly.
|
||||||
|
// We only write the private key to the console if it is not a tty, e.g. if
|
||||||
|
// this is being called in a subshell or piped to another command.
|
||||||
|
//
|
||||||
|
// E.g. this will print the private key:
|
||||||
|
// $ echo `yarn tsx infra/scripts/keys/get-key.ts -e mainnet3 --role deployer`
|
||||||
|
// or this too:
|
||||||
|
// $ echo $(yarn tsx infra/scripts/keys/get-key.ts -e mainnet3 --role deployer)
|
||||||
|
// and even this:
|
||||||
|
// $ yarn tsx infra/scripts/keys/get-key.ts -e mainnet3 --role deployer | cat
|
||||||
|
//
|
||||||
|
// But this will not print the private key directly to the shell:
|
||||||
|
// $ yarn tsx infra/scripts/keys/get-key.ts -e mainnet3 --role deployer
|
||||||
|
if (process.stdout.isTTY) { |
||||||
|
console.log('<omitted in tty, use in subshell>'); |
||||||
|
} else { |
||||||
|
const key = getCloudAgentKey(agentConfig, argv.role); |
||||||
|
await key.fetch(); |
||||||
|
console.log(key.privateKey); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
main().catch(console.error); |
@ -1,11 +1,10 @@ |
|||||||
import { AccountConfig, InterchainAccount } from '@hyperlane-xyz/sdk'; |
import { AccountConfig, InterchainAccount } from '@hyperlane-xyz/sdk'; |
||||||
import { Address, eqAddress, isZeroishAddress } from '@hyperlane-xyz/utils'; |
import { Address, eqAddress, isZeroishAddress } from '@hyperlane-xyz/utils'; |
||||||
|
|
||||||
import { chainsToSkip } from '../src/config/chain.js'; |
import { chainsToSkip } from '../../src/config/chain.js'; |
||||||
import { isEthereumProtocolChain } from '../src/utils/utils.js'; |
import { isEthereumProtocolChain } from '../../src/utils/utils.js'; |
||||||
|
import { getArgs as getEnvArgs, withChains } from '../agent-utils.js'; |
||||||
import { getArgs as getEnvArgs, withChains } from './agent-utils.js'; |
import { getEnvironmentConfig, getHyperlaneCore } from '../core-utils.js'; |
||||||
import { getEnvironmentConfig, getHyperlaneCore } from './core-utils.js'; |
|
||||||
|
|
||||||
function getArgs() { |
function getArgs() { |
||||||
return withChains(getEnvArgs()) |
return withChains(getEnvArgs()) |
Loading…
Reference in new issue