Skip to content

Instantly share code, notes, and snippets.

@isaacs
Last active September 12, 2019 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/00699c8ce69942262662d8a0545ec788 to your computer and use it in GitHub Desktop.
Save isaacs/00699c8ce69942262662d8a0545ec788 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# create keybase-proof folder
mkdir -p keybase-proof
cd keybase-proof
NAME=$(npm whoami -s || true)
if [ -z "$NAME" ]; then
npm login
NAME=$(npm whoami -s)
fi
# create JSON blob
# make the version unique, in case they do this multiple times.
cat > package.json <<JSON
{
"name":"@$NAME/keybase-proof",
"version": "1.0.0-$(date +%s).$RANDOM",
"description": "Just proving my npm account for keybase"
}
JSON
# create README.md
cat > README.md <<MARKDOWN
# @$NAME/keybase-proof
Proving my npm account for keybase.io
Maybe some kind of mathy crypto junk should go here.
MARKDOWN
# publish the package!
npm publish --access=public
# To verify, either scrape the url at
# https://www.npmjs.com/package/@$NAME/keybase-proof
# or download the JSON blob at
# https://registry.npmjs.org/@$NAME/keybase-proof
# The `dist-tags` object will tell you which version is "latest"
# So, `obj.versions[obj['dist-tags'].latest]` is the version you want.
# That has a `dist` object with a checksummed tgz file.
# Right now, there is only a sha1 checksum, but that'll start being
# a SHA2-512 value in dist.sha512sum relatively soon.
# crack open the tarball, and you'll see the README.md file.
# Also, it's a package! If you create any old random file above,
# it'll be included in the tgz as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment