keypin 0.9.0 → 0.10.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
@@ -16,140 +16,108 @@
16
16
  <p align="center">
17
17
  <a href="https://www.npmjs.com/package/keypin"><img src="https://img.shields.io/npm/v/keypin?color=121311" alt="npm version"></a>
18
18
  <img src="https://img.shields.io/badge/license-MIT-121311" alt="MIT">
19
- <img src="https://img.shields.io/badge/runtime-Bun-121311" alt="Bun">
20
19
  </p>
21
20
 
22
- Each project lists its keys in a `keypin.toml`: names, vault items and destinations, never values. keypin runs your
23
- commands with dev keys, publishes keys to GitHub Actions and Cloudflare Workers, and reminds you when a key is due
24
- for rotation. It reads values from 1Password only while a command runs, and never writes them to disk.
21
+ Each project lists its keys in a `keypin.toml`: names, 1Password items and destinations, never values. keypin runs
22
+ your commands with the dev keys and publishes the prod keys to GitHub Actions and Cloudflare Workers. It reads
23
+ values from 1Password only while a command runs.
25
24
 
26
25
  ## Install
27
26
 
28
- You need [Bun](https://bun.sh) 1.4.4 or newer and the [1Password](https://1password.com/downloads) desktop app.
29
- To publish, you also need a [`gh`](https://cli.github.com) login for GitHub, or a
30
- [`wrangler`](https://developers.cloudflare.com/workers/wrangler/) login for Cloudflare (macOS or Linux).
27
+ keypin runs on macOS, and on Linux with glibc (not Alpine), on arm64 or x64. You need the
28
+ [1Password](https://1password.com/downloads) desktop app.
31
29
 
32
30
  ```sh
33
- bun add -g keypin
31
+ npm install -g keypin
34
32
  ```
35
33
 
36
- In 1Password, open **Settings → Developer**. Under **Integrate with the 1Password SDKs**, select **Integrate with
37
- other apps**. 1Password then asks you to approve each keypin command.
34
+ Don't install with `--omit=optional`: the build for your platform is an optional dependency.
38
35
 
39
- ## Use with an agent
36
+ In 1Password, open **Settings → Developer** and, under **Integrate with the 1Password SDKs**, select **Integrate
37
+ with other apps**. 1Password then asks you to approve each keypin command.
38
+
39
+ To publish, you also need a [`gh`](https://cli.github.com) login for GitHub, or a
40
+ [`wrangler`](https://developers.cloudflare.com/workers/wrangler/) login for Cloudflare.
40
41
 
41
- The keypin skill tells a coding agent how to use keypin: keep values out of chat and files, and hand each approval
42
- back to you. It works with Claude Code, Codex, Cursor and other agents that read skills.
42
+ ## Get started
43
43
 
44
44
  ```sh
45
- npx skills add caiopizzol/keypin # this project
46
- npx skills add caiopizzol/keypin -g # all your projects
45
+ cd ~/code/my-project
46
+ keypin init # write keypin.toml
47
+ keypin check # what the project uses, what's missing, and what to run or add
47
48
  ```
48
49
 
49
- ## Quick start
50
+ ### Local keys
50
51
 
51
- Register a project. `keypin init` writes a commented `keypin.toml` for you to fill in:
52
+ Move the secrets from your `.env` into 1Password, then run your app with them:
52
53
 
53
54
  ```sh
54
- cd ~/code/my-project
55
- keypin init
55
+ keypin import .env STRIPE_KEY DATABASE_URL --vault Private --account my.1password.com
56
+ keypin run -- npm run dev
56
57
  ```
57
58
 
58
- A key looks like this:
59
+ `import` creates one item per variable and maps it. Variables you don't name, such as `PORT`, stay in the file.
60
+ It never changes the file: it tells you which lines to remove. See
61
+ [Import](https://github.com/caiopizzol/keypin/blob/main/docs/import.md).
59
62
 
60
- ```toml
61
- [1password]
62
- account = "my.1password.com"
63
+ ### Production keys
64
+
65
+ For each secret a workflow or Worker needs, `keypin check` prints the TOML to add:
63
66
 
64
- [keys.API_TOKEN] # the variable your program reads
67
+ ```toml
68
+ [keys.STRIPE_KEY]
65
69
  rotate_every = "90d"
66
- dev = "op://Private/my-project dev api token/credential" # read by keypin run
67
70
 
68
- [keys.API_TOKEN.prod] # read by keypin publish
69
- from = "op://Private/my-project prod api token/credential"
71
+ [keys.STRIPE_KEY.prod]
72
+ from = "op://<vault>/<item>/<field>"
70
73
 
71
- [[keys.API_TOKEN.prod.publish]] # where publish writes it
74
+ [[keys.STRIPE_KEY.prod.publish]]
72
75
  to = "github-actions"
73
76
  repo = "me/my-project"
74
77
  ```
75
78
 
76
- Each `op://` reference is a 1Password secret reference: in the item, open the field's menu and select **Copy Secret
77
- Reference**. Add a `rotated` date to the item. Now use it:
79
+ Paste it into `keypin.toml` and replace each `<...>`. For `from`, open the field's menu in 1Password and select
80
+ **Copy Secret Reference**. Then publish:
78
81
 
79
82
  ```sh
80
- keypin status # every key, when it's due, and any problem
81
- keypin run -- npm run dev # run a command with the dev keys
82
- keypin publish API_TOKEN # write the prod value to the GitHub secret
83
+ keypin publish --all
83
84
  ```
84
85
 
85
- ### Coming from a .env
86
-
87
- `keypin import` moves a `.env` file's keys into new 1Password items and maps them. Name the keys, and plain
88
- settings such as `PORT` stay in the file:
89
-
90
- ```sh
91
- keypin import .env STRIPE_KEY DATABASE_URL --vault Private --account my.1password.com
92
- ```
93
-
94
- Without names, it imports every variable. It shows each item it will create and waits for you to type `yes`. It
95
- never overwrites an item, and it never changes the `.env` file: it tells you which lines to remove from it, and
96
- `keypin run -- <command>` provides those values.
97
- See [Import](https://github.com/caiopizzol/keypin/blob/main/docs/import.md).
86
+ `publish` shows what it will write where and waits for you to type `yes`. See
87
+ [Publishing](https://github.com/caiopizzol/keypin/blob/main/docs/publishing.md).
98
88
 
99
89
  ## Commands
100
90
 
101
91
  ```sh
102
- keypin init [folder] # register a project and write a keypin.toml
103
- keypin unregister [folder] # stop listing a project (its keypin.toml stays)
104
- keypin status [--json] # every key, when it's due, and any problem
105
- keypin check [folder] # check the map, vault items and logins, and write nothing
106
- keypin discover [folder] # every key name a project uses, where it's set, and a draft map
107
- # (--write saves the draft as keypin.toml and registers the project)
92
+ keypin init [folder] # write keypin.toml and register the project
93
+ keypin check [folder] # report one project; writes nothing
108
94
  keypin import <env-file> [NAME...] --vault <vault>
109
- # move an env file's values into 1Password and map them
110
- keypin run -- <command> # run a command with the project's dev keys (--env for another)
111
- keypin publish <VARIABLE> # check each destination's account, then write the key
112
- keypin publish --all # publish every key, with one plan and one approval
113
- keypin publish --all --plan # show that plan without a terminal, and write nothing
95
+ # move an env file's values into 1Password and map them
96
+ keypin run -- <command> # run a command with the dev keys
97
+ keypin publish <VARIABLE> | --all # write prod keys to their destinations
98
+ keypin status # every project's keys, and when each is due for rotation
99
+ keypin unregister [folder] # stop listing a project
114
100
  ```
115
101
 
116
- ### Check a setup
117
-
118
- `keypin check` checks a project before you publish, and changes nothing:
119
-
120
- - the map parses;
121
- - each `op://` reference's item and field exist;
122
- - for each destination, the login keypin would use, who it acts as, the account it reaches, and how to fix a
123
- mismatch.
124
-
125
- It reads each value to check its field, so 1Password asks you to approve it, and it never prints a value. It
126
- also notes a login stored in plain text, such as wrangler's. It exits 0 when everything checks out, and 1 with
127
- one line per problem. `--json` prints the same as JSON.
102
+ `keypin <command> --help` lists every option, and `keypin --help` the exit codes.
128
103
 
129
- Add `--plan` to `publish` to see the plan without a terminal. It changes nothing, and prints the command that
130
- does.
131
-
132
- `import` and `publish` show a plan and wait for you to type `yes`. `--yes` approves `import`, which only creates
133
- new items. For `publish`, it skips that only for routine updates: it never approves a first write, or a changed
134
- account or vault item. `keypin --help` lists the exit codes.
104
+ ## Use with an agent
135
105
 
136
- ### Rotate a key
106
+ The keypin skill teaches a coding agent to use keypin without seeing values, and to hand each approval back to
107
+ you:
137
108
 
138
- `keypin status` shows when each key is due, from its `rotate_every` and its item's `rotated` date. To rotate one,
139
- make a new value where the key comes from (the provider's dashboard, for example), paste it into the 1Password
140
- field, set `rotated` to today, then run `keypin publish <VARIABLE>`. Revoke the old value once everything uses the
141
- new one.
109
+ ```sh
110
+ npx skills add caiopizzol/keypin # this project
111
+ npx skills add caiopizzol/keypin -g # all your projects
112
+ ```
142
113
 
143
114
  ## Docs
144
115
 
145
116
  - [Configuration](https://github.com/caiopizzol/keypin/blob/main/docs/configuration.md): every field in
146
- `keypin.toml` and in the vault items.
147
- - [Discover](https://github.com/caiopizzol/keypin/blob/main/docs/discover.md): what `discover` reads, the problems
148
- it reports, and its draft map.
149
- - [Import](https://github.com/caiopizzol/keypin/blob/main/docs/import.md): moving a `.env` file's values into
150
- 1Password.
151
- - [Publishing](https://github.com/caiopizzol/keypin/blob/main/docs/publishing.md): destinations, account checks and
152
- approvals.
153
- - [Notes](https://github.com/caiopizzol/keypin/blob/main/docs/notes.md): `wrangler dev`, and the files keypin keeps.
154
- - [Development](https://github.com/caiopizzol/keypin/blob/main/docs/development.md): install from source, checks and
155
- releases.
117
+ `keypin.toml`, and how to rotate a key
118
+ - [Import](https://github.com/caiopizzol/keypin/blob/main/docs/import.md): moving an env file's values into 1Password
119
+ - [Publishing](https://github.com/caiopizzol/keypin/blob/main/docs/publishing.md): destinations, approvals and
120
+ `--plan`
121
+ - [Notes](https://github.com/caiopizzol/keypin/blob/main/docs/notes.md): `wrangler dev`, the wrangler login, and the
122
+ files keypin keeps
123
+ - [Development](https://github.com/caiopizzol/keypin/blob/main/docs/development.md): working on keypin
package/bin/keypin ADDED
@@ -0,0 +1,72 @@
1
+ #!/bin/sh
2
+ # keypin's npm command: runs the binary from the @keypin/cli-<platform> package
3
+ # installed with this one, found from this file's own path. It loads no .env file.
4
+ # src/layout.ts looks in the same places, in the same order.
5
+ # find_binary runs in a $(...) subshell, so the names it sets never reach keypin's
6
+ # environment, even when the caller exported one of them.
7
+ set -eu
8
+
9
+ find_binary() {
10
+ self=$0
11
+ case $self in /* | ./* | ../*) ;; *) self=./$self ;; esac
12
+ while [ -L "$self" ]; do
13
+ link=$(command readlink -- "$self")
14
+ case $link in
15
+ /*) self=$link ;;
16
+ *) self=${self%/*}/$link ;;
17
+ esac
18
+ done
19
+ keypin=$(command cd -P -- "${self%/*}/.." && command pwd -P)
20
+
21
+ case $(command uname -s) in
22
+ Darwin) os=darwin ;;
23
+ Linux) os=linux ;;
24
+ *) os= ;;
25
+ esac
26
+ case $(command uname -m) in
27
+ x86_64 | amd64) arch=x64 ;;
28
+ arm64 | aarch64) arch=arm64 ;;
29
+ *) arch= ;;
30
+ esac
31
+ if [ -z "$os" ] || [ -z "$arch" ]; then
32
+ echo "keypin: keypin runs on macOS and Linux, on arm64 or x64, and this is $(command uname -s) $(command uname -m)." >&2
33
+ return 1
34
+ fi
35
+
36
+ # An x64 npm under Rosetta installs the x64 build on Apple Silicon, so macOS
37
+ # tries this shell's architecture first, then the other one.
38
+ if [ "$os" = darwin ]; then
39
+ case $arch in
40
+ arm64) cpus="arm64 x64" ;;
41
+ *) cpus="x64 arm64" ;;
42
+ esac
43
+ else
44
+ cpus=$arch
45
+ case $arch in
46
+ x64) loader=/lib64/ld-linux-x86-64.so.2 ;;
47
+ *) loader=/lib/ld-linux-aarch64.so.1 ;;
48
+ esac
49
+ if [ ! -e "$loader" ]; then
50
+ echo "keypin: keypin's Linux build needs glibc, and this system has no $loader. musl systems such as Alpine aren't supported." >&2
51
+ return 1
52
+ fi
53
+ fi
54
+
55
+ for cpu in $cpus; do
56
+ for binary in \
57
+ "$keypin/node_modules/@keypin/cli-$os-$cpu/bin/keypin" \
58
+ "$keypin/../@keypin/cli-$os-$cpu/bin/keypin"; do
59
+ if [ -f "$binary" ]; then
60
+ printf '%s\n' "$binary"
61
+ return 0
62
+ fi
63
+ done
64
+ done
65
+
66
+ echo "keypin: the package @keypin/cli-$os-$arch isn't installed next to $keypin, so there's no keypin binary to run. npm installs it with keypin as an optional dependency: reinstall keypin without --omit=optional or --no-optional." >&2
67
+ return 1
68
+ }
69
+
70
+ set -- "$(find_binary)" "$@"
71
+ [ -n "$1" ] || exit 1
72
+ exec "$@"
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "keypin",
3
- "version": "0.9.0",
4
- "description": "A map of every app key across your projects, published to the account it's pinned to. Values stay in your vault.",
3
+ "version": "0.10.0",
5
4
  "license": "MIT",
6
5
  "homepage": "https://github.com/caiopizzol/keypin#readme",
7
6
  "bugs": {
@@ -11,15 +10,25 @@
11
10
  "type": "git",
12
11
  "url": "git+https://github.com/caiopizzol/keypin.git"
13
12
  },
14
- "type": "module",
13
+ "description": "A map of every app key across your projects, published to the account it's pinned to. Values stay in your vault.",
15
14
  "bin": {
16
- "keypin": "main.js"
17
- },
18
- "engines": {
19
- "bun": ">=1.4.4"
15
+ "keypin": "bin/keypin"
20
16
  },
21
- "dependencies": {
22
- "@1password/sdk": "0.5.0",
23
- "libsodium-wrappers": "0.8.4"
17
+ "files": [
18
+ "bin/keypin"
19
+ ],
20
+ "os": [
21
+ "darwin",
22
+ "linux"
23
+ ],
24
+ "cpu": [
25
+ "arm64",
26
+ "x64"
27
+ ],
28
+ "optionalDependencies": {
29
+ "@keypin/cli-darwin-arm64": "0.10.0",
30
+ "@keypin/cli-darwin-x64": "0.10.0",
31
+ "@keypin/cli-linux-x64": "0.10.0",
32
+ "@keypin/cli-linux-arm64": "0.10.0"
24
33
  }
25
34
  }