@atrib/cli 0.1.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/LICENSE +190 -0
- package/README.md +85 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +416 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/keychain.d.ts +45 -0
- package/dist/keychain.d.ts.map +1 -0
- package/dist/keychain.js +132 -0
- package/dist/keychain.js.map +1 -0
- package/dist/keygen.d.ts +9 -0
- package/dist/keygen.d.ts.map +1 -0
- package/dist/keygen.js +23 -0
- package/dist/keygen.js.map +1 -0
- package/package.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
+
improving the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or otherwise designated in writing by the copyright owner as
|
|
57
|
+
"Not a Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and subsequently
|
|
61
|
+
incorporated within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent claims licensable
|
|
76
|
+
by such Contributor that are necessarily infringed by their
|
|
77
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
78
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
+
institute patent litigation against any entity (including a cross-claim
|
|
80
|
+
or counterclaim in a lawsuit) alleging that the Work or a Contribution
|
|
81
|
+
incorporated within the Work constitutes direct or contributory patent
|
|
82
|
+
infringement, then any patent licenses granted to You under this License
|
|
83
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
84
|
+
|
|
85
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
86
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
87
|
+
modifications, and in Source or Object form, provided that You
|
|
88
|
+
meet the following conditions:
|
|
89
|
+
|
|
90
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
91
|
+
a copy of this License; and
|
|
92
|
+
|
|
93
|
+
(b) You must cause any modified files to carry prominent notices
|
|
94
|
+
stating that You changed the files; and
|
|
95
|
+
|
|
96
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
97
|
+
that You distribute, all copyright, patent, trademark, and
|
|
98
|
+
attribution notices from the Source form of the Work,
|
|
99
|
+
excluding those notices that do not pertain to any part of
|
|
100
|
+
the Derivative Works; and
|
|
101
|
+
|
|
102
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
103
|
+
distribution, You must include a readable copy of the attribution
|
|
104
|
+
notices contained within such NOTICE file, in at least one
|
|
105
|
+
of the following places: within a NOTICE text file distributed
|
|
106
|
+
as part of the Derivative Works; within the Source form or
|
|
107
|
+
documentation, if provided along with the Derivative Works; or,
|
|
108
|
+
within a display generated by the Derivative Works, if and
|
|
109
|
+
wherever such third-party notices normally appear. The contents
|
|
110
|
+
of the NOTICE file are for informational purposes only and
|
|
111
|
+
do not modify the License. You may add Your own attribution
|
|
112
|
+
notices within Derivative Works that You distribute, alongside
|
|
113
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
114
|
+
that such additional attribution notices cannot be construed
|
|
115
|
+
as modifying the License.
|
|
116
|
+
|
|
117
|
+
You may add Your own license statement for Your modifications and
|
|
118
|
+
may provide additional grant of rights to use, modify, or distribute
|
|
119
|
+
those modifications in accordance with this License.
|
|
120
|
+
|
|
121
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
122
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
123
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
124
|
+
this License, without any additional terms or conditions.
|
|
125
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
126
|
+
the terms of any separate license agreement you may have executed
|
|
127
|
+
with Licensor regarding such Contributions.
|
|
128
|
+
|
|
129
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
130
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
131
|
+
except as required for reasonable and customary use in describing the
|
|
132
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
133
|
+
|
|
134
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
135
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
136
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
137
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
138
|
+
implied, including, without limitation, any warranties or conditions
|
|
139
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
140
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
141
|
+
appropriateness of using or reproducing the Work and assume any
|
|
142
|
+
risks associated with Your exercise of permissions under this License.
|
|
143
|
+
|
|
144
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
145
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
146
|
+
unless required by applicable law (such as deliberate and grossly
|
|
147
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
148
|
+
liable to You for damages, including any direct, indirect, special,
|
|
149
|
+
incidental, or exemplary damages of any character arising as a
|
|
150
|
+
result of this License or out of the use or inability to use the
|
|
151
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
152
|
+
work stoppage, computer failure or malfunction, or all other
|
|
153
|
+
commercial damages or losses), even if such Contributor has been
|
|
154
|
+
advised of the possibility of such damages.
|
|
155
|
+
|
|
156
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
157
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
158
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
159
|
+
or other liability obligations and/or rights consistent with this
|
|
160
|
+
License. However, in accepting such obligations, You may act only
|
|
161
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
162
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
163
|
+
defend, and hold each Contributor harmless for any liability
|
|
164
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
165
|
+
of your accepting any such warranty or additional liability.
|
|
166
|
+
|
|
167
|
+
END OF TERMS AND CONDITIONS
|
|
168
|
+
|
|
169
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
170
|
+
|
|
171
|
+
To apply the Apache License to your work, attach the following
|
|
172
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
173
|
+
replaced with your own identifying information. (Don't include
|
|
174
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
175
|
+
comment syntax for the file format in question. Also, an optional
|
|
176
|
+
"Statement of Purpose" appears after the copyright notice.
|
|
177
|
+
|
|
178
|
+
Copyright 2025-2026 Atrib contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
189
|
+
implied. See the License for the specific language governing
|
|
190
|
+
permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# `@atrib/cli`
|
|
2
|
+
|
|
3
|
+
**The atrib operator CLI. Generate Ed25519 keypairs, manage them in macOS Keychain, and publish identity claims to the atrib directory (spec §6).**
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx @atrib/cli keygen --keychain
|
|
7
|
+
# Generates an Ed25519 keypair. Stores the seed in macOS Keychain
|
|
8
|
+
# under service "atrib-creator" (or --service NAME). Prints only the
|
|
9
|
+
# public key to stdout.
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The CLI is the operator-side companion to the SDK packages: producers (`@atrib/mcp`, `@atrib/agent`) read keys from environment variables or Keychain entries; this CLI is what creates and manages those entries.
|
|
13
|
+
|
|
14
|
+
## Subcommands
|
|
15
|
+
|
|
16
|
+
### `keygen`
|
|
17
|
+
|
|
18
|
+
Generate a new Ed25519 keypair. Without `--keychain`, prints both seed and pubkey to stdout in env-var format (suitable for piping to `.env`). With `--keychain`, the seed is stored in macOS Keychain and only the pubkey is printed.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
atrib keygen
|
|
22
|
+
# ATRIB_PRIVATE_KEY=<base64url-32-byte-seed>
|
|
23
|
+
# ATRIB_PUBLIC_KEY=<base64url-32-byte-pubkey>
|
|
24
|
+
|
|
25
|
+
atrib keygen --keychain --service atrib-creator-claude-code
|
|
26
|
+
# pubkey: <base64url-32-byte-pubkey>
|
|
27
|
+
# (seed stored in Keychain under service=atrib-creator-claude-code)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### `export-pubkey --keychain`
|
|
31
|
+
|
|
32
|
+
Read a seed from Keychain and print the derived public key only. Useful for confirming which identity a Keychain entry maps to.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
atrib export-pubkey --keychain --service atrib-creator-claude-code
|
|
36
|
+
# pubkey: <base64url-32-byte-pubkey>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### `delete-key --keychain`
|
|
40
|
+
|
|
41
|
+
Remove a Keychain entry. Operator-confirmable destructive operation.
|
|
42
|
+
|
|
43
|
+
### `publish-claim --keychain`
|
|
44
|
+
|
|
45
|
+
Publish an `IdentityClaim` to the atrib directory (spec §6.1), optionally with a §6.7 capability envelope. The seed is read from Keychain, the claim is canonicalized + signed, and POST'd to `--directory URL` (defaults to `https://directory.atrib.dev/v6`).
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
atrib publish-claim --keychain \
|
|
49
|
+
--service atrib-creator-claude-code \
|
|
50
|
+
--display-name "My Agent" \
|
|
51
|
+
--organization "My Org" \
|
|
52
|
+
--email "ops@my-org.example.com" \
|
|
53
|
+
--url "https://my-tool.example.com" \
|
|
54
|
+
--tool-names search,fetch \
|
|
55
|
+
--event-types tool_call \
|
|
56
|
+
--max-amount-currency USD --max-amount-value 100 \
|
|
57
|
+
--expires-at 2027-01-01T00:00:00Z
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Capability envelope fields are optional; an empty envelope means "any tool, any event_type, no payment limits, no expiry."
|
|
61
|
+
|
|
62
|
+
### `revoke --keychain`
|
|
63
|
+
|
|
64
|
+
Revoke a key per spec §1.9 (key rotation and revocation). Emits a `key_revocation` record to the log endpoint, signed by the key being retired.
|
|
65
|
+
|
|
66
|
+
## macOS Keychain integration
|
|
67
|
+
|
|
68
|
+
Keychain support requires macOS (`security` binary). On other platforms the CLI exits with a clear error directing operators to the `--key-file` alternative used by the SDK packages.
|
|
69
|
+
|
|
70
|
+
Service naming convention (matches what `@atrib/mcp` and `@atrib/agent` look up):
|
|
71
|
+
|
|
72
|
+
- `atrib-creator-<agent>`: agent-scoped (e.g. `atrib-creator-claude-code`)
|
|
73
|
+
- `atrib-creator`: generic fallback
|
|
74
|
+
|
|
75
|
+
## Install
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm install -g @atrib/cli
|
|
79
|
+
# or use one-off:
|
|
80
|
+
npx @atrib/cli keygen --keychain
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
Apache-2.0.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* atrib CLI entry point (§5.6.1).
|
|
5
|
+
*
|
|
6
|
+
* Subcommands:
|
|
7
|
+
* keygen [--keychain] [--service NAME] Generate an Ed25519 keypair.
|
|
8
|
+
* export-pubkey --keychain [--service NAME] Print the pubkey for a Keychain entry.
|
|
9
|
+
* delete-key --keychain [--service NAME] Remove a Keychain entry.
|
|
10
|
+
* publish-claim --keychain [--service NAME] [--display-name NAME] [--organization ORG] [--email EMAIL] [--url URL]
|
|
11
|
+
* [--directory URL] [--capabilities-file PATH] [--tool-names CSV] [--event-types CSV]
|
|
12
|
+
* [--max-amount-currency USD --max-amount-value 100] [--counterparties CSV] [--expires-at ISO8601]
|
|
13
|
+
* Publish an IdentityClaim (§6.1) to the
|
|
14
|
+
* directory, optionally with a §6.7 capability
|
|
15
|
+
* envelope. Reads the seed from Keychain.
|
|
16
|
+
*/
|
|
17
|
+
import { isKeychainSupported, KeychainError, KeychainNotSupportedError, loadSeed, resolveServiceAccount, storeSeed, deleteSeed, } from './keychain.js';
|
|
18
|
+
import { keygen, printKeypair } from './keygen.js';
|
|
19
|
+
import { base64urlDecode, getPublicKey, base64urlEncode } from '@atrib/mcp';
|
|
20
|
+
import { signClaim } from '@atrib/directory';
|
|
21
|
+
import { signRecord, genesisChainRoot, sha256, hexEncode, canonicalRecord } from '@atrib/mcp';
|
|
22
|
+
import { readFileSync } from 'node:fs';
|
|
23
|
+
import { randomBytes } from 'node:crypto';
|
|
24
|
+
const VERSION = '0.2.0';
|
|
25
|
+
const HELP = `atrib CLI v${VERSION}
|
|
26
|
+
|
|
27
|
+
Usage:
|
|
28
|
+
atrib keygen [--keychain] [--service NAME]
|
|
29
|
+
Generate an Ed25519 keypair. Without --keychain, prints both keys to
|
|
30
|
+
stdout in env-var format. With --keychain (macOS only), the seed is
|
|
31
|
+
stored in the Keychain and only the public key is printed.
|
|
32
|
+
|
|
33
|
+
atrib export-pubkey --keychain [--service NAME]
|
|
34
|
+
Read a seed from Keychain and print the derived public key only.
|
|
35
|
+
|
|
36
|
+
atrib delete-key --keychain [--service NAME]
|
|
37
|
+
Remove a Keychain entry.
|
|
38
|
+
|
|
39
|
+
atrib revoke {--keychain [--service NAME] | --key-file PATH} --reason {rotation|retirement|compromise} [--successor PUBKEY] [--log URL] [--context-id HEX] [--dry-run]
|
|
40
|
+
Submit a §1.9 key_revocation record signed by the key being retired.
|
|
41
|
+
--reason rotation requires --successor (the new active key).
|
|
42
|
+
The retired key remains valid for any record with log_index < the
|
|
43
|
+
revocation's log_index; later records signed by it are flagged
|
|
44
|
+
'revoked_after_revocation' by §1.9.3-aware verifiers.
|
|
45
|
+
|
|
46
|
+
atrib publish-claim {--keychain [--service NAME] | --key-file PATH} [options]
|
|
47
|
+
Publish an IdentityClaim (§6.1) to a directory, optionally with a
|
|
48
|
+
§6.7 capability envelope (D051). Reads the signing seed from
|
|
49
|
+
Keychain or a base64url-encoded file. Subject options:
|
|
50
|
+
--display-name NAME Human-readable name (most common)
|
|
51
|
+
--organization ORG Organization name
|
|
52
|
+
--email EMAIL Contact email
|
|
53
|
+
--url URL Homepage URL
|
|
54
|
+
--handle HANDLE Social handle (e.g., @atrib)
|
|
55
|
+
Capability envelope options (all optional):
|
|
56
|
+
--capabilities-file PATH JSON file with the full envelope
|
|
57
|
+
--tool-names CSV Comma-separated allowed tool names
|
|
58
|
+
--event-types CSV Comma-separated allowed event types
|
|
59
|
+
--counterparties CSV Comma-separated counterparty keys
|
|
60
|
+
--max-amount-currency C Currency code (e.g., USD)
|
|
61
|
+
--max-amount-value N Numeric amount (requires --max-amount-currency)
|
|
62
|
+
--expires-at ISO8601 Capability expiration (e.g., 2027-01-01T00:00:00Z)
|
|
63
|
+
Where to publish:
|
|
64
|
+
--directory URL Default: https://directory.atrib.dev/v6
|
|
65
|
+
--dry-run Print the signed claim without POSTing
|
|
66
|
+
|
|
67
|
+
atrib help Show this help message
|
|
68
|
+
atrib --version Show version
|
|
69
|
+
|
|
70
|
+
Defaults:
|
|
71
|
+
--service defaults to "atrib-creator". Use a custom name when running
|
|
72
|
+
multiple agents on one machine, or for merchant/witness keys.
|
|
73
|
+
|
|
74
|
+
Notes:
|
|
75
|
+
Keychain mode shells out to /usr/bin/security and is currently macOS-only.
|
|
76
|
+
Linux users can integrate libsecret via the callback-mode keystore (see
|
|
77
|
+
@atrib/mcp middleware options).
|
|
78
|
+
`;
|
|
79
|
+
function parseFlags(args) {
|
|
80
|
+
const flags = { keychain: false };
|
|
81
|
+
const stringFlags = [
|
|
82
|
+
{ flag: '--service', key: 'service' },
|
|
83
|
+
{ flag: '--key-file', key: 'keyFile' },
|
|
84
|
+
{ flag: '--reason', key: 'reason' },
|
|
85
|
+
{ flag: '--successor', key: 'successor' },
|
|
86
|
+
{ flag: '--log', key: 'log' },
|
|
87
|
+
{ flag: '--context-id', key: 'contextId' },
|
|
88
|
+
{ flag: '--display-name', key: 'displayName' },
|
|
89
|
+
{ flag: '--organization', key: 'organization' },
|
|
90
|
+
{ flag: '--email', key: 'email' },
|
|
91
|
+
{ flag: '--url', key: 'url' },
|
|
92
|
+
{ flag: '--handle', key: 'handle' },
|
|
93
|
+
{ flag: '--directory', key: 'directory' },
|
|
94
|
+
{ flag: '--capabilities-file', key: 'capabilitiesFile' },
|
|
95
|
+
{ flag: '--tool-names', key: 'toolNames' },
|
|
96
|
+
{ flag: '--event-types', key: 'eventTypes' },
|
|
97
|
+
{ flag: '--counterparties', key: 'counterparties' },
|
|
98
|
+
{ flag: '--max-amount-currency', key: 'maxAmountCurrency' },
|
|
99
|
+
{ flag: '--max-amount-value', key: 'maxAmountValue' },
|
|
100
|
+
{ flag: '--expires-at', key: 'expiresAt' },
|
|
101
|
+
];
|
|
102
|
+
for (let i = 0; i < args.length; i++) {
|
|
103
|
+
const arg = args[i];
|
|
104
|
+
if (arg === '--keychain') {
|
|
105
|
+
flags.keychain = true;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (arg === '--dry-run') {
|
|
109
|
+
flags.dryRun = true;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const sf = stringFlags.find((s) => s.flag === arg);
|
|
113
|
+
if (sf) {
|
|
114
|
+
const value = args[i + 1];
|
|
115
|
+
if (!value)
|
|
116
|
+
throw new Error(`${arg} requires a value`);
|
|
117
|
+
flags[sf.key] = value;
|
|
118
|
+
i++;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return flags;
|
|
123
|
+
}
|
|
124
|
+
async function runKeygen(flags) {
|
|
125
|
+
const keys = await keygen();
|
|
126
|
+
if (!flags.keychain) {
|
|
127
|
+
printKeypair(keys);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (!isKeychainSupported()) {
|
|
131
|
+
throw new KeychainNotSupportedError('Keychain integration is currently macOS-only. Run without --keychain.');
|
|
132
|
+
}
|
|
133
|
+
storeSeed(keys.privateKey, flags.service ? { service: flags.service } : {});
|
|
134
|
+
const { service, account } = resolveServiceAccount(flags.service ? { service: flags.service } : {});
|
|
135
|
+
// Print only the pubkey + Keychain location. The seed never leaves
|
|
136
|
+
// the call to storeSeed.
|
|
137
|
+
console.log(`ATRIB_PUBLIC_KEY=${keys.publicKey}`);
|
|
138
|
+
console.log(`# Seed stored in macOS Keychain (service=${service}, account=${account})`);
|
|
139
|
+
console.log(`# Retrieve with: atrib export-pubkey --keychain${flags.service ? ` --service ${service}` : ''}`);
|
|
140
|
+
}
|
|
141
|
+
async function runExportPubkey(flags) {
|
|
142
|
+
if (!flags.keychain) {
|
|
143
|
+
throw new Error('export-pubkey currently requires --keychain.');
|
|
144
|
+
}
|
|
145
|
+
const seed = loadSeed(flags.service ? { service: flags.service } : {});
|
|
146
|
+
if (!seed) {
|
|
147
|
+
const { service, account } = resolveServiceAccount(flags.service ? { service: flags.service } : {});
|
|
148
|
+
throw new Error(`No Keychain entry found for service=${service} account=${account}.`);
|
|
149
|
+
}
|
|
150
|
+
const seedBytes = base64urlDecode(seed);
|
|
151
|
+
if (seedBytes.length !== 32) {
|
|
152
|
+
throw new Error(`Stored seed is not 32 bytes (got ${seedBytes.length}). Re-run keygen.`);
|
|
153
|
+
}
|
|
154
|
+
const pub = await getPublicKey(seedBytes);
|
|
155
|
+
console.log(`ATRIB_PUBLIC_KEY=${base64urlEncode(pub)}`);
|
|
156
|
+
// Zero the seed bytes after use.
|
|
157
|
+
seedBytes.fill(0);
|
|
158
|
+
}
|
|
159
|
+
function buildClaimSubject(flags) {
|
|
160
|
+
const subject = {};
|
|
161
|
+
if (flags.displayName)
|
|
162
|
+
subject.display_name = flags.displayName;
|
|
163
|
+
if (flags.organization)
|
|
164
|
+
subject.organization = flags.organization;
|
|
165
|
+
if (flags.email)
|
|
166
|
+
subject.email = flags.email;
|
|
167
|
+
if (flags.url)
|
|
168
|
+
subject.url = flags.url;
|
|
169
|
+
if (flags.handle)
|
|
170
|
+
subject.handle = flags.handle;
|
|
171
|
+
if (Object.keys(subject).length === 0) {
|
|
172
|
+
throw new Error('publish-claim needs at least one of: --display-name, --organization, --email, --url, --handle');
|
|
173
|
+
}
|
|
174
|
+
return subject;
|
|
175
|
+
}
|
|
176
|
+
function buildCapabilities(flags) {
|
|
177
|
+
// File takes precedence and replaces all other capability flags.
|
|
178
|
+
if (flags.capabilitiesFile) {
|
|
179
|
+
const raw = readFileSync(flags.capabilitiesFile, 'utf-8');
|
|
180
|
+
return JSON.parse(raw);
|
|
181
|
+
}
|
|
182
|
+
const env = {};
|
|
183
|
+
if (flags.toolNames)
|
|
184
|
+
env.tool_names = flags.toolNames.split(',').map((s) => s.trim()).filter(Boolean);
|
|
185
|
+
if (flags.eventTypes)
|
|
186
|
+
env.event_types = flags.eventTypes.split(',').map((s) => s.trim()).filter(Boolean);
|
|
187
|
+
if (flags.counterparties)
|
|
188
|
+
env.counterparties = flags.counterparties.split(',').map((s) => s.trim()).filter(Boolean);
|
|
189
|
+
if (flags.maxAmountCurrency || flags.maxAmountValue) {
|
|
190
|
+
if (!flags.maxAmountCurrency || !flags.maxAmountValue) {
|
|
191
|
+
throw new Error('--max-amount-currency and --max-amount-value must be set together');
|
|
192
|
+
}
|
|
193
|
+
const value = Number(flags.maxAmountValue);
|
|
194
|
+
if (!Number.isFinite(value))
|
|
195
|
+
throw new Error(`--max-amount-value not a number: ${flags.maxAmountValue}`);
|
|
196
|
+
env.max_amount = { currency: flags.maxAmountCurrency, value };
|
|
197
|
+
}
|
|
198
|
+
if (flags.expiresAt) {
|
|
199
|
+
const ts = Date.parse(flags.expiresAt);
|
|
200
|
+
if (Number.isNaN(ts))
|
|
201
|
+
throw new Error(`--expires-at not a valid ISO8601 timestamp: ${flags.expiresAt}`);
|
|
202
|
+
env.expires_at = ts;
|
|
203
|
+
}
|
|
204
|
+
return Object.keys(env).length > 0 ? env : undefined;
|
|
205
|
+
}
|
|
206
|
+
async function loadSigningSeed(flags) {
|
|
207
|
+
if (flags.keychain) {
|
|
208
|
+
const seed = loadSeed(flags.service ? { service: flags.service } : {});
|
|
209
|
+
if (!seed) {
|
|
210
|
+
const { service, account } = resolveServiceAccount(flags.service ? { service: flags.service } : {});
|
|
211
|
+
throw new Error(`No Keychain entry for service=${service} account=${account}.`);
|
|
212
|
+
}
|
|
213
|
+
const bytes = base64urlDecode(seed);
|
|
214
|
+
if (bytes.length !== 32)
|
|
215
|
+
throw new Error(`Stored seed is not 32 bytes (got ${bytes.length}).`);
|
|
216
|
+
return bytes;
|
|
217
|
+
}
|
|
218
|
+
if (flags.keyFile) {
|
|
219
|
+
const raw = readFileSync(flags.keyFile, 'utf-8').trim();
|
|
220
|
+
const bytes = base64urlDecode(raw);
|
|
221
|
+
if (bytes.length !== 32)
|
|
222
|
+
throw new Error(`Key file ${flags.keyFile} did not decode to 32 bytes (got ${bytes.length}).`);
|
|
223
|
+
return bytes;
|
|
224
|
+
}
|
|
225
|
+
throw new Error('publish-claim needs --keychain (with optional --service NAME) or --key-file PATH.');
|
|
226
|
+
}
|
|
227
|
+
async function runRevoke(flags) {
|
|
228
|
+
const reason = flags.reason;
|
|
229
|
+
if (reason !== 'rotation' && reason !== 'retirement' && reason !== 'compromise') {
|
|
230
|
+
throw new Error('--reason must be one of: rotation, retirement, compromise');
|
|
231
|
+
}
|
|
232
|
+
if (reason === 'rotation' && !flags.successor) {
|
|
233
|
+
throw new Error('--reason rotation requires --successor PUBKEY (43-char base64url)');
|
|
234
|
+
}
|
|
235
|
+
if (flags.successor && !/^[A-Za-z0-9_-]{43}$/.test(flags.successor)) {
|
|
236
|
+
throw new Error('--successor must be a 43-char base64url Ed25519 pubkey');
|
|
237
|
+
}
|
|
238
|
+
const seedBytes = await loadSigningSeed(flags);
|
|
239
|
+
const pub = await getPublicKey(seedBytes);
|
|
240
|
+
const creatorKey = base64urlEncode(pub);
|
|
241
|
+
// Per §1.9.2: standard revocation is signed by the key being retired.
|
|
242
|
+
// creator_key === revoked_key in that case. Compromise + emergency-key
|
|
243
|
+
// path is V2 — not exposed here.
|
|
244
|
+
const revokedKey = creatorKey;
|
|
245
|
+
// Use the supplied --context-id or generate a fresh one. Revocation
|
|
246
|
+
// records form their own session for traceability per §1.9.
|
|
247
|
+
const contextId = flags.contextId ?? randomBytes(16).toString('hex');
|
|
248
|
+
if (!/^[0-9a-f]{32}$/.test(contextId)) {
|
|
249
|
+
throw new Error('--context-id must be 32 hex chars');
|
|
250
|
+
}
|
|
251
|
+
const unsigned = {
|
|
252
|
+
spec_version: 'atrib/1.0',
|
|
253
|
+
content_id: 'sha256:' + hexEncode(sha256(Buffer.from(`revoke:${revokedKey}:${reason}:${Date.now()}`))),
|
|
254
|
+
creator_key: creatorKey,
|
|
255
|
+
chain_root: genesisChainRoot(contextId),
|
|
256
|
+
event_type: 'https://atrib.dev/v1/types/key_revocation',
|
|
257
|
+
context_id: contextId,
|
|
258
|
+
timestamp: Date.now(),
|
|
259
|
+
revoked_key: revokedKey,
|
|
260
|
+
revocation_reason: reason,
|
|
261
|
+
...(flags.successor ? { successor_key: flags.successor } : {}),
|
|
262
|
+
signature: '',
|
|
263
|
+
};
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
|
+
const signed = await signRecord(unsigned, seedBytes);
|
|
266
|
+
seedBytes.fill(0);
|
|
267
|
+
const recordHash = 'sha256:' + hexEncode(sha256(canonicalRecord(signed)));
|
|
268
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
269
|
+
if (flags.dryRun) {
|
|
270
|
+
console.log(JSON.stringify(signed, null, 2));
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const logEndpoint = flags.log ?? 'https://log.atrib.dev/v1';
|
|
274
|
+
const submitUrl = `${logEndpoint.replace(/\/$/, '')}/entries`;
|
|
275
|
+
const res = await fetch(submitUrl, {
|
|
276
|
+
method: 'POST',
|
|
277
|
+
headers: { 'content-type': 'application/json' },
|
|
278
|
+
body: JSON.stringify(signed),
|
|
279
|
+
});
|
|
280
|
+
const body = (await res.json().catch(() => ({})));
|
|
281
|
+
if (!res.ok) {
|
|
282
|
+
throw new Error(`log submit failed (${res.status}): ${JSON.stringify(body)}`);
|
|
283
|
+
}
|
|
284
|
+
console.log(`# Revoked key ${revokedKey}`);
|
|
285
|
+
console.log(`# reason: ${reason}${flags.successor ? `, successor: ${flags.successor}` : ''}`);
|
|
286
|
+
console.log(`# log_index: ${String(body.log_index)}`);
|
|
287
|
+
console.log(`# record_hash: ${recordHash}`);
|
|
288
|
+
console.log(`# context_id: ${contextId}`);
|
|
289
|
+
console.log(`# Records signed by ${revokedKey} with log_index >= ${String(body.log_index)} are now`);
|
|
290
|
+
console.log(`# flagged 'revoked_after_revocation' by §1.9.3-aware verifiers.`);
|
|
291
|
+
}
|
|
292
|
+
async function runPublishClaim(flags) {
|
|
293
|
+
const seedBytes = await loadSigningSeed(flags);
|
|
294
|
+
const pub = await getPublicKey(seedBytes);
|
|
295
|
+
const creatorKey = base64urlEncode(pub);
|
|
296
|
+
const subject = buildClaimSubject(flags);
|
|
297
|
+
const capabilities = buildCapabilities(flags);
|
|
298
|
+
const unsigned = {
|
|
299
|
+
creator_key: creatorKey,
|
|
300
|
+
claim_type: 'self_attested',
|
|
301
|
+
claim_method: 'self',
|
|
302
|
+
claim_subject: subject,
|
|
303
|
+
...(capabilities ? { capabilities } : {}),
|
|
304
|
+
};
|
|
305
|
+
const claim = await signClaim(unsigned, seedBytes);
|
|
306
|
+
// Zero seed bytes after signing
|
|
307
|
+
seedBytes.fill(0);
|
|
308
|
+
if (flags.dryRun) {
|
|
309
|
+
console.log(JSON.stringify(claim, null, 2));
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const directory = flags.directory ?? 'https://directory.atrib.dev/v6';
|
|
313
|
+
const endpoint = `${directory.replace(/\/$/, '')}/publish`;
|
|
314
|
+
const res = await fetch(endpoint, {
|
|
315
|
+
method: 'POST',
|
|
316
|
+
headers: { 'content-type': 'application/json' },
|
|
317
|
+
body: JSON.stringify(claim),
|
|
318
|
+
});
|
|
319
|
+
const body = (await res.json().catch(() => ({})));
|
|
320
|
+
if (!res.ok) {
|
|
321
|
+
throw new Error(`directory publish failed (${res.status}): ${JSON.stringify(body)}`);
|
|
322
|
+
}
|
|
323
|
+
console.log(`# Published identity claim for ${creatorKey}`);
|
|
324
|
+
console.log(`# directory: ${directory}`);
|
|
325
|
+
console.log(`# epoch: ${String(body.epoch)}`);
|
|
326
|
+
console.log(`# root_hash: ${String(body.root_hash)}`);
|
|
327
|
+
if (body.anchor && typeof body.anchor === 'object') {
|
|
328
|
+
const a = body.anchor;
|
|
329
|
+
if (a.submitted)
|
|
330
|
+
console.log(`# anchored: record_hash=${String(a.record_hash)}`);
|
|
331
|
+
else if (a.error)
|
|
332
|
+
console.log(`# anchor error: ${String(a.error)}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function runDeleteKey(flags) {
|
|
336
|
+
if (!flags.keychain) {
|
|
337
|
+
throw new Error('delete-key currently requires --keychain.');
|
|
338
|
+
}
|
|
339
|
+
const removed = deleteSeed(flags.service ? { service: flags.service } : {});
|
|
340
|
+
const { service, account } = resolveServiceAccount(flags.service ? { service: flags.service } : {});
|
|
341
|
+
if (removed) {
|
|
342
|
+
console.log(`# Removed Keychain entry service=${service} account=${account}`);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
console.log(`# No Keychain entry found for service=${service} account=${account}`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
async function main() {
|
|
349
|
+
const args = process.argv.slice(2);
|
|
350
|
+
const command = args[0];
|
|
351
|
+
if (!command || command === 'help' || command === '--help' || command === '-h') {
|
|
352
|
+
console.log(HELP);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (command === '--version' || command === '-v') {
|
|
356
|
+
console.log(VERSION);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const tail = args.slice(1);
|
|
360
|
+
let flags;
|
|
361
|
+
try {
|
|
362
|
+
flags = parseFlags(tail);
|
|
363
|
+
}
|
|
364
|
+
catch (err) {
|
|
365
|
+
console.error(`atrib: ${err instanceof Error ? err.message : String(err)}`);
|
|
366
|
+
process.exitCode = 1;
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
try {
|
|
370
|
+
if (command === 'keygen') {
|
|
371
|
+
await runKeygen(flags);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (command === 'export-pubkey') {
|
|
375
|
+
await runExportPubkey(flags);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (command === 'delete-key') {
|
|
379
|
+
runDeleteKey(flags);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (command === 'publish-claim') {
|
|
383
|
+
await runPublishClaim(flags);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (command === 'revoke') {
|
|
387
|
+
await runRevoke(flags);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
catch (err) {
|
|
392
|
+
if (err instanceof KeychainNotSupportedError) {
|
|
393
|
+
console.error(`atrib: ${err.message}`);
|
|
394
|
+
process.exitCode = 2;
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (err instanceof KeychainError) {
|
|
398
|
+
console.error(`atrib: keychain error (status ${err.status}): ${err.message}`);
|
|
399
|
+
if (err.stderr)
|
|
400
|
+
console.error(err.stderr);
|
|
401
|
+
process.exitCode = 3;
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
console.error(`atrib: ${err instanceof Error ? err.message : String(err)}`);
|
|
405
|
+
process.exitCode = 1;
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
console.error(`Unknown command: ${command}`);
|
|
409
|
+
console.error('Run "atrib help" for usage.');
|
|
410
|
+
process.exitCode = 1;
|
|
411
|
+
}
|
|
412
|
+
main().catch((err) => {
|
|
413
|
+
console.error('atrib: fatal error', err);
|
|
414
|
+
process.exitCode = 1;
|
|
415
|
+
});
|
|
416
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,sCAAsC;AAEtC;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,yBAAyB,EACzB,QAAQ,EACR,qBAAqB,EACrB,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,OAAO,GAAG,OAAO,CAAA;AAEvB,MAAM,IAAI,GAAG,cAAc,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDjC,CAAA;AA6BD,SAAS,UAAU,CAAC,IAAc;IAChC,MAAM,KAAK,GAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;IACxC,MAAM,WAAW,GAA8C;QAC7D,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE;QACrC,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,SAA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AQ,GAAG,CAAC,CAAA;QACpB,OAAM;IACR,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAA;IAC5C,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;IAC5C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAA;IACxC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,iEAAiE;AAEjE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface KeychainOptions {
|
|
2
|
+
service?: string;
|
|
3
|
+
account?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class KeychainNotSupportedError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class KeychainError extends Error {
|
|
9
|
+
readonly status: number | null;
|
|
10
|
+
readonly stderr: string;
|
|
11
|
+
constructor(message: string, status: number | null, stderr: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolve service + account names with sensible defaults. Pure: no side
|
|
15
|
+
* effects, easy to test.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveServiceAccount(options?: KeychainOptions): {
|
|
18
|
+
service: string;
|
|
19
|
+
account: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Store a base64url-encoded seed in the macOS Keychain. If an entry for the
|
|
23
|
+
* same service+account already exists, it is overwritten (`-U`). The seed
|
|
24
|
+
* is passed via the `-w` flag, which goes through argv and is therefore
|
|
25
|
+
* visible to other processes on the machine for the brief lifetime of the
|
|
26
|
+
* `security` invocation. This is acceptable on a single-user laptop; for
|
|
27
|
+
* stricter environments use `storeSeedFromStdin` for argv-free entry.
|
|
28
|
+
*/
|
|
29
|
+
export declare function storeSeed(seedB64: string, options?: KeychainOptions): void;
|
|
30
|
+
/**
|
|
31
|
+
* Read a base64url-encoded seed from the macOS Keychain. Returns null if no
|
|
32
|
+
* entry exists for the given service+account. Throws on other errors.
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadSeed(options?: KeychainOptions): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Remove a key from the macOS Keychain. Returns true if the entry was
|
|
37
|
+
* removed, false if it didn't exist.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deleteSeed(options?: KeychainOptions): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Check whether Keychain integration is supported on the current platform.
|
|
42
|
+
* Useful for callers that want to fall back to env vars without throwing.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isKeychainSupported(): boolean;
|
|
45
|
+
//# sourceMappingURL=keychain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../src/keychain.ts"],"names":[],"mappings":"AAiCA,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,aAAc,SAAQ,KAAK;aAGpB,MAAM,EAAE,MAAM,GAAG,IAAI;aACrB,MAAM,EAAE,MAAM;gBAF9B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,MAAM,EAAE,MAAM;CAKjC;AAYD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,eAAoB,GAAG;IACpE,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB,CAKA;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI,CAqB9E;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,MAAM,GAAG,IAAI,CAyBrE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAmBjE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C"}
|
package/dist/keychain.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* macOS Keychain integration for atrib creator keys.
|
|
4
|
+
*
|
|
5
|
+
* Why a keystore: env vars and `~/.claude.json` are 644-by-default and end
|
|
6
|
+
* up in shell history, process listings, and command transcripts. The macOS
|
|
7
|
+
* Keychain is encrypted at rest, ACL'd to a specific app or user, and
|
|
8
|
+
* survives reboots without any plaintext leaving the keychain DB.
|
|
9
|
+
*
|
|
10
|
+
* Why shell out to `security` rather than a native bridge: zero install
|
|
11
|
+
* dependencies. `security` ships with macOS. The cost is two `spawnSync`
|
|
12
|
+
* calls per key operation — fine at MCP wrapper boot.
|
|
13
|
+
*
|
|
14
|
+
* Linux/Windows are NOT supported in this initial cut. Linux users can
|
|
15
|
+
* shell out to `secret-tool` (libsecret) via a similar wrapper; see
|
|
16
|
+
* `loadFromSecretTool` for the planned shape. Windows is out of scope.
|
|
17
|
+
*
|
|
18
|
+
* Service name convention:
|
|
19
|
+
* atrib-creator default for the agent's primary creator key
|
|
20
|
+
* atrib-creator-<agent-id> per-agent variants when an operator runs
|
|
21
|
+
* multiple agents on one machine
|
|
22
|
+
* atrib-merchant merchant key for settlement signing
|
|
23
|
+
*
|
|
24
|
+
* Account name: always the current user (`$USER`) — the keychain ACL is
|
|
25
|
+
* implicit "this user only" via the account binding.
|
|
26
|
+
*/
|
|
27
|
+
import { spawnSync } from 'node:child_process';
|
|
28
|
+
import { platform, userInfo } from 'node:os';
|
|
29
|
+
const DEFAULT_SERVICE = 'atrib-creator';
|
|
30
|
+
export class KeychainNotSupportedError extends Error {
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = 'KeychainNotSupportedError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class KeychainError extends Error {
|
|
37
|
+
status;
|
|
38
|
+
stderr;
|
|
39
|
+
constructor(message, status, stderr) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.status = status;
|
|
42
|
+
this.stderr = stderr;
|
|
43
|
+
this.name = 'KeychainError';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function assertMacos() {
|
|
47
|
+
if (platform() !== 'darwin') {
|
|
48
|
+
throw new KeychainNotSupportedError('Keychain integration is currently macOS-only. ' +
|
|
49
|
+
'On Linux, use libsecret/secret-tool or a callback-mode keystore. ' +
|
|
50
|
+
'On Windows, use a callback-mode keystore that reads from DPAPI or a Vault.');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Resolve service + account names with sensible defaults. Pure: no side
|
|
55
|
+
* effects, easy to test.
|
|
56
|
+
*/
|
|
57
|
+
export function resolveServiceAccount(options = {}) {
|
|
58
|
+
return {
|
|
59
|
+
service: options.service ?? DEFAULT_SERVICE,
|
|
60
|
+
account: options.account ?? userInfo().username,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Store a base64url-encoded seed in the macOS Keychain. If an entry for the
|
|
65
|
+
* same service+account already exists, it is overwritten (`-U`). The seed
|
|
66
|
+
* is passed via the `-w` flag, which goes through argv and is therefore
|
|
67
|
+
* visible to other processes on the machine for the brief lifetime of the
|
|
68
|
+
* `security` invocation. This is acceptable on a single-user laptop; for
|
|
69
|
+
* stricter environments use `storeSeedFromStdin` for argv-free entry.
|
|
70
|
+
*/
|
|
71
|
+
export function storeSeed(seedB64, options = {}) {
|
|
72
|
+
assertMacos();
|
|
73
|
+
const { service, account } = resolveServiceAccount(options);
|
|
74
|
+
const result = spawnSync('security', [
|
|
75
|
+
'add-generic-password',
|
|
76
|
+
'-U', // update if exists
|
|
77
|
+
'-a', account,
|
|
78
|
+
'-s', service,
|
|
79
|
+
'-w', seedB64,
|
|
80
|
+
], { encoding: 'utf8' });
|
|
81
|
+
if (result.status !== 0) {
|
|
82
|
+
throw new KeychainError(`security add-generic-password failed for service=${service} account=${account}`, result.status, result.stderr ?? '');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Read a base64url-encoded seed from the macOS Keychain. Returns null if no
|
|
87
|
+
* entry exists for the given service+account. Throws on other errors.
|
|
88
|
+
*/
|
|
89
|
+
export function loadSeed(options = {}) {
|
|
90
|
+
assertMacos();
|
|
91
|
+
const { service, account } = resolveServiceAccount(options);
|
|
92
|
+
const result = spawnSync('security', [
|
|
93
|
+
'find-generic-password',
|
|
94
|
+
'-a', account,
|
|
95
|
+
'-s', service,
|
|
96
|
+
'-w', // print password only
|
|
97
|
+
], { encoding: 'utf8' });
|
|
98
|
+
if (result.status === 0) {
|
|
99
|
+
return (result.stdout ?? '').trim();
|
|
100
|
+
}
|
|
101
|
+
// status 44 = not found
|
|
102
|
+
if (result.status === 44) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
throw new KeychainError(`security find-generic-password failed for service=${service} account=${account}`, result.status, result.stderr ?? '');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Remove a key from the macOS Keychain. Returns true if the entry was
|
|
109
|
+
* removed, false if it didn't exist.
|
|
110
|
+
*/
|
|
111
|
+
export function deleteSeed(options = {}) {
|
|
112
|
+
assertMacos();
|
|
113
|
+
const { service, account } = resolveServiceAccount(options);
|
|
114
|
+
const result = spawnSync('security', [
|
|
115
|
+
'delete-generic-password',
|
|
116
|
+
'-a', account,
|
|
117
|
+
'-s', service,
|
|
118
|
+
], { encoding: 'utf8' });
|
|
119
|
+
if (result.status === 0)
|
|
120
|
+
return true;
|
|
121
|
+
if (result.status === 44)
|
|
122
|
+
return false;
|
|
123
|
+
throw new KeychainError(`security delete-generic-password failed for service=${service} account=${account}`, result.status, result.stderr ?? '');
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Check whether Keychain integration is supported on the current platform.
|
|
127
|
+
* Useful for callers that want to fall back to env vars without throwing.
|
|
128
|
+
*/
|
|
129
|
+
export function isKeychainSupported() {
|
|
130
|
+
return platform() === 'darwin';
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=keychain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keychain.js","sourceRoot":"","sources":["../src/keychain.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAE5C,MAAM,eAAe,GAAG,eAAe,CAAA;AAOvC,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IACzC,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,KAAK;IAGpB;IACA;IAHlB,YACE,OAAe,EACC,MAAqB,EACrB,MAAc;QAE9B,KA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AED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,QAAQ,EAAE,KAAK,QAAQ,CAAA;AAChC,CAAC"}
|
package/dist/keygen.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keygen.d.ts","sourceRoot":"","sources":["../src/keygen.ts"],"names":[],"mappings":"AAWA,wBAAsB,MAAM,IAAI,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAajF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAGlF"}
|
package/dist/keygen.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Ed25519 key generation for atrib (§5.6.1).
|
|
4
|
+
*
|
|
5
|
+
* Generates a 32-byte random seed, derives the Ed25519 public key,
|
|
6
|
+
* and outputs both in the ATRIB_PRIVATE_KEY / ATRIB_PUBLIC_KEY format.
|
|
7
|
+
*/
|
|
8
|
+
import { getPublicKey, base64urlEncode } from '@atrib/mcp';
|
|
9
|
+
export async function keygen() {
|
|
10
|
+
const seed = new Uint8Array(32);
|
|
11
|
+
crypto.getRandomValues(seed);
|
|
12
|
+
const publicKeyBytes = await getPublicKey(seed);
|
|
13
|
+
const privateKey = base64urlEncode(seed);
|
|
14
|
+
const publicKey = base64urlEncode(publicKeyBytes);
|
|
15
|
+
// Zero the seed from memory after encoding (§5.6.3)
|
|
16
|
+
seed.fill(0);
|
|
17
|
+
return { privateKey, publicKey };
|
|
18
|
+
}
|
|
19
|
+
export function printKeypair(keys) {
|
|
20
|
+
console.log(`ATRIB_PRIVATE_KEY=${keys.privateKey}`);
|
|
21
|
+
console.log(`ATRIB_PUBLIC_KEY=${keys.publicKey}`);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=keygen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keygen.js","sourceRoot":"","sources":["../src/keygen.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE1D,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;IAC/B,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;IAE5B,MAAM,cAAc,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAA;IAE/C,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IACxC,MAAM,SAAS,GAAG,eAAe,CAAC,cAAc,CAAC,CAAA;IAEjD,oDAAoD;IACpD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAEZ,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAA+C;IAC1E,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IACnD,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;AACnD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atrib/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"atrib": "./dist/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/cli.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"description": "CLI tools for atrib. Key generation and utilities.",
|
|
13
|
+
"author": "atrib <hello@atrib.dev>",
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"homepage": "https://atrib.dev",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"atrib",
|
|
18
|
+
"cli",
|
|
19
|
+
"ed25519",
|
|
20
|
+
"keygen"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@atrib/directory": "0.1.0",
|
|
24
|
+
"@atrib/mcp": "0.1.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.19.17",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"vitest": "^3.2.4"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"test": "vitest run"
|
|
35
|
+
}
|
|
36
|
+
}
|