Skip to content

ci: publish to npm from the tag-only "release" environment - #21

Closed
kuzane wants to merge 1 commit into
mainfrom
ci/release-environment
Closed

kuzane wants to merge 1 commit into
mainfrom
ci/release-environment

Conversation

@kuzane

@kuzane kuzane commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

The npm publish job now runs in the release environment, so NPM_TOKEN is only readable from a v* tag build.

Why: NPM_TOKEN is a repository secret today. Any workflow on any pushed branch can read a repository secret, so anyone with write access could push a branch with their own workflow and publish to npm without a review or a release. Only admins can merge to main and create tags now, and this closes the remaining route.

Already set up (Settings → Environments → release): deployments are limited to tags matching v*. Only admins can create tags (ruleset "tag creation").

Steps for an admin, in this order:

  1. Settings → Environments → release → Add environment secret: name NPM_TOKEN, value = the current npm token. A fresh automation token is better.
  2. Merge this PR.
  3. Settings → Secrets and variables → Actions → delete the repository secret NPM_TOKEN. Until it is deleted, branch workflows can still read it.

If this PR is merged before step 1, the next release's publish step fails for lack of a token. Nothing gets published, and the job can be re-run after adding the secret.


Generated by Claude Code

NPM_TOKEN moves from a repository secret to an environment secret of
"release". The environment only accepts v* tags, and only admins can
create tags, so a workflow pushed on a branch can no longer read the
token or publish.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DD55YeoZ91Vo3UHnTi
kuzane pushed a commit that referenced this pull request Dec 2, 2026
Folds in #21. NPM_TOKEN moves to an environment secret of "release",
which only v* tags may deploy to (tags are admin-only), so a workflow
pushed on a branch can no longer read it. The trusted-publisher setup
on npmjs.com should name this environment too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7

kuzane commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #20 (commit 6871a1b): the publish job now runs in the tag-only release environment, and the admin steps from this PR are listed in #20's description. Closing in favour of #20.


Generated by Claude Code

@kuzane kuzane closed this Dec 2, 2026
kuzane added a commit that referenced this pull request Dec 2, 2026
…checks, December bounty fixes; release v0.5.2 (#20)

* ci: harden the npm release workflow and add PR checks

publish.yml
- pin actions/checkout (v7.0.1) and actions/setup-node (v7.1.0) to full
  commit SHAs instead of movable tags
- empty workflow-level permissions; the job gets contents:read +
  id-token:write only
- run in a protected `npm-publish` environment (add required reviewers
  in repo settings so a release can't publish on its own)
- Node 24 with an npm >= 11.5.1 check, so npm trusted publishing (OIDC)
  works as soon as it is configured on npmjs.com; until then npm falls
  back to NPM_TOKEN
- `npm publish --provenance --access public`
- fail if the release tag doesn't match package.json version
- `npm ci --ignore-scripts` (no dependency needs install scripts), no
  dependency cache and no persisted git credentials in the release job

ci.yml (new)
- type check, tests, build and production `npm audit` on Node 20/22/24
  for every pull request and push to main; read-only token, no secrets
  (pull_request, not pull_request_target), so fork PRs are safe

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7

* build: publish npm-shrinkwrap.json so installs use pinned dependencies

`npm i -g minara` used to resolve chalk / commander / inquirer / ora /
cli-table3 and their dependencies fresh at install time, so a
compromised upstream release could reach users without any change in
this repo. `npm shrinkwrap` turns package-lock.json into
npm-shrinkwrap.json, which npm honours for consumers. It is added to
`files` so it ships in the tarball (verified: a packed install gets
exactly the pinned versions). `npm ci` in CI keeps working unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7

* fix(output): sanitize every API response at the boundary

- move sanitizeTerminal / sanitizeDeep to a dependency-free
  src/sanitize.ts (re-exported from utils.ts, so imports are unchanged);
  sanitizeDeep gains a `multiline` option
- the API client now strips terminal control sequences, C1 and bidi
  override characters from every string in every response (JSON and
  non-JSON, success and error), keeping line breaks; Hyperliquid public
  API responses (coin names, leverage, fills, orders) get the same
  treatment. Display paths can no longer forget to sanitize server data.
- names shown on a single line (wallets, strategies, subscription plans,
  checkout URLs, order errors, token address in limit-order) are also
  sanitized in single-line mode so a newline can't fake extra rows

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7

* docs: document pinned dependencies, provenance, boundary sanitization and client-side limits

Also drops the stale note about the OAuth callback server (removed in #17).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7

* fix(perps): follow Hyperliquid tick/lot rules and check per-order results

Market orders, closes and the ask quick order priced the IOC limit with
`(mark * 1.01).toPrecision(5)`. That gives "3535.0" (a trailing zero
changes the signed payload) and "1.0201e+5" once a price passes 100,000,
and it ignored the `6 - szDecimals` decimal limit. Hyperliquid also
answers status "ok" when an individual order is rejected, so an IOC that
found no liquidity was reported as "submitted" / "closed" (the original
symptom in #13).

- new src/hl-format.ts: price formatting per the official SDK (5
  significant figures, then 6 - szDecimals decimals, plain decimal
  string), size formatting, user price/size validation, and a parser
  for per-order statuses wherever the backend nests them
- order / close / ask use it; user-entered --price / --size are checked
  against the asset's tick and lot size before anything is sent (with
  the nearest valid price as a hint) and sent without trailing zeros
- new orders under Hyperliquid's $10 minimum are refused up front
- after submitting, the CLI reports the filled size and average price,
  warns on partial fills, and exits non-zero when Hyperliquid rejected
  the order; `perps close --all/--symbol` lists partial or rejected
  closes as failures and sets exit code 1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7

* chore: release v0.5.2

Ships #19 (perps execution and token lookup fixes) together with this
PR's release hardening, pinned dependencies, response sanitization and
Hyperliquid order formatting / result checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7

* ci: publish from the tag-only "release" environment

Folds in #21. NPM_TOKEN moves to an environment secret of "release",
which only v* tags may deploy to (tags are admin-only), so a workflow
pushed on a branch can no longer read it. The trusted-publisher setup
on npmjs.com should name this environment too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7

* fix: close the remaining CLI findings from the December bounty table

- perps cancel / limit-order cancel (M-316): cancelling may remove a
  stop-loss or take-profit, so both now use the transaction
  confirmation (single prompt, full order details) and Touch ID like
  placing an order; perps cancel reads frontendOpenOrders and warns
  when the order is reduce-only or a TP/SL trigger
- perps order on a sub-wallet: leverage is read from that wallet's
  address, never the default wallet's; the preview and confirmation
  show the wallet and its leverage
- damaged config.json (M-353): an unreadable or non-object config no
  longer falls back to defaults silently; fund operations fail closed
  until it is fixed or rewritten via `minara config`. Config and
  credentials are written atomically (temp file + rename)
- logout (M-352): a failed server-side revocation is reported as a
  failure and local credentials are kept so it can be retried;
  `--local` clears them anyway; a 401 counts as already logged out and
  no longer triggers the re-login flow
- swap (M-333 / M-337 / M-348): the quote is always fetched and shown,
  also with -y (not printed with -y --json); quotes with slippage
  tolerance or price impact above 10% are refused (--max-slippage /
  --max-price-impact); an unattended -y swap is never sent without a
  quote
- Solana recipients (M-351): must base58-decode to a 32-byte key;
  off-curve (non-wallet) keys get a warning
- terminal sanitization (M-332): also strips zero-width characters,
  soft hyphen, BOM, word joiner, variation selectors, Unicode tag
  characters and other invisible format characters, and treats
  U+2028/U+2029/NEL as line breaks; token picker addresses are
  sanitized explicitly too
- base URL (M-316): loopback hosts are only accepted with MINARA_DEV=1,
  so a development base URL left in the config cannot send the token
  to whatever later listens on that local port

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants