npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@typinghare/trick

v2.1.2

Published

Save credential files to remote safely and easily.

Downloads

66

Readme

Trick

Trick is a CLI tool that helps you safely encrypt sensitive files (such as .env, API keys, or credentials) so they can be stored in Git repositories and easily restored on other machines or servers.

It uses OpenSSL (AES-256-CBC + PBKDF2) under the hood and keeps encryption keys outside your repository.

Features

  • 🔐 Encrypt and decrypt sensitive files with strong encryption
  • 🎯 Group files into targets
  • 📦 Store encrypted files under a dedicated .trick/ directory
  • 🗝️ Keep passphrases outside your repo (per-target, permission-protected)
  • 🔁 Works across machines and servers
  • ⚙️ Fully configurable, project-aware

Installation

# npm
npm install -g @typinghare/trick

# pnpm
pnpm add -g @typinghare/trick

# yarn
yarn add -g @typinghare/trick

Requirements

  • Node.js ≥ 18
  • openssl available in your system PATH

Philosophy

Sensitive files are usually added to .gitignore to avoid accidental leaks. But that means:

  • You must manually copy them to every new machine
  • They’re easy to lose
  • They don’t version well

Trick encrypts those files, allowing you to commit the encrypted versions safely, while keeping passphrases out of Git entirely.

Getting Started

1. Initialize Trick

Run this inside your project:

trick init

This creates a trick.config.json in your project root.

2. Add Files to a Target

A target is a named group of files to encrypt together.

trick add MyTarget .env api_key.conf

List all targets:

trick list

3. Set a Passphrase for the Target

Each target has its own passphrase file stored locally (not in Git).

trick set-passphrase MyTarget

This creates a file at:

~/.config/trick/passphrases/MyTarget
  • File permissions are set to 600
  • You must manually edit this file and paste your passphrase
  • The file content is read as plain text (trimmed)

⚠️ Important Back up your passphrase files. Losing them means losing access to your encrypted data.

4. Encrypt Files

trick encrypt MyTarget

Encrypted files are written to:

.trick/<original-path>.enc

Example output:

🟩 Encrypted: .env -> .trick/.env.enc
🟩 Encrypted: api_key.conf -> .trick/api_key.conf.enc

You can now commit the .trick/ directory safely.

5. Decrypt Files (on another machine or server)

  1. Copy or recreate the passphrase file:

    ~/.config/trick/passphrases/MyTarget
  2. Run:

    trick decrypt MyTarget

Files are restored to their original locations.

Default Targets

You can mark targets as default, so you don’t need to specify them every time.

trick add-default MyTarget

List default targets:

trick list-defaults

Now you can simply run:

trick encrypt
trick decrypt

Configuration

trick.config.json

Example:

{
  "targets": {
    "MyTarget": {
      "files": [".env", "api_key.conf"]
    }
  },
  "trickRootDirectory": ".trick",
  "passphraseDirectory": "~/.config/trick/passphrases",
  "defaultTargetNames": ["MyTarget"],
  "encryption": {
    "iterationCount": 100000
  }
}

Key Fields

| Field | Description | | ------------------------ | ------------------------------------- | | targets | Mapping of target names to file lists | | trickRootDirectory | Where encrypted files are stored | | passphraseDirectory | Where passphrase files live | | defaultTargetNames | Targets used when none specified | | encryption.iterationCount | PBKDF2 iteration count |

Commands Overview

| Command | Description | | ---------------------------------- | -------------------------- | | trick init | Initialize configuration | | trick config | Print current config | | trick add <target> [files...] | Add files to a target | | trick remove <target> [files...] | Remove files from a target | | trick remove <target> --target | Remove a target | | trick list | List targets and files | | trick set-passphrase <target> | Create passphrase file | | trick encrypt [targets...] | Encrypt files | | trick decrypt [targets...] | Decrypt files | | trick add-default [targets...] | Add default targets | | trick list-defaults | Show default targets |

Security Notes

  • Encryption uses:

    • AES-256-CBC
    • PBKDF2 with configurable iteration count
  • Passphrases:

    • Never stored in Git
    • Stored as local files with strict permissions
  • Losing passphrases = losing access to encrypted files

License

MIT