keypin 0.9.0 → 0.11.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 +61 -91
- package/bin/keypin +72 -0
- package/package.json +19 -10
- package/chunk-8jhj2smy.js +0 -12632
- package/chunk-t31ce2x2.js +0 -80
- package/main.js +0 -30
package/README.md
CHANGED
|
@@ -16,140 +16,110 @@
|
|
|
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,
|
|
23
|
-
commands with dev keys
|
|
24
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
31
|
+
npm install -g keypin
|
|
34
32
|
```
|
|
35
33
|
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
|
|
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
|
-
|
|
50
|
+
`check` starts with the logins and apps you still need to set up, if any.
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
### Local keys
|
|
53
|
+
|
|
54
|
+
Move the secrets from your `.env` into 1Password, then run your app with them:
|
|
52
55
|
|
|
53
56
|
```sh
|
|
54
|
-
|
|
55
|
-
keypin
|
|
57
|
+
keypin import .env STRIPE_KEY DATABASE_URL --vault Private --account my.1password.com
|
|
58
|
+
keypin run -- npm run dev
|
|
56
59
|
```
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
`import` creates one item per variable and maps it. Variables you don't name, such as `PORT`, stay in the file.
|
|
62
|
+
It never changes the file: it tells you which lines to remove. See
|
|
63
|
+
[Import](https://github.com/caiopizzol/keypin/blob/main/docs/import.md).
|
|
59
64
|
|
|
60
|
-
|
|
61
|
-
[1password]
|
|
62
|
-
account = "my.1password.com"
|
|
65
|
+
### Production keys
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
For each secret a workflow or Worker needs, `keypin check` prints the TOML to add:
|
|
68
|
+
|
|
69
|
+
```toml
|
|
70
|
+
[keys.STRIPE_KEY]
|
|
65
71
|
rotate_every = "90d"
|
|
66
|
-
dev = "op://Private/my-project dev api token/credential" # read by keypin run
|
|
67
72
|
|
|
68
|
-
[keys.
|
|
69
|
-
from = "op
|
|
73
|
+
[keys.STRIPE_KEY.prod]
|
|
74
|
+
from = "op://<vault>/<item>/<field>"
|
|
70
75
|
|
|
71
|
-
[[keys.
|
|
76
|
+
[[keys.STRIPE_KEY.prod.publish]]
|
|
72
77
|
to = "github-actions"
|
|
73
78
|
repo = "me/my-project"
|
|
74
79
|
```
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
Reference**.
|
|
78
|
-
|
|
79
|
-
```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
|
-
```
|
|
84
|
-
|
|
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:
|
|
81
|
+
Paste it into `keypin.toml` and replace each `<...>`. For `from`, open the field's menu in 1Password and select
|
|
82
|
+
**Copy Secret Reference**. Then publish:
|
|
89
83
|
|
|
90
84
|
```sh
|
|
91
|
-
keypin
|
|
85
|
+
keypin publish --all
|
|
92
86
|
```
|
|
93
87
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
`keypin run -- <command>` provides those values.
|
|
97
|
-
See [Import](https://github.com/caiopizzol/keypin/blob/main/docs/import.md).
|
|
88
|
+
`publish` shows what it will write where and waits for you to type `yes`. See
|
|
89
|
+
[Publishing](https://github.com/caiopizzol/keypin/blob/main/docs/publishing.md).
|
|
98
90
|
|
|
99
91
|
## Commands
|
|
100
92
|
|
|
101
93
|
```sh
|
|
102
|
-
keypin init [folder]
|
|
103
|
-
keypin
|
|
104
|
-
keypin
|
|
105
|
-
|
|
106
|
-
keypin
|
|
107
|
-
|
|
108
|
-
keypin
|
|
109
|
-
|
|
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
|
|
94
|
+
keypin init [folder] # write keypin.toml and register the project
|
|
95
|
+
keypin check [folder] # report one project; writes nothing
|
|
96
|
+
keypin import <env-file> [NAME...] [--env <name>] --vault <vault>
|
|
97
|
+
# move an env file's values into 1Password and map them
|
|
98
|
+
keypin run -- <command> # run a command with the dev keys
|
|
99
|
+
keypin publish <VARIABLE> | --all # write prod keys to their destinations
|
|
100
|
+
keypin status # every project's keys, and when each is due for rotation
|
|
101
|
+
keypin unregister [folder] # stop listing a project
|
|
114
102
|
```
|
|
115
103
|
|
|
116
|
-
|
|
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.
|
|
104
|
+
`keypin <command> --help` lists every option, and `keypin --help` the exit codes.
|
|
124
105
|
|
|
125
|
-
|
|
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.
|
|
128
|
-
|
|
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.
|
|
106
|
+
## Use with an agent
|
|
135
107
|
|
|
136
|
-
|
|
108
|
+
The keypin skill teaches a coding agent to use keypin without seeing values, and to hand each approval back to
|
|
109
|
+
you:
|
|
137
110
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
111
|
+
```sh
|
|
112
|
+
npx skills add caiopizzol/keypin # this project
|
|
113
|
+
npx skills add caiopizzol/keypin -g # all your projects
|
|
114
|
+
```
|
|
142
115
|
|
|
143
116
|
## Docs
|
|
144
117
|
|
|
145
118
|
- [Configuration](https://github.com/caiopizzol/keypin/blob/main/docs/configuration.md): every field in
|
|
146
|
-
`keypin.toml
|
|
147
|
-
- [
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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.
|
|
119
|
+
`keypin.toml`, and how to rotate a key
|
|
120
|
+
- [Import](https://github.com/caiopizzol/keypin/blob/main/docs/import.md): moving an env file's values into 1Password
|
|
121
|
+
- [Publishing](https://github.com/caiopizzol/keypin/blob/main/docs/publishing.md): destinations, approvals and
|
|
122
|
+
`--plan`
|
|
123
|
+
- [Notes](https://github.com/caiopizzol/keypin/blob/main/docs/notes.md): `wrangler dev`, the wrangler login, and the
|
|
124
|
+
files keypin keeps
|
|
125
|
+
- [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.
|
|
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.11.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
|
-
"
|
|
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": "
|
|
17
|
-
},
|
|
18
|
-
"engines": {
|
|
19
|
-
"bun": ">=1.4.4"
|
|
15
|
+
"keypin": "bin/keypin"
|
|
20
16
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
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.11.0",
|
|
30
|
+
"@keypin/cli-darwin-x64": "0.11.0",
|
|
31
|
+
"@keypin/cli-linux-x64": "0.11.0",
|
|
32
|
+
"@keypin/cli-linux-arm64": "0.11.0"
|
|
24
33
|
}
|
|
25
34
|
}
|