@certen.io/cli 0.7.2 → 0.8.0

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/README.md CHANGED
@@ -1,232 +1,234 @@
1
- # `@certen.io/cli`
2
-
3
- The `certen` command line for the [CERTEN Gateway](https://gateway.kompendium.co/reference) —
4
- proof-gated cross-chain execution on Accumulate.
5
-
6
- **Docs: <https://docs.kompendium.co>** · **Portal: <https://gateway.kompendium.co/portal>**
7
-
8
- ```bash
9
- npm install -g @certen.io/cli
10
- ```
11
-
12
- ## From nothing to a proof
13
-
14
- ```bash
15
- certen login # approve this machine once in the portal; the key arrives here
16
- certen init # signing key, identity, funding — created and checked
17
-
18
- certen call --identity <id> --chain base-sepolia --to 0xYourContract \
19
- --fn 'confirm(bytes32)' --arg 0x… --sign-with dev --wait
20
-
21
- certen proof get <intent-id> # the evidence, to hand to a counterparty
22
- ```
23
-
24
- **You never copy an API key.** `certen login` uses the device authorization grant: it prints a
25
- short code, you approve that code in a portal session you already trust, and the CLI collects the
26
- key over its own channel. The secret is never displayed here and never passes through your
27
- clipboard or your shell history.
28
-
29
- `certen init` is idempotent. It creates only what is missing, records the identity id so a later
30
- run reuses it, waits until the identity can actually sign, and tells you if an abstract account
31
- needs gas before it can execute anything.
32
-
33
- Stuck at any point:
34
-
35
- ```bash
36
- certen doctor # names the one thing blocking you, and the command that fixes it
37
- ```
38
-
39
- ### If your gateway predates device authorization
40
-
41
- `certen login` will say so and point at the portal. Mint a key there and hand it over without
42
- putting it in your shell history:
43
-
44
- ```bash
45
- certen auth login --api-key - # reads the key from stdin
46
- ```
47
-
48
- ## Your key never leaves this machine
49
-
50
- `certen keys generate` creates an Ed25519 key, encrypts it with a passphrase (scrypt + AES-256-GCM),
51
- and writes it to `~/.certen/keys/<name>.json` with `0600` permissions. The CLI sends **signatures**
52
- to the gateway. It never sends a private key, and there is no code path that could.
53
-
54
- ```bash
55
- certen keys generate --name dev # prompts for a passphrase (confirmed)
56
- certen keys generate --name ci --no-passphrase # unencrypted; file permissions only
57
- certen keys list # metadata only — never decrypts
58
- certen keys show dev
59
- certen keys verify dev # proves the key decrypts and signs correctly
60
- certen keys sign --name dev --hash <hex> # print a signature, send nothing
61
- certen keys delete dev --yes
62
- certen keys path
63
- ```
64
-
65
- Set `CERTEN_KEY_PASSPHRASE` to skip the prompt in CI. When it is set and there is no TTY, the CLI
66
- uses it; when neither is available it fails with an explanation rather than hanging on a prompt
67
- nobody can see.
68
-
69
- **`certen keys sign` sends nothing anywhere.** It is the air-gapped path: generate on one machine,
70
- carry the hash to it, carry the signature back.
71
-
72
- ## Proof-gated contract calls
73
-
74
- ```bash
75
- certen call --identity <uuid> --chain base-sepolia --to 0xTarget \
76
- --fn 'confirm(bytes32)' --arg 0x… --sign-with dev --wait
77
- ```
78
-
79
- `--fn` takes a Solidity signature and `--arg` repeats positionally. Arguments are checked against
80
- the signature **before** anything is sent — on a proof-gated call, a valid proof of the *wrong*
81
- call is still a valid proof, so a mis-encoded argument is worse than an error.
82
-
83
- The ADI URL, the abstract account (`msg.sender` on chain) and the numeric chain id are all derived
84
- from the identity. You do not supply them, and you should not need to know that omitting them
85
- produces a bodyless 502.
86
-
87
- `--dry-run` prints the intent that would be sent without sending it — also the starting point if
88
- you need a multi-leg intent, which you then pass to `tx create --intent @file.json`.
89
-
90
- ## Transfers
91
-
92
- ```bash
93
- certen tx create --identity <uuid> --to-chain ethereum-sepolia \
94
- --from 0xYourAbstractAccount --to 0xRecipient --amount 0.001 --sign-with dev --wait
95
- ```
96
-
97
- **`--amount` is in WHOLE UNITS.** `1` means one ETH, `0.5` means half. This is the field most
98
- worth reading twice: the gateway documented it as wei until 2026-08-11, and someone sending `1`
99
- meaning one wei moves a whole ETH — which on a funded account succeeds silently.
100
-
101
- `--from` is the identity's abstract account on the source chain; `certen portfolio` shows it.
102
-
103
- If that account has no gas, the CLI refuses before submitting. That refusal is worth having: an
104
- intent from an empty abstract account is accepted, signed and submitted — every step reports
105
- success — and then parks at `anchoring` forever, because the execution leg cannot run on chain.
106
- `--force` overrides it.
107
-
108
- Or drive the steps yourself — useful when the signer is an HSM, another machine, or your own
109
- policy engine:
110
-
111
- ```bash
112
- certen tx create --identity <uuid> ... # returns signing_data.hash_to_sign
113
- certen keys sign --name dev --hash <hash> # or your HSM
114
- certen tx sign <intent-id> --signature <sig> --public-key <pub>
115
- ```
116
-
117
- `--signature`/`--public-key` remain first-class. `--sign-with` is a convenience, not a replacement.
118
-
119
- ## Proofs
120
-
121
- ```bash
122
- certen proof get <intent-id> # also accepts a proof id or a transaction hash
123
- certen proof bundle <proof-id> # the artifact to hand over
124
- certen proof share <proof-id> # a link a counterparty opens without a key of yours
125
- certen proof verify <intent-id> # what was, and was NOT, verified
126
- ```
127
-
128
- `proof verify` reports three separate judgements — inclusion, authorization, outcome — and it can
129
- establish only the first, and only as something the gateway asserted. It says so. Asking the
130
- gateway is not independent verification; to verify without trusting CERTEN, query an Accumulate
131
- node for the receipt and read the execution on the destination chain.
132
-
133
- `proof get` falls back to the Accumulate merkle receipt when the proof-service is unavailable or
134
- when an intent has no `proof_id` — the normal case for governance and authorization transactions.
135
- A 5xx from the proof-service means that service is down, **not** that your proof is missing.
136
-
137
- ## Multi-party approvals
138
-
139
- ```bash
140
- certen pending list
141
- certen pending sign <id> --identity <adi> --vote approve
142
- certen pending submit <request-id> --sign-with dev --hash <hash>
143
- ```
144
-
145
- `--vote` takes `approve`, `reject`, or `abstain` — lowercase strings. Not `accept`, and not a
146
- number.
147
-
148
- ## Everything else
149
-
150
- ```bash
151
- certen chains # what CERTEN is deployed on (no API key needed)
152
- certen whoami # which key, which gateway, what standing
153
- certen identity get <id> | list | link-chain <id> --chain <chain> | retire <id> --yes
154
- certen portfolio # balances across every identity and chain
155
- certen tx status <id> --wait | tx list
156
- certen pricing # everything CERTEN charges for, in one call
157
- certen balance | quote --chain <chain> [--sku <sku>] | fund <amount> --chain <chain>
158
- certen governance add-delegate | set-threshold
159
- certen admin api-keys list | create | rotate | revoke
160
- certen admin audit-log | usage
161
- ```
162
-
163
- Run `certen <group> --help` for the flags on any of them, or `certen --help` for the whole tree
164
- grouped by where you are in the journey.
165
-
166
- ## Chains
167
-
168
- This CLI targets `ethereum-sepolia`, `base-sepolia` and `arbitrum-sepolia`. A chain outside that
169
- set is refused with the reason — and if the gateway genuinely serves it, the refusal says so
170
- rather than claiming it does not exist. `CERTEN_ALLOW_ANY_CHAIN=1` lifts the restriction.
171
-
172
- ## Scripting and AI agents: `--json`
173
-
174
- `--json` turns the CLI into a machine interface. It is a contract, documented in full in
175
- [docs/CLI-CONTRACT.md](../../docs/CLI-CONTRACT.md) and enforced by a conformance suite.
176
-
177
- ```bash
178
- certen --json tx status <id>
179
- # {"ok":true,"data":{"intent_id":"…","status":"completed"}}
180
-
181
- certen --json portfolio
182
- # {"ok":false,"error":{"code":"NETWORK_ERROR","message":"connect ECONNREFUSED","retryable":true,"status":0}}
183
- ```
184
-
185
- - **Exactly one JSON object on stdout**, nothing else. Every human-facing line goes to stderr.
186
- - **Exit codes:** `0` ok · `1` operation failed · `2` usage error · `3` gateway unreachable. Branch on
187
- these instead of parsing text. `3` guarantees nothing was submitted, so a retry cannot
188
- double-execute.
189
- - **`error.retryable`** comes from the SDK's own `CertenError.isRetryable`, so the CLI and the SDK
190
- give an identical retry decision.
191
- - **`certen --help --json`** returns the entire command tree every command, flag and exit code — in
192
- one call.
193
-
194
- Without `--json`, output is the human table format as before. Do not parse it.
195
-
196
- ## Configuration
197
-
198
- | | |
199
- |---|---|
200
- | `CERTEN_API_KEY` | API key. Always wins, so CI never touches the keyring or config file. |
201
- | `CERTEN_API_URL` | Gateway base URL. Defaults to `https://gateway.kompendium.co`. |
202
- | `CERTEN_KEY_PASSPHRASE` | Passphrase for local signing keys. |
203
-
204
- `certen auth login` stores the API key in your OS keyring by default, or in
205
- `~/.certen/config.json` at `0600` with `--no-keyring`.
206
-
207
- ## Things that will bite you
208
-
209
- **Identity creation is asynchronous.** `identity create` returns `202` and provisioning continues.
210
- Poll until the status is terminal, and check `can_sign` — it derives from the on-chain key page, so
211
- it can read `true` while the status is still `creating`.
212
-
213
- **A proof cycle takes 60–110 seconds.** Real validator work, not a tunable delay. Do not wrap it in
214
- a 30-second timeout.
215
-
216
- **Sign the bytes, not the text.** If you are producing signatures outside this CLI: sign the raw
217
- bytes of the hash, do not hash it again, and do not sign the ASCII of the hex string. All three
218
- mistakes produce a well-formed 128-hex signature the gateway rejects. `certen keys sign` handles
219
- this for you.
220
-
221
- ## Documentation
222
-
223
- **<https://docs.kompendium.co>** — getting started, authentication, errors, idempotency, and
224
- task-shaped guides: onboarding an identity, external signing, proof-gating a contract call, M-of-N
225
- panels, and verifying a proof.
226
-
227
- The [live API reference](https://gateway.kompendium.co/reference) is generated from the running
228
- gateway and is authoritative — when a guide and the spec disagree, the spec is right.
229
-
230
- ## License
231
-
232
- MIT
1
+ # `@certen.io/cli`
2
+
3
+ The `certen` command line for the [CERTEN Gateway](https://gateway.kompendium.co/reference) —
4
+ proof-gated cross-chain execution on Accumulate.
5
+
6
+ **Docs: <https://docs.kompendium.co>** · **Portal: <https://gateway.kompendium.co/portal>**
7
+
8
+ ```bash
9
+ npm install -g @certen.io/cli
10
+ ```
11
+
12
+ ## From nothing to a proof
13
+
14
+ ```bash
15
+ certen login # approve this machine once in the portal; the key arrives here
16
+ certen init # signing key, identity, funding — created and checked
17
+
18
+ certen call --identity <id> --chain base-sepolia --to 0xYourContract \
19
+ --fn 'confirm(bytes32)' --arg 0x… --sign-with dev --wait
20
+
21
+ certen proof get <intent-id> # the evidence, to hand to a counterparty
22
+ ```
23
+
24
+ **You never copy an API key.** `certen login` uses the device authorization grant: it prints a
25
+ short code, you approve that code in a portal session you already trust, and the CLI collects the
26
+ key over its own channel. The secret is never displayed here and never passes through your
27
+ clipboard or your shell history.
28
+
29
+ `certen init` is idempotent. It creates only what is missing, records the identity id so a later
30
+ run reuses it, waits until the identity can actually sign, and tells you if an abstract account
31
+ needs gas before it can execute anything.
32
+
33
+ Stuck at any point:
34
+
35
+ ```bash
36
+ certen doctor # names the one thing blocking you, and the command that fixes it
37
+ ```
38
+
39
+ ### If your gateway predates device authorization
40
+
41
+ `certen login` will say so and point at the portal. Mint a key there and hand it over without
42
+ putting it in your shell history:
43
+
44
+ ```bash
45
+ certen auth login --api-key - # reads the key from stdin
46
+ ```
47
+
48
+ ## Your key never leaves this machine
49
+
50
+ `certen keys generate` creates an Ed25519 key, encrypts it with a passphrase (scrypt + AES-256-GCM),
51
+ and writes it to `~/.certen/keys/<name>.json` with `0600` permissions. The CLI sends **signatures**
52
+ to the gateway. It never sends a private key, and there is no code path that could.
53
+
54
+ ```bash
55
+ certen keys generate --name dev # prompts for a passphrase (confirmed)
56
+ certen keys generate --name ci --no-passphrase # unencrypted; file permissions only
57
+ certen keys list # metadata only — never decrypts
58
+ certen keys show dev
59
+ certen keys verify dev # proves the key decrypts and signs correctly
60
+ certen keys sign --name dev --hash <hex> # print a signature, send nothing
61
+ certen keys delete dev --yes
62
+ certen keys path
63
+ ```
64
+
65
+ Set `CERTEN_KEY_PASSPHRASE` to skip the prompt in CI. When it is set and there is no TTY, the CLI
66
+ uses it; when neither is available it fails with an explanation rather than hanging on a prompt
67
+ nobody can see.
68
+
69
+ **`certen keys sign` sends nothing anywhere.** It is the air-gapped path: generate on one machine,
70
+ carry the hash to it, carry the signature back.
71
+
72
+ ## Proof-gated contract calls
73
+
74
+ ```bash
75
+ certen call --identity <uuid> --chain base-sepolia --to 0xTarget \
76
+ --fn 'confirm(bytes32)' --arg 0x… --sign-with dev --wait
77
+ ```
78
+
79
+ `--fn` takes a Solidity signature and `--arg` repeats positionally. Arguments are checked against
80
+ the signature **before** anything is sent — on a proof-gated call, a valid proof of the *wrong*
81
+ call is still a valid proof, so a mis-encoded argument is worse than an error.
82
+
83
+ The ADI URL, the abstract account (`msg.sender` on chain) and the numeric chain id are all derived
84
+ from the identity. You do not supply them, and you should not need to know that omitting them
85
+ produces a bodyless 502.
86
+
87
+ `--dry-run` prints the intent that would be sent without sending it — also the starting point if
88
+ you need a multi-leg intent, which you then pass to `tx create --intent @file.json`.
89
+
90
+ ## Transfers
91
+
92
+ ```bash
93
+ certen tx create --identity <uuid> --to-chain ethereum-sepolia \
94
+ --from 0xYourAbstractAccount --to 0xRecipient --amount 0.001 --sign-with dev --wait
95
+ ```
96
+
97
+ **`--amount` is in WHOLE UNITS.** `1` means one ETH, `0.5` means half. This is the field most
98
+ worth reading twice: the gateway documented it as wei until 2026-08-11, and someone sending `1`
99
+ meaning one wei moves a whole ETH — which on a funded account succeeds silently.
100
+
101
+ `--from` is the identity's abstract account on the source chain; `certen portfolio` shows it.
102
+
103
+ If that account has no gas, the CLI refuses before submitting. That refusal is worth having: an
104
+ intent from an empty abstract account is accepted, signed and submitted — every step reports
105
+ success — and then parks at `anchoring` forever, because the execution leg cannot run on chain.
106
+ `--force` overrides it.
107
+
108
+ Or drive the steps yourself — useful when the signer is an HSM, another machine, or your own
109
+ policy engine:
110
+
111
+ ```bash
112
+ certen tx create --identity <uuid> ... # returns signing_data.hash_to_sign
113
+ certen keys sign --name dev --hash <hash> # or your HSM
114
+ certen tx sign <intent-id> --signature <sig> --public-key <pub>
115
+ ```
116
+
117
+ `--signature`/`--public-key` remain first-class. `--sign-with` is a convenience, not a replacement.
118
+
119
+ ## Proofs
120
+
121
+ ```bash
122
+ certen proof get <intent-id> # also accepts a proof id or a transaction hash
123
+ certen proof bundle <proof-id> # the artifact to hand over
124
+ certen proof share <proof-id> # a link a counterparty opens without a key of yours
125
+ certen proof verify <intent-id> # what was, and was NOT, verified
126
+ ```
127
+
128
+ `proof verify` reports three separate judgements — inclusion, authorization, outcome — and it can
129
+ establish only the first, and only as something the gateway asserted. It says so. Asking the
130
+ gateway is not independent verification; to verify without trusting CERTEN, query an Accumulate
131
+ node for the receipt and read the execution on the destination chain.
132
+
133
+ `proof get` falls back to the Accumulate merkle receipt when the proof-service is unavailable or
134
+ when an intent has no `proof_id` — the normal case for governance and authorization transactions.
135
+ A 5xx from the proof-service means that service is down, **not** that your proof is missing.
136
+
137
+ ## Multi-party approvals
138
+
139
+ ```bash
140
+ certen pending list
141
+ certen pending sign <id> --identity <adi> --vote approve
142
+ certen pending submit <request-id> --sign-with dev --hash <hash>
143
+ ```
144
+
145
+ `--vote` takes `approve`, `reject`, or `abstain` — lowercase strings. Not `accept`, and not a
146
+ number.
147
+
148
+ ## Everything else
149
+
150
+ ```bash
151
+ certen chains # what CERTEN is deployed on (no API key needed)
152
+ certen whoami # which key, which gateway, what standing
153
+ certen identity get <id> | list | link-chain <id> --chain <chain> | retire <id> --yes
154
+ certen portfolio # balances across every identity and chain
155
+ certen tx status <id> --wait | tx list
156
+ certen pricing # everything CERTEN charges for, in one call
157
+ certen balance | quote --chain <chain> [--sku <sku>] | fund <amount> --chain <chain>
158
+ certen governance add-key | remove-key | set-threshold | add-authority | remove-authority | add-delegate | sign
159
+ # --sign-with <key> signs and submits in one step; add-authority is how
160
+ # a policy signer becomes a required co-signer on an agent
161
+ certen admin api-keys list | create | rotate | revoke
162
+ certen admin audit-log | usage
163
+ ```
164
+
165
+ Run `certen <group> --help` for the flags on any of them, or `certen --help` for the whole tree
166
+ grouped by where you are in the journey.
167
+
168
+ ## Chains
169
+
170
+ This CLI targets `ethereum-sepolia`, `base-sepolia` and `arbitrum-sepolia`. A chain outside that
171
+ set is refused with the reason — and if the gateway genuinely serves it, the refusal says so
172
+ rather than claiming it does not exist. `CERTEN_ALLOW_ANY_CHAIN=1` lifts the restriction.
173
+
174
+ ## Scripting and AI agents: `--json`
175
+
176
+ `--json` turns the CLI into a machine interface. It is a contract, documented in full in
177
+ [docs/CLI-CONTRACT.md](../../docs/CLI-CONTRACT.md) and enforced by a conformance suite.
178
+
179
+ ```bash
180
+ certen --json tx status <id>
181
+ # {"ok":true,"data":{"intent_id":"…","status":"completed"}}
182
+
183
+ certen --json portfolio
184
+ # {"ok":false,"error":{"code":"NETWORK_ERROR","message":"connect ECONNREFUSED","retryable":true,"status":0}}
185
+ ```
186
+
187
+ - **Exactly one JSON object on stdout**, nothing else. Every human-facing line goes to stderr.
188
+ - **Exit codes:** `0` ok · `1` operation failed · `2` usage error · `3` gateway unreachable. Branch on
189
+ these instead of parsing text. `3` guarantees nothing was submitted, so a retry cannot
190
+ double-execute.
191
+ - **`error.retryable`** comes from the SDK's own `CertenError.isRetryable`, so the CLI and the SDK
192
+ give an identical retry decision.
193
+ - **`certen --help --json`** returns the entire command tree — every command, flag and exit code — in
194
+ one call.
195
+
196
+ Without `--json`, output is the human table format as before. Do not parse it.
197
+
198
+ ## Configuration
199
+
200
+ | | |
201
+ |---|---|
202
+ | `CERTEN_API_KEY` | API key. Always wins, so CI never touches the keyring or config file. |
203
+ | `CERTEN_API_URL` | Gateway base URL. Defaults to `https://gateway.kompendium.co`. |
204
+ | `CERTEN_KEY_PASSPHRASE` | Passphrase for local signing keys. |
205
+
206
+ `certen auth login` stores the API key in your OS keyring by default, or in
207
+ `~/.certen/config.json` at `0600` with `--no-keyring`.
208
+
209
+ ## Things that will bite you
210
+
211
+ **Identity creation is asynchronous.** `identity create` returns `202` and provisioning continues.
212
+ Poll until the status is terminal, and check `can_sign` — it derives from the on-chain key page, so
213
+ it can read `true` while the status is still `creating`.
214
+
215
+ **A proof cycle takes 60–110 seconds.** Real validator work, not a tunable delay. Do not wrap it in
216
+ a 30-second timeout.
217
+
218
+ **Sign the bytes, not the text.** If you are producing signatures outside this CLI: sign the raw
219
+ bytes of the hash, do not hash it again, and do not sign the ASCII of the hex string. All three
220
+ mistakes produce a well-formed 128-hex signature the gateway rejects. `certen keys sign` handles
221
+ this for you.
222
+
223
+ ## Documentation
224
+
225
+ **<https://docs.kompendium.co>** — getting started, authentication, errors, idempotency, and
226
+ task-shaped guides: onboarding an identity, external signing, proof-gating a contract call, M-of-N
227
+ panels, and verifying a proof.
228
+
229
+ The [live API reference](https://gateway.kompendium.co/reference) is generated from the running
230
+ gateway and is authoritative — when a guide and the spec disagree, the spec is right.
231
+
232
+ ## License
233
+
234
+ MIT
@@ -116,8 +116,8 @@ export function registerChainsCommands(program) {
116
116
  hint('');
117
117
  hint('Detail for one: certen chains base-sepolia');
118
118
  });
119
- chains.addHelpText('after', `
120
- Registry version and Accumulate network are included in --json output.
119
+ chains.addHelpText('after', `
120
+ Registry version and Accumulate network are included in --json output.
121
121
  This command needs no API key, so it also answers "is the gateway up".`);
122
122
  }
123
123
  //# sourceMappingURL=chains.js.map
@@ -1,36 +1,106 @@
1
1
  import { CertenClient } from '@certen.io/sdk';
2
2
  import { getApiKey, getApiUrl } from '../config.js';
3
- import { printOutput } from '../output.js';
3
+ import { printOutput, hint } from '../output.js';
4
+ import { resolveSigner } from '../signer.js';
4
5
  async function getClient() {
5
6
  return new CertenClient({ apiKey: await getApiKey(), baseUrl: getApiUrl() });
6
7
  }
8
+ /**
9
+ * Every governance operation is the same two steps: the gateway builds the Accumulate transaction
10
+ * and returns `signing_data.hash_to_sign`; a key that is ON THE PAGE signs it and the signature is
11
+ * submitted. Without `--sign-with` the first step happens and the hash is printed for an external
12
+ * signer, which is how an HSM or the policy signer participates. With it, both steps happen here.
13
+ */
14
+ async function submitGovernance(operation, opts) {
15
+ const client = await getClient();
16
+ const signer = opts.signWith ? await resolveSigner(opts.signWith) : null;
17
+ const created = await client.governance.create({
18
+ identity: opts.identity,
19
+ operations: [operation],
20
+ signerKeyPage: opts.signerKeyPage,
21
+ signerPublicKey: signer?.publicKey,
22
+ });
23
+ const hash = created.signing_data?.hash_to_sign;
24
+ if (!signer || !hash) {
25
+ printOutput(created);
26
+ if (hash) {
27
+ hint('');
28
+ hint(`Sign signing_data.hash_to_sign with a key on the page, then: certen governance sign ${created.governance_op_id} --signature <hex> --public-key <hex>`);
29
+ }
30
+ return;
31
+ }
32
+ const submitted = await client.governance.submitSignature(created.governance_op_id, {
33
+ signature: signer.sign(hash),
34
+ publicKey: signer.publicKey,
35
+ });
36
+ printOutput({ ...created, ...submitted });
37
+ }
7
38
  export function registerGovernanceCommands(program) {
8
- const governance = program.command('governance').description('Governance operations');
9
- governance
10
- .command('add-delegate')
11
- // `--identity` is the ADI (acc://org.acme), not a uuid — the governance endpoint keys on the ADI.
12
- .description('Add a delegate to an identity key book')
39
+ const governance = program.command('governance').description('Who may sign for an identity, and under what rules');
40
+ const signing = (cmd) => cmd
41
+ .option('--sign-with <key>', 'Local key on the page: sign the returned hash and submit it in one step')
42
+ .option('--signer-key-page <url>', 'Sign with a specific page of the book, e.g. acc://org.acme/book/2');
43
+ signing(governance
44
+ .command('add-key')
45
+ .description('Seat another key on the identity\'s key page — a co-signer, a human, a second agent')
13
46
  .requiredOption('--identity <adi>', 'Identity ADI, e.g. acc://org.acme')
14
- .requiredOption('--delegate-url <url>', 'Delegate URL to add')
47
+ .requiredOption('--public-key-hash <hex>', 'sha256 of the new key\'s raw public key, 64 hex (certen keys list shows it)'))
15
48
  .action(async (opts) => {
16
- const client = await getClient();
17
- const result = await client.governance.create({
18
- identity: opts.identity,
19
- operations: [{ type: 'add_delegate', delegate_url: opts.delegateUrl }],
20
- });
21
- printOutput(result);
49
+ await submitGovernance({ type: 'add_key', public_key_hash: opts.publicKeyHash }, opts);
22
50
  });
23
- governance
51
+ signing(governance
52
+ .command('remove-key')
53
+ .description('Remove a seat from the identity\'s key page')
54
+ .requiredOption('--identity <adi>', 'Identity ADI, e.g. acc://org.acme')
55
+ .requiredOption('--public-key-hash <hex>', 'sha256 of the key to remove, 64 hex'))
56
+ .action(async (opts) => {
57
+ await submitGovernance({ type: 'remove_key', public_key_hash: opts.publicKeyHash }, opts);
58
+ });
59
+ signing(governance
24
60
  .command('set-threshold')
25
61
  .description('Set the M-of-N acceptThreshold on an identity key page')
26
62
  .requiredOption('--identity <adi>', 'Identity ADI, e.g. acc://org.acme')
27
- .requiredOption('--threshold <n>', 'New threshold', parseInt)
63
+ .requiredOption('--threshold <n>', 'New threshold', parseInt))
28
64
  .action(async (opts) => {
65
+ await submitGovernance({ type: 'set_threshold', threshold: opts.threshold }, opts);
66
+ });
67
+ signing(governance
68
+ .command('add-authority')
69
+ .description('Name a key book as a REQUIRED authority: every transaction then waits for it to sign too — how a policy signer regulates an agent')
70
+ .requiredOption('--identity <adi>', 'Identity ADI, e.g. acc://org.acme')
71
+ .requiredOption('--authority <book-url>', 'The key book that must co-sign, e.g. acc://owner-policy.acme/book'))
72
+ .action(async (opts) => {
73
+ await submitGovernance({ type: 'add_authority', authority_url: opts.authority }, opts);
74
+ });
75
+ signing(governance
76
+ .command('remove-authority')
77
+ .description('Release a required authority')
78
+ .requiredOption('--identity <adi>', 'Identity ADI, e.g. acc://org.acme')
79
+ .requiredOption('--authority <book-url>', 'The key book to release'))
80
+ .action(async (opts) => {
81
+ await submitGovernance({ type: 'remove_authority', authority_url: opts.authority }, opts);
82
+ });
83
+ signing(governance
84
+ .command('add-delegate')
85
+ // `--identity` is the ADI (acc://org.acme), not a uuid — the governance endpoint keys on the ADI.
86
+ .description('Add a delegate to an identity key book')
87
+ .requiredOption('--identity <adi>', 'Identity ADI, e.g. acc://org.acme')
88
+ .requiredOption('--delegate-url <url>', 'Delegate URL to add'))
89
+ .action(async (opts) => {
90
+ await submitGovernance({ type: 'add_delegate', delegate_url: opts.delegateUrl }, opts);
91
+ });
92
+ governance
93
+ .command('sign <governance-op-id>')
94
+ .description('Submit a signature for a governance operation created without --sign-with')
95
+ .option('--sign-with <key>', 'Local key to sign with (needs --hash)')
96
+ .option('--hash <hex>', 'The operation\'s signing_data.hash_to_sign')
97
+ .option('--signature <hex>', 'A signature produced elsewhere (with --public-key)')
98
+ .option('--public-key <hex>', 'The signing key\'s public key, 64 hex')
99
+ .action(async (id, opts) => {
100
+ const { resolveSignature } = await import('../signer.js');
101
+ const { signature, publicKey } = await resolveSignature(opts);
29
102
  const client = await getClient();
30
- const result = await client.governance.create({
31
- identity: opts.identity,
32
- operations: [{ type: 'set_threshold', threshold: opts.threshold }],
33
- });
103
+ const result = await client.governance.submitSignature(id, { signature, publicKey });
34
104
  printOutput(result);
35
105
  });
36
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/commands/governance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,KAAK,UAAU,SAAS;IACtB,OAAO,IAAI,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAgB;IACzD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAEtF,UAAU;SACP,OAAO,CAAC,cAAc,CAAC;QACxB,kGAAkG;SACjG,WAAW,CAAC,wCAAwC,CAAC;SACrD,cAAc,CAAC,kBAAkB,EAAE,mCAAmC,CAAC;SACvE,cAAc,CAAC,sBAAsB,EAAE,qBAAqB,CAAC;SAC7D,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;YAC5C,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;SACvE,CAAC,CAAC;QACH,WAAW,CAAC,MAA4C,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEL,UAAU;SACP,OAAO,CAAC,eAAe,CAAC;SACxB,WAAW,CAAC,wDAAwD,CAAC;SACrE,cAAc,CAAC,kBAAkB,EAAE,mC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