NPM Automation Token Setup Guide
TL;DR: Use granular automation tokens with read/write permissions for
chatlineonly.
Why Automation Tokens?
Regular tokens can publish ALL your packages. Automation tokens can be restricted to specific packages.
Security: If token leaks, damage is limited to this package only.
Step-by-Step Setup
1. Go to NPM Token Page
Visit: https://www.npmjs.com/settings/YOUR_USERNAME/tokens
(Replace YOUR_USERNAME with your npm username)
2. Click "Generate New Token"
Button is in the top right.
3. Select Token Type
Choose: Automation
(Not "Publish" - automation tokens have better security)
4. Configure Token Permissions
Package permissions:
- Select: "Read and write"
- Package:
chatline
IP Allowlist: Leave empty (GitHub Actions IPs rotate)
Expiration:
- Recommended: 90 days
- Set a calendar reminder to rotate
5. Copy the Token
IMPORTANT: You only see this ONCE!
Format: npm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
6. Add to GitHub Secrets
- Go to:
https://github.com/nathanvale/chatline/settings/secrets/actions - Click "New repository secret"
- Name:
NPM_TOKEN - Value: Paste the token
- Click "Add secret"
7. Verify It Works
The token is used in these workflows:
.github/workflows/changesets-manage-publish.yml.github/workflows/alpha-snapshot.yml.github/workflows/channel-release.yml
Next time you merge a "Version Packages" PR, it will use this token to publish.
Security Best Practices
✅ DO:
- Use automation tokens (not classic tokens)
- Set expiration dates
- Rotate tokens every 90 days
- Restrict to specific packages
- Store in GitHub Secrets only
❌ DON'T:
- Use classic "Publish" tokens
- Share tokens in chat/email
- Commit tokens to git
- Use tokens without expiration
- Give tokens access to all packages
Troubleshooting
"403 Forbidden" Error
Problem: Token doesn't have permission to publish package
Solution:
- Check token has "Read and write" permission
- Verify package name is
chatline - Make sure you're an owner/maintainer of the package
"401 Unauthorized" Error
Problem: Token is invalid or expired
Solution:
- Generate a new token following steps above
- Update GitHub secret
NPM_TOKEN - Re-run the workflow
Token Expired
Problem: Got email "Your npm token is expiring soon"
Solution:
- Generate a new token (same steps)
- Update GitHub secret
NPM_TOKEN - Old token is automatically revoked
Rotation Schedule
Recommended: Rotate tokens every 90 days
- Set calendar reminder for rotation date
- Generate new token
- Update GitHub secret
- Old token automatically expires
- Reset calendar reminder for 90 days later
Related Documentation
- NPM Automation Tokens Docs
- GitHub Actions Secrets
docs/automated-release-workflow.md- How publishing workflows use the token