From b94803506252fbd7ba504c3c0de66c20f25a2400 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Tue, 1 Dec 2026 22:24:22 +0100 Subject: [PATCH 1/3] PFM-ISSUE-34294 - Add research and design for the runtime-generated .npmrc and DOT_NPMRC cutover Co-Authored-By: Claude Opus 5.5 --- .../design.md | 350 +++++++++++++++++ .../research.md | 356 ++++++++++++++++++ 2 files changed, 706 insertions(+) create mode 100644 specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md create mode 100644 specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/research.md diff --git a/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md new file mode 100644 index 0000000..fcae149 --- /dev/null +++ b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md @@ -0,0 +1,350 @@ +--- +date: 2026-12-01 +ticket: PFM-ISSUE-34294 +related: PFM-ISSUE-33675 +topic: "Runtime-generated read .npmrc from JFROG_TOKEN and removal of DOT_NPMRC from master" +status: approved-for-planning +research: ./research.md +--- + +# Runtime-generated `.npmrc` and `DOT_NPMRC` cutover - Design Approach + +## Overview + +Replace the stored whole-`.npmrc` secret `DOT_NPMRC` in the shared FE workflows with a `~/.npmrc` generated at +runtime from the existing per-repo `JFROG_TOKEN` (introduced by PFM-ISSUE-34293). `use-npmrc` is rewritten in place +to generate the file. A short dual-support window lets the FE repos switch over, and then every `DOT_NPMRC` +reference is removed from master. Deleting the repo secrets is left to a separate cleanup ticket. + +## Problem Statement + +Install-time npm auth comes from `DOT_NPMRC`, a per-repo secret holding a complete, hand-maintained `.npmrc` that +`use-npmrc` writes verbatim to `~/.npmrc` ([Research §1](./research.md)). The routing and credentials live in +opaque secret text, they drift between repos, and they cannot be reviewed. Publishing already generates its own +`.npmrc` from `JFROG_*` (34293). PFM-ISSUE-34294 asks to generate the read `.npmrc` the same way and to remove +`DOT_NPMRC`. The removal gate, PFM-ISSUE-34301 (all third-party registries proxied through JFrog, Bryntum lockfile +PRs #476–#480 merged), is met. + +### Requirements +- The install/read `~/.npmrc` is generated at workflow runtime, not stored as a secret. +- Installs and publishes succeed with the generated file. +- No FE workflow on master relies on `DOT_NPMRC`; `DOT_NPMRC` and its `use-npmrc` usage are removed from master. +- Keep the PFM-ISSUE-34453 `replace-registry-host=never` mitigation and the advisory `warn-foreign-registry.sh` step. + +### Constraints +- Default branches follow the reusables and `use-npmrc` at `@master`. Removing a declared secret breaks callers + that still pass it, and adding a required one breaks callers that don't. +- Release branches are self-contained. On 25.2–26.4 they pin `use-npmrc@release/X.Y`, and 23.1–25.1 use + `bduff9/use-npmrc@v1.1`. No release line loads the composite from master, so they keep working for as long as + the `DOT_NPMRC` repo secret exists. +- Credentials are per repo. project-planning-fe must read as `svcusr_cf_projplanning-fe`, the only build identity + in `bryntum-readers`, and that account is also its `JFROG_USER`. +- Live testing happens only on `clone-cplace-fe`, never on real `release/*` branches. Secret changes need the + user's consent. + +## Design Decisions Summary + +1. **One credential, `JFROG_TOKEN`, for read and publish**: the generated `~/.npmrc` authenticates with each + repo's existing per-repo `JFROG_TOKEN`. No separate read secret is introduced. + - In most repos the `DOT_NPMRC` install user is already the `JFROG_USER` account + (`secrets-comparison.md`), and for project-planning-fe this is exactly the Bryntum-entitled identity. + - 33675 AC1 (separate read/publish secrets) and AC3 (read-only jobs without publish credential) are dropped. + This is recorded on the ticket. +2. **Generation in `use-npmrc`, rewritten in place, with a literal token**: the composite keeps its path and name + and gains a `jfrog-token` input. It writes the token literally into `~/.npmrc` (`chmod 600`, never echoed). + - Exposure is the same as today (credentials already sit in `~/.npmrc`), and no per-step env wiring is + needed: every later npm call in the job authenticates, including the `npm view`/`npm search` calls in + `artifacts`/`snapshots`. + - The `replace-registry-host=never` line, the warn step, the bats tests and the comments that name + `use-npmrc` all stay. The inaccurate comments at `:20` and `:44` are corrected. +3. **Minimal file content from the shared proxy constant**: `registry=` and `_authToken` keyed to the + `cplace-npm` virtual, plus `replace-registry-host=never`. There are no scope lines. + - The URL comes from `JFROG_NPM_PROXY` (`tools/scripts/lockfile/lib.sh:20`), the single source of truth + shared with the lockfile checks. No URL secret is used. + - `@fortawesome`, own scopes and Bryntum all resolve through `cplace-npm`, so none of them is handled + specially. +4. **Dual-support window, token wins**: during migration `use-npmrc` takes `jfrog-token` and `dot-npmrc`, both + optional, and the reusables declare `JFROG_TOKEN` and `DOT_NPMRC` as `required: false`. + - Token present: the action generates the file and ignores `DOT_NPMRC`. Only `DOT_NPMRC`: it writes that + verbatim and emits a `::warning::` deprecation. Neither: it fails with `::error::`. This mirrors 34293's + `JfrogCredentials.authMode`. + - Callers that already receive `JFROG_TOKEN` switch at merge: `fe-release-flow` via `secrets: inherit`, and + the mixed publish/delete jobs. The user checks every repo's `JFROG_TOKEN` for `cplace-npm` read access + before the merge. +5. **Removal scope: everything on master in two PRs, secrets deleted elsewhere**: + - PR 1: dual support, templates (pass `JFROG_TOKEN` instead of `DOT_NPMRC`) and the README. Callers then + migrate repo by repo. + - PR 2, once every default-branch caller has migrated: drop the `DOT_NPMRC` declarations from all + reusables, drop the `dot-npmrc` input and fallback from `use-npmrc`, and make `jfrog-token` required. + - Deleting the `DOT_NPMRC` repo secrets is a separate cleanup ticket. It waits for the last release line + through 26.4 to go out of support and for the external direct consumers to migrate. +6. **Validation follows the 34293 process**: the user's pre-merge token check, then a live matrix on + `clone-cplace-fe`, then two reference repos. + - The matrix covers four input cases: token only, `DOT_NPMRC` only, both, neither. It runs install-deps, + licenses, sonar, pr-snapshot, pr-close, cleanup-snapshots and the release flow, and includes a log check + that the token never appears. + - Reference repos: `cplace-remote-filesystem-fe` (34293 pilot) and `cplace-project-planning-fe` (Bryntum + identity), green before the remaining 12 repos. + +This means: +- Nothing about install auth is hidden in secret text anymore: the read registry is committed code, and the only + secret is the token each repo already has. +- Most FE workflows switch to the generated file the moment PR 1 merges. Per-repo work is adding `JFROG_TOKEN` + to the `install-deps`/`licenses`/`sonar` callers and deleting `DOT_NPMRC` lines. +- Repos that haven't migrated show up as deprecation warnings in their run summaries, and a misconfigured repo + fails with an explicit error instead of an anonymous npm 401/404. +- After PR 2, master contains no reference to `DOT_NPMRC`. Release lines keep running unchanged on their own + pinned `use-npmrc` and the still-existing repo secret. +- The cleanup-snapshots `npm view`/`npm search` E404 (D2) is expected to disappear as a side effect. + +Major trade-offs we're accepting: +1. **No least-privilege split between read and publish**: read-only jobs (`fe-install-deps`, `fe-licenses`, + `fe-sonar`) now receive a token that can deploy and delete on `cplace-npm-local`. In exchange we avoid a + second set of secrets to provision and maintain, and avoid a special identity case for project-planning-fe. + 33675 AC1/AC3 are dropped explicitly rather than met. +2. **The token is on disk in `~/.npmrc`**, unlike the dist `.npmrc`'s placeholder style. In exchange there is no + fragile per-step env wiring. Exposure is the same as with today's `DOT_NPMRC`. +3. **Big switch at merge instead of per-repo opt-in**: with the token winning, the release flow and the mixed jobs + switch in all repos at once, and rollback is a master revert. In exchange there are far fewer caller edits. + The risk is moved before the merge through the token check and the clone matrix. +4. **Strict auth scope**: lockfile entries still pointing directly at a non-proxy URL (e.g. `cplace-npm-local/`) + are fetched without auth and fail. In exchange the token goes only to the read registry, and leftovers are + exposed instead of masked. The 34301 audit and the warn step cover this. + +What we're NOT doing (out of scope): +- Deleting `DOT_NPMRC` repo secrets (separate cleanup ticket). +- Backporting to release lines 23.1–26.4. +- Migrating direct `DOT_NPMRC` consumers outside this repo: cplace-e2e (`bduff9/use-npmrc`, no `JFROG_*`), + cplace-fe (visual-regression, xray, Windows PR, devkit-test-template, `deploy_storybook`/`DOT_NPMRC_CONTENT`), + and project-planning-fe (`bryntum-update.yml`, `sonar-scan.yml`). Each is a follow-up. +- A separate read token or read-scoped identity (`JFROG_READ_*`), and the org-level `ENV_CPLACE_ARTIFACTORY_*` pair. +- Adding `~/.npmrc` generation to `fe-snapshot` or `fe-check-upmerge`, which work without it today. +- Removing JFrog secrets from `fe-tag` (decided in 34293), and `dist/` / `.gitignore` test hygiene. +- Minting tokens or setting secrets (done by the user). + +Success criteria: +- On `clone-cplace-fe`, all four input cases behave as specified across the full workflow set, cleanup-snapshots + no longer fails with E404, and no log line contains the token value. +- `cplace-remote-filesystem-fe` and `cplace-project-planning-fe` (including the Bryntum packages) run CI green on + `JFROG_TOKEN` with no `DOT_NPMRC` passed. +- After PR 2, `git grep -i dot_npmrc` on master finds no workflow, template or action reference, and all 14 FE + repos' default-branch CI stays green. + +## Design Decisions - Details + +### Read credential: identity and scoping + +**Chosen Approach:** Reuse each repo's existing per-repo `JFROG_TOKEN` (a JFrog reference token of the +`JFROG_USER` service account) for installs as well as publishing. + +**Rationale:** The secrets comparison shows that in most repos the `DOT_NPMRC` install user already is the +`JFROG_USER` account, so the account behind `JFROG_TOKEN` already reads `cplace-npm`. A separate shared read +token would complicate project-planning-fe, whose Bryntum access is bound to `svcusr_cf_projplanning-fe`, and +that account is its `JFROG_USER`. One token per repo keeps provisioning as it is today. Repos to double-check +during the pre-merge token check: office-reports-fe and workflow-fe (`JFROG_USER` `svcusr_cf_lowcode_jfrog` vs +`.npmrc` user `svcusr_cf_cplace_docu`), and resource-management-fe (opaque token, read identity unknown). + +**Alternatives Considered:** +- **Separate read token (`JFROG_READ_*`), shared identity**: rejected. project-planning-fe would need an + override or a change to the `bryntum-readers` membership, and the provisioning effort doubles. +- **Read-scoped second token of the same service account**: rejected. It would keep 33675 AC3, but doubles + per-repo provisioning for a least-privilege gain the user chose to forgo. +- **Org-level `ENV_CPLACE_ARTIFACTORY_ACTOR/_TOKEN`**: rejected. It collapses identities and its rights are + unknown (as already rejected in 34293). +- **Separate read token, recommended initially**: in the problem framing, reusing `JFROG_TOKEN` was treated as + ruled out by 34293 Decision 7 ("publish tokens may lack read on the virtual"). This was overturned by the + user: the assumption that the publish identity differs from the install identity did not hold for most repos, + and the project-planning-fe identity requirement favours reuse. + +**Implications:** +- 33675 AC1/AC3 must be formally revised on the ticket (by the user, together with the requester). +- Read-only reusables now declare `JFROG_TOKEN`, a publish-capable credential. + +--- + +### Generation mechanism and token handling + +**Chosen Approach:** Rewrite `.github/actions/use-npmrc` in place. It gets a new `jfrog-token` input, and the +token is written literally into `~/.npmrc` with mode `600` and never echoed. + +**Rationale:** Keeping the path keeps every `@master` call site and the warn-step tooling valid. A literal token +matches today's `~/.npmrc` exposure and needs no env propagation. With a `${JFROG_TOKEN}` placeholder, any npm +or npx call in the job without that env var fails with "Failed to replace env in config". + +**Alternatives Considered:** +- **Placeholder `${JFROG_TOKEN}` with per-step `env:`**: rejected because it's fragile. Every npm step in about 8 + workflows would need the env var, and a forgotten line breaks only at runtime. +- **Placeholder plus export via `$GITHUB_ENV`**: rejected. It puts the token into the process env of every later + step, including third-party actions, which is broader exposure than a file in HOME. +- **New composite / TypeScript generator next to `writeNPMRCInDist`**: not pursued. In-place keeps the contract + stable and the shell composite already hosts both behaviours to preserve. + +**Implications:** +- The `artifacts`/`snapshots` composites' `printenv` does not print files, and the token is a masked secret value. +- Comments at `action.yml:20` (prefix misattributed to `JFROG_URL`) and `:44` ("seven workflows") are corrected. + +--- + +### Generated file content and URL source + +**Chosen Approach:** A minimal file containing `registry=` set to the `cplace-npm` virtual, `_authToken` keyed to +that same path, and `replace-registry-host=never`. The URL comes from the committed `JFROG_NPM_PROXY` constant +in `tools/scripts/lockfile/lib.sh`. + +**Rationale:** This matches the 34301 design's target file. The lockfile checks and the install config share +one source of truth, and the token goes only to the read registry. + +**Alternatives Considered:** +- **Auth keyed at `//cplace.jfrog.io/artifactory/api/npm/`**: rejected. It relies on unverified npm parent-path + credential matching, masks leftover non-proxy lockfile entries the audit is meant to remove, and sends the + token to every npm repo on the host. +- **Scope lines (`@fortawesome`, own scopes)**: not needed, because all of them resolve through `cplace-npm`. + +**Implications:** +- The composite must load the constant from `lib.sh` (it already reaches `tools/scripts/lockfile/` through + `$GITHUB_ACTION_PATH`). +- Any repo with lockfile entries outside the proxy prefix fails to install. The warn step and a pre-merge + `npm ci` per identity group catch this early. + +--- + +### Transition: precedence during the dual-support window + +**Chosen Approach:** The token wins. `DOT_NPMRC` is the fallback and emits a deprecation `::warning::`. If +neither is present, the action fails with an explicit `::error::`. Both secrets are declared `required: false` +on the reusables during the window. + +**Rationale:** This is consistent with 34293's `JFROG_TOKEN`/`JFROG_BASE64_TOKEN` handling. It needs the fewest +caller edits, because the release flow (`secrets: inherit`) and the mixed jobs already receive `JFROG_TOKEN`. +Unmigrated repos are visible as warnings. + +**Alternatives Considered:** +- **`DOT_NPMRC` wins while present**: rejected. `fe-release-flow` with `secrets: inherit` could never switch + before the final removal, so the big switch would only move later. There would also be no deprecation signal, + and precedence would be the reverse of 34293. + +**Implications:** +- Mandatory pre-merge check, done by the user: every repo's `JFROG_TOKEN` can read `cplace-npm`. +- Rollback during the window is a master revert, not a per-repo edit. +- `fe-release-flow`'s nested `install-deps` call gains `JFROG_TOKEN` in its explicit secret list. + +--- + +### Removal scope and release-line reach + +**Chosen Approach:** Master only, in two PRs within this ticket. PR 1 adds dual support, templates and README. +PR 2, after all default-branch callers have migrated, removes the `DOT_NPMRC` declarations, the `dot-npmrc` +input and the fallback, and makes `jfrog-token` required. Deleting the repo secrets is a separate cleanup ticket. + +**Rationale:** Release branches pin their own `use-npmrc` (`@release/X.Y` on 25.2–26.4, `bduff9/use-npmrc@v1.1` +on 23.1–25.1) and never load it from master. So master can drop the fallback entirely without affecting them. +Only the repo secret keeps release lines alive. + +**Alternatives Considered:** +- **This ticket only opens the window, and a follow-up closes it (34293 style)**: rejected, because 34294 would + close without removing anything. +- **Backport to release lines and remove everything now**: rejected. It touches 4+ release lines across 14 repos + against the master-only practice, and still can't delete the secrets before the external consumers migrate. + +**Implications:** +- The ticket stays open while 14 repos migrate. PR 2 is gated on every default-branch caller being migrated. +- Residual risk: a consumer's release branch still pointing at `@master` reusables (contrary to the README) + would break at PR 2. A check across the 14 repos before PR 2 covers this. + +--- + +### Validation and reference repositories + +**Chosen Approach:** The user's pre-merge token check, then a live matrix on `clone-cplace-fe` (master +redirected to the feature branch) covering the four input cases across install-deps, licenses, sonar, +pr-snapshot, pr-close, cleanup-snapshots and the release flow, plus a token-leak log check. After that, +`cplace-remote-filesystem-fe` and `cplace-project-planning-fe` serve as reference repos (33675 AC4) before the +remaining 12. + +**Rationale:** Under token-wins precedence the merge itself is the big switch, so every precedence branch and +the D2 path must be proven on the clone first. project-planning-fe covers the identity-sensitive Bryntum case. + +**Alternatives Considered:** +- **Pilot only, no clone matrix**: rejected. A defect would surface across production repos at merge, and the + fallback and error paths would go unproven before they're live. + +**Implications:** +- A `live-test-plan.md` is created during planning, modelled on 34293's. + +--- + +### Side issues from the research + +**Chosen Approach:** +- In scope: correcting the `use-npmrc` comments, the deprecated `fe-release.yml` (still on the live path), and + verifying D2 through the matrix without dedicated code. +- Unchanged: the warn script path, bats tests, `fe-snapshot`, `fe-check-upmerge`. +- Out of scope: `fe-tag` JFrog secrets, `dist/`/`.gitignore`. + +**Rationale:** Keep the change focused on the cutover. Items already decided elsewhere (34293) or unrelated stay +out. + +**Implications:** +- If D2 persists with the new token, it stays with its own ticket. + +## Overall Architecture + +At install time each FE job runs `use-npmrc`, which builds `~/.npmrc` from the committed read registry constant +and the repo's `JFROG_TOKEN`, appends the npm-11 mitigation, and runs the advisory lockfile warning. `npm ci` and +every later npm call in the job authenticate through that file. Publishing and deleting keep using the dist +`.npmrc` generated by the TypeScript tooling from the same `JFROG_TOKEN` passed as step env. So one per-repo +token now drives both files, and no npm configuration is stored as a secret. + +### Key Components +1. **`.github/actions/use-npmrc`**: generates `~/.npmrc` from `jfrog-token`. During the window it falls back to + `dot-npmrc` with a warning. It keeps `replace-registry-host=never` and the warn step. +2. **`JFROG_NPM_PROXY` (`tools/scripts/lockfile/lib.sh`)**: the single committed source of the read registry URL. +3. **Reusables** (`fe-install-deps`, `fe-licenses`, `fe-sonar`, `fe-pr-snapshot`, `fe-pr-close`, + `fe-cleanup-snapshots`, `fe-release`, `fe-release-flow`): pass `JFROG_TOKEN` to `use-npmrc`. They declare + `DOT_NPMRC` as optional during the window and drop it in PR 2. +4. **Templates (`.github/workflow-templates/fe/`) and README**: pass and document `JFROG_TOKEN` in place of + `DOT_NPMRC`. +5. **Dist `.npmrc` writer (`nx-project.ts`)**: unchanged. + +### Data Flow +`JFROG_TOKEN` repo secret → reusable `secrets.JFROG_TOKEN` → `use-npmrc` input → `~/.npmrc` (read, `cplace-npm`) +→ `npm ci` / `npm view` / `npm search`. In parallel: `JFROG_TOKEN` → `artifacts`/`snapshots` step env → +`dist//.npmrc` placeholder → `npm publish` / `dist-tag` / `unpublish` on `cplace-npm-local`. + +### Integration Points +- FE consumer repos' workflow callers (templates, hand-wired `fe-sonar` callers). +- `fe-release-flow` via `secrets: inherit` (no caller edit), and its explicit secret list to `fe-install-deps`. +- JFrog: `cplace-npm` virtual (read), `cplace-npm-local` (publish), the Bryntum remote via `bryntum-readers`. + +## Known Risks + +1. **A repo's `JFROG_TOKEN` identity lacks read on `cplace-npm`** (suspects: office-reports-fe, workflow-fe, + resource-management-fe). Mitigation: the user's pre-merge token check, and fixing the identity or permission + before merge. +2. **Leftover non-proxy lockfile entries fail without auth.** Mitigation: the 34301 audit, the warn step, and an + `npm ci` per identity group during the pre-merge check. +3. **Merge switches many repos at once.** Mitigation: the clone matrix before merge, and a fast master revert as + the rollback. +4. **PR 2 breaks a default-branch caller that still passes `DOT_NPMRC`, or a consumer release branch on + `@master`.** Mitigation: inventory the 14 repos' callers before PR 2 and gate PR 2 on zero remaining + references. +5. **The token is readable by every step in jobs that run `use-npmrc`, including read-only jobs.** Accepted + (trade-off 1). The file is `chmod 600`, and runners are ephemeral. + +## Next Steps + +1. Review this design document. +2. User actions: revise 33675 AC1/AC3 on the ticket, set the target release, and run the token read check. +3. Proceed to implementation planning: `/spec-driven-development:create_plan specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/design.md` + +## References + +- Tickets: [PFM-ISSUE-34294](https://base.cplace.io/pages/chduu2mpiug4855q91t5eerdh/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT-NPMRC-secret), + [PFM-ISSUE-33675](https://base.cplace.io/pages/keq1ackt7c8iqg12ifgx9l6pa/PFM-ISSUE-33675-Standardize-JFrog-npm-read-and-publish-authentication-in-frontend-workflows) +- Research: [research.md](./research.md) +- Secrets overview: `C:/cplace-dev/secrets fe repos/secrets-comparison.md` (local, not committed) +- Prior designs: [34293 design](../2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md), + [34293 live-test plan](../2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md), + [34301 design](../2026-11-16_PFM-ISSUE-34301_third-party-npm-registries-jfrog/design.md) +- Similar features: `tools/scripts/artifacts/jfrog-credentials.ts` (precedence/fallback pattern), + `tools/scripts/artifacts/nx-project.ts` `writeNPMRCInDist()` (generated publish `.npmrc`) diff --git a/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/research.md b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/research.md new file mode 100644 index 0000000..55d9272 --- /dev/null +++ b/specs/2026-12-01_PFM-ISSUE-34294_jfrog-npmrc-secret-cutover/research.md @@ -0,0 +1,356 @@ +--- +date: 2026-12-01T13:14:08+01:00 +git_commit: 87b8f01daa0c99062b6701e150f1daabb8d5e501 +branch: master +topic: "PFM-ISSUE-34294 + PFM-ISSUE-33675: runtime-generated read .npmrc, separate JFrog read/publish credentials, removal of DOT_NPMRC / use-npmrc" +tags: [research, codebase, dot-npmrc, use-npmrc, jfrog, npmrc, secrets, fe-workflows, workflow-templates, artifacts] +status: complete +last_updated: 2026-12-01 +--- + +# Research: Runtime-generated `.npmrc` and the `DOT_NPMRC` cutover (PFM-ISSUE-34294 + PFM-ISSUE-33675) + +**Date**: 2026-12-01T13:14:08+01:00 +**Git Commit**: 87b8f01daa0c99062b6701e150f1daabb8d5e501 +**Branch**: master + +## Research Question + +For both related issues, PFM-ISSUE-34294 ("Use the new secrets and remove the stored DOT_NPMRC secret") and PFM-ISSUE-33675 ("Standardize JFrog npm read and publish authentication in frontend workflows"): + +- Where is `DOT_NPMRC` / `use-npmrc` used? +- How is `.npmrc` produced today for install (read) and for publish? +- How are the 34293 secrets wired in? +- What does the codebase need so that: + - the read `.npmrc` is generated at runtime, + - read-only jobs cannot reach the publish credential, and + - `DOT_NPMRC` can be removed? + +The scope also includes the unmerged blocker PFM-ISSUE-34301, to judge whether the removal gate is met. + +## PFM Ticket Context + +### PFM-ISSUE-34294 (primary, used for the folder name) +- **Ticket**: [PFM-ISSUE-34294](https://base.cplace.io/pages/chduu2mpiug4855q91t5eerdh/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT-NPMRC-secret) +- **Title**: Use the new secrets and remove the stored DOT_NPMRC secret +- **Type**: PFM-ISSUE, groundwork. Priority high. Status 50.working. The impediment attribute says "Blocked". +- **Target Release**: not set +- **Assignee**: Vladimir Arsov +- **Epic**: WP-1963 Modernize FE 2.0 Frontend Workflow Authentication +- **Links**: + - Blocked by PFM-ISSUE-34293. That ticket is merged as `87b8f01` (#191). + - Blocked by PFM-ISSUE-34301. That ticket is in progress. + - Relates to PFM-ISSUE-33675. +- **Suggested Branch**: `improvement/PFM-ISSUE-34294-Use-the-new-secrets-and-remove-the-stored-DOT_NPMRC` (does not exist yet, locally or on origin) +- **Description**: + > ## Description + > Complete the credential cutover: once the new separate user/token secrets are in use, remove the full `.npmrc` that is currently stored as a GitHub Actions secret (`DOT_NPMRC`). + > ## Requirements + > - Generate the read/install `.npmrc` at build time from the new secrets (publishing already regenerates `.npmrc` in `dist`). + > - Remove `DOT_NPMRC` and its `use-npmrc` usage **completely** once covered. + > - Execute as one coordinated cutover with the new-secrets issue (add new secrets → use them → remove `DOT_NPMRC`). + > ## Acceptance Criteria + > - No FE workflow relies on a stored `DOT_NPMRC` secret. + > - Installs and publishes succeed using the build-time-generated `.npmrc`. + > ## Dependencies + > Tightly coupled with (and follows) the new-secrets issue. Gated by the registry work — all third-party registries proxied through JFrog and the registry audit signed off — so removal breaks nothing. Relates to PFM-ISSUE-33675. + +### PFM-ISSUE-33675 (related parent story) +- **Ticket**: [PFM-ISSUE-33675](https://base.cplace.io/pages/keq1ackt7c8iqg12ifgx9l6pa/PFM-ISSUE-33675-Standardize-JFrog-npm-read-and-publish-authentication-in-frontend-workflows) +- **Title**: Standardize JFrog npm read and publish authentication in frontend workflows +- **Type**: PFM-ISSUE, groundwork. Priority high. Status 50.working. Topic JFrog Artifactory. +- **Target Release**: not set +- **Assignee**: Vladimir Arsov. Requested by Christian Kaltenbach. +- **Epic**: WP-1963 +- **Links**: relates to PFM-ISSUE-34293 +- **Suggested Branch**: `improvement/PFM-ISSUE-33675-Standardize-JFrog-npm-read-and-publish-authentication` (does not exist yet) +- **Description**: + > **User Story**: As a developer maintaining a FE 2.0 frontend repository, I want JFrog npm read and publish credentials stored as separate GitHub Actions secrets with the `.npmrc` generated at workflow runtime, so that credential maintenance is straightforward and read-only jobs cannot accidentally use publish credentials. + > + > **Description**: Replace the current pattern of storing a full `.npmrc` in a single GitHub Actions secret. Each JFrog technical user (read and publish) is stored as its own GitHub Actions secret; the `.npmrc` is generated at workflow runtime from those secrets. Read-only jobs do not get access to the publish credential. + > + > **Open Questions (decide at implementation start)**: Read user as GitHub organization-level secret vs repository/environment secret; publish user scoping. Whether additional npm scopes need to be added beyond what the current `.npmrc` covers. + > + > **Acceptance Criteria**: (1) Read and publish JFrog technical users are stored as separate GitHub Actions secrets. (2) The `.npmrc` file is generated at workflow runtime from those secrets. (3) Read-only jobs do not have access to the publish credential. (4) At least one reference frontend repository runs CI on the new pattern. + +## Summary + +1. **34293 added only the publish side. No read credential exists.** + - Commit `87b8f01` added `JFROG_TOKEN`, a JFrog reference token for `JFROG_USER` with deploy, delete and annotate rights on `cplace-npm-local`. It is used as a plain `_authToken` in the generated **dist** `.npmrc`. `JFROG_BASE64_TOKEN` became deprecated. + - There is no `JFROG_READ_*` or similar read secret anywhere in the repo. + - 34294's phrase "the new secrets" therefore has no read-side counterpart yet. 33675 AC1 (separate read **and** publish secrets) is only half done. + - The 34293 design explicitly rejected deriving install auth from `JFROG_USER`/`JFROG_TOKEN`. Two reasons: publish tokens are not guaranteed to have read rights on the `cplace-npm` virtual repo, and it would hand the publish credential to every `npm ci`. +2. **The read/install `.npmrc` has no generator today.** + - `.github/actions/use-npmrc/action.yml:15` writes the `DOT_NPMRC` secret verbatim to `~/.npmrc`. + - It then appends `replace-registry-host=never` (`:31`), the PFM-ISSUE-34453 npm-11 mitigation. + - It then runs `warn-foreign-registry.sh || true` (`:47`). + - Whatever replaces it must keep both of those behaviours. +3. **`DOT_NPMRC` is declared by 8 reusables and passed by 6 templates.** + - `fe-release.yml` (template) passes it via `secrets: inherit`. + - Consumers wire `fe-sonar` by hand. + - Four publish/delete jobs hold **both** credentials in the same job: `fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, and `fe-release` / the `fe-release-flow` `release` job. + - The separation today is per **step**: `JFROG_*` is passed as `env:` on the `artifacts`/`snapshots` step only. Read access goes through `~/.npmrc`, publish access through `dist//.npmrc`. +4. **The target read `.npmrc` is small.** + - According to the 34301 design, it is `registry=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/` plus `//cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=${}`, with no scope lines. + - This holds because the `cplace-npm` virtual includes `cplace-npm-local` and, once 34301 Phase 1 is done, Bryntum. + - The proxy URL already exists as a hard-coded constant in `tools/scripts/lockfile/lib.sh:20` (`JFROG_NPM_PROXY`). It is not `JFROG_URL`, which is the publish target `cplace-npm-local`. +5. **The removal gate (34301) is not yet met.** + - Phase 1 (Bryntum remote in JFrog) is done. + - Phase 2 (the project-planning-fe secret switch, Option B lockfile PRs #476–#480) is paused or pending. + - Phases 3 and 4 (merge, `audit.md`, README policy section, sign-off) are open. + - Residual non-JFrog lockfile entries remain on release branches: primeng `git+ssh`, and cplace-e2e `release/26.1` with npmjs. +6. **Release branches and `@master` coupling are the main compatibility constraint.** + - Templates pin reusables at `@master`, and consumers rewrite that to `@release/X.Y` per branch. + - Removing the `DOT_NPMRC` declaration or `use-npmrc` from master breaks callers that still pass the secret: undeclared secrets are a validation error for explicit callers. + - It also breaks branches that still depend on its contents. + - There is precedent from 34293 and 34282: drop the declaration in master, keep repo secrets until the last dependent release line is out of support. +7. **There are direct `DOT_NPMRC` consumers outside this repo**, which must migrate before the secret can be deleted: + - cplace-e2e: `bduff9/use-npmrc` + - cplace-fe: visual-regression, xray, Windows PR, devkit-test-template, `deploy_storybook` with `DOT_NPMRC_CONTENT` + - project-planning-fe: `bryntum-update.yml` and `sonar-scan.yml` + +## Detailed Findings + +### 1. The `use-npmrc` composite (current read path) +- Single required input `dot-npmrc` (`.github/actions/use-npmrc/action.yml:3-6`). It has no registry, scope or URL input, so all routing lives inside the secret text. +- `echo "$DOT_NPMRC" > ~/.npmrc` (`:15`) overwrites the runner HOME `.npmrc`. +- `echo 'replace-registry-host=never' >> ~/.npmrc` (`:31`). This is the PFM-ISSUE-34453 mitigation: npm 11.3 drops the proxy path prefix when it rewrites npmjs `resolved` URLs. + - The comment at `:20` says "the prefix is the JFROG_URL secret". That is inaccurate. The read prefix comes from the `registry=` line inside `DOT_NPMRC` (the `cplace-npm` virtual), while `JFROG_URL` is the publish target. +- `bash ".../tools/scripts/lockfile/warn-foreign-registry.sh" || true` (`:47`) is advisory only. The comment at `:44` says "all seven workflows"; the real count is eight. +- Callers load it as `collaborationFactory/github-actions/.github/actions/use-npmrc@master`, an external ref. Every caller therefore gets master behaviour regardless of its own ref. + +### 2. Per-workflow credential map (reusables in `.github/workflows/`) + +| Workflow | Job | Credential today | Kind | Notes | +|---|---|---|---|---| +| `fe-install-deps.yml` | install-deps | `DOT_NPMRC` → use-npmrc (`:32-35`), `npm ci` (`:39`) | read | `DOT_NPMRC` is `required: true` (`:10`). use-npmrc runs always. Only `npm ci` is gated on a cache miss. | +| `fe-build.yml` | build | none | read | Uses the node_modules cache. `run-many` runs `npm ci` in the actions repo with no `~/.npmrc`. | +| `fe-e2e.yml` | e2e | `PERCY_TOKEN` (optional) | read | Cache only | +| `fe-code-quality.yml` | code-quality / sonar | `SONAR_CLOUD_TOKEN` (optional) | read | No npm install | +| `fe-sonar.yml` | sonarqube-scan | `DOT_NPMRC` → use-npmrc (`:56-61`), `npm ci` (`:65`) | read | `DOT_NPMRC` required (`:10`). This is the only workflow that gates use-npmrc on a cache miss (`:57`). It has no template; consumers wire it by hand. | +| `fe-licenses.yml` | check-licenses | `DOT_NPMRC` → use-npmrc (`:38-41`), `npm ci` (`:45`) | read | `DOT_NPMRC` required (`:13`) | +| `fe-pr-snapshot.yml` | publish-pr-snapshot | `DOT_NPMRC` → use-npmrc (`:59-62`), `npm ci` (`:66`), then `JFROG_*` env on `artifacts` (`:68-77`) | **publish** | Both credentials in one job | +| `fe-snapshot.yml` | snapshot | `JFROG_*` env on `artifacts` (`:44-53`) | **publish** | No `DOT_NPMRC`. Relies on the install-deps cache. | +| `fe-pr-close.yml` | remove-artifacts | `DOT_NPMRC` → use-npmrc (`:41-44`), `npm ci` (`:48`), `JFROG_*` on `artifacts` with `ONLY_DELETE_ARTIFACTS` (`:50-60`) | **delete** | Both credentials in one job | +| `fe-cleanup-snapshots.yml` | build | `DOT_NPMRC` → use-npmrc (`:39-42`), then `JFROG_*` env on `snapshots` (`:44-50`) | **delete** | `cleanup-snapshots.ts:33,71` runs `npm view` and `npm search` through `~/.npmrc` (`DOT_NPMRC`) | +| `fe-release.yml` (deprecated) | release-version | `DOT_NPMRC` → use-npmrc (`:45-48`), `npm ci \|\| yarn` (`:52`), `JFROG_*` (`:54-61`) | **publish** | Deprecation warning at `:27` | +| `fe-tag.yml` (deprecated) | tag | `JFROG_*` (`:56-65`), `GIT_USER_TOKEN` | bump/tag | No `DOT_NPMRC`. The JFrog secrets are likely unnecessary because bump-only needs no credentials. | +| `fe-check-upmerge.yml` | check-upmerge | none (Slack and git) | read | `upmerge/action.yml:8,10` runs `npm ci` and `npm install -g @cplace/cli` without an `.npmrc` | +| `pr-checks.yml` | lockfile, scripts | none | n/a | `check-lockfile.sh --prefix-only`, shellcheck, bats | +| `fe-release-flow.yml` | guard | none | read | `contents: read` | +| `fe-release-flow.yml` | install-deps | `DOT_NPMRC` passed explicitly (`:78-79`) → fe-install-deps | read | Explicit secret list. A new read secret must be added here. | +| `fe-release-flow.yml` | build, e2e | none / `PERCY_TOKEN` (`:99-100`) | read | | +| `fe-release-flow.yml` | release | `DOT_NPMRC` → use-npmrc (`:134-137`), `npm ci` (`:141`), `JFROG_*` on `artifacts` (`:151-160`), plus a failure-cleanup delete (`:189-198`) | **publish + tag** | `contents: write` (`:112`). The inline job sees every declared secret. | +| `fe-release-flow.yml` | github-release | `github.token` | release | No npm | + +**Declared `workflow_call.secrets`:** +- `DOT_NPMRC` is required in `fe-install-deps`, `fe-licenses`, `fe-sonar`, `fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, `fe-release` and `fe-release-flow`. +- `JFROG_URL` and `JFROG_USER` are required, and `JFROG_TOKEN` and `JFROG_BASE64_TOKEN` are optional, in `fe-snapshot`, `fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, `fe-release`, `fe-tag` and `fe-release-flow`. + +### 3. Publish-side `.npmrc` generation (TypeScript, already runtime-generated) +- `tools/scripts/artifacts/jfrog-credentials.ts`: + - Reads `JFROG_URL`, `JFROG_USER`, `JFROG_BASE64_TOKEN` and `JFROG_TOKEN` (`:21-31`), each defaulting to `''`. + - `authMode` (`:34-38`) is TOKEN, LEGACY or NONE, decided by truthiness. Unset optional secrets arrive as `''`. + - `requireForPublishing()` (`:41-52`): LEGACY logs `::warning::`, NONE logs `::error::` and throws. + - `getJfrogUrlNoHttp()` (`:54`) strips `https:`. + - `toJSON()` (`:59`) redacts secrets. + - `TOKEN_PLACEHOLDER = '${JFROG_TOKEN}'` (`:9`) is written literally, and npm expands it from the step env. +- `tools/scripts/artifacts/nx-project.ts:293-324` `writeNPMRCInDist()` writes `dist///.npmrc`: + - TOKEN mode: `:registry=` and `////:_authToken=${JFROG_TOKEN}`. + - LEGACY mode: the four-line `_auth` / `always-auth` / `email` format. + - It has no default `registry=` and no `replace-registry-host`. + - Call sites: `artifacts-handler.ts:170` (build → write → publish) and `nx-project.ts:247` (`deleteArtifact` when the dist path is missing; cleanup and `ONLY_DELETE_ARTIFACTS`). +- `tools/scripts/artifacts/configuration.ts:1-5` `getJfrogUrl()` defaults to `https://cplace.jfrog.io/artifactory/cplace-npm-local`. `JFROG_URL` must end with `/` (README). +- Reads that rely on the **ambient** `~/.npmrc` (that is, `DOT_NPMRC`), not on the dist file: + - `utils.ts:338` (`npm view /`) + - `cleanup-snapshots.ts:31-33` (`npm view`) + - `cleanup-snapshots.ts:69-71` (`npm search`) + - A runtime read `.npmrc` must cover these too. + - 34293's live test T5 already fails here with E404 via `DOT_NPMRC`. This is pre-existing defect D2, failing since 2026-07. +- The `artifacts` and `snapshots` composites run `printenv` first (`artifacts/action.yml:16`, `snapshots/action.yml:6`). Secret values are masked, but derived values are not. Any token written to a file must not be echoed, or must be registered via `::add-mask::`. +- Tests: + - `jfrog-credentials.test.ts` covers modes, empty strings and redaction. + - `nx-project.test.ts:141-152` covers the TOKEN content. + - `artifacts-handler.test.ts:103-104`, `:161-162` and `:198-199` cover npmrc content expectations. +- No reusable function produces an install `.npmrc`. The closest building blocks are `JfrogCredentials` with its placeholder pattern, and `JFROG_NPM_PROXY` in bash (`lib.sh:20`, deliberately hard-coded, documented at `lib.sh:10-19`). +- Untracked `dist/apps/cf-components/{.npmrc,package.json}` is a jest side effect: a LEGACY-format file with empty values, produced by `artifacts-handler*.test.ts` running with an empty env. It is not a build artifact, and `.gitignore` has no `dist` entry. + +### 4. Lockfile tooling (relevant constraints) +- `tools/scripts/lockfile/lib.sh:20`: `JFROG_NPM_PROXY='https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/'`. This is the read proxy. It is hard-coded on purpose and is not `JFROG_URL`. +- `check-lockfile.sh:146-184` asserts a single registry prefix equal to the proxy. +- `normalize-lockfile.sh` rewrites `resolved` URLs onto the proxy, and must not depend on `npm ci`. +- `warn-foreign-registry.sh` references the `replace-registry-host=never` behaviour. It is exercised by bats tests in `pr-checks.yml:57-61`. If the warn step moves out of `use-npmrc`, the comments and tests that name `use-npmrc` must follow. + +### 5. Consumer templates (`.github/workflow-templates/fe/`) +All `uses:` are `@master`. Consumers rewrite them to `@release/X.Y` per branch (README `:48-49`). + +| Template | `DOT_NPMRC` | JFrog | Other | +|---|---|---|---| +| `fe-main.yml` | install-deps (`:27-28`) | snapshot gets `JFROG_TOKEN`/`URL`/`USER` (`:53-56`) | e2e gets `PERCY_TOKEN` | +| `fe-pr.yml` | install-deps (`:27-28`) | n/a | code-quality gets no secrets | +| `fe-pr-snapshot.yml` | yes (`:19-23`) | yes | n/a | +| `fe-pr-close.yml` | yes (`:19-23`) | yes | n/a | +| `fe-cleanup-snapshots.yml` | yes (`:16-20`) | yes | n/a | +| `fe-licenses.yml` | yes (`:24-25`) | n/a | n/a | +| `fe-release.yml` | via `secrets: inherit` (`:32`) | via inherit | `permissions: contents: write` | +| `fe-check-upmerge.yml` | n/a | n/a | Slack and git | + +- README: `:12` describes `use-npmrc` / `dot-npmrc`, `:85-87` lists the required secrets, `:93-109` is the JFrog and npm secrets table (`:101` says `DOT_NPMRC` is "a complete .npmrc … never used for publishing"), and `:103-109` covers the `JFROG_TOKEN` migration and the `@release/26.4`-and-older compatibility split. +- The README has no org-level vs repo-level secret guidance and no "Third-party npm registries" section yet. 34301 Phase 4 plans one. +- `CODEOWNERS` (repo root): `/* @slaven3kopic @alekhya-cplace @senthanal`. Every change needs a Frontend Core approval. + +### 6. Least-privilege constraint ("read-only jobs must not get the publish credential") +- `workflow_call` secrets are workflow-wide. Inside one reusable, isolation is possible only per **job** (via the secrets passed to nested `uses:` jobs) or per **step** (via `env:`). The jobs below cannot be isolated at the workflow level. +- Read-only reusables (`fe-install-deps`, `fe-licenses`, `fe-sonar`) declare only `DOT_NPMRC` today. Swapping it for a read-token secret keeps them free of publish credentials. +- In the mixed publish jobs (`fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, the `fe-release-flow` `release` job), the publish token is already confined to the `artifacts`/`snapshots` step `env:`. The install step would use the read token. This is step-level isolation inside a job that holds both credentials. +- `fe-release-flow` is called with `secrets: inherit` (34283 Decision 6, accepted trade-off). Its nested `install-deps` job gets only explicitly passed secrets (`:78-79`). The inline `release` job sees all of them. +- `fe-snapshot` has no install step. It relies on the cache and needs no read credential, unless a cache miss requires an install, which it does not do today. + +### 7. Blocker status: PFM-ISSUE-34301 (unmerged spec folder plus test branch) +- Folder: `specs/2026-11-16_PFM-ISSUE-34301_third-party-npm-registries-jfrog/` (untracked). + - research.md is complete, design.md is still `draft`, and plan.md is partially executed. +- **Done**: Phase 1 (2026-11-17). + - JFrog remote `bryntum-remote` (the design says `bryntum-npm-remote`), with includes `@bryntum/**` and `.npm/@bryntum/**`, placed before npmjs in the `cplace-npm` virtual. + - `cplace-npm-org-proxy` excludes Bryntum. + - `svcusr_cf_projplanning-fe` has Deploy/Cache rights and is in `bryntum-readers`. + - `squad_fe` and anonymous access are denied. +- **Paused**: Phase 2. + - An in-place edit of project-planning-fe's live `DOT_NPMRC` produced E403 from npm.bryntum.com and was reverted. + - Decision change on 2026-11-18, Option B: re-resolve the Bryntum lock entries on all supported branches. The PRs are project-planning-fe #476 (master), #477 (26.4), #478 (26.3), #479 (26.2) and #480 (26.1). + - The order is to merge the PRs, then switch the secret. + - design.md has not been updated for Option B. +- **Open**: Phase 3 (merge) and Phase 4 (`audit.md`, the README "Third-party npm registries" section, sign-off by Vladimir Arsov and Philip). Philip has not yet confirmed the `bryntum-readers` members. +- **Test branch** `origin/test/PFM-ISSUE-34301-dot-npmrc-test` (`5d06eca`, based on `3e8a45b`, before 34293): + - It switches only `fe-install-deps.yml` and `fe-sonar.yml` to `DOT_NPMRC_TEST`, paired with project-planning-fe's `test/PFM-ISSUE-34301-bryntum-via-jfrog`. + - Main CI run 44277324607 and Bryntum Update Check 44277343429 succeeded. + - It is throwaway: it predates `JFROG_TOKEN` handling and must not be merged. +- **What 34301 says the generated read `.npmrc` should be** (design "Overall Architecture"): `registry=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/` plus `//cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=…`. No scope lines are needed: + - `@fortawesome` is redundant. + - Own scopes (`@cplace-next`, `@cplace-project-planning-fe`) resolve via `cplace-npm`, which includes `cplace-npm-local`. + - Bryntum resolves via the new remote. +- **Identity constraint**: project-planning-fe's read `.npmrc` must authenticate as `svcusr_cf_projplanning-fe`, the only build identity in `bryntum-readers`. It cannot use the shared `squad_fe` that the other repos use. A single org-level read secret therefore cannot serve project-planning-fe unless that identity changes. +- **Residual gate blockers** (release branches only): + - primeng-sass-theme `git+ssh` on cplace-fe and resource-management 26.1–26.3. + - cplace-e2e `release/26.1` with 328 `registry.npmjs.org` entries. It uses `bduff9/use-npmrc`, so it does not get `replace-registry-host=never`, and its replacement must keep a default `registry=` without that line. + - Neither 34301 doc says whether sign-off covers all supported branches or only default branches. + +### 8. Current `DOT_NPMRC` contents across repos (from the 34293/34301 research) +- It is an opaque per-repo whole `.npmrc`. + - Most repos use `_auth` (basic `user:password`). `cplace-e2e` and `resource-management-fe` use `_authToken`. + - All have `registry=…/api/npm/cplace-npm/`. + - Some have redundant scope lines. + - project-planning-fe, plus a dead entry in cplace-fe, have `@bryntum:registry=https://npm.bryntum.com` plus a **personal** Bryntum JWT. +- All current secrets are **per-repo**. There are no org-level `JFROG_*` or `DOT_NPMRC` secrets. + - The org does have `ENV_CPLACE_ARTIFACTORY_ACTOR` / `ENV_CPLACE_ARTIFACTORY_TOKEN`, visible to the 15 repos and used by cplace-fe xray and devkit. + - 34293 rejected that pair for publish because it collapses identities and has unknown rights. +- `JFROG_TOKEN` was set on all FE repos and on `clone-cplace-fe` on 2026-11-24 (34293 live-test-plan §2.1). + - The callers' switch from `JFROG_BASE64_TOKEN` to `JFROG_TOKEN` is rolling out per repo, starting with the pilot `cplace-remote-filesystem-fe`. + +## Code References +- `.github/actions/use-npmrc/action.yml:3-6`: the single `dot-npmrc` input +- `.github/actions/use-npmrc/action.yml:15`: writes the secret verbatim to `~/.npmrc` +- `.github/actions/use-npmrc/action.yml:31`: appends `replace-registry-host=never` (PFM-ISSUE-34453) +- `.github/actions/use-npmrc/action.yml:47`: the advisory `warn-foreign-registry.sh` call +- `.github/actions/artifacts/action.yml:16-21`: `printenv`, `npm ci` in the actions repo, `ts-node main.ts` +- `.github/workflows/fe-install-deps.yml:10,32-35,39`: required `DOT_NPMRC`, then use-npmrc, then `npm ci` +- `.github/workflows/fe-sonar.yml:10,56-61,65`: the cache-gated use-npmrc +- `.github/workflows/fe-licenses.yml:13,38-41,45` +- `.github/workflows/fe-pr-snapshot.yml:19,59-62,66,68-77`: mixed read and publish job +- `.github/workflows/fe-pr-close.yml:19,41-44,48,50-60`: mixed read and delete job +- `.github/workflows/fe-cleanup-snapshots.yml:15,39-42,44-50`: mixed read and delete job +- `.github/workflows/fe-release.yml:15,27,45-48,52,54-61`: deprecated +- `.github/workflows/fe-release-flow.yml:25,78-79,112,134-137,141,151-160,189-198` +- `.github/workflows/fe-snapshot.yml:44-53`: publish, no `DOT_NPMRC` +- `.github/workflows/fe-tag.yml:56-65`: deprecated, JFrog secrets likely unnecessary +- `tools/scripts/artifacts/jfrog-credentials.ts:9,21-31,34-38,41-52,54,59` +- `tools/scripts/artifacts/nx-project.ts:247,293-324,430`: the dist `.npmrc` writer +- `tools/scripts/artifacts/artifacts-handler.ts:130,148-155,170` +- `tools/scripts/artifacts/cleanup-snapshots.ts:14,31-33,69-71,79,102` +- `tools/scripts/artifacts/utils.ts:338`: `npm view` through the ambient `.npmrc` +- `tools/scripts/artifacts/configuration.ts:1-5`: the `JFROG_URL` default (`cplace-npm-local`) +- `tools/scripts/lockfile/lib.sh:10-20`: the hard-coded `JFROG_NPM_PROXY` read proxy +- `tools/scripts/lockfile/check-lockfile.sh:146-184` +- `.github/workflow-templates/fe/*.yml`: consumer callers (see section 5) +- `README.md:12,85-87,93-109`: documentation to update +- `.github/workflows/pr-checks.yml:39-40,57-61`: lockfile check and bats + +## Architecture Insights +- **Two `.npmrc` files with different lifetimes.** + - `~/.npmrc` (read) comes from a secret, today via `use-npmrc`. + - `dist//.npmrc` (publish) is generated in TypeScript from `JFROG_*`. + - npm uses the dist file for `publish`, `dist-tag` and `show` with `cwd` in dist. + - The ticket's "generate the read `.npmrc` at build time" adds generation for the first file only. The second is already done. +- **The placeholder pattern** (`_authToken=${VAR}`, written literally and expanded by npm from the step env) keeps tokens out of files and logs. It is the established pattern to reuse for the read file. The read step would set the read token as step `env:` for `npm ci` / `npm view` / `npm search`. + - Caveat: npm expands `${VAR}` when it reads the config. Every later npm invocation in the job that needs the read registry (for example, `npm view` inside the `artifacts`/`snapshots` steps) must also have that env var set. Otherwise npm fails on an unset variable or sends an empty token. +- **The read URL is a constant, not a secret.** `JFROG_NPM_PROXY` is deliberately hard-coded and committed. A read generator can use the same constant, or share it with `lib.sh`, instead of introducing a `JFROG_READ_URL` secret. +- **Secret-contract changes ripple through `@master`.** Reusables and composites are loaded at `@master` (nested calls and `use-npmrc@master`). + - Removing a declared secret breaks explicit callers that still pass it. + - Adding a required secret breaks callers that don't pass it. + - Precedent from 34293/34282: add new secrets as `required: false`, drop old declarations only when callers are migrated, and keep repo secrets until the last release line using them is out of support. +- **`secrets: inherit` for the release flow** (34283) means release callers need no edits for the secret swap, but least privilege comes only from per-job or per-step wiring inside the reusable. +- **Per-repo secrets and identities** are the norm (34293). project-planning-fe needs its own read identity, `svcusr_cf_projplanning-fe`, for Bryntum. + +## Historical Context (from specs/) +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md`: + - Introduced `JFROG_TOKEN` (optional), kept `JFROG_USER`/`JFROG_URL` required, and deprecated `JFROG_BASE64_TOKEN`. + - Kept per-repo secrets. + - Rejected `JFROG_NPM_*` naming and the org-level `ENV_CPLACE_ARTIFACTORY_*` pair. + - **Explicitly deferred** `DOT_NPMRC`, `use-npmrc` and install auth to 33675 ("What we're NOT doing", Decision 7). + - Rejected deriving install auth from the publish token. +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md` (Migration Notes): the master-only merge, then the pilot repo, then 13 repos. The cleanup ticket that removes the legacy fallback is "to be created". +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md`: + - Test on `clone-cplace-fe` against `cplace-npm-test`, never on real `release/*`. + - Secret changes need user consent. + - T5 fails because of the pre-existing `DOT_NPMRC` E404 in cleanup (D2). +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md`: open findings 1.1 (test gap for gate paths) and 1.2 (duplicated gate logic). +- `specs/2026-11-16_PFM-ISSUE-34301_third-party-npm-registries-jfrog/{research,design,plan}.md`: + - The generated read `.npmrc` shape. + - The Bryntum remote. + - Option B. + - The direct-consumer inventory. + - Known Risk 4: master removal breaks release branches. + - The replacement for `use-npmrc` must keep `warn-foreign-registry.sh`. +- `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/design.md`: + - Decision 6 and "Secrets and permissions contract" (`:228-245`): `secrets: inherit` was chosen so later secret changes, explicitly including the `DOT_NPMRC` removal, need no caller edits. + - `:119`: one install definition for later npmrc changes. +- `specs/2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/{research,design}.md`: precedent for retiring a secret. Drop the callee declaration and keep repo secrets until no branch needs them. It also shows the hazard of callers passing undeclared secrets, for example cplace-fe `push_main.yaml` with `GIT_USER_TOKEN`. +- External: `C:/cplace-dev/FE2.0-initiative/PFM-Issues-FE2.0-Build-Integration.md:63-123` (FE-B02). It was not read in this session; the 34301 research references it. + +## Related Research +- `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/research.md` +- `specs/2026-11-16_PFM-ISSUE-34301_third-party-npm-registries-jfrog/research.md` +- `specs/2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/research.md` +- `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/research.md` +- `specs/2026-06-05_node24-workflow-migration/research.md`: mentions `DOT_NPMRC` in the Node 24 rollout context + +## Open Questions +1. **Which secret is the read credential?** + - 34294 says "use the new secrets", but 34293 delivered only a publish token. + - Option (a): a new read pair (`JFROG_READ_USER` / `JFROG_READ_TOKEN`, or similar), which satisfies 33675 AC1 and AC3. + - Option (b): reuse `JFROG_TOKEN`. This contradicts 33675 AC3 and the 34293 Decision 7 rationale. + - Naming has to be decided. +2. **Scoping of the read secret** (33675 open question): org-level, repo-level or environment-level. + - An org-level read secret is simplest, but project-planning-fe needs `svcusr_cf_projplanning-fe` for Bryntum. + - Either the org secret is overridden per repo (a repo secret with the same name takes precedence), or the Bryntum readers group gains the shared read identity. + - Should `ENV_CPLACE_ARTIFACTORY_ACTOR/_TOKEN` be reused or replaced? +3. **Scopes** (33675 open question): the 34301 design says no scope lines are needed. This needs confirmation for no-lockfile installs (`upmerge` `npm install -g @cplace/cli`, cplace-fe `pull_request_windows` and `devkit-test-template`) and for the `@fortawesome` line. +4. **Where generation lives**: + - Rewrite `use-npmrc` in place with new inputs, keeping the path stable for `@master` callers. + - Or add a new composite and delete `use-npmrc` later. + - Or generate in TypeScript next to `writeNPMRCInDist`. + - Whichever is chosen must keep `replace-registry-host=never` and the `warn-foreign-registry.sh` step. +5. **Release-branch compatibility.** How long must `use-npmrc` and the `DOT_NPMRC` declaration stay on master (as optional) for `@release/26.x` callers? Is "remove completely" (34294) achievable now, or only after the last supported release line migrates? Who updates the release branches' callers? +6. **Is the 34301 gate met?** + - Phases 2–4 are open, and the Option B PRs #476–#480 are not yet confirmed merged. + - The audit scope (all supported branches vs default branch) is undecided. + - cplace-e2e `release/26.1` (npmjs) and the primeng `git+ssh` entries are unresolved. +7. **Direct consumers outside github-actions** (cplace-e2e, cplace-fe including `deploy_storybook` and `DOT_NPMRC_CONTENT`, project-planning-fe `bryntum-update.yml` / `sonar-scan.yml`): are they in scope for 34294, or tracked separately? The secret can only be deleted per repo after these migrate. +8. **The "coordinated cutover" wording** (34294) vs 34293 Decision 7, which dropped the coordinated cutover. 34293 is merged on its own, so the sequence is now: add the read secret, switch the workflows, then remove `DOT_NPMRC`. +9. **Reference repository** for 33675 AC4: `clone-cplace-fe` (the test clone) or the 34293 pilot `cplace-remote-filesystem-fe`? +10. **Pre-existing D2** (cleanup `npm view`/`npm search` E404 via `DOT_NPMRC`): fix it as part of the new read `.npmrc`, or leave it to its separate ticket? +11. **Housekeeping found along the way**: + - The `use-npmrc` comment at `:20` misattributes the prefix to `JFROG_URL`. + - The comment at `:44` says "seven workflows" instead of eight. + - `fe-tag` passes JFrog secrets it doesn't need. + - Untracked `dist/` is jest output with no `.gitignore` entry. + - The target release is not set on either ticket. From 7c59f31bb80d10826ac311bd412e145de7428bb9 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Thu, 3 Dec 2026 16:03:58 +0100 Subject: [PATCH 2/3] PFM-ISSUE-34294 - Generate ~/.npmrc from JFROG_TOKEN in use-npmrc; DOT_NPMRC becomes a deprecated fallback use-npmrc delegates to write-npmrc.sh: with jfrog-token it writes the cplace-npm virtual as registry plus the token as _authToken; with only dot-npmrc it writes that content with a deprecation warning; with neither it fails before npm ci. fe-install-deps passes both secrets, both optional. pr-checks runs shellcheck and bats over the new script. Co-Authored-By: Claude Opus 5.5 --- .github/actions/use-npmrc/action.yml | 39 +++++------- .github/actions/use-npmrc/write-npmrc.bats | 24 ++++++++ .github/actions/use-npmrc/write-npmrc.sh | 70 ++++++++++++++++++++++ .github/workflows/fe-install-deps.yml | 6 +- .github/workflows/pr-checks.yml | 4 +- 5 files changed, 116 insertions(+), 27 deletions(-) create mode 100644 .github/actions/use-npmrc/write-npmrc.bats create mode 100755 .github/actions/use-npmrc/write-npmrc.sh diff --git a/.github/actions/use-npmrc/action.yml b/.github/actions/use-npmrc/action.yml index 40fa562..9841b90 100644 --- a/.github/actions/use-npmrc/action.yml +++ b/.github/actions/use-npmrc/action.yml @@ -1,47 +1,38 @@ name: 'Use .npmrc' -description: 'Writes the given .npmrc content to ~/.npmrc and warns about lockfile entries outside the cplace npm proxy' +description: 'Writes ~/.npmrc from JFROG_TOKEN (or the deprecated DOT_NPMRC) and warns about lockfile entries outside the cplace npm proxy' inputs: + jfrog-token: + description: 'JFrog token (the JFROG_TOKEN secret); authenticates installs against the cplace-npm virtual' + required: false + default: '' dot-npmrc: - description: 'Content of the .npmrc file' - required: true + description: 'Deprecated: content of a complete .npmrc; used only when jfrog-token is empty' + required: false + default: '' runs: using: 'composite' steps: - name: Write ~/.npmrc shell: bash env: + JFROG_TOKEN: ${{ inputs.jfrog-token }} DOT_NPMRC: ${{ inputs.dot-npmrc }} - run: | - echo "$DOT_NPMRC" > ~/.npmrc - # PFM-ISSUE-34453 mitigation. npm's default `replace-registry-host=npmjs` - # rewrites a lockfile's registry.npmjs.org URLs onto the configured - # registry. npm 10.2.4 does that correctly and the entry resolves through - # the proxy; npm 11.3.0 DROPS that registry's path prefix, producing an - # E404 masked as *** because the prefix is the JFROG_URL secret. Measured - # 2026-08-14 on a runner and locally with the same one-package fixture. - # - # `never` makes npm fetch each `resolved` URL verbatim, which survives - # both versions - at a cost: an entry still on npmjs is then fetched FROM - # npmjs, outside the proxy. This line buys npm-11 compatibility and - # spends proxy routing; normalizing the lockfile buys both. - # - # This is a no-op on a lockfile that already resolves entirely through - # the proxy, so it is safe to leave in place, and it is removable once - # the warning below stops firing anywhere. - echo 'replace-registry-host=never' >> ~/.npmrc + # Generation, precedence and the PFM-ISSUE-34453 mitigation live in the + # script, where bats covers them. + run: bash "$GITHUB_ACTION_PATH/write-npmrc.sh" - name: Warn on lockfile entries outside the cplace npm proxy shell: bash # Advisory only - never fails the build. The warnings are the inventory of - # lockfiles that still need normalizing; when none report, the mitigation - # above can be dropped. + # lockfiles that still need normalizing; when none report, the mitigation in + # write-npmrc.sh can be dropped. # # Invoked as `bash "" || true`, not as a bare path. The script's own # "every precondition is a silent success" contract cannot cover NOT BEING # REACHABLE - a missing exec bit after checkout, a path containing spaces, # or a runner where action_path is a backslashed Windows path. That is an # exit 127 from the shell rather than from the script, and it would fail - # the consumer's job before `npm ci` in all seven workflows using this + # the consumer's job before `npm ci` in every workflow using this # action. `continue-on-error:` is not honoured on composite steps, so # `|| true` is the mechanism that actually works here. run: bash "$GITHUB_ACTION_PATH/../../../tools/scripts/lockfile/warn-foreign-registry.sh" || true diff --git a/.github/actions/use-npmrc/write-npmrc.bats b/.github/actions/use-npmrc/write-npmrc.bats new file mode 100644 index 0000000..b8db404 --- /dev/null +++ b/.github/actions/use-npmrc/write-npmrc.bats @@ -0,0 +1,24 @@ +#!/usr/bin/env bats +# +# Behavioural tests for write-npmrc.sh, the generator behind the use-npmrc +# composite. HOME is redirected so that the tests never touch the real ~/.npmrc. +# +# Run with: bats .github/actions/use-npmrc/ + +setup() { + WRITE="${BATS_TEST_DIRNAME}/write-npmrc.sh" + export HOME="${BATS_TEST_TMPDIR}" + NPMRC="${HOME}/.npmrc" + unset JFROG_TOKEN DOT_NPMRC +} + +@test "writes registry, auth token and mitigation when only JFROG_TOKEN is set" { + export JFROG_TOKEN='test-token' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [ "$(cat "${NPMRC}")" = "registry=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/ +//cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=test-token +replace-registry-host=never" ] +} diff --git a/.github/actions/use-npmrc/write-npmrc.sh b/.github/actions/use-npmrc/write-npmrc.sh new file mode 100755 index 0000000..bfce0f8 --- /dev/null +++ b/.github/actions/use-npmrc/write-npmrc.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# +# Writes ~/.npmrc for npm installs. Run by the use-npmrc composite. +# +# Inputs (environment only, never arguments, so that they never appear in a +# process listing): JFROG_TOKEN, DOT_NPMRC. An empty value counts as not set, +# because a composite receives an input that was not passed as ''. +# +# JFROG_TOKEN set -> generated file: the cplace-npm virtual as registry and the +# token as its _authToken. DOT_NPMRC, if also set, is +# ignored with a ::notice::. +# only DOT_NPMRC -> DEPRECATED: written verbatim, with a ::warning::. +# neither -> ::error::, exit 1, no file written. +# +# The token is written literally, never printed. See PFM-ISSUE-34294. + +set -euo pipefail + +LIB="$(dirname "${BASH_SOURCE[0]}")/../../../tools/scripts/lockfile/lib.sh" +readonly LIB +# shellcheck source=tools/scripts/lockfile/lib.sh +source "${LIB}" + +main() { + local npmrc="${HOME}/.npmrc" + local token="${JFROG_TOKEN:-}" dot_npmrc="${DOT_NPMRC:-}" + + umask 077 + if [[ -n "${token}" ]]; then + if [[ "${token}" =~ [[:space:]] ]]; then + echo '::error::JFROG_TOKEN contains whitespace; check the repository secret.' + return 1 + fi + printf 'registry=%s\n%s:_authToken=%s\n' \ + "${JFROG_NPM_PROXY}" "${JFROG_NPM_PROXY#https:}" "${token}" >"${npmrc}" + if [[ -n "${dot_npmrc}" ]]; then + echo '::notice::DOT_NPMRC is passed but ignored, because JFROG_TOKEN is set. Remove the DOT_NPMRC line from this caller.' + fi + elif [[ -n "${dot_npmrc}" ]]; then + printf '%s\n' "${dot_npmrc}" >"${npmrc}" + echo '::warning::DOT_NPMRC is deprecated. Pass JFROG_TOKEN instead, see "JFrog and npm secrets" in the github-actions README.' + else + echo '::error::No npm credentials: pass the JFROG_TOKEN secret (see "JFrog and npm secrets" in the github-actions README).' + return 1 + fi + + # PFM-ISSUE-34453 mitigation. npm's default `replace-registry-host=npmjs` + # rewrites a lockfile's registry.npmjs.org URLs onto the configured + # registry. npm 10.2.4 does that correctly and the entry resolves through + # the proxy; npm 11.3.0 DROPS that registry's path prefix (the + # `/artifactory/api/npm/cplace-npm/` part of the `registry=` URL), producing + # an E404. In the generated file that URL is committed, not secret; in the + # DOT_NPMRC fallback it comes from the secret, so the E404 is masked as ***. + # Measured 2026-08-14 on a runner and locally with the same one-package + # fixture. + # + # `never` makes npm fetch each `resolved` URL verbatim, which survives + # both versions - at a cost: an entry still on npmjs is then fetched FROM + # npmjs, outside the proxy. This line buys npm-11 compatibility and + # spends proxy routing; normalizing the lockfile buys both. + # + # This is a no-op on a lockfile that already resolves entirely through + # the proxy, so it is safe to leave in place, and it is removable once + # the lockfile advisory in use-npmrc stops firing anywhere. + echo 'replace-registry-host=never' >>"${npmrc}" + # umask covers a new file only; a pre-existing ~/.npmrc keeps its mode. + chmod 600 "${npmrc}" +} + +main "$@" diff --git a/.github/workflows/fe-install-deps.yml b/.github/workflows/fe-install-deps.yml index 0e31f9e..660c9a4 100644 --- a/.github/workflows/fe-install-deps.yml +++ b/.github/workflows/fe-install-deps.yml @@ -7,8 +7,11 @@ on: type: string required: true secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: install-deps: @@ -32,6 +35,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 5be329c..af4c6d3 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -55,7 +55,7 @@ jobs: sudo apt-get install -y bats shellcheck - name: shellcheck - run: shellcheck tools/scripts/lockfile/*.sh tools/scripts/lockfile/test-helper.bash + run: shellcheck tools/scripts/lockfile/*.sh tools/scripts/lockfile/test-helper.bash .github/actions/use-npmrc/*.sh - name: bats - run: bats tools/scripts/lockfile/ + run: bats tools/scripts/lockfile/ .github/actions/use-npmrc/ From e48a4b367b111e803f413460f409e2ea59e3bf2e Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Thu, 3 Dec 2026 17:06:53 +0100 Subject: [PATCH 3/3] PFM-ISSUE-34294 - Pass JFROG_TOKEN to use-npmrc in every FE reusable; templates and README drop DOT_NPMRC All eight reusables that run use-npmrc declare JFROG_TOKEN and DOT_NPMRC as optional and pass both; fe-release-flow's nested install-deps gets both. write-npmrc.bats covers every input case, whitespace tokens, overwrite and mode 600. The templates pass JFROG_TOKEN and no DOT_NPMRC; the README documents JFROG_TOKEN as the install credential (read on the cplace-npm virtual), marks DOT_NPMRC deprecated and adds the migration steps. Co-Authored-By: Claude Opus 5.5 --- .github/actions/use-npmrc/write-npmrc.bats | 112 ++++++++++++++++++ .../fe/fe-cleanup-snapshots.yml | 1 - .github/workflow-templates/fe/fe-licenses.yml | 2 +- .github/workflow-templates/fe/fe-main.yml | 2 +- .github/workflow-templates/fe/fe-pr-close.yml | 1 - .../workflow-templates/fe/fe-pr-snapshot.yml | 1 - .github/workflow-templates/fe/fe-pr.yml | 2 +- .github/workflows/fe-cleanup-snapshots.yml | 4 +- .github/workflows/fe-licenses.yml | 6 +- .github/workflows/fe-pr-close.yml | 4 +- .github/workflows/fe-pr-snapshot.yml | 4 +- .github/workflows/fe-release-flow.yml | 5 +- .github/workflows/fe-release.yml | 4 +- .github/workflows/fe-sonar.yml | 8 +- README.md | 32 +++-- tools/scripts/lockfile/README.md | 3 +- 16 files changed, 166 insertions(+), 25 deletions(-) diff --git a/.github/actions/use-npmrc/write-npmrc.bats b/.github/actions/use-npmrc/write-npmrc.bats index b8db404..b7a0bf0 100644 --- a/.github/actions/use-npmrc/write-npmrc.bats +++ b/.github/actions/use-npmrc/write-npmrc.bats @@ -22,3 +22,115 @@ setup() { //cplace.jfrog.io/artifactory/api/npm/cplace-npm/:_authToken=test-token replace-registry-host=never" ] } + +@test "prints neither the token nor an annotation when only JFROG_TOKEN is set" { + export JFROG_TOKEN='secret-token-value' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [[ "${output}" != *'secret-token-value'* ]] + [[ "${output}" != *'::'* ]] +} + +@test "makes the written file readable by its owner only" { + [[ "$(uname -s)" != MINGW* && "$(uname -s)" != MSYS* ]] || skip 'NTFS has no Unix file modes' + export JFROG_TOKEN='test-token' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [ "$(stat -c %a "${NPMRC}")" = '600' ] +} + +@test "uses JFROG_NPM_PROXY from lib.sh as the registry" { + # shellcheck source=tools/scripts/lockfile/lib.sh + source "${BATS_TEST_DIRNAME}/../../../tools/scripts/lockfile/lib.sh" + export JFROG_TOKEN='test-token' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [ "$(head -n 1 "${NPMRC}")" = "registry=${JFROG_NPM_PROXY}" ] +} + +@test "prefers JFROG_TOKEN over DOT_NPMRC and says so in a notice" { + export JFROG_TOKEN='test-token' + export DOT_NPMRC='registry=https://legacy.example/npm/' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + grep -q '_authToken=test-token' "${NPMRC}" + [[ "$(cat "${NPMRC}")" != *'legacy.example'* ]] + [[ "${output}" == *'::notice::'* ]] + [[ "${output}" != *'::warning::'* ]] +} + +@test "writes DOT_NPMRC verbatim plus the mitigation, with a deprecation warning, when only it is set" { + export DOT_NPMRC='registry=https://legacy.example/npm/ +//legacy.example/npm/:_auth=abc' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [ "$(cat "${NPMRC}")" = "registry=https://legacy.example/npm/ +//legacy.example/npm/:_auth=abc +replace-registry-host=never" ] + [[ "${output}" == *'::warning::'* ]] + [[ "${output}" == *'DOT_NPMRC is deprecated'* ]] +} + +@test "fails without writing a file when neither secret is set" { + run "${WRITE}" + + [ "${status}" -ne 0 ] + [[ "${output}" == *'::error::'* ]] + [[ "${output}" == *'No npm credentials'* ]] + [ ! -e "${NPMRC}" ] +} + +@test "treats empty strings as not set, as a composite passes an omitted input" { + export JFROG_TOKEN='' DOT_NPMRC='' + + run "${WRITE}" + + [ "${status}" -ne 0 ] + [[ "${output}" == *'::error::'* ]] + [[ "${output}" == *'No npm credentials'* ]] + [ ! -e "${NPMRC}" ] +} + +@test "rejects a token containing a space, without printing it or writing a file" { + export JFROG_TOKEN='secret-part other-part' + + run "${WRITE}" + + [ "${status}" -ne 0 ] + [[ "${output}" == *'::error::'* ]] + [[ "${output}" != *'secret-part'* ]] + [ ! -e "${NPMRC}" ] +} + +@test "rejects a token containing a newline, without printing it or writing a file" { + export JFROG_TOKEN='secret-part +other-part' + + run "${WRITE}" + + [ "${status}" -ne 0 ] + [[ "${output}" == *'::error::'* ]] + [[ "${output}" != *'secret-part'* ]] + [ ! -e "${NPMRC}" ] +} + +@test "replaces an existing ~/.npmrc instead of appending to it" { + printf 'stale=content\n' >"${NPMRC}" + export JFROG_TOKEN='test-token' + + run "${WRITE}" + + [ "${status}" -eq 0 ] + [[ "$(cat "${NPMRC}")" != *'stale=content'* ]] + [ "$(wc -l <"${NPMRC}")" -eq 3 ] +} diff --git a/.github/workflow-templates/fe/fe-cleanup-snapshots.yml b/.github/workflow-templates/fe/fe-cleanup-snapshots.yml index 6426e03..26773ee 100644 --- a/.github/workflow-templates/fe/fe-cleanup-snapshots.yml +++ b/.github/workflow-templates/fe/fe-cleanup-snapshots.yml @@ -17,4 +17,3 @@ jobs: JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} diff --git a/.github/workflow-templates/fe/fe-licenses.yml b/.github/workflow-templates/fe/fe-licenses.yml index aa73fb0..dd30fd5 100644 --- a/.github/workflow-templates/fe/fe-licenses.yml +++ b/.github/workflow-templates/fe/fe-licenses.yml @@ -22,4 +22,4 @@ jobs: FOSS_DIST: dist CUSTOM_LICENSES_JSON: custom-licenses/custom-licenses.json secrets: - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} diff --git a/.github/workflow-templates/fe/fe-main.yml b/.github/workflow-templates/fe/fe-main.yml index 9f5f197..7fda954 100644 --- a/.github/workflow-templates/fe/fe-main.yml +++ b/.github/workflow-templates/fe/fe-main.yml @@ -25,7 +25,7 @@ jobs: with: GHA_REF: '' secrets: - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} # This job is only needed in case you are using Percy e2e-tests: diff --git a/.github/workflow-templates/fe/fe-pr-close.yml b/.github/workflow-templates/fe/fe-pr-close.yml index 343e941..da0682c 100644 --- a/.github/workflow-templates/fe/fe-pr-close.yml +++ b/.github/workflow-templates/fe/fe-pr-close.yml @@ -20,4 +20,3 @@ jobs: JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} diff --git a/.github/workflow-templates/fe/fe-pr-snapshot.yml b/.github/workflow-templates/fe/fe-pr-snapshot.yml index 7354093..2c7051e 100644 --- a/.github/workflow-templates/fe/fe-pr-snapshot.yml +++ b/.github/workflow-templates/fe/fe-pr-snapshot.yml @@ -20,4 +20,3 @@ jobs: JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} diff --git a/.github/workflow-templates/fe/fe-pr.yml b/.github/workflow-templates/fe/fe-pr.yml index d77f0e6..3b2523f 100644 --- a/.github/workflow-templates/fe/fe-pr.yml +++ b/.github/workflow-templates/fe/fe-pr.yml @@ -25,7 +25,7 @@ jobs: with: GHA_REF: ${{ github.event.pull_request.head.ref }} secrets: - DOT_NPMRC: ${{ secrets.DOT_NPMRC }} + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} build: needs: install-deps diff --git a/.github/workflows/fe-cleanup-snapshots.yml b/.github/workflows/fe-cleanup-snapshots.yml index fbdac7b..b613ada 100644 --- a/.github/workflows/fe-cleanup-snapshots.yml +++ b/.github/workflows/fe-cleanup-snapshots.yml @@ -12,8 +12,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: build: @@ -39,6 +40,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Cleanup Snapshot Artifacts diff --git a/.github/workflows/fe-licenses.yml b/.github/workflows/fe-licenses.yml index d2f4b3d..7a6f1c3 100644 --- a/.github/workflows/fe-licenses.yml +++ b/.github/workflows/fe-licenses.yml @@ -10,8 +10,11 @@ on: required: false type: string secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: check-licenses: @@ -38,6 +41,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules diff --git a/.github/workflows/fe-pr-close.yml b/.github/workflows/fe-pr-close.yml index 75e1ccf..fae84ac 100644 --- a/.github/workflows/fe-pr-close.yml +++ b/.github/workflows/fe-pr-close.yml @@ -16,8 +16,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: remove-artifacts: @@ -41,6 +42,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules diff --git a/.github/workflows/fe-pr-snapshot.yml b/.github/workflows/fe-pr-snapshot.yml index df2c86c..dde25af 100644 --- a/.github/workflows/fe-pr-snapshot.yml +++ b/.github/workflows/fe-pr-snapshot.yml @@ -16,8 +16,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false jobs: publish-pr-snapshot: @@ -59,6 +60,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules diff --git a/.github/workflows/fe-release-flow.yml b/.github/workflows/fe-release-flow.yml index 63f0844..f16c5f6 100644 --- a/.github/workflows/fe-release-flow.yml +++ b/.github/workflows/fe-release-flow.yml @@ -22,8 +22,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false GIT_USER: required: true GIT_USER_EMAIL: @@ -76,6 +77,7 @@ jobs: with: GHA_REF: '' secrets: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} DOT_NPMRC: ${{ secrets.DOT_NPMRC }} build: @@ -134,6 +136,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install Modules diff --git a/.github/workflows/fe-release.yml b/.github/workflows/fe-release.yml index 3198cdc..f6536c5 100644 --- a/.github/workflows/fe-release.yml +++ b/.github/workflows/fe-release.yml @@ -12,8 +12,9 @@ on: required: true JFROG_USER: required: true + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed DOT_NPMRC: - required: true + required: false env: NX_BRANCH: ${{ github.event.number }} @@ -45,6 +46,7 @@ jobs: - name: Use .npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install Modules diff --git a/.github/workflows/fe-sonar.yml b/.github/workflows/fe-sonar.yml index 59fe86b..e975b08 100644 --- a/.github/workflows/fe-sonar.yml +++ b/.github/workflows/fe-sonar.yml @@ -7,9 +7,12 @@ on: SONAR_CLOUD_TOKEN: required: true description: "SonarCloud authentication token" + JFROG_TOKEN: + required: false + description: "JFrog token; authenticates npm installs against the cplace-npm virtual" DOT_NPMRC: - required: true - description: "Contents of the .npmrc file for authenticating against private npm registries" + required: false + description: "Deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed" inputs: SONAR_CLOUD_ORG: required: false @@ -58,6 +61,7 @@ jobs: id: use-npmrc uses: collaborationFactory/github-actions/.github/actions/use-npmrc@master with: + jfrog-token: ${{ secrets.JFROG_TOKEN }} dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install dependencies diff --git a/README.md b/README.md index f47c531..441a3db 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ JavaScript action runtime since June 2026). the latest majors: checkout v6, cache v5, setup-node v6, upload-artifact v7, download-artifact v8, github-script v9, sonarqube-scan-action v8. - Self-hosted runners must run GitHub Actions Runner **>= 2.327.1**. -- `.npmrc` provisioning uses the in-repo composite `.github/actions/use-npmrc` (input `dot-npmrc`), - referenced per release branch like all internal composites. +- `.npmrc` provisioning uses the in-repo composite `.github/actions/use-npmrc` (input `jfrog-token`; + `dot-npmrc` is deprecated), referenced per release branch like all internal composites. - `.github/dependabot.yml` keeps the SHA pins current on `master` and the active release branches (`release/25.2` through `release/26.2`) via per-branch `target-branch` entries; each branch gets one grouped Action-update PR per week. @@ -82,7 +82,7 @@ run ends green with the warning "FORCE is ignored". ### Required secrets -Passed with `secrets: inherit`: `JFROG_TOKEN`, `JFROG_URL`, `JFROG_USER`, `DOT_NPMRC`, +Passed with `secrets: inherit`: `JFROG_TOKEN`, `JFROG_URL`, `JFROG_USER`, `GIT_USER`, `GIT_USER_EMAIL`, and optionally `PERCY_TOKEN`. The caller needs `permissions: contents: write`; the flow grants it only to the `release` and `github-release` jobs. @@ -92,13 +92,13 @@ its branches calls them. #### JFrog and npm secrets (all FE workflows) -| Secret | Content | Used for | -| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -| `JFROG_URL` | URL of the npm repository artifacts are published to (`cplace-npm-local`); must end with `/`, or `npm publish` fails with ENEEDAUTH | `:registry=`, `publishConfig.registry`, `--registry=` and the credential key of the generated dist `.npmrc` | -| `JFROG_USER` | JFrog user that owns `JFROG_TOKEN` | logged as the publishing identity; not used for authentication | -| `JFROG_TOKEN` | JFrog reference token of `JFROG_USER` with deploy, delete and annotate rights on `cplace-npm-local` | publish, unpublish, `npm show` and `dist-tag`: written literally as `_authToken=${JFROG_TOKEN}` into the dist `.npmrc` and expanded by npm at runtime | -| `JFROG_BASE64_TOKEN` | **Deprecated.** `base64(user:secret)` | `_auth` in the dist `.npmrc`, only when `JFROG_TOKEN` is not passed; the run shows a deprecation warning | -| `DOT_NPMRC` | a complete `.npmrc` | installs (`npm ci`), `npm search`/`npm view` in snapshot cleanup, third-party registries; never used for publishing | +| Secret | Content | Used for | +| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `JFROG_URL` | URL of the npm repository artifacts are published to (`cplace-npm-local`); must end with `/`, or `npm publish` fails with ENEEDAUTH | `:registry=`, `publishConfig.registry`, `--registry=` and the credential key of the generated dist `.npmrc` | +| `JFROG_USER` | JFrog user that owns `JFROG_TOKEN` | logged as the publishing identity; not used for authentication | +| `JFROG_TOKEN` | JFrog reference token of `JFROG_USER` with deploy, delete and annotate rights on `cplace-npm-local`, and **read on the `cplace-npm` virtual** (for `cplace-project-planning-fe`, `JFROG_USER` must be in `bryntum-readers`) | publish, unpublish, `npm show` and `dist-tag`: written literally as `_authToken=${JFROG_TOKEN}` into the dist `.npmrc` and expanded by npm at runtime; installs: `use-npmrc` writes it literally as `_authToken` for the `cplace-npm` virtual into `~/.npmrc` (`npm ci`, `npm view`/`npm search` in snapshot cleanup). Read-only workflows (install-deps, licenses, sonar) therefore receive this publish-capable token too | +| `JFROG_BASE64_TOKEN` | **Deprecated.** `base64(user:secret)` | `_auth` in the dist `.npmrc`, only when `JFROG_TOKEN` is not passed; the run shows a deprecation warning | +| `DOT_NPMRC` | **Deprecated.** A complete `.npmrc` | installs, only when `JFROG_TOKEN` is not passed; the run shows a deprecation warning, and a `::notice::` when both are passed; never used for publishing | To migrate a repository: set the `JFROG_TOKEN` secret (and make `JFROG_USER` its owner), then replace the `JFROG_BASE64_TOKEN:` line with `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}` in every caller that references the @@ -108,6 +108,18 @@ those reusables do not declare `JFROG_TOKEN` and still require `JFROG_BASE64_TOK release branch still passes it. A publishing or deleting run without either secret fails with "No JFrog credentials". +To switch installs to `JFROG_TOKEN` (the token needs read on the `cplace-npm` virtual, see the table): + +- In every caller that references the reusables `@master`, replace the `DOT_NPMRC:` line with + `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}` in the `fe-install-deps`, `fe-licenses` and `fe-sonar` callers, + and delete it in the others, which already pass `JFROG_TOKEN`. +- Callers that reference `@release/26.4` or older stay unchanged. Keep the `DOT_NPMRC` repository secret while + a release branch still uses it. +- Workflows called with `secrets: inherit` switch without an edit. +- A run with neither secret fails in `use-npmrc` with "No npm credentials". +- The generated `~/.npmrc` authenticates only the cplace npm proxy. Lockfile entries on other JFrog paths are + fetched without credentials and fail, so normalize them first (`tools/scripts/lockfile/README.md`). + ### Tag rulesets The tag is pushed as GitHub Actions (`GITHUB_TOKEN`), after publish and promote. A ruleset that diff --git a/tools/scripts/lockfile/README.md b/tools/scripts/lockfile/README.md index 55c341d..1b0eedf 100644 --- a/tools/scripts/lockfile/README.md +++ b/tools/scripts/lockfile/README.md @@ -53,7 +53,8 @@ replace-registry-host=never This tells npm to fetch each `resolved` URL **verbatim** rather than rewriting its host onto the configured registry. It makes an un-normalized lockfile install on any npm version, so it protects **consumer** repositories too, not just -this one. JFrog URLs stay authenticated by the secret, so it introduces no dependency on anonymous JFrog access. +this one. Entries on the proxy stay authenticated by the token in the generated `~/.npmrc`. JFrog entries outside the +proxy prefix get no credentials. **The rewrite it disables is broken on npm 11, not on npm 10.** Measured 2026-08-14 with a one-package fixture, on a runner and locally: