From bde0fb093f19634194683b50b7001fe84458aa54 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Tue, 24 Nov 2026 16:48:17 +0100 Subject: [PATCH 01/10] PFM-ISSUE-34293 - Publish with a plain JFROG_TOKEN (_authToken) in fe-snapshot JfrogCredentials reads JFROG_TOKEN and selects TOKEN, LEGACY or NONE by truthiness. In token mode the dist .npmrc authenticates with _authToken=${JFROG_TOKEN}, written literally and expanded by npm. The legacy _auth file is unchanged. toJSON() keeps both secrets out of logs. fe-snapshot.yml accepts JFROG_TOKEN; JFROG_BASE64_TOKEN becomes optional. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/fe-snapshot.yml | 6 +- .../artifacts/artifacts-handler.test.ts | 18 +++++ .../artifacts/jfrog-credentials.test.ts | 68 +++++++++++++++++++ tools/scripts/artifacts/jfrog-credentials.ts | 28 ++++++++ tools/scripts/artifacts/nx-project.test.ts | 34 ++++++++++ tools/scripts/artifacts/nx-project.ts | 37 ++++++---- tools/scripts/artifacts/test-data.ts | 3 + 7 files changed, 180 insertions(+), 14 deletions(-) create mode 100644 tools/scripts/artifacts/jfrog-credentials.test.ts diff --git a/.github/workflows/fe-snapshot.yml b/.github/workflows/fe-snapshot.yml index 894cc312..63ac25dd 100644 --- a/.github/workflows/fe-snapshot.yml +++ b/.github/workflows/fe-snapshot.yml @@ -10,8 +10,11 @@ on: type: string required: true secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed JFROG_BASE64_TOKEN: - required: true + required: false JFROG_URL: required: true JFROG_USER: @@ -41,6 +44,7 @@ jobs: - name: Build and Push to Jfrog NPM Registry uses: collaborationFactory/github-actions/.github/actions/artifacts@master env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} diff --git a/tools/scripts/artifacts/artifacts-handler.test.ts b/tools/scripts/artifacts/artifacts-handler.test.ts index 12474227..67cf0f5d 100644 --- a/tools/scripts/artifacts/artifacts-handler.test.ts +++ b/tools/scripts/artifacts/artifacts-handler.test.ts @@ -17,6 +17,7 @@ import { lib2, libsDir, npmrc, + npmrcToken, packageJsonLib1, packageJsonLib2, } from './test-data'; @@ -42,6 +43,7 @@ afterEach(() => { process.env.GITHUB_EVENT_NAME = ''; process.env.GITHUB_HEAD_REF = ''; process.env.GITHUB_REF_NAME = ''; + delete process.env.JFROG_TOKEN; }); beforeEach(() => { @@ -167,6 +169,22 @@ test('can create and overwrite Snapshots in main branch', async () => { ).toBe('snapshot'); }); +test('can write the token .npmrc for Snapshots in main branch', async () => { + jest + .spyOn(Utils, 'getCurrentBranchNameFromGithubEnv') + .mockReturnValueOnce('main'); + process.env.SNAPSHOT = 'true'; + process.env.BASE = base; + process.env.GITHUB_REF_NAME = 'main'; + process.env.JFROG_TOKEN = 'jfrog_token'; + + const artifactHandler = await exec(); + + expect(artifactHandler.projects).toHaveLength(3); + expect(artifactHandler.projects[0].npmrcContent).toBe(npmrcToken); + expect(artifactHandler.projects[1].npmrcContent).toBe(npmrcToken); +}); + async function exec() { jest .spyOn(Utils, 'parseScopeFromPackageJson') diff --git a/tools/scripts/artifacts/jfrog-credentials.test.ts b/tools/scripts/artifacts/jfrog-credentials.test.ts new file mode 100644 index 00000000..7a2dcb47 --- /dev/null +++ b/tools/scripts/artifacts/jfrog-credentials.test.ts @@ -0,0 +1,68 @@ +import { expect } from '@jest/globals'; +import { JfrogAuthMode, JfrogCredentials } from './jfrog-credentials'; + +const JFROG_ENV = [ + 'JFROG_URL', + 'JFROG_USER', + 'JFROG_TOKEN', + 'JFROG_BASE64_TOKEN', +]; + +afterEach(() => { + JFROG_ENV.forEach((name) => delete process.env[name]); + jest.restoreAllMocks(); +}); + +test('JfrogCredentials uses the token when JFROG_TOKEN and JFROG_BASE64_TOKEN are both set', () => { + process.env.JFROG_TOKEN = 'jfrog_token'; + process.env.JFROG_BASE64_TOKEN = 'jfrog_base64_token'; + + expect(new JfrogCredentials().authMode).toBe(JfrogAuthMode.TOKEN); +}); + +test('JfrogCredentials falls back to the legacy mode when only JFROG_BASE64_TOKEN is set', () => { + process.env.JFROG_BASE64_TOKEN = 'jfrog_base64_token'; + + expect(new JfrogCredentials().authMode).toBe(JfrogAuthMode.LEGACY); +}); + +test('JfrogCredentials has no auth mode when neither secret is set', () => { + expect(new JfrogCredentials().authMode).toBe(JfrogAuthMode.NONE); +}); + +test('JfrogCredentials treats empty secrets as absent, the way workflows pass unset optional secrets', () => { + process.env.JFROG_TOKEN = ''; + process.env.JFROG_BASE64_TOKEN = ''; + + expect(new JfrogCredentials().authMode).toBe(JfrogAuthMode.NONE); +}); + +test.each([ + 'https://cplace.jfrog.io/artifactory/cplace-npm-test', + 'https://cplace.jfrog.io/artifactory/cplace-npm-test/', + 'https://cplace.jfrog.io/artifactory/cplace-npm-test//', +])( + 'JfrogCredentials builds an auth key with exactly one trailing slash from %s', + (url) => { + process.env.JFROG_URL = url; + + expect(new JfrogCredentials().getAuthKey()).toBe( + '//cplace.jfrog.io/artifactory/cplace-npm-test/' + ); + } +); + +test('JfrogCredentials does not serialize its secrets', () => { + process.env.JFROG_URL = + 'https://cplace.jfrog.io/artifactory/cplace-npm-test/'; + process.env.JFROG_USER = 'jfrog_user'; + process.env.JFROG_TOKEN = 'secret_token_value'; + process.env.JFROG_BASE64_TOKEN = 'secret_base64_value'; + + const json = JSON.stringify({ jfrogCredentials: new JfrogCredentials() }); + + expect(json).not.toContain('secret_token_value'); + expect(json).not.toContain('secret_base64_value'); + expect(json).toContain('"authMode":"TOKEN"'); + expect(json).toContain('"user":"jfrog_user"'); +}); diff --git a/tools/scripts/artifacts/jfrog-credentials.ts b/tools/scripts/artifacts/jfrog-credentials.ts index 636746f0..427a7c88 100644 --- a/tools/scripts/artifacts/jfrog-credentials.ts +++ b/tools/scripts/artifacts/jfrog-credentials.ts @@ -1,7 +1,16 @@ +export enum JfrogAuthMode { + TOKEN = 'TOKEN', + LEGACY = 'LEGACY', + NONE = 'NONE', +} + export class JfrogCredentials { + /** written literally into the dist .npmrc; npm expands it from the step env */ + public static readonly TOKEN_PLACEHOLDER = '${JFROG_TOKEN}'; public url = ''; public user = ''; public base64Token = ''; + public token = ''; constructor() { this.url = process.env.JFROG_URL != undefined ? process.env.JFROG_URL : ''; @@ -11,9 +20,28 @@ export class JfrogCredentials { process.env.JFROG_BASE64_TOKEN != undefined ? process.env.JFROG_BASE64_TOKEN : ''; + this.token = + process.env.JFROG_TOKEN != undefined ? process.env.JFROG_TOKEN : ''; + } + + /** an optional secret the caller does not pass arrives as '', so presence is truthiness */ + public get authMode(): JfrogAuthMode { + if (this.token) return JfrogAuthMode.TOKEN; + if (this.base64Token) return JfrogAuthMode.LEGACY; + return JfrogAuthMode.NONE; } public getJfrogUrlNoHttp(): string { return this.url.replace('https:', ''); } + + /** npm looks credentials up by the registry's nerf-dart, which ends in exactly one '/' */ + public getAuthKey(): string { + return this.getJfrogUrlNoHttp().replace(/\/+$/, '') + '/'; + } + + /** keeps secrets out of JSON.stringify, e.g. the handler's "Configuration" log line */ + public toJSON() { + return { url: this.url, user: this.user, authMode: this.authMode }; + } } diff --git a/tools/scripts/artifacts/nx-project.test.ts b/tools/scripts/artifacts/nx-project.test.ts index e9da3600..f7de6c24 100644 --- a/tools/scripts/artifacts/nx-project.test.ts +++ b/tools/scripts/artifacts/nx-project.test.ts @@ -7,6 +7,7 @@ import { Utils } from './utils'; import { sep } from 'node:path'; import { Version } from './version'; import { TASK } from './artifacts-handler'; +import { JfrogCredentials } from './jfrog-credentials'; jest.mock('child_process'); @@ -14,6 +15,9 @@ afterEach(() => { jest.resetAllMocks(); jest.clearAllMocks(); jest.restoreAllMocks(); + delete process.env.JFROG_URL; + delete process.env.JFROG_USER; + delete process.env.JFROG_TOKEN; }); beforeEach(() => { @@ -119,6 +123,36 @@ test('regular app is always publishable regardless of public_api.ts', async () = expect(nxProject.isPublishable).toBe(true); }); +test('NxProject writes a token .npmrc when JFROG_TOKEN is set', () => { + jest.spyOn(fs, 'existsSync').mockReturnValue(true); + const writeFileSync = jest.spyOn(fs, 'writeFileSync').mockReturnValue(); + process.env.JFROG_URL = + 'https://cplace.jfrog.io/artifactory/cplace-npm-test/'; + process.env.JFROG_USER = 'jfrog_user'; + process.env.JFROG_TOKEN = 'secret_value'; + const nxProject = new NxProject( + 'my-app', + NxProjectKind.Application, + undefined, + undefined, + '@cplace-next' + ); + + nxProject.writeNPMRCInDist(new JfrogCredentials(), '@cplace-next'); + + expect(nxProject.npmrcContent).toBe( + '@cplace-next:registry=https://cplace.jfrog.io/artifactory/cplace-npm-test/\n' + + '//cplace.jfrog.io/artifactory/cplace-npm-test/:_authToken=${JFROG_TOKEN}' + ); + expect(nxProject.npmrcContent).not.toContain('secret_value'); + expect(nxProject.npmrcContent).not.toContain('always-auth'); + expect(nxProject.npmrcContent).not.toContain('email'); + expect(writeFileSync).toHaveBeenCalledWith( + expect.anything(), + nxProject.npmrcContent + ); +}); + describe('NxProject.deleteArtifact', () => { const JFROG_REGISTRY = 'https://cplace.jfrog.io/artifactory/cplace-npm-local'; const version = new Version('0.0.0', '-my-branch-46'); diff --git a/tools/scripts/artifacts/nx-project.ts b/tools/scripts/artifacts/nx-project.ts index 99968f7b..6f4a9b8c 100644 --- a/tools/scripts/artifacts/nx-project.ts +++ b/tools/scripts/artifacts/nx-project.ts @@ -4,7 +4,7 @@ import * as path from 'path'; import { Utils } from './utils'; import { TASK } from './artifacts-handler'; -import { JfrogCredentials } from './jfrog-credentials'; +import { JfrogAuthMode, JfrogCredentials } from './jfrog-credentials'; import { Version } from './version'; import { getJfrogUrl } from './configuration'; import { NpmPackage } from './types'; @@ -291,18 +291,29 @@ export class NxProject { } public writeNPMRCInDist(jfrogCredentials: JfrogCredentials, scope: string) { - this.npmrcContent = `${scope}:registry=${jfrogCredentials.url} \n`; - this.npmrcContent = - this.npmrcContent + - `${jfrogCredentials.getJfrogUrlNoHttp()}:_auth=${ - jfrogCredentials.base64Token - } \n`; - this.npmrcContent = - this.npmrcContent + - `${jfrogCredentials.getJfrogUrlNoHttp()}:always-auth=true \n`; - this.npmrcContent = - this.npmrcContent + - `${jfrogCredentials.getJfrogUrlNoHttp()}:email=${jfrogCredentials.user}`; + if (jfrogCredentials.authMode === JfrogAuthMode.TOKEN) { + this.npmrcContent = + `${scope}:registry=${jfrogCredentials.url}\n` + + `${jfrogCredentials.getAuthKey()}:_authToken=${ + JfrogCredentials.TOKEN_PLACEHOLDER + }`; + console.log( + `Publishing as JFrog user ${jfrogCredentials.user} with JFROG_TOKEN` + ); + } else { + this.npmrcContent = `${scope}:registry=${jfrogCredentials.url} \n`; + this.npmrcContent = + this.npmrcContent + + `${jfrogCredentials.getJfrogUrlNoHttp()}:_auth=${ + jfrogCredentials.base64Token + } \n`; + this.npmrcContent = + this.npmrcContent + + `${jfrogCredentials.getJfrogUrlNoHttp()}:always-auth=true \n`; + this.npmrcContent = + this.npmrcContent + + `${jfrogCredentials.getJfrogUrlNoHttp()}:email=${jfrogCredentials.user}`; + } console.log(this.npmrcContent + '\n\n'); const npmrcPathInDist = this.getNpmrcPathInDist(); if (!fs.existsSync(npmrcPathInDist)) { diff --git a/tools/scripts/artifacts/test-data.ts b/tools/scripts/artifacts/test-data.ts index 8668a9f0..18d05d70 100644 --- a/tools/scripts/artifacts/test-data.ts +++ b/tools/scripts/artifacts/test-data.ts @@ -86,3 +86,6 @@ export const npmrc = 'jfrog_url:_auth=jfrog_base64_token \n' + 'jfrog_url:always-auth=true \n' + 'jfrog_url:email=jfrog_user'; +export const npmrcToken = + '@cplace-frontend-applications:registry=jfrog_url\n' + + 'jfrog_url/:_authToken=${JFROG_TOKEN}'; From 6b13f2f3f4b864163f098d87621d17968986fe30 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Tue, 24 Nov 2026 21:39:56 +0100 Subject: [PATCH 02/10] PFM-ISSUE-34293 - Fail fast without JFrog credentials, warn on JFROG_BASE64_TOKEN JfrogCredentials.requireForPublishing() stays silent in token mode, emits a deprecation ::warning:: in legacy mode and an ::error:: plus a throw when neither secret is set. ArtifactsHandler.handle() calls it for every publishing or deleting mode, before any build, publish, delete or release-version file; bump-only and the release flow's non-forced default-branch run stay credential-free. CleanupSnapshots checks once before deleting and reuses one credentials instance. Co-Authored-By: Claude Opus 5.5 --- .../artifacts-handler-release-flow.test.ts | 30 +++++++++++++++++ .../artifacts/artifacts-handler-tag.test.ts | 27 ++++++++++++++++ .../artifacts/artifacts-handler.test.ts | 14 ++++++++ tools/scripts/artifacts/artifacts-handler.ts | 12 +++++++ .../artifacts/cleanup-snapshots.test.ts | 28 ++++++++++++++++ tools/scripts/artifacts/cleanup-snapshots.ts | 5 +-- .../artifacts/jfrog-credentials.test.ts | 32 +++++++++++++++++++ tools/scripts/artifacts/jfrog-credentials.ts | 20 ++++++++++++ 8 files changed, 166 insertions(+), 2 deletions(-) diff --git a/tools/scripts/artifacts/artifacts-handler-release-flow.test.ts b/tools/scripts/artifacts/artifacts-handler-release-flow.test.ts index e9f6d48f..a2ba1611 100644 --- a/tools/scripts/artifacts/artifacts-handler-release-flow.test.ts +++ b/tools/scripts/artifacts/artifacts-handler-release-flow.test.ts @@ -27,6 +27,8 @@ afterEach(() => { process.env.ONLY_BUMP_VERSION = 'false'; process.env.ONLY_DELETE_ARTIFACTS = 'false'; process.env.PR_NUMBER = ''; + delete process.env.JFROG_TOKEN; + process.env.JFROG_BASE64_TOKEN = 'jfrog_base64_token'; }); test('a push to a release branch with affected projects publishes all projects at the new version, then tags', async () => { @@ -286,6 +288,34 @@ test('a run on the default branch without force does nothing', async () => { expect(output).not.toHaveBeenCalled(); }); +test('a release without JFrog credentials fails before the version file is written', async () => { + process.env.RELEASE_FLOW = 'true'; + process.env.JFROG_BASE64_TOKEN = ''; + const execMock = mockGit(); + mockBranch('release/26.4'); + const publish = mockPublish(); + + await expect(new ArtifactsHandler().handle()).rejects.toThrow( + 'No JFrog credentials' + ); + + expect(publish).not.toHaveBeenCalled(); + expect(Utils.writeReleaseVersionFile).not.toHaveBeenCalled(); + expect(gitTagOrPushCalls(execMock)).toEqual([]); +}); + +test('a run on the default branch without force needs no JFrog credentials', async () => { + process.env.RELEASE_FLOW = 'true'; + process.env.JFROG_BASE64_TOKEN = ''; + mockGit(); + mockBranch('master'); + const publish = mockPublish(); + + await expect(new ArtifactsHandler().handle()).resolves.toBeUndefined(); + + expect(publish).not.toHaveBeenCalled(); +}); + test('the old version bump mode writes no outputs', async () => { process.env.ONLY_BUMP_VERSION = 'true'; const execMock = mockGit(); diff --git a/tools/scripts/artifacts/artifacts-handler-tag.test.ts b/tools/scripts/artifacts/artifacts-handler-tag.test.ts index cbf9f384..de39cb3a 100644 --- a/tools/scripts/artifacts/artifacts-handler-tag.test.ts +++ b/tools/scripts/artifacts/artifacts-handler-tag.test.ts @@ -20,6 +20,8 @@ afterEach(() => { process.env.TAG = ''; process.env.BASE = ''; process.env.PR_NUMBER = ''; + delete process.env.JFROG_TOKEN; + process.env.JFROG_BASE64_TOKEN = 'jfrog_base64_token'; }); test('can find latest version Tag of a given branch and bump the version', async () => { @@ -47,6 +49,31 @@ test('can find latest version Tag of a given branch and bump the version', async ); }); +test('bumps the version on a release branch without JFrog credentials', async () => { + process.env.ONLY_BUMP_VERSION = 'true'; + process.env.JFROG_BASE64_TOKEN = ''; + process.env.JFROG_TOKEN = ''; + mockProjects(); + const execMock = jest + .spyOn(child_process, 'execSync') + .mockReturnValueOnce(Buffer.from(gitLs)) + .mockReturnValue(Buffer.from('')); + jest + .spyOn(Utils, 'getCurrentBranchNameFromGithubEnv') + .mockReturnValueOnce('release/5.18'); + jest + .spyOn(Utils, 'parseScopeFromPackageJson') + .mockReturnValueOnce('@cplace-frontend-applications'); + + const artifactHandler = new ArtifactsHandler(); + await artifactHandler.handle(); + + expect(artifactHandler.calculatedNewVersion.getGitTag()).toBe( + 'version/5.18.121' + ); + expect(execMock).toHaveBeenCalledWith('git push origin version/5.18.121'); +}); + test('can create a release tag in case release branch is pushed for the first time', async () => { process.env.ONLY_BUMP_VERSION = 'true'; mockProjects(); diff --git a/tools/scripts/artifacts/artifacts-handler.test.ts b/tools/scripts/artifacts/artifacts-handler.test.ts index 67cf0f5d..61ce93d9 100644 --- a/tools/scripts/artifacts/artifacts-handler.test.ts +++ b/tools/scripts/artifacts/artifacts-handler.test.ts @@ -44,6 +44,7 @@ afterEach(() => { process.env.GITHUB_HEAD_REF = ''; process.env.GITHUB_REF_NAME = ''; delete process.env.JFROG_TOKEN; + process.env.JFROG_BASE64_TOKEN = 'jfrog_base64_token'; }); beforeEach(() => { @@ -105,6 +106,19 @@ test('can delete artifacts when a Pull Request is closed', async () => { expect(artifactHandler.projects[1].getPrettyPackageJson()).toBe('{}'); }); +test('refuses to delete artifacts when a Pull Request is closed without JFrog credentials', async () => { + process.env.BASE = 'main'; + process.env.PR_NUMBER = '222'; + process.env.ONLY_DELETE_ARTIFACTS = 'true'; + process.env.GITHUB_EVENT_NAME = Utils.PULL_REQUEST; + process.env.GITHUB_HEAD_REF = 'feat/PFM-ISSUE-543-another-feature'; + process.env.JFROG_BASE64_TOKEN = ''; + + await expect(exec()).rejects.toThrow('No JFrog credentials'); + + expect(deleteArtifactSpy).not.toHaveBeenCalled(); +}); + test('can remove unallowed characters from branch name ', async () => { process.env.PR_NUMBER = '419'; process.env.GITHUB_EVENT_NAME = Utils.PULL_REQUEST; diff --git a/tools/scripts/artifacts/artifacts-handler.ts b/tools/scripts/artifacts/artifacts-handler.ts index 33e62c32..6749b3f0 100644 --- a/tools/scripts/artifacts/artifacts-handler.ts +++ b/tools/scripts/artifacts/artifacts-handler.ts @@ -126,6 +126,8 @@ export class ArtifactsHandler { } return Promise.resolve(); } + if (this.requiresPublishCredentials()) + this.jfrogCredentials.requireForPublishing(); if (this.releaseFlow) { await this.tagAndPublishRelease(); } else if ( @@ -142,6 +144,16 @@ export class ArtifactsHandler { return Promise.resolve(); } + /** mirrors the dispatch in handle(): only bump-only and the release flow's no-op path need no credentials */ + private requiresPublishCredentials(): boolean { + const onReleaseBranch = this.currentBranch.startsWith( + ArtifactsHandler.RELEASE_BRANCH_PREFIX + ); + if (this.releaseFlow) return onReleaseBranch || this.force; + if (this.onlyBumpVersion && onReleaseBranch) return false; + return true; + } + private async buildAndPublishProjects() { console.log(`Number of projects being processed: ${this.projects.length}`); console.log(`Projects being processed: ${JSON.stringify(this.projects)}`); diff --git a/tools/scripts/artifacts/cleanup-snapshots.test.ts b/tools/scripts/artifacts/cleanup-snapshots.test.ts index 86e7cfba..8dd5c9be 100644 --- a/tools/scripts/artifacts/cleanup-snapshots.test.ts +++ b/tools/scripts/artifacts/cleanup-snapshots.test.ts @@ -9,6 +9,11 @@ beforeEach(() => { jest.clearAllMocks(); }); +afterEach(() => { + delete process.env.JFROG_URL; + delete process.env.JFROG_TOKEN; +}); + test('can find latest version Tag of a given branch and bump the version', async () => { const spy = jest.spyOn(Utils, 'parseScopeFromPackageJson'); spy.mockReturnValue('@cplace-next'); @@ -17,7 +22,30 @@ test('can find latest version Tag of a given branch and bump the version', async .mockReturnValueOnce(npmSearchResult) .mockReturnValue(npmViewResult); jest.useFakeTimers().setSystemTime(new Date('2023-05-22')); + process.env.JFROG_URL = 'jfrog_url'; + process.env.JFROG_TOKEN = 'jfrog_token'; const cleanupSnaps = new CleanupSnapshots(); await cleanupSnaps.deleteSuperfluousArtifacts(); expect(cleanupSnaps.npmSearchResults[0].versions.length).toBe(4); }); + +test('refuses to delete snapshots without JFrog credentials', async () => { + jest + .spyOn(Utils, 'parseScopeFromPackageJson') + .mockReturnValue('@cplace-next'); + const execMock = jest + .spyOn(child_process, 'execSync') + .mockReturnValueOnce(npmSearchResult) + .mockReturnValue(npmViewResult); + jest.useFakeTimers().setSystemTime(new Date('2023-05-22')); + const cleanupSnaps = new CleanupSnapshots(); + + await expect(cleanupSnaps.deleteSuperfluousArtifacts()).rejects.toThrow( + 'No JFrog credentials' + ); + + const unpublishCalls = execMock.mock.calls.filter(([command]) => + String(command).startsWith('npm unpublish') + ); + expect(unpublishCalls).toEqual([]); +}); diff --git a/tools/scripts/artifacts/cleanup-snapshots.ts b/tools/scripts/artifacts/cleanup-snapshots.ts index 778d2bd4..0b9f26ab 100644 --- a/tools/scripts/artifacts/cleanup-snapshots.ts +++ b/tools/scripts/artifacts/cleanup-snapshots.ts @@ -11,6 +11,7 @@ export class CleanupSnapshots { private _npmSearchResults: NpmPackage[] = []; private scope = ''; private static readonly RELEASE_CADENCE = 4; + private readonly jfrogCredentials = new JfrogCredentials(); constructor() { this.initPackagesAndVersions(); @@ -75,6 +76,7 @@ export class CleanupSnapshots { } public async deleteSuperfluousArtifacts() { + this.jfrogCredentials.requireForPublishing(); for (const npmPackage of this._npmSearchResults) { if (npmPackage.versions.length) { await this.removeSnapshotArtifacts(npmPackage); @@ -85,7 +87,6 @@ export class CleanupSnapshots { private async removeSnapshotArtifacts(npmPackage: NpmPackage) { npmPackage.scope = npmPackage.name.split('/')[0]; npmPackage.name = npmPackage.name.split('/')[1]; - const jfrogCredentials = new JfrogCredentials(); for (const sortedVersion of npmPackage.versions) { const currentVersion = sortedVersion.replace( `${ArtifactsHandler.SNAPSHOT_VERSION}`, @@ -98,7 +99,7 @@ export class CleanupSnapshots { new Version(ArtifactsHandler.SNAPSHOT_VERSION, currentVersion), npmPackage.scope ); - await project.deleteArtifact(project.version, jfrogCredentials); + await project.deleteArtifact(project.version, this.jfrogCredentials); } } } diff --git a/tools/scripts/artifacts/jfrog-credentials.test.ts b/tools/scripts/artifacts/jfrog-credentials.test.ts index 7a2dcb47..707a2eef 100644 --- a/tools/scripts/artifacts/jfrog-credentials.test.ts +++ b/tools/scripts/artifacts/jfrog-credentials.test.ts @@ -66,3 +66,35 @@ test('JfrogCredentials does not serialize its secrets', () => { expect(json).toContain('"authMode":"TOKEN"'); expect(json).toContain('"user":"jfrog_user"'); }); + +test('JfrogCredentials requires nothing more in token mode', () => { + process.env.JFROG_TOKEN = 'jfrog_token'; + const log = jest.spyOn(console, 'log').mockImplementation(() => undefined); + + new JfrogCredentials().requireForPublishing(); + + expect(log).not.toHaveBeenCalled(); +}); + +test('JfrogCredentials warns once that JFROG_BASE64_TOKEN is deprecated in legacy mode', () => { + process.env.JFROG_BASE64_TOKEN = 'jfrog_base64_token'; + const log = jest.spyOn(console, 'log').mockImplementation(() => undefined); + + new JfrogCredentials().requireForPublishing(); + + expect(log).toHaveBeenCalledTimes(1); + expect(log).toHaveBeenCalledWith( + `::warning::${JfrogCredentials.LEGACY_WARNING}` + ); +}); + +test('JfrogCredentials fails with an error annotation when neither secret is set', () => { + const log = jest.spyOn(console, 'log').mockImplementation(() => undefined); + + expect(() => new JfrogCredentials().requireForPublishing()).toThrow( + JfrogCredentials.MISSING_ERROR + ); + expect(log).toHaveBeenCalledWith( + `::error::${JfrogCredentials.MISSING_ERROR}` + ); +}); diff --git a/tools/scripts/artifacts/jfrog-credentials.ts b/tools/scripts/artifacts/jfrog-credentials.ts index 427a7c88..b9c3552d 100644 --- a/tools/scripts/artifacts/jfrog-credentials.ts +++ b/tools/scripts/artifacts/jfrog-credentials.ts @@ -7,6 +7,12 @@ export enum JfrogAuthMode { export class JfrogCredentials { /** written literally into the dist .npmrc; npm expands it from the step env */ public static readonly TOKEN_PLACEHOLDER = '${JFROG_TOKEN}'; + public static readonly LEGACY_WARNING = + 'JFROG_BASE64_TOKEN is deprecated: set the JFROG_TOKEN repository secret and pass ' + + 'JFROG_TOKEN instead of JFROG_BASE64_TOKEN to the github-actions FE workflows (PFM-ISSUE-34293).'; + public static readonly MISSING_ERROR = + 'No JFrog credentials: pass the JFROG_TOKEN secret (or the deprecated JFROG_BASE64_TOKEN) ' + + 'to this workflow. Publishing and deleting npm artifacts needs one of them.'; public url = ''; public user = ''; public base64Token = ''; @@ -31,6 +37,20 @@ export class JfrogCredentials { return JfrogAuthMode.NONE; } + /** call once per run, before anything is published or deleted */ + public requireForPublishing(): void { + switch (this.authMode) { + case JfrogAuthMode.TOKEN: + return; + case JfrogAuthMode.LEGACY: + console.log(`::warning::${JfrogCredentials.LEGACY_WARNING}`); + return; + default: + console.log(`::error::${JfrogCredentials.MISSING_ERROR}`); + throw new Error(JfrogCredentials.MISSING_ERROR); + } + } + public getJfrogUrlNoHttp(): string { return this.url.replace('https:', ''); } From e07372d9020a3ab7816d0c34ffa230baaff0dda1 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Tue, 24 Nov 2026 21:39:56 +0100 Subject: [PATCH 03/10] PFM-ISSUE-34293 - Accept JFROG_TOKEN in all FE reusables and templates The six remaining reusables declare JFROG_TOKEN and JFROG_BASE64_TOKEN as optional and pass both to every artifacts step. The FE starter templates pass JFROG_TOKEN. The README documents the JFrog and npm secrets and how a repository migrates. Co-Authored-By: Claude Opus 5.5 --- .../fe/fe-cleanup-snapshots.yml | 2 +- .github/workflow-templates/fe/fe-main.yml | 2 +- .github/workflow-templates/fe/fe-pr-close.yml | 2 +- .../workflow-templates/fe/fe-pr-snapshot.yml | 2 +- .github/workflows/fe-cleanup-snapshots.yml | 6 +++++- .github/workflows/fe-pr-close.yml | 6 +++++- .github/workflows/fe-pr-snapshot.yml | 6 +++++- .github/workflows/fe-release-flow.yml | 7 ++++++- .github/workflows/fe-release.yml | 6 +++++- .github/workflows/fe-tag.yml | 6 +++++- README.md | 18 +++++++++++++++++- 11 files changed, 52 insertions(+), 11 deletions(-) diff --git a/.github/workflow-templates/fe/fe-cleanup-snapshots.yml b/.github/workflow-templates/fe/fe-cleanup-snapshots.yml index f5c48cb4..6426e039 100644 --- a/.github/workflow-templates/fe/fe-cleanup-snapshots.yml +++ b/.github/workflow-templates/fe/fe-cleanup-snapshots.yml @@ -14,7 +14,7 @@ jobs: cleanup-snapshots: uses: collaborationFactory/github-actions/.github/workflows/fe-cleanup-snapshots.yml@master secrets: - JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} + 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-main.yml b/.github/workflow-templates/fe/fe-main.yml index 8598370c..9f5f1977 100644 --- a/.github/workflow-templates/fe/fe-main.yml +++ b/.github/workflow-templates/fe/fe-main.yml @@ -51,6 +51,6 @@ jobs: GHA_REF: '' GHA_BASE: ${{ github.event.before }} secrets: - JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} diff --git a/.github/workflow-templates/fe/fe-pr-close.yml b/.github/workflow-templates/fe/fe-pr-close.yml index 5d0f2a6a..343e941e 100644 --- a/.github/workflow-templates/fe/fe-pr-close.yml +++ b/.github/workflow-templates/fe/fe-pr-close.yml @@ -17,7 +17,7 @@ jobs: with: GHA_BASE: ${{ github.event.pull_request.base.ref }} secrets: - JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} + 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 05fd4afd..73540931 100644 --- a/.github/workflow-templates/fe/fe-pr-snapshot.yml +++ b/.github/workflow-templates/fe/fe-pr-snapshot.yml @@ -17,7 +17,7 @@ jobs: with: GHA_BASE: ${{ github.event.pull_request.base.ref }} secrets: - JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} DOT_NPMRC: ${{ secrets.DOT_NPMRC }} diff --git a/.github/workflows/fe-cleanup-snapshots.yml b/.github/workflows/fe-cleanup-snapshots.yml index fa41afef..fbdac7b3 100644 --- a/.github/workflows/fe-cleanup-snapshots.yml +++ b/.github/workflows/fe-cleanup-snapshots.yml @@ -3,8 +3,11 @@ name: Cleanup Snapshot Artifacts on a CRON Schedule on: workflow_call: secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed JFROG_BASE64_TOKEN: - required: true + required: false JFROG_URL: required: true JFROG_USER: @@ -41,6 +44,7 @@ jobs: - name: Cleanup Snapshot Artifacts uses: collaborationFactory/github-actions/.github/actions/snapshots@master env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} diff --git a/.github/workflows/fe-pr-close.yml b/.github/workflows/fe-pr-close.yml index ffe2f774..75e1ccf6 100644 --- a/.github/workflows/fe-pr-close.yml +++ b/.github/workflows/fe-pr-close.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 JFROG_BASE64_TOKEN: - required: true + required: false JFROG_URL: required: true JFROG_USER: @@ -47,6 +50,7 @@ jobs: - name: Delete Snapshots from NPM Registry uses: collaborationFactory/github-actions/.github/actions/artifacts@master env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} diff --git a/.github/workflows/fe-pr-snapshot.yml b/.github/workflows/fe-pr-snapshot.yml index f839237e..df2c86c7 100644 --- a/.github/workflows/fe-pr-snapshot.yml +++ b/.github/workflows/fe-pr-snapshot.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 JFROG_BASE64_TOKEN: - required: true + required: false JFROG_URL: required: true JFROG_USER: @@ -65,6 +68,7 @@ jobs: - name: Build and Push to Jfrog NPM Registry uses: collaborationFactory/github-actions/.github/actions/artifacts@master env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} diff --git a/.github/workflows/fe-release-flow.yml b/.github/workflows/fe-release-flow.yml index a0874870..63f08443 100644 --- a/.github/workflows/fe-release-flow.yml +++ b/.github/workflows/fe-release-flow.yml @@ -13,8 +13,11 @@ on: required: false default: true secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed JFROG_BASE64_TOKEN: - required: true + required: false JFROG_URL: required: true JFROG_USER: @@ -149,6 +152,7 @@ jobs: id: release uses: collaborationFactory/github-actions/.github/actions/artifacts@master env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} @@ -186,6 +190,7 @@ jobs: if: (failure() || cancelled()) && steps.incomplete.outputs.tag != '' uses: collaborationFactory/github-actions/.github/actions/artifacts@master env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} diff --git a/.github/workflows/fe-release.yml b/.github/workflows/fe-release.yml index 1d2e8520..3198cdc0 100644 --- a/.github/workflows/fe-release.yml +++ b/.github/workflows/fe-release.yml @@ -3,8 +3,11 @@ name: Frontend Release Workflow on: workflow_call: secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed JFROG_BASE64_TOKEN: - required: true + required: false JFROG_URL: required: true JFROG_USER: @@ -51,6 +54,7 @@ jobs: - name: Build and Push to Jfrog NPM Registry uses: collaborationFactory/github-actions/.github/actions/artifacts@master env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} diff --git a/.github/workflows/fe-tag.yml b/.github/workflows/fe-tag.yml index 5321a631..cd239e10 100644 --- a/.github/workflows/fe-tag.yml +++ b/.github/workflows/fe-tag.yml @@ -10,8 +10,11 @@ on: type: string required: true secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed JFROG_BASE64_TOKEN: - required: true + required: false JFROG_URL: required: true JFROG_USER: @@ -53,6 +56,7 @@ jobs: - name: Bump Version and Push new Tag uses: collaborationFactory/github-actions/.github/actions/artifacts@master env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} JFROG_USER: ${{ secrets.JFROG_USER }} diff --git a/README.md b/README.md index 671c78db..73ecf5f3 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ run ends green with the warning "FORCE is ignored". ### Required secrets -Passed with `secrets: inherit`: `JFROG_BASE64_TOKEN`, `JFROG_URL`, `JFROG_USER`, `DOT_NPMRC`, +Passed with `secrets: inherit`: `JFROG_TOKEN`, `JFROG_URL`, `JFROG_USER`, `DOT_NPMRC`, `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. @@ -90,6 +90,22 @@ The tag is pushed with `GITHUB_TOKEN`; the flow does not use `GIT_USER_TOKEN`. T `fe-tag.yml` and `workflows/fe-release.yml` still need it: remove it from a repo only once none of 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`); a trailing slash does not matter | `: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 | + +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. Workflows called +with `secrets: inherit` pick it up without an edit. Keep the `JFROG_BASE64_TOKEN` repository secret while a +release branch still passes it. A publishing or deleting run without either secret fails with "No JFrog +credentials". + ### Tag rulesets The tag is pushed as GitHub Actions (`GITHUB_TOKEN`), after publish and promote. A ruleset that From a245d8e1d7dd760c671f7e7e4496ee7d9a088fa9 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Tue, 24 Nov 2026 21:39:57 +0100 Subject: [PATCH 04/10] PFM-ISSUE-34293 - Add research, design, plan and live test plan Co-Authored-By: Claude Opus 5.5 --- .../design.md | 249 ++++++++ .../live-test-plan.md | 298 +++++++++ .../plan.md | 566 ++++++++++++++++++ .../research.md | 306 ++++++++++ 4 files changed, 1419 insertions(+) create mode 100644 specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md create mode 100644 specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md create mode 100644 specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md create mode 100644 specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/research.md diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md new file mode 100644 index 00000000..426ddca8 --- /dev/null +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md @@ -0,0 +1,249 @@ +--- +date: 2026-11-23 +ticket: PFM-ISSUE-34293 +topic: "Introduce separate JFrog user and token secrets (plain _authToken)" +status: approved-for-planning +research: ./research.md +--- + +# Separate JFrog User and Token Secrets (plain `_authToken`) - Design Approach + +## Overview + +Switch npm publish/delete authentication in the shared FE workflows from the combined base64 `_auth` blob (`JFROG_BASE64_TOKEN`) to the standard `///:_authToken=${JFROG_TOKEN}` pattern, with the JFrog user and token held as separate, correctly named secrets. The change is shipped as a dual-support window so the 14 workflow-calling FE repos can migrate one by one; a follow-up ticket closes the window. + +## Problem Statement + +Publish, unpublish, `npm show` and `dist-tag` in the artifacts tooling authenticate via a generated dist `.npmrc` containing `_auth=` — a misnamed secret that actually holds `base64(user:secret)`. `JFROG_USER` only feeds a deprecated `email=` line and in several repos does not even match the identity inside the blob. The ticket requires a plain `_authToken` sourced from separate user and token secrets, and retirement of the blob and its name. + +The rollout is the hard part, not the code: all callers pass secrets explicitly and default branches follow `@master` live, so any change to required/declared secrets breaks every caller at once ([Research §3–4](./research.md)). + +### Requirements +- npm publish auth uses `///:_authToken=${JFROG_TOKEN}`. +- JFrog user and token are separate, correctly named secrets. +- `JFROG_BASE64_TOKEN` and the base64 blob are no longer used once repos have migrated. +- `.github/actions/artifacts` (via the TS tooling) and all consuming workflows use the new secrets. + +### Constraints +- 14 FE repos pass secrets explicitly (no `secrets: inherit`); defaults follow `@master`, `release/26.4` follows `@release/26.4`. +- `DOT_NPMRC` remains the install / Bryntum / direct-use credential and is not touched here. +- Live testing only on `clone-cplace-fe` → `cplace-npm-test`; never on real `release/*` branches. +- Deprecated `fe-release.yml` / `fe-tag.yml` are still on the live path of every FE repo. + +## Design Decisions Summary + +1. **Secret naming**: new per-repo `JFROG_TOKEN` holds the token; existing `JFROG_USER` is kept as the user secret and must name the owner of `JFROG_TOKEN`; `JFROG_URL` is unchanged. + - `JFROG_USER` is no longer needed for npm auth; it is logged as the publishing identity. + - Fixes today's `JFROG_USER` vs. auth-identity mismatch as part of provisioning. +2. **Token provisioning**: one JFrog reference token per existing service account (deploy, delete, annotate on `cplace-npm-local`), stored as `JFROG_TOKEN` in each repo that account serves. + - Minting and secret assignment are done by the user with existing token tooling and the maintained token list; no code or workflow involvement. + - Today's service-account grouping across repos is preserved. +3. **Dist `.npmrc` format (token path)**: exactly two lines — `:registry=` and `////:_authToken=${JFROG_TOKEN}`, with the placeholder written **literally** so npm expands it from the step env. + - The auth key is derived from `JFROG_URL` normalized to end in exactly one `/`; `JFROG_URL` itself is used unchanged everywhere else, so its stored format does not matter. + - `always-auth` and `email` are dropped; the legacy `_auth` path stays byte-for-byte unchanged. +4. **Transition mechanics**: dual-support window — `JFROG_TOKEN` and `JFROG_BASE64_TOKEN` both `required: false` in the reusables. + - Token present → `_authToken` path (legacy ignored); only legacy present → `_auth` path plus a `::warning::` deprecation annotation; neither, in a mode that publishes/deletes → fail fast with a clear error. + - Callers migrate by replacing their `JFROG_BASE64_TOKEN:` line with `JFROG_TOKEN:`. + - Removing the fallback and making `JFROG_TOKEN` required is a **follow-up ticket** after all 14 repos have migrated. +5. **Workflow scope**: all seven reusables declaring JFrog secrets (`fe-snapshot`, `fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, `fe-release-flow`, deprecated `fe-release`, deprecated `fe-tag`), the FE starter templates, and the README. + - README documents what `JFROG_URL` / `JFROG_USER` / `JFROG_TOKEN` contain, deprecates `JFROG_BASE64_TOKEN`, and states that `DOT_NPMRC` stays for installs. +6. **Release-line reach**: master only; release lines keep working on `JFROG_BASE64_TOKEN`; new lines pick up dual support at branch-off. +7. **`DOT_NPMRC` boundary**: untouched; its future is handled by a separate ticket. No reusable uses `DOT_NPMRC` purely for publishing, so the two are cleanly decoupled. +8. **Validation**: unit tests for selection and format, a live matrix on `clone-cplace-fe` against `cplace-npm-test`, then a pilot on `cplace-remote-filesystem-fe` before the remaining 13 repos. + +This means: +- The token never appears in the dist `.npmrc`, its `console.log`, or any artifact — no reliance on secret masking. +- Each FE repo migrates independently with a one-line edit per caller; reverting that edit is the rollback. +- Unmigrated repos are visible as warning annotations in their run summaries. +- A repo with neither secret fails with an explicit error instead of an anonymous npm 401/404. +- npm 11 no longer warns about `always-auth` on the token path. + +Major trade-offs we're accepting: +1. Temporary dual path: fallback code and two optional secrets live on master until the cleanup ticket, and GitHub's "required secret missing" check is replaced by our own fail-fast check — in exchange for per-repo, independently reversible migration. +2. Old credential lives on: `JFROG_BASE64_TOKEN` stays in repos as long as release lines reference it — in exchange for not touching release branches at all. +3. `JFROG_USER` becomes metadata: still a secret callers pass, but not used for auth — in exchange for meeting the ticket's "separate user and token secrets" requirement with minimal churn. +4. Deprecated workflows are edited: `fe-release` and `fe-tag` change — in exchange for repos being able to stop using `JFROG_BASE64_TOKEN` before `fe-release-flow` is rolled out. + +What we're NOT doing (out of scope): +- Any change to `DOT_NPMRC`, `use-npmrc`, install auth, Bryntum auth, or cplace-fe/project-planning-fe/cplace-e2e direct `DOT_NPMRC` uses (separate ticket). The ticket's "coordinated cutover with `DOT_NPMRC` removal" dependency no longer applies. +- `cplace-e2e` (no `JFROG_*`, does not publish). +- Backporting to `release/26.4` or older lines. +- Removing the legacy fallback / making `JFROG_TOKEN` required (follow-up ticket). +- Deleting `JFROG_BASE64_TOKEN` repo secrets (separate concern, after the last referencing release line is out of support). +- Removing JFrog secrets from `fe-tag` (it does not need them, but dropping declarations would break callers). +- Rolling out `secrets: inherit` to callers (PFM-ISSUE-34283/34287 track). +- Minting tokens or setting secrets (done by the user with existing tooling). + +Success criteria: +- On `clone-cplace-fe`, with only `JFROG_TOKEN` set: snapshot publish, PR-snapshot publish/replace (incl. `npm show`), PR-close unpublish, release-flow publish + dist-tag promote, and cleanup-snapshots delete all succeed, and no log line contains the token value. +- With only `JFROG_BASE64_TOKEN` set, the same flows still succeed and show the deprecation annotation; with neither set, the run fails fast with the explicit error. +- The pilot `cplace-remote-filesystem-fe` publishes successfully from master after switching to `JFROG_TOKEN`. +- A cross-repo search of the 14 FE repos' default branches finds no `JFROG_BASE64_TOKEN` reference — the entry condition for the cleanup ticket. + +## Design Decisions - Details + +### 1. Secret naming and semantics + +**Chosen Approach:** `JFROG_TOKEN` + keep `JFROG_USER` + +**Rationale:** Matches the ticket's `${JFROG_TOKEN}` pattern literally; `JFROG_USER` is already correctly named and passed everywhere, so callers change one line per call. With `_authToken` the user is not needed for npm auth; it remains the documented owner of the token and is logged as the publishing identity. + +**Alternatives Considered:** +- **New namespaced pair `JFROG_NPM_USER` / `JFROG_NPM_TOKEN`**: Rejected because it deviates from the ticket's name and doubles the per-repo secrets and caller edits, plus a second retirement cycle for `JFROG_USER`. +- **Reuse org-level `ENV_CPLACE_ARTIFACTORY_ACTOR` / `_TOKEN`**: Rejected because it collapses all repos onto one org-wide identity with unknown rights on `cplace-npm-local`, owned and rotated outside this workstream, and deviates from per-repo secret storage. + +**Implications:** +- `JFROG_USER` must be set to the token's owner during provisioning (fixes office-reports/workflow/project-planning mismatches). + +--- + +### 2. Token type and provisioning + +**Chosen Approach:** One reference token per existing service account + +**Rationale:** Reference tokens via `_authToken` are already proven on this JFrog instance (`cplace-e2e`, `resource-management-fe` `DOT_NPMRC`). Keeping today's account grouping changes nothing about who can publish what, and the switch doubles as a credential rotation. The user mints tokens and sets secrets with existing tooling and maintains the token list (incl. expiry/rotation). + +**Alternatives Considered:** +- **Reuse the secret inside `JFROG_BASE64_TOKEN`**: Rejected because it only works if that secret is a token (not a password), would require decoding secrets outside GitHub, and carries an old credential forward instead of rotating it. +- **One dedicated publish account for all FE repos**: Rejected because it removes per-account separation (one leak affects all repos) and needs new JFrog account/permission setup. + +**Implications:** +- Each token needs deploy, delete and annotate (dist-tag) on `cplace-npm-local`; the `clone-cplace-fe` token needs the same on `cplace-npm-test`. + +--- + +### 3. Generated dist `.npmrc` format + +**Chosen Approach:** Literal `${JFROG_TOKEN}`, normalized key, minimal lines + +**Rationale:** Writing the placeholder literally keeps the token out of the dist file and the `console.log` at `nx-project.ts:306` (research open question 9). npm looks up credentials by the registry's nerf-dart with a trailing slash, so the key is normalized to end in exactly one `/` regardless of the `JFROG_URL` secret's format; `JFROG_URL` itself stays unchanged for `:registry=`, `publishConfig.registry` and `--registry=`, so whatever works today keeps working. `always-auth` is removed in current npm and `email` has no role with tokens. + +**Alternatives Considered:** +- **Write the expanded token value**: Rejected because the token would sit in the dist file and logs, relying solely on GitHub masking, and it contradicts the ticket's pattern. +- **Keep `always-auth` / `email` on the token path**: Rejected because it carries deprecated config and npm 11 warnings into the new format. + +**Implications:** +- All npm calls running in the dist `cwd` must have `JFROG_TOKEN` in env — true today since they run inside the same composite step; the token line is only written when the token is present, avoiding npm's "Failed to replace env in config" error. +- Unit tests must cover `JFROG_URL` with and without a trailing slash. +- The legacy `_auth` output (and `test-data.ts:84-88` fixture) remain byte-for-byte unchanged. + +--- + +### 4. Transition mechanics + +**Chosen Approach:** Token wins; legacy fallback with deprecation annotation; fail fast on missing credentials + +**Rationale:** Explicit secret passing plus `@master` tracking means any required/declared change breaks callers at once (34282 open question #10). Making both secrets optional lets each repo migrate independently; the annotation makes progress visible; the fail-fast check restores the protection lost by dropping `required: true` (today credentials silently default to `''`). + +**Alternatives Considered:** +- **Silent fallback, no annotation, no fail-fast**: Rejected because migration tracking would require manual greps across 14 repos and a repo with neither secret would fail late with an opaque npm auth error. + +**Implications:** +- Per-repo migration = set `JFROG_TOKEN` secret, then replace `JFROG_BASE64_TOKEN:` with `JFROG_TOKEN:` in each caller. +- Follow-up cleanup ticket (after all 14 repos migrated): remove fallback, drop `JFROG_BASE64_TOKEN` declarations, make `JFROG_TOKEN` required. +- The fail-fast applies only to modes that publish or delete; `ONLY_BUMP_VERSION` (`fe-tag`) must not fail on missing credentials. + +--- + +### 5. Workflow scope + +**Chosen Approach:** All seven JFrog-declaring reusables + templates + README + +**Rationale:** Deprecated `fe-release` / `fe-tag` are still called from every FE repo's default branch; leaving them on a required `JFROG_BASE64_TOKEN` would block the acceptance criterion until `fe-release-flow` is rolled out everywhere. Uniform treatment keeps the caller edit mechanical. + +**Alternatives Considered:** +- **Only non-deprecated reusables**: Rejected because repos could not stop passing `JFROG_BASE64_TOKEN`, coupling this ticket to the release-flow rollout. +- **Remove JFrog secrets from `fe-tag` entirely**: Rejected because callers still pass them and would break immediately (34282 #10 failure mode); needs its own transition. + +**Implications:** +- Each reusable's `env:` into `artifacts`/`snapshots` passes both `JFROG_TOKEN` and `JFROG_BASE64_TOKEN`. +- Templates `fe-main.yml`, `fe-pr-snapshot.yml`, `fe-pr-close.yml`, `fe-cleanup-snapshots.yml` pass `JFROG_TOKEN`; `fe-release.yml` (inherit) unchanged. +- README "Required secrets" explains each JFrog secret's content, marks `JFROG_BASE64_TOKEN` deprecated, and notes `DOT_NPMRC` stays for installs. + +--- + +### 6. Release-line reach + +**Chosen Approach:** Master only + +**Rationale:** Follows the 34283/34282 precedents; release lines keep working unchanged, and no live testing on release branches is needed. New release lines inherit dual support at branch-off via cf-devkit ref rewriting. + +**Alternatives Considered:** +- **Backport to `release/26.4` and older lines**: Rejected because it multiplies PRs (one per `github-actions` line plus release-branch caller edits in 14 repos) and those branches cannot be live-tested. + +**Implications:** +- `JFROG_BASE64_TOKEN` repo secrets must stay until the last referencing release line is out of support; deleting them is a separate concern. + +--- + +### 7. `DOT_NPMRC` boundary + +**Chosen Approach:** Leave `DOT_NPMRC` untouched; record the decoupling + +**Rationale:** No reusable uses `DOT_NPMRC` purely for publishing (`fe-snapshot` has no `use-npmrc`; every other publishing workflow also runs `npm ci` or cleanup lookups). `DOT_NPMRC` remains the install, Bryntum and direct-use credential and is handled by a separate existing ticket. + +**Alternatives Considered:** +- **Also derive JFrog install auth from `JFROG_USER`/`JFROG_TOKEN`**: Rejected because it widens scope to every `npm ci` across 14 repos, needs read rights on the `cplace-npm` virtual repo for publish tokens, and overlaps the separate `DOT_NPMRC` ticket. + +**Implications:** +- The ticket's "coordinated cutover with `DOT_NPMRC` removal" dependency no longer applies. + +--- + +### 8. Validation + +**Chosen Approach:** Unit tests + live matrix on `clone-cplace-fe` + pilot on `cplace-remote-filesystem-fe` + +**Rationale:** Unpublish and dist-tag with Bearer auth are the least proven parts; the clone harness exercises every dist-`.npmrc` npm command without touching real packages, under the established JFrog safety rules (own versions only, exact paths, show hits before delete). + +**Alternatives Considered:** +- **Unit tests, then pilot directly on a real FE repo**: Rejected because the first live unpublish/dist-tag with `_authToken` would hit real `cplace-npm-local` packages, departing from 34282/34283 practice. + +**Implications:** +- Unit: legacy fixture unchanged; new token fixture; selection cases (token only / legacy only + warning / both → token / neither → fail fast); key normalization with and without trailing slash; file contains literal `${JFROG_TOKEN}`, never the value. +- Live: legacy-only, token-only, and neither scenarios on `clone-cplace-fe` with callers pointed at the feature-branch ref; changing the clone repo's secrets requires the user's consent. +- Pilot `cplace-remote-filesystem-fe` after merge, then remaining 13 repos. + +--- + +## Overall Architecture + +Install auth and publish auth stay separated. `DOT_NPMRC` → `use-npmrc` → `~/.npmrc` continues to serve installs. The publish side gains a second credential mode: the TS tooling selects `_authToken` when `JFROG_TOKEN` is present and falls back to the legacy `_auth` otherwise, writing the corresponding per-project dist `.npmrc`. + +### Key Components +1. **`JfrogCredentials` (`tools/scripts/artifacts/jfrog-credentials.ts`)**: reads `JFROG_TOKEN` in addition to the existing vars; decides the credential mode; derives the trailing-slash auth key; reports missing credentials. +2. **`writeNPMRCInDist` (`nx-project.ts:293-313`)**: writes the two-line token `.npmrc` (literal placeholder) or the unchanged legacy four-line one; logs the publishing identity, never a token. +3. **Artifacts entry points (`artifacts-handler.ts`, `cleanup-snapshots.ts`)**: emit the deprecation annotation on the legacy path and fail fast when a publish/delete mode has no credentials. +4. **Reusable workflows (7)**: declare `JFROG_TOKEN` and `JFROG_BASE64_TOKEN` as optional and pass both into the composite step env. +5. **Templates + README**: show callers the new secret and document the secrets contract. + +### Data Flow +Repo secrets (`JFROG_URL`, `JFROG_USER`, `JFROG_TOKEN` | `JFROG_BASE64_TOKEN`) → caller workflow (explicit `secrets:`) → reusable workflow → step `env:` of `artifacts`/`snapshots` composite → `JfrogCredentials` → dist `.npmrc` (`_authToken=${JFROG_TOKEN}` literal) → `npm publish/show/unpublish/dist-tag` in dist `cwd`, where npm expands the placeholder from the same step env and sends `Authorization: Bearer`. + +### Integration Points +- 14 FE repos' caller workflows (one-line swap per call, after the repo secret exists). +- JFrog `cplace-npm-local` (prod) and `cplace-npm-test` (validation) — Bearer auth via reference tokens. +- User's token tooling and token list (provisioning, rotation). + +## Known Risks + +1. **Bearer auth lacks a needed right (e.g. unpublish/annotate) for a reference token**: Mitigation — live matrix on `clone-cplace-fe` covers every command before any real repo switches; token scopes listed in Decision 2. +2. **npm call in dist `cwd` runs without `JFROG_TOKEN` in env** ("Failed to replace env in config"): Mitigation — token line only written when the token is present; all such calls stay inside the composite step; covered by live matrix. +3. **Caller passes a secret the callee no longer declares** (34282 #10 failure mode): Mitigation — no declarations are removed in this ticket; removal happens only in the cleanup ticket after a cross-repo search shows zero references. +4. **Fail-fast misfires in a mode that needs no credentials** (`fe-tag` `ONLY_BUMP_VERSION`): Mitigation — fail-fast scoped to publish/delete modes; unit test for bump-only with no credentials. +5. **Window never closes**: Mitigation — deprecation annotations make stragglers visible; follow-up cleanup ticket with an explicit entry condition. + +## Next Steps + +1. Review this design document +2. Refine if needed based on feedback +3. Create the follow-up cleanup ticket (remove fallback, make `JFROG_TOKEN` required) +4. Proceed to implementation planning: `/spec-driven-development:create_plan specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md` + +## References + +- Original ticket: [PFM-ISSUE-34293](https://base.cplace.io/pages/writuvh8xnwnf0bzeo6c6u2hc/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets-plain-auth-token) +- Related research: [Research](./research.md) +- Related ticket: PFM-ISSUE-33675 (standardize JFrog npm read and publish auth); separate `DOT_NPMRC` ticket +- Precedents: `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/design.md`, `specs/2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/`, `specs/2026-06-05_node24-workflow-migration/` +- Similar code: `tools/scripts/artifacts/nx-project.ts:293-313`, `tools/scripts/artifacts/jfrog-credentials.ts` diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md new file mode 100644 index 00000000..40f4f3c7 --- /dev/null +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md @@ -0,0 +1,298 @@ +--- +date: 2026-11-24 +branch: improvement/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets +topic: "Live test plan for PFM-ISSUE-34293 - separate JFrog user and token secrets (plain _authToken)" +tags: [live-test, test-plan, clone-cplace-fe, jfrog, npm, authtoken, cplace-npm-test] +status: draft +--- + +# Live test plan: PFM-ISSUE-34293 in `clone-cplace-fe` + +This plan validates the PFM-ISSUE-34293 implementation on the test fork `collaborationFactory/clone-cplace-fe`. It publishes and deletes only in the JFrog test registry `cplace-npm-test`, and only `@cplace-next/*` versions created by these runs. + +**What it proves.** Every npm command that runs from a dist directory works with `_authToken=${JFROG_TOKEN}`: `publish`, `show`, `unpublish`, `dist-tag add`/`rm`. The legacy `_auth` path keeps working and is flagged with a deprecation warning. A publishing or deleting run without either secret fails fast, before it publishes or deletes anything. + +**What it reuses.** The environment, tools, helper library, per-case procedure, JFrog rule and teardown come from the 34283 live-test document [`clone-cplace-fe-live-tests.md`](../2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/clone-cplace-fe-live-tests.md), abbreviated **LT** below (Parts 1, 2 and 4; e.g. "LT 2.2" is its helper library). The release expected-state rules come from LT 3.1, and the snapshot helper and rules from the 34282 plan [`live-test-plan.md`](../2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/live-test-plan.md) (abbreviated **LT82**, e.g. "LT82 2.4"). This plan lists only the deltas and the cases. + +**Already done.** The Phase 1 smoke ([plan.md](./plan.md), Phase 1 §6) ran on 2026-11-24: run `45430072566` published 21 snapshot packages with `_authToken=${JFROG_TOKEN}`. Case T1 repeats it on the final branch. + +--- + +## 1. Expected change + +| ID | Item | Before (master) | Expected with 34293 | +|---|---|---|---| +| C1 | dist `.npmrc`, token mode (`JFROG_TOKEN` non-empty) | four lines: `:registry=`, `_auth=`, `always-auth=true`, `email=` | exactly two lines: `@cplace-next:registry=` and `//cplace.jfrog.io/artifactory/api/npm/cplace-npm-test/:_authToken=${JFROG_TOKEN}`. The placeholder is printed literally; the key ends in exactly one `/` | +| C2 | dist `.npmrc`, legacy mode (only `JFROG_BASE64_TOKEN`) | four lines | unchanged, byte for byte | +| C3 | publishing identity log | none | token mode: `Publishing as JFrog user *** with JFROG_TOKEN` before each `.npmrc` printout | +| C4 | `Configuration` log line | serializes `base64Token` (masked only by GitHub) | `"jfrogCredentials":{"url":"***","user":"***","authMode":"TOKEN"\|"LEGACY"\|"NONE"}`, never a `"token":` or `"base64Token":` key | +| C5 | annotation, legacy mode | none | one `::warning::JFROG_BASE64_TOKEN is deprecated: …` per run of a publishing or deleting step | +| C6 | neither secret, publishing or deleting mode | `required: true` blocks the call at startup | the run starts; the artifacts step fails with `::error::No JFrog credentials: …` before build, publish, delete or the release-version file | +| C7 | secret declarations in the seven reusables | `JFROG_BASE64_TOKEN: required: true` | `JFROG_TOKEN` and `JFROG_BASE64_TOKEN` both `required: false`; both passed to every artifacts step (8 env blocks) | +| C8 | modes without credentials | bump-only (`fe-tag` on `release/*`), release flow on the default branch without force | unchanged: no gate, no annotation | + +**What does not change:** `DOT_NPMRC` (installs, `npm search`/`npm view` in cleanup), `JFROG_URL` and `JFROG_USER` (still `required: true`), the registry target (`JFROG_URL` decides it, LT 1.2). + +--- + +## 2. Test environment + +### 2.1 State on 2026-11-24 (read-only check) + +| Item | Value | +|---|---| +| Secrets | `DOT_NPMRC`, `GIT_USER`, `GIT_USER_EMAIL`, `GIT_USER_TOKEN`, `GRADLE_PROPERTIES`, `JFROG_BASE64_TOKEN`, `JFROG_TOKEN` (set by the user 2026-11-24), `JFROG_URL`, `JFROG_USER` | +| Branches | `main`, `release/26.4`, `release/26.3`, `fix/PFM-ISSUE-35119-…` (leftover) | +| Version tags | up to `version/26.4.10` (latest release). The next release on `26.4` is `26.4.11` | +| `main` tip | the Phase 1 smoke replay (upstream #2991) | +| `main` callers | `push_main.yaml`: `fe-install-deps`/`fe-build` `@test/PFM-ISSUE-34282-github-token`, `fe-snapshot` `@test/PFM-ISSUE-34293-jfrog-token` with `JFROG_TOKEN`. `pull_request_snapshot.yaml`, `pull_request_close.yaml`, `cron_cleanup_snapshots.yaml`: `@master` with `JFROG_BASE64_TOKEN`. `fe-release.yml` → `fe-release-flow.yml@test/PFM-ISSUE-34282-github-token`, `secrets: inherit` | +| `release/26.4` callers | `fe-release.yml` → `fe-release-flow.yml@test/PFM-ISSUE-34282-github-token`, `secrets: inherit`, `RUN_E2E` not set (defaults to `true`). Other callers `@release/26.4`. Canary `zz-tag-push-canary.yml` present | +| PR triggers | `pull_request_snapshot.yaml` on `labeled`, `synchronize`, `reopened`; `fe-pr-snapshot.yml` runs only with label `snapshot` (the clone has no such label yet; adding it to a PR creates it). `pull_request_close.yaml` on `closed` | +| Cleanup trigger | `cron_cleanup_snapshots.yaml`: `workflow_dispatch` only (schedule disabled in the fork) | +| Snapshot ages in `cplace-npm-test` | every `@cplace-next` snapshot tarball dates from 2026-10/11. The cleanup computes the age from the version suffix (`…-YYYYMMDD`), so no version there reaches the 4-month threshold | + +Recheck the rows before Phase 5 starts; record any change in the report. + +### 2.2 Placeholders (in addition to LT) + +| Name | Value | +|---|---| +| `TEST_BRANCH` | `test/PFM-ISSUE-34293-jfrog-token` | +| `FB` | `improvement/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets` | +| `MB` | `main` | +| `BR` | `release/26.4` | +| `OUT` | `/34293` (results, captures, `lib.sh`) | +| `WT` | `$OUT/wt`, a working copy of the clone (LT 1.4: `core.longpaths`, `core.autocrlf false`) | + +### 2.3 Setup + +Every push to `github-actions` and every secret change is a stop (LT 2.1). Pushes to the clone are allowed. + +**S1: Recreate the test branch** (stop: push). The Phase 1 test branch predates Phases 2 and 3, so P3 fails until it is recreated. +1. Delete the remote `TEST_BRANCH` and recreate it from `origin/$FB` (stop: the delete and the push). +2. One commit rewrites every internal `collaborationFactory/github-actions/.github/...@master` ref in `.github/workflows` and `.github/actions` to `@$TEST_BRANCH` (34282 plan T1 step 2 command; 14 files). `workflow-templates` stay on `@master`. +3. No e2e-removal commit: the release cases switch e2e off in the caller instead (S3). +4. Run LT P2 and P3 against `TEST_BRANCH`/`FB`. Both must be empty. + +**S2: Point the `main` callers at the test branch.** One commit on `MB`, `.github/workflows` only, no `package.json`/`package-lock.json` (xray): +- `pull_request_snapshot.yaml`, `pull_request_close.yaml`, `cron_cleanup_snapshots.yaml`: `@master` → `@$TEST_BRANCH`, and their `JFROG_BASE64_TOKEN:` line → `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}`. +- `push_main.yaml`: `fe-snapshot` already `@$TEST_BRANCH` with `JFROG_TOKEN` (Phase 1). `fe-install-deps`/`fe-build` stay on the 34282 test branch (they handle no JFrog secret). +- The push starts the main CI with no project affected. Record it as an extra observation: `success`, nothing published. + +**S3: Point the release caller at the test branch.** One commit on `BR`: in `fe-release.yml`, `@test/PFM-ISSUE-34282-github-token` → `@$TEST_BRANCH`, and uncomment `RUN_E2E: false` (the clone cannot run e2e; LT 1.7). Keep `secrets: inherit`. The push starts a release run with nothing affected: expected NO-RELEASE (LT 3.1 N1, N2), token mode, no annotation. Record it as **T4a**. + +**S4: Helpers.** Source LT 2.2 into `$OUT/lib.sh`, plus LT82 2.4 `snap_tgz`, plus: + +```bash +# annotations : check-run annotations (level, message) of one job +annotations() { + local id=$(awk -F'\t' -v n="$2" '$1==n{print $3}' "$1/jobs.tsv") + gh api "repos/$R/check-runs/$id/annotations" --jq '.[] | "\(.annotation_level)\t\(.message)"' +} +# leak_check : lines that must not appear in any 34293 run +leak_check() { grep -nE '"token":|"base64Token":|Failed to replace env in config' "$1"; } +``` + +**S5: Preflight.** LT P2, P3, P5 (registry target), P9 (nothing in flight), P10 (tools), plus: + +| ID | Check | Pass | +|---|---|---| +| Q1 | `gh api repos/$R/actions/secrets --jq '.secrets[].name'` | lists `JFROG_TOKEN`, `JFROG_BASE64_TOKEN`, `JFROG_URL`, `JFROG_USER` | +| Q2 | `uses:` and `JFROG_*` lines of the four explicit callers on `MB` and of `fe-release.yml` on `BR` | as after S2/S3 | +| Q3 | `git diff origin/master...origin/$FB --stat -- .github README.md tools` | only the files of [plan.md](./plan.md) Phases 1–3 | + +### 2.4 Replay commits + +Main and PR cases need real changes. Recompute before use (LT 1.5 rules apply; skip upstream upmerge merges as LT82 did): + +```bash +git -C "$WT" log --first-parent --reverse --format='%h %ad %s' --date=short 320b61b22..upstream/main +git -C "$WT" log --first-parent --reverse --format='%h %ad %s' --date=short b93fdc38e..upstream/release/26.4 +``` + +| Use | Upstream commit (state 2026-11-24) | Note | +|---|---|---| +| T1 (on `MB`) | `a79102a2` #3002, 35103 FE 2.0 dialog to configure aggregations | next non-upmerge after the Phase 1 replay (#2991) | +| L1 (on `MB`) | the next non-upmerge commit after `a79102a2` | | +| PR branches (T2/T3, L2, N2) | one further `main` commit, cherry-picked onto each PR branch | PRs are closed unmerged, so the same commit can serve every PR | +| T4 (on `BR`) | `4b83e9883e5` #3010 (`-m 1`), 35135 split ai-companion e2e | LT 1.5 #6, adds apps; if it conflicts outside fork-setup files, stop; `d9d83f5a6ee` is the spare | + +Each case must show a project affected in its log (`Projects being processed` non-empty) before its artifacts rows are evaluated. + +--- + +## 3. Expected-state rules + +**A: authentication, every token case** + +| Row | Rule | Evidence | +|---|---|---| +| A1 | Each dist `.npmrc` printout is the two C1 lines, preceded by C3 | artifacts job log | +| A2 | `"authMode":"TOKEN"` in the `Configuration` line (C4) | log | +| A3 | `leak_check` is empty; no `always-auth`, no `:_auth=` | log | +| A4 | No `E401`, `E403`, `ENEEDAUTH`, `Unable to authenticate` in an npm command | `grep -nE 'E401\|E403\|ENEEDAUTH\|Unable to authenticate' ` | +| A5 | No `::warning::JFROG_BASE64_TOKEN` and no `No JFrog credentials` annotation | `annotations` | +| A6 | Every version the run created or deleted, checked by exact path in `cplace-npm-test` (LT 4.2) | AQL | + +**L: legacy cases** — the four legacy lines per printout (masked `_auth`), `"authMode":"LEGACY"`, exactly one `warning` annotation with `JFROG_BASE64_TOKEN is deprecated` on the artifacts job, A3, A4, A6. + +**N: neither cases** — the artifacts job `failure`; one `failure` annotation `No JFrog credentials: pass the JFROG_TOKEN secret …`; `"authMode":"NONE"`; no `nx run`/build output in the artifacts step, no `+ @cplace-next/` line, no `npm unpublish`; `snap_tgz "$T0"` adds nothing; no run is blocked at startup with `Secret … is required`. + +**Release rules** — LT 3.1 RELEASE(N) with E7 in its Phase B form (no run for `version/N`, as the tag is pushed with `GITHUB_TOKEN`); NO-RELEASE as in LT 3.1. + +**Snapshot rules** — LT82 3 S1–S5. + +--- + +## 4. Test cases + +Run one at a time in this order (LT 2.1, LT 2.3). Before each case: `T0`, `snapshot "$OUT//before"`, `snap_tgz` baseline. After: capture, evaluate, `verdict.md`, ledger, results line. + +| ID | Mode | Flow | Trigger | Proves | Outcome | +|---|---|---|---|---|---| +| T1 | token | main snapshot (`fe-snapshot`) | push of the T1 replay to `MB` | publish (re-run of the Phase 1 smoke on the final branch) | LT82 S1–S5 + A1–A6 | +| T2 | token | PR snapshot (`fe-pr-snapshot`), labelled PR pushed twice | PR from `test/34293-pr-token`, label `snapshot`, then a second push | `npm show` + unpublish + republish of the same version with Bearer auth | publish, then replace; A1–A6 | +| T3 | token | PR close (`fe-pr-close`) on T2's PR | close T2's PR unmerged | unpublish via the "dist missing" path of `deleteArtifact`, the same path cleanup uses | versions deleted; A1–A6 | +| T4 | token | release flow push on `BR` with a real change | push of the T4 replay to `BR` | publish under the staging tag, then `dist-tag add`/`rm` promote | RELEASE(26.4.11) + A1–A6 | +| T5 | token | cleanup (`fe-cleanup-snapshots`, dispatch) | `gh workflow run cron_cleanup_snapshots.yaml -R $R --ref main` | gate + search + authenticated `npm show`; deletion only if a snapshot in `cplace-npm-test` is ≥ 4 months old, otherwise deletion is covered by T3 (record which) | `success`; no deletion expected (2.1) | +| T6 (optional) | token | release flow with induced publish failure (LT A8 method) | forced dispatch on `BR` with a placeholder at `N` (stop) | failure-cleanup unpublish | cleanup, then RELEASE(N) on re-run | +| L1 | legacy | main snapshot | caller edit + push of the L1 replay to `MB` | legacy path still publishes; `::warning::` annotation present; dist `.npmrc` printout has the four legacy lines | LT82 S1–S5 + L | +| L2 | legacy | PR snapshot + PR close | PR from `test/34293-pr-legacy` with a legacy caller on the PR branch | legacy unpublish still works with the warning | publish, close deletes; L | +| L3 | legacy | release flow via explicit-secrets caller | forced dispatch on `BR` with an explicit-secrets caller without `JFROG_TOKEN` | legacy release + promote still works with the warning | RELEASE(26.4.12) + L | +| N1 | neither | main snapshot | caller edit on `MB` without either line | run fails before `npm run`/build, with the `::error::` annotation; nothing published | N | +| N2 | neither | PR close | PR from `test/34293-pr-none` without label, closed | fails before any `npm unpublish` | N | + +Version numbers assume that nothing else releases on `26.4` in between; each case computes `N` from its own before-snapshot. + +### T1: Main snapshot, token (re-run of the smoke) + +- **Precondition:** S1–S5 done. +- **Trigger:** `git -C "$WT" fetch origin && git -C "$WT" switch -C main-wt origin/main && git -C "$WT" cherry-pick && git -C "$WT" push origin HEAD:main`. +- **Expected:** one "Frontend Main CI" run, `success`. The snapshot job `Uses` `fe-snapshot.yml@refs/heads/$TEST_BRANCH`. One `0.0.0-SNAPSHOT-` for the affected publishable projects, each `+ @cplace-next/

@…` line with a matching tarball (LT82 S2); `snapshot` dist-tag moved (S3); S4, S5; A1–A6. +- **Compare** with the Phase 1 run `45430072566`: same `.npmrc` printout format. + +### T2: PR snapshot, token, pushed twice + +- **Setup:** branch `test/34293-pr-token` from `origin/main` with the PR replay commit; the PR callers on `MB` are already token callers (S2). Open a PR to `main`: `gh pr create -R $R --base main --head test/34293-pr-token --title "34293 T2 token PR snapshot" --body "live test, do not merge"`. +- **Trigger 1:** add the label: `gh api repos/$R/issues//labels -f 'labels[]=snapshot'`. +- **Expected 1:** "Frontend Pull Request Snapshot CI" `success`. Version `0.0.0-test-34293-pr-token-` (`Utils.getPRVersion`) for every affected publishable project; dist-tag `latest-pr-snapshot`. Log per project: `npm show … --registry=…cplace-npm-test` ran with the token `.npmrc` (the version does not exist yet: `Skipping deletion`), then publish. A1–A6. Record the package list. +- **Trigger 2:** push one more commit to the PR branch (an empty commit is enough: `git commit --allow-empty`). Affected is computed against the base, so the same projects are processed. +- **Expected 2:** `success`. For each project: `Package … exists in registry`, `npm unpublish …@ --force`, `Deleted artifact from Jfrog`, then the same version is published again. AQL: one tarball per package at that version, `created` inside the second run's window. A1–A6. +- **Why:** this is the first `npm show` and `npm unpublish` with Bearer auth (design risk 1). + +### T3: PR close, token + +- **Trigger:** `gh pr close -R $R` (unmerged). +- **Expected:** "Frontend Pull Request Close CI" `success`. For each project: `Path to project in dist does not exist, creating it`, the token `.npmrc` printout (A1), `Package … exists in registry`, `npm unpublish`, `Deleted artifact from Jfrog`. AQL for every T2 version = 0 hits (allow LT 2.3 step 5 metadata delay). A2–A5. +- **Cleanup:** delete the branch `test/34293-pr-token`. + +### T4: Release flow on `BR`, token + +- **Precondition:** T4a (S3 push) evaluated. Nothing in flight on `BR`. +- **Trigger:** `git -C "$WT" fetch origin && git -C "$WT" switch -C br-wt origin/$BR && git -C "$WT" cherry-pick -m 1 4b83e9883e5 && git -C "$WT" push origin HEAD:$BR`. +- **Expected:** RELEASE(26.4.11) (LT 3.1 E1–E8, E7 Phase B), plus A1–A6 on the `release` job: + - `Publish phase: publishing all publishable projects as 26.4.11`, one `+ @cplace-next/

@26.4.11` per publishable project, each published under `release-26.4-pending`. + - `Promote phase`: one `npm dist-tag add …@26.4.11 release-26.4` and one `npm dist-tag rm … release-26.4-pending` per package, each without an auth error (A4). After the run: `release-26.4` → `26.4.11` everywhere, no `release-26.4-pending` left. + - Tag `version/26.4.11`, GitHub release by `github-actions[bot]`, no canary run. +- **Why:** the only case that runs `dist-tag add`/`rm` with Bearer auth. + +### T5: Snapshot cleanup, token + +- **Precondition:** S2 done (the cleanup caller passes `JFROG_TOKEN`). +- **Trigger:** `gh workflow run cron_cleanup_snapshots.yaml -R $R --ref main`; find the run with `runs_since "$T0"`. +- **Expected:** `success`. `"authMode":"TOKEN"`, no annotation (A5). `npm search`/`npm view` run with `DOT_NPMRC` (unchanged), so the candidates come from the install registry, not from `cplace-npm-test`. Two outcomes are valid: + - **Candidates found** (old snapshots in the install registry): for each, the dist `.npmrc` printout is the token form (A1) and `npm show … --registry=…cplace-npm-test` answers without an auth error (A4). Per 2.1 none exists in `cplace-npm-test`, so each ends with `does not exist in the registry. Skipping deletion`. + - **No candidate** (`versions to delete: []` everywhere): only the gate and the search are proven; record that `show` is covered by T2/T3. + - Either way, AQL before = after. +- **Stop** if any `npm unpublish` appears: compare its version against the ledger before anything else (it must be one of ours; LT 4.2). +- **Record:** "deletion covered by T3" (or, if a deletion happened, its versions and their check). + +### T6 (optional): Failure cleanup, token + +- **Setup and trigger:** as LT A8 / LT82 R3: upload a placeholder tarball for the last package of T4's publish order at the next `N` (stop: show the upload), then `gh workflow run fe-release.yml -R $R --ref $BR -f force=true`. +- **Expected attempt 1:** `failure` on the placeholder's package; "Unpublish the incomplete release" deletes every package at `N` with the token `.npmrc` (A1, A4); AQL at `N` = 0 (placeholder included); no tag. **Attempt 2** (`gh run rerun --failed`): RELEASE(N). + +### L1: Main snapshot, legacy + +- **Trigger:** one push to `MB` with two commits: a caller edit in `push_main.yaml` (`JFROG_TOKEN:` line → `JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }}`; ref unchanged), then the L1 replay. +- **Expected:** "Frontend Main CI" `success`; LT82 S1–S5; the L rules: four-line printout per project (`:_auth=***`, `:always-auth=true`, `:email=***`), `"authMode":"LEGACY"`, one `warning` annotation with `JFROG_BASE64_TOKEN is deprecated` on the snapshot job, visible in the run summary. +- **Restore:** push the caller back to `JFROG_TOKEN` (nothing affected; record the run as an extra observation). + +### L2: PR snapshot and close, legacy + +- **Setup:** branch `test/34293-pr-legacy` from `origin/main` with the PR replay commit plus one commit that changes the `JFROG_TOKEN:` line in both `pull_request_snapshot.yaml` and `pull_request_close.yaml` to `JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }}`. `pull_request` runs use the workflow files of the PR's merge ref, so this selects legacy mode for this PR only. Open the PR. +- **Trigger 1:** add the label `snapshot`. **Expected:** `success`; L rules; versions `0.0.0-test-34293-pr-legacy-` published. +- **Trigger 2:** close the PR. **Expected:** `success`; L rules on the close job; AQL for the L2 versions = 0. +- **Cleanup:** delete the branch. + +### L3: Release flow via explicit secrets, legacy + +- **Why explicit secrets:** `secrets: inherit` hands the clone's `JFROG_TOKEN` to the flow, which then selects token mode. Never delete the clone's `JFROG_TOKEN` secret for this case. +- **Setup:** one commit on `BR`: in `fe-release.yml`, replace `secrets: inherit` with + ```yaml + secrets: + JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} + JFROG_URL: ${{ secrets.JFROG_URL }} + JFROG_USER: ${{ secrets.JFROG_USER }} + DOT_NPMRC: ${{ secrets.DOT_NPMRC }} + GIT_USER: ${{ secrets.GIT_USER }} + GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} + ``` + Its push starts a release run with nothing affected: expected NO-RELEASE, plus the L warning (the gate runs on every `release/*` run). Record it as **L3a**. +- **Trigger:** `gh workflow run fe-release.yml -R $R --ref $BR -f force=true`. +- **Expected:** RELEASE(26.4.12) (E7 Phase B) with the L rules on the `release` job: legacy printout, warning annotation, publish under `release-26.4-pending`, promote (`dist-tag add`/`rm`) without an auth error. +- **Restore:** one commit on `BR` back to `secrets: inherit` (another NO-RELEASE run, token mode, no annotation). + +### N1: Main snapshot, neither + +- **Trigger:** one commit on `MB` that removes the `JFROG_TOKEN:` line from `push_main.yaml`'s snapshot job (so it passes only `JFROG_URL` and `JFROG_USER`). No replay needed: the gate runs before the affected computation. +- **Expected:** the run starts (no `Secret … is required` startup failure, C7). `install-deps` and `build` `success`; `snapshot` `failure`; the N rules. The log line before the failure is the `Configuration` line with `"authMode":"NONE"`; `About to build and release projects` does not appear. +- **Restore:** push the caller back to `JFROG_TOKEN` (extra observation, nothing affected). + +### N2: PR close, neither + +- **Setup:** branch `test/34293-pr-none` from `origin/main` plus one commit removing the `JFROG_TOKEN:` line from `pull_request_close.yaml` (and from `pull_request_snapshot.yaml`, which does not run without the label). Open the PR without a label, so nothing is published for it. +- **Trigger:** close the PR. +- **Expected:** "Frontend Pull Request Close CI" `failure` in the artifacts step; N rules; no `npm show`, no `npm unpublish`, no `Path to project in dist does not exist` line. +- **Cleanup:** delete the branch. + +--- + +## 5. Pass criteria for the ticket + +| Requirement / success criterion ([design.md](./design.md)) | Shown by | +|---|---| +| npm publish auth uses `///:_authToken=${JFROG_TOKEN}` | A1 in T1–T5 | +| Every dist-`.npmrc` npm command works with Bearer auth (design risk 1) | publish T1/T2/T4, `show` T2/T3/T5, `unpublish` T2/T3 (+T6), `dist-tag add`/`rm` T4 | +| npm never runs without `JFROG_TOKEN` in env (design risk 2) | A3 (`Failed to replace env in config` absent) in every case | +| Legacy callers keep working, and are flagged | L1–L3 publish, unpublish and promote with the warning annotation | +| No startup failure for callers passing either, both or neither (design risk 3) | T cases (both declared, token passed), L cases (legacy only), N cases (neither) all start | +| Fail-fast only in publishing and deleting modes (design risk 4) | N1, N2 fail before any npm write; T4a/L3a/the restore runs show the release flow's gate on `release/*`; bump-only and the default-branch no-op are covered by unit tests | +| No secret value in logs | A2/A3 (C4) in every case | + +Any failed row stops the series (LT 2.1). Record it, fix it on `FB`, recreate the test branch (S1) and rerun from the failed case. T1–T5, N1 and N2 must pass; L1–L3 must pass unless a deviation is accepted by the user; T6 is optional. + +--- + +## 6. Report + +To be filled in Phase 5. One row per case; the verdict is `pass`, `fail` or `skipped`. + +| Case | Run(s) | Evidence | Versions touched in `cplace-npm-test` (state) | Verdict | Note | +|---|---|---|---|---|---| + +Deviations, each with its evidence file: + +--- + +## 7. Teardown + +Stop before each step (LT 4.3). `clone-cplace-fe` and `cplace-npm-test` are test-only: tags, releases and release tarballs created here stay unless the user decides otherwise. PR-snapshot versions are already deleted by T3/L2. + +1. **Callers.** Revert the clone's callers to `@master`: + - after `FB` is merged: `@master` with `JFROG_TOKEN` (master then declares it); + - before the merge: `@master` with `JFROG_BASE64_TOKEN`, because `@master` does not declare `JFROG_TOKEN` yet and a caller passing it fails at startup (design risk 3); + - `BR`'s `fe-release.yml`: decide with the user (its `RUN_E2E: false` stays as long as the clone cannot run e2e). +2. **Test branch.** Delete `TEST_BRANCH` in `github-actions` only after no clone caller references it (`gh api` contents grep for `@test/PFM-ISSUE-34293` on `MB` and `BR` is empty). Pushing the deletion is a stop. +3. **Secrets.** The clone's `JFROG_TOKEN` secret stays. +4. **Throwaway branches.** `test/34293-pr-*` are deleted inside their cases; verify none is left. diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md new file mode 100644 index 00000000..fe2d3e1e --- /dev/null +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md @@ -0,0 +1,566 @@ +--- +date: 2026-11-23 +ticket: PFM-ISSUE-34293 +topic: "Introduce separate JFrog user and token secrets (plain _authToken)" +status: draft +design: ./design.md +research: ./research.md +branch: improvement/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets +--- + +# Separate JFrog User and Token Secrets (plain `_authToken`) Implementation Plan + +## Overview + +The artifacts tooling gets a second publish-credential mode. When `JFROG_TOKEN` is present, the generated dist `.npmrc` authenticates with `////:_authToken=${JFROG_TOKEN}`. The placeholder is written literally and npm expands it from the step env. When only the deprecated `JFROG_BASE64_TOKEN` is present, the legacy `_auth` file is written byte-for-byte as today, and the run gets a `::warning::` deprecation annotation. When neither is present in a mode that publishes or deletes, the run fails fast with an explicit `::error::`. + +All seven reusable workflows that declare JFrog secrets declare `JFROG_TOKEN` and `JFROG_BASE64_TOKEN` as optional and pass both to the composite step. The FE starter templates switch to `JFROG_TOKEN`, and the README documents the secrets contract. Everything is validated live on `clone-cplace-fe` against `cplace-npm-test`. + +Scope is the `github-actions` repository only. The pilot on `cplace-remote-filesystem-fe` and the rollout to the other FE repos follow this plan (see "Migration Notes"). + +## Current State Analysis + +- `tools/scripts/artifacts/jfrog-credentials.ts:1-19` reads `JFROG_URL`, `JFROG_USER` and `JFROG_BASE64_TOKEN`, each defaulting to `''`. `getJfrogUrlNoHttp()` strips `https:` and produces a key with **no** trailing slash. No `JFROG_TOKEN` is read anywhere. +- `tools/scripts/artifacts/nx-project.ts:293-313`, `writeNPMRCInDist`, is the only writer of publish credentials. It writes four lines (`:registry=`, `_auth=`, `always-auth=true`, `email=`), each except the last ending in a literal space, and `console.log`s the full content at `:306`. +- `tools/scripts/artifacts/artifacts-handler.ts:105` logs `'Configuration ' + JSON.stringify(this)`. That serializes `jfrogCredentials`, including `base64Token`, and would include a new token field too. Only GitHub's secret masking hides it today. +- `artifacts-handler.ts:108-143`, `handle()`, dispatches after the branch-off early return (`:117-128`): + - `releaseFlow` → `tagAndPublishRelease()`. It publishes only on `release/*` or with `force`, and writes the release-version file at `:285` *before* publishing. + - `onlyBumpVersion` on `release/*` → bump only (`fe-tag`), which needs no credentials. + - everything else → `buildAndPublishProjects()`, which publishes, or deletes when `onlyDeleteArtifacts` is set. +- `fe-release-flow.yml:102-106` runs the `release` job only for a push or `FORCE`. The release-flow "no force, non-release branch" no-op path is therefore never reached in CI. +- `tools/scripts/artifacts/cleanup-snapshots.ts:77-83`, `deleteSuperfluousArtifacts()`, is the delete entry point. `:88` constructs `JfrogCredentials`. The constructor's `npm search` / `npm view` calls use `~/.npmrc` (`DOT_NPMRC`), not the JFrog secrets. +- **Unset optional secrets arrive as empty strings.** `${{ secrets.X }}` for an optional secret the caller does not pass yields `''` in the step env, so presence must be decided by truthiness. +- Tests: + - `test-data.ts:84-88` holds the legacy fixture. + - Four `artifacts-handler*.test.ts` files set `JFROG_BASE64_TOKEN`, `JFROG_URL` and `JFROG_USER` at module level. + - `cleanup-snapshots.test.ts` sets no `JFROG_*` env and runs the real `deleteArtifact`. + - No test covers `jfrog-credentials.ts`. + - CI (`pr-checks.yml`) runs shellcheck and bats but **not** jest or prettier, so the test suite runs locally with `npm test`. `npx prettier --check .` already reports 85 files on `master`, so the plan checks whitespace with `git diff --check` instead. +- Seven reusables declare `JFROG_BASE64_TOKEN: required: true`: `fe-snapshot`, `fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`, `fe-release`, `fe-tag` and `fe-release-flow`. Between them they have eight `env:` blocks; `fe-release-flow` has two, at `:150-156` and `:187-193`. Four templates pass `JFROG_BASE64_TOKEN` explicitly: `fe-main.yml:54`, `fe-pr-snapshot.yml:20`, `fe-pr-close.yml:20` and `fe-cleanup-snapshots.yml:17`. + +## Desired End State + +- **Token present** (`JFROG_TOKEN` non-empty): the dist `.npmrc` is exactly + ``` + :registry= + ////:_authToken=${JFROG_TOKEN} + ``` + It has no `always-auth` and no `email`. The key ends in exactly one `/` whatever the format of `JFROG_URL`. The log shows the publishing user and the literal placeholder, never a token value. +- **Only `JFROG_BASE64_TOKEN` present:** the legacy four-line file is unchanged, and the run carries the deprecation warning annotation. +- **Neither present**, in a publish or delete mode (snapshot, PR snapshot, PR close, release flow on `release/*` or forced, deprecated tag-push release, cleanup): the run fails before any build, publish, delete or release-version file, with an `::error::` that names `JFROG_TOKEN`. Bump-only (`fe-tag` on `release/*`) still succeeds without credentials. +- `JSON.stringify` of `JfrogCredentials` never contains `base64Token` or `token`. +- The seven reusables accept callers that pass `JFROG_TOKEN`, `JFROG_BASE64_TOKEN`, both or neither, with no workflow-level "required secret" error. The templates show `JFROG_TOKEN`, and the README documents every JFrog secret. +- The live matrix in `live-test-plan.md` passes on `clone-cplace-fe`, and its results are recorded in that file. + +### Key Discoveries: +- `nx-project.ts:293-313` is the single `.npmrc` writer, and `deleteArtifact` (`:243-258`) reuses it when the dist directory is missing. PR close and cleanup therefore run through the same writer. +- `artifacts-handler.ts:105` is a second log path for credentials that the design does not mention. Redacting with `toJSON()` closes it for both secrets. +- `artifacts-handler.ts:285` writes the release-version file before publishing. The credential gate must run before it, or the workflow's failure cleanup (`fe-release-flow.yml:160-193`) would start an unpublish that fails a second time. +- `fe-release-flow.yml` callers use `secrets: inherit`, so on the release-flow path the clone's repository secrets alone decide which credential mode applies. The other reusables are selected by what the caller passes. +- Test style to follow is `nx-project.test.ts`: top-level `test(...)` blocks, `expect` from `@jest/globals`, `jest.spyOn` mocks, and names in the form "`` can/does …". + +## What We're NOT Doing + +- No change to `DOT_NPMRC`, `use-npmrc`, install auth, the `npm search`/`npm view` calls in cleanup, or Bryntum auth. +- No removal of the legacy fallback, and `JFROG_TOKEN` is not made required. Both belong to the follow-up cleanup ticket. +- No removal of JFrog secret declarations from any reusable, including `fe-tag`. +- No change to `fe-release.yml` in the templates (it uses `secrets: inherit`), and no change to `JFROG_URL` or `JFROG_USER` declarations (they stay `required: true`). +- No backport to `release/26.4` or older lines. +- No minting of tokens or setting of secrets in any production FE repo. No edits to callers in FE repos: the pilot and rollout are follow-ups. +- `printenv` in the `artifacts`/`snapshots` composites stays as is. `JFROG_TOKEN` is a registered secret and is masked there like `JFROG_BASE64_TOKEN` today. +- No jest step added to `pr-checks.yml`. + +## Implementation Approach + +The first phase builds a thin vertical slice: token mode in `JfrogCredentials`, the token branch of the writer, the redaction, and `fe-snapshot.yml`. It is proven live with one token-only snapshot publish on `clone-cplace-fe` before anything else is built on it. That run settles the two least certain assumptions early: npm expands the literal placeholder from the step env, and JFrog accepts the reference token as Bearer. + +Phase 2 adds the transition behavior (gate, warning, fail-fast) behind the same interfaces. Phase 3 extends the workflow change to the remaining reusables, the templates and the README. Phases 4 and 5 write and run the full live matrix. + +All live runs use the 34283 harness: `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/clone-cplace-fe-live-tests.md`, Parts 1, 2 and 4. They target a github-actions test branch, `test/PFM-ISSUE-34293-jfrog-token`, which is the feature branch plus one commit that rewrites every internal `collaborationFactory/github-actions/...@master` ref in `.github/workflows` and `.github/actions` to `@test/PFM-ISSUE-34293-jfrog-token` (harness 1.3 step 5, preflight P2). That commit never lands on the feature branch. + +Credential scenarios on the clone are selected by **caller edits**: which secret name the clone's caller passes. Secrets are only deleted where `secrets: inherit` leaves no other choice. Adding the `JFROG_TOKEN` secret to the clone is the one secret change every phase needs, and it requires the user's consent and value. + +--- + +## Phase 1: Walking skeleton — token `.npmrc` for snapshot publish, proven live + +### Overview +Introduce token mode end to end for the main-branch snapshot path: env → `JfrogCredentials` → dist `.npmrc` → `npm publish`. It runs live once, token-only, on `clone-cplace-fe`. The new test file's pattern is reviewed before more tests are written. + +### Changes Required: + +#### 1. Sample test (pattern gate — stop for review before step 2) +**File**: `tools/scripts/artifacts/jfrog-credentials.test.ts` (new) +**Changes**: Write only this one test first. Then call `AskUserQuestion`: "Sample test for jfrog-credentials.test.ts written (pattern: top-level `test`, env cleared in `afterEach`). Approve the pattern before the remaining tests are written?" Do not write further tests in this file until the user approves. + +```ts +import { expect } from '@jest/globals'; +import { JfrogAuthMode, JfrogCredentials } from './jfrog-credentials'; + +const JFROG_ENV = ['JFROG_URL', 'JFROG_USER', 'JFROG_TOKEN', 'JFROG_BASE64_TOKEN']; + +afterEach(() => { + JFROG_ENV.forEach((name) => delete process.env[name]); + jest.restoreAllMocks(); +}); + +test('JfrogCredentials uses the token when JFROG_TOKEN and JFROG_BASE64_TOKEN are both set', () => { + process.env.JFROG_TOKEN = 'jfrog_token'; + process.env.JFROG_BASE64_TOKEN = 'jfrog_base64_token'; + + expect(new JfrogCredentials().authMode).toBe(JfrogAuthMode.TOKEN); +}); +``` + +#### 2. Token mode, auth key, redaction +**File**: `tools/scripts/artifacts/jfrog-credentials.ts` +**Changes**: Read `JFROG_TOKEN`. Add `JfrogAuthMode` and an `authMode` getter that decides by truthiness, so an empty string counts as absent. Add `getAuthKey()` (normalized nerf-dart key with exactly one trailing slash) and `toJSON()` redaction. `getJfrogUrlNoHttp()` and the existing fields stay unchanged; the legacy writer still uses them. + +```ts +export enum JfrogAuthMode { + TOKEN = 'TOKEN', + LEGACY = 'LEGACY', + NONE = 'NONE', +} + +export class JfrogCredentials { + /** written literally into the dist .npmrc; npm expands it from the step env */ + public static readonly TOKEN_PLACEHOLDER = '${JFROG_TOKEN}'; + public url = ''; + public user = ''; + public base64Token = ''; + public token = ''; + + constructor() { + // ...existing url/user/base64Token reads unchanged... + this.token = process.env.JFROG_TOKEN != undefined ? process.env.JFROG_TOKEN : ''; + } + + /** an optional secret the caller does not pass arrives as '', so presence is truthiness */ + public get authMode(): JfrogAuthMode { + if (this.token) return JfrogAuthMode.TOKEN; + if (this.base64Token) return JfrogAuthMode.LEGACY; + return JfrogAuthMode.NONE; + } + + public getJfrogUrlNoHttp(): string { + return this.url.replace('https:', ''); + } + + /** npm looks credentials up by the registry's nerf-dart, which ends in exactly one '/' */ + public getAuthKey(): string { + return this.getJfrogUrlNoHttp().replace(/\/+$/, '') + '/'; + } + + /** keeps secrets out of JSON.stringify, e.g. the handler's "Configuration" log line */ + public toJSON() { + return { url: this.url, user: this.user, authMode: this.authMode }; + } +} +``` + +#### 3. Token branch of the dist `.npmrc` writer +**File**: `tools/scripts/artifacts/nx-project.ts` (`writeNPMRCInDist`, `:293-313`) +**Changes**: In token mode, write the two lines with the literal placeholder and log the publishing identity. Every other mode uses the existing four-line code **unchanged**: move it into an `else` without touching the strings. The `console.log(this.npmrcContent)` and file-write lines stay shared. + +```ts +public writeNPMRCInDist(jfrogCredentials: JfrogCredentials, scope: string) { + if (jfrogCredentials.authMode === JfrogAuthMode.TOKEN) { + this.npmrcContent = + `${scope}:registry=${jfrogCredentials.url}\n` + + `${jfrogCredentials.getAuthKey()}:_authToken=${JfrogCredentials.TOKEN_PLACEHOLDER}`; + console.log(`Publishing as JFrog user ${jfrogCredentials.user} with JFROG_TOKEN`); + } else { + // legacy _auth path: byte-for-byte unchanged (existing lines 294-305) + } + console.log(this.npmrcContent + '\n\n'); + // ...existing mkdir + writeFileSync unchanged... +} +``` + +#### 4. Token fixture and remaining Phase 1 tests +**File**: `tools/scripts/artifacts/test-data.ts` +**Changes**: Add a token fixture next to `npmrc`, which stays untouched. + +```ts +export const npmrcToken = + '@cplace-frontend-applications:registry=jfrog_url\n' + + 'jfrog_url/:_authToken=${JFROG_TOKEN}'; +``` + +**File**: `tools/scripts/artifacts/jfrog-credentials.test.ts` +**Changes**: Add after the sample is approved: +- `authMode` is `LEGACY` with only `JFROG_BASE64_TOKEN`, and `NONE` with neither. +- `authMode` is `NONE` when both are set to `''`, which is how workflows pass unset optional secrets. +- `getAuthKey()` returns `//cplace.jfrog.io/artifactory/cplace-npm-test/` for `JFROG_URL` without a trailing slash, with one, and with `//`. +- `JSON.stringify(new JfrogCredentials())` contains neither the token nor the base64 value. + +**File**: `tools/scripts/artifacts/nx-project.test.ts` +**Changes**: Add `NxProject writes a token .npmrc when JFROG_TOKEN is set`. It sets `JFROG_URL=https://cplace.jfrog.io/artifactory/cplace-npm-test/` and `JFROG_TOKEN=secret_value`, then calls `writeNPMRCInDist` with fs mocked as in the existing tests. It asserts: +- the content equals the two expected lines with the literal placeholder; +- the content does not contain `secret_value`, `always-auth` or `email`; +- `fs.writeFileSync` received the same content. + +Clear the env in the file's `afterEach`. + +**File**: `tools/scripts/artifacts/artifacts-handler.test.ts` +**Changes**: Add `can write the token .npmrc for Snapshots in main branch`. It mirrors `can create and overwrite Snapshots in main branch` with `JFROG_TOKEN = 'jfrog_token'` set and expects `npmrcContent` to equal `npmrcToken`. Add `delete process.env.JFROG_TOKEN` to `afterEach`. The existing legacy assertion (`:145-146`, `npmrc`) stays and must keep passing. + +#### 5. `fe-snapshot.yml` wiring +**File**: `.github/workflows/fe-snapshot.yml` +**Changes**: Declare `JFROG_TOKEN` and make `JFROG_BASE64_TOKEN` optional (`:12-18`). Pass both in the `artifacts` step env (`:43-46`). + +```yaml + secrets: + JFROG_TOKEN: + required: false + # deprecated, replaced by JFROG_TOKEN; used only when JFROG_TOKEN is not passed + JFROG_BASE64_TOKEN: + required: false + JFROG_URL: + required: true + JFROG_USER: + required: true +... + env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} + JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} + JFROG_URL: ${{ secrets.JFROG_URL }} + JFROG_USER: ${{ secrets.JFROG_USER }} +``` + +#### 6. Live smoke: token-only snapshot publish on `clone-cplace-fe` +**Repos**: `collaborationFactory/github-actions` (test branch), `collaborationFactory/clone-cplace-fe` +**Changes**: +1. Create `test/PFM-ISSUE-34293-jfrog-token` from the feature branch, plus the ref-rewrite commit (harness 1.3 step 5). Run harness preflight P2 (refs point to the test branch) and P3 (test branch is current). **Stop for user confirmation before every push** (harness 2.1). +2. **Stop for consent:** the user sets the `JFROG_TOKEN` secret on `clone-cplace-fe`. The value is a reference token of the clone's `JFROG_USER` with deploy, delete and annotate rights on `cplace-npm-test`. The agent never handles the value. +3. On the clone's `main`, point the caller of `fe-snapshot.yml` at `@test/PFM-ISSUE-34293-jfrog-token`, and replace its `JFROG_BASE64_TOKEN:` line with `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}`. Push a change that affects at least one publishable project. The 34282 `live-test-plan.md` M1 shows the procedure. +4. Capture the run with the harness `capture` helper (2.2). + +### Success Criteria: + +#### Automated Verification: +- [x] The sample test was approved by the user before any other test in `jfrog-credentials.test.ts` was written +- [x] Unit tests pass: `npm test` (all new tests pass; the 8 failures in `utils`, `artifacts-handler-tag` and `nx-project` also fail on `master` on Windows: path separators and local env) +- [x] No whitespace errors in the change: `git diff --check master` is empty (a repo-wide `prettier --check` is not usable: 85 files on `master` already fail it) +- [x] Legacy fixture unchanged: `git diff master -- tools/scripts/artifacts/test-data.ts` shows only added lines +- [x] `fe-snapshot.yml` declares `JFROG_TOKEN` and `JFROG_BASE64_TOKEN` as `required: false` and passes both: `grep -A1 -E '^ JFROG_(BASE64_)?TOKEN:$' .github/workflows/fe-snapshot.yml` shows `required: false` twice, and `grep -c 'secrets.JFROG_TOKEN' .github/workflows/fe-snapshot.yml` is `1` +- [x] The feature branch contains no test-branch refs: `git grep -n '@test/' -- .github` is empty +- [x] Live smoke run on `clone-cplace-fe` concluded `success`. Its log contains `_authToken=${JFROG_TOKEN}` literally, `Publishing as JFrog user`, a `+ @cplace-next/` publish line and `"authMode":"TOKEN"`. It contains no `Failed to replace env in config` and no `"token":` / `"base64Token":` keys. The published version exists in `cplace-npm-test` (harness AQL check) + - _Result 2026-11-24: run [45430072566](https://github.com/collaborationFactory/clone-cplace-fe/actions/runs/45430072566) ("Frontend Main CI", `success`, all jobs `success`). Trigger: on the clone's `main`, `push_main.yaml`'s snapshot caller switched to `@test/PFM-ISSUE-34293-jfrog-token` with `JFROG_TOKEN` in place of `JFROG_BASE64_TOKEN`, plus upstream `cplace-fe` #2991 replayed (it touches `cf-frontend-sdk`). The user set `JFROG_TOKEN` on the clone (and on all FE repos) on 2026-11-24. Snapshot job log: `_authToken=${JFROG_TOKEN}` ×21, `Publishing as JFrog user *** with JFROG_TOKEN` ×21, 21 `+ @cplace-next/…@0.0.0-SNAPSHOT-mwuw5lai-20261124` lines, `"jfrogCredentials":{"url":"***","user":"***","authMode":"TOKEN"}`. No `Failed to replace env in config`, `"token":`, `"base64Token":`, `always-auth` or `:_auth=` lines. AQL finds all 21 tarballs in `cplace-npm-test`, deployed by the token's owner. `cf-frontend-sdk` dist-tag `snapshot` → `0.0.0-SNAPSHOT-mwuw5lai-20261124`._ +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 1 complete. Summary: token mode, auth-key normalization and redaction in JfrogCredentials; token branch in writeNPMRCInDist; fe-snapshot.yml accepts JFROG_TOKEN; token-only snapshot publish succeeded live on clone-cplace-fe (run ). Please review the changes and reply 'yes' to continue to Phase 2." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +- [x] In the smoke run's job log, the dist `.npmrc` printout has exactly two lines, and the registry/key part is masked as `***` while `_authToken=${JFROG_TOKEN}` stays readable + - _Observed in run 45430072566: two lines; `@cplace-next:registry=***` is masked, but the key line shows `//cplace.jfrog.io/artifactory/api/npm/cplace-npm-test/` in clear. The key is `JFROG_URL` without `https:`, so it isn't a substring match of the secret. Legacy mode prints its `getJfrogUrlNoHttp()` keys the same way (harness P5 relies on these unmasked paths). The repository URL isn't a credential. Accepted by the user at the Phase 1 checkpoint._ +- [x] The installed snapshot (`npm view @cplace-next/@` against `cplace-npm-test`) has the expected tag `snapshot` + +--- + +## Phase 2: Credential gate, deprecation warning, fail-fast + +### Overview +Restore the protection that `required: true` gave, scoped to the modes that publish or delete, and make unmigrated callers visible. The gate runs once per run, before any work. + +### Changes Required: + +#### 1. Gate on the credentials class +**File**: `tools/scripts/artifacts/jfrog-credentials.ts` +**Changes**: Add `requireForPublishing()`, which emits the annotation for the selected mode and throws when nothing can authenticate. + +```ts +public static readonly LEGACY_WARNING = + 'JFROG_BASE64_TOKEN is deprecated: set the JFROG_TOKEN repository secret and pass ' + + 'JFROG_TOKEN instead of JFROG_BASE64_TOKEN to the github-actions FE workflows (PFM-ISSUE-34293).'; +public static readonly MISSING_ERROR = + 'No JFrog credentials: pass the JFROG_TOKEN secret (or the deprecated JFROG_BASE64_TOKEN) ' + + 'to this workflow. Publishing and deleting npm artifacts needs one of them.'; + +/** call once per run, before anything is published or deleted */ +public requireForPublishing(): void { + switch (this.authMode) { + case JfrogAuthMode.TOKEN: + return; + case JfrogAuthMode.LEGACY: + console.log(`::warning::${JfrogCredentials.LEGACY_WARNING}`); + return; + default: + console.log(`::error::${JfrogCredentials.MISSING_ERROR}`); + throw new Error(JfrogCredentials.MISSING_ERROR); + } +} +``` + +#### 2. Mode-scoped gate in the handler +**File**: `tools/scripts/artifacts/artifacts-handler.ts` +**Changes**: Insert the gate in `handle()` after the branch-off early return (after `:128`) and before the dispatch. Add a private predicate that mirrors the dispatch order exactly. The thrown error rejects `handle()`, and the unhandled rejection in `main.ts` exits non-zero. + +```ts + if (this.requiresPublishCredentials()) + this.jfrogCredentials.requireForPublishing(); + if (this.releaseFlow) { +... + + /** mirrors the dispatch in handle(): only bump-only and the release flow's no-op path need no credentials */ + private requiresPublishCredentials(): boolean { + const onReleaseBranch = this.currentBranch.startsWith( + ArtifactsHandler.RELEASE_BRANCH_PREFIX + ); + if (this.releaseFlow) return onReleaseBranch || this.force; + if (this.onlyBumpVersion && onReleaseBranch) return false; + return true; + } +``` + +#### 3. Gate in cleanup +**File**: `tools/scripts/artifacts/cleanup-snapshots.ts` +**Changes**: Construct `JfrogCredentials` once, as a field. Call `requireForPublishing()` at the top of `deleteSuperfluousArtifacts()`, before the loop, and pass the field to `removeSnapshotArtifacts` instead of creating new credentials at `:88`. + +#### 4. Tests +**File**: `tools/scripts/artifacts/jfrog-credentials.test.ts` +**Changes**: +- `requireForPublishing` logs no annotation in token mode. +- It logs exactly one `::warning::` with `LEGACY_WARNING` in legacy mode. +- It logs `::error::` and throws `MISSING_ERROR` with neither set. + +Use `jest.spyOn(console, 'log')` for the logging checks. + +**File**: `tools/scripts/artifacts/artifacts-handler.test.ts` +**Changes**: Add `refuses to delete artifacts when a Pull Request is closed without JFrog credentials`. It sets `JFROG_BASE64_TOKEN = ''` with no `JFROG_TOKEN`, then expects `exec()` to reject with `No JFrog credentials` and `deleteArtifactSpy` not to have been called. Restore `JFROG_BASE64_TOKEN = 'jfrog_base64_token'` in `afterEach`. + +**File**: `tools/scripts/artifacts/artifacts-handler-tag.test.ts` +**Changes**: Add a bump-only test on `release/5.18` with both secrets cleared that still tags and pushes. Restore the env in `afterEach`. + +**File**: `tools/scripts/artifacts/artifacts-handler-release-flow.test.ts` +**Changes**: Add: +- A release flow on `release/26.4` without credentials rejects with `No JFrog credentials`, and neither publish nor `Utils.writeReleaseVersionFile` is called. +- A non-forced release flow on `main` without credentials resolves and publishes nothing. + +Restore the env in `afterEach`. + +**File**: `tools/scripts/artifacts/cleanup-snapshots.test.ts` +**Changes**: +- Set `process.env.JFROG_URL` and `process.env.JFROG_TOKEN` for the existing test, which now needs credentials to reach deletion. +- Add `refuses to delete snapshots without JFrog credentials`: neither secret set, `deleteSuperfluousArtifacts()` rejects, and no `npm unpublish` call goes to `execSync`. + +### Success Criteria: + +#### Automated Verification: +- [x] Unit tests pass: `npm test` (117 tests; only the 8 failures that also fail on `master` on Windows. Mutation check: without the gate calls, the PR-close, release and cleanup gate tests fail) +- [x] No whitespace errors in the change: `git diff --check master` is empty (a repo-wide `prettier --check` is not usable: 85 files on `master` already fail it) +- [x] Gate called exactly once per entry point: `grep -c 'requireForPublishing()' tools/scripts/artifacts/artifacts-handler.ts tools/scripts/artifacts/cleanup-snapshots.ts` prints `1` for each +- [x] `cleanup-snapshots.ts` constructs `JfrogCredentials` once: `grep -c 'new JfrogCredentials' tools/scripts/artifacts/cleanup-snapshots.ts` is `1` +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 2 complete. Summary: requireForPublishing (token silent / legacy ::warning:: / none ::error:: + throw) gated by mode in ArtifactsHandler.handle() and CleanupSnapshots.deleteSuperfluousArtifacts(); bump-only and the release flow's no-op path stay credential-free; unit tests cover all cases. Please review the changes and reply 'yes' to continue to Phase 3." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +- [ ] The warning and error texts read clearly in a GitHub annotation and name the exact secret to set + +--- + +## Phase 3: Remaining reusables, templates, README + +### Overview +Apply the `fe-snapshot.yml` pattern from Phase 1 to the other six reusables. Point the templates at `JFROG_TOKEN`, and document the secrets contract. + +### Changes Required: + +#### 1. Reusable workflows +**Files**: +- `.github/workflows/fe-pr-snapshot.yml` (declarations `:9-17`, env `:67-70`) +- `.github/workflows/fe-pr-close.yml` (`:9-17`, `:49-52`) +- `.github/workflows/fe-cleanup-snapshots.yml` (`:5-13`, `:43-46`) +- `.github/workflows/fe-release.yml` (`:5-13`, `:53-56`) +- `.github/workflows/fe-tag.yml` (`:12-24`, `:55-58`) +- `.github/workflows/fe-release-flow.yml` (`:15-29`; env in **both** `artifacts` steps, `:150-156` and `:187-193`) + +**Changes**: Identical to Phase 1 §5. Add `JFROG_TOKEN: required: false` above `JFROG_BASE64_TOKEN`, switch `JFROG_BASE64_TOKEN` to `required: false` with the same deprecation comment, and add `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}` above every `JFROG_BASE64_TOKEN:` env line. `JFROG_URL`, `JFROG_USER` and all other secrets are unchanged. + +#### 2. Templates +**Files**: `.github/workflow-templates/fe/fe-main.yml:54`, `fe-pr-snapshot.yml:20`, `fe-pr-close.yml:20`, `fe-cleanup-snapshots.yml:17` +**Changes**: Replace `JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }}` with `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}`. `fe-release.yml` (`secrets: inherit`) is unchanged. + +#### 3. README +**File**: `README.md` ("Required secrets", `:83-91`) +**Changes**: +- In the inherit list, replace `JFROG_BASE64_TOKEN` with `JFROG_TOKEN`. +- Add a subsection with the secrets contract that applies to all FE workflows: + +```markdown +#### 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`); a trailing slash does not matter | `: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 | + +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. Workflows called +with `secrets: inherit` pick it up without an edit. Keep the `JFROG_BASE64_TOKEN` repository secret while a +release branch still passes it. A publishing or deleting run without either secret fails with "No JFrog +credentials". +``` + +### Success Criteria: + +#### Automated Verification: +- [x] No whitespace errors in the change: `git diff --check master` is empty (a repo-wide `prettier --check` is not usable: 85 files on `master` already fail it) +- [x] Unit tests still pass: `npm test` (117 tests, only the 8 `master`-on-Windows failures; `actionlint` reports the same findings on the FE workflows as on `master`) +- [x] Every reusable that declares `JFROG_BASE64_TOKEN` also passes `JFROG_TOKEN`: `for f in $(grep -l 'JFROG_BASE64_TOKEN:' .github/workflows/*.yml); do grep -q 'secrets.JFROG_TOKEN' "$f" || echo "MISSING $f"; done` prints nothing +- [x] Env blocks are paired: `grep -c 'secrets.JFROG_TOKEN' .github/workflows/*.yml` sums to the same total as `grep -c 'secrets.JFROG_BASE64_TOKEN' .github/workflows/*.yml` (8) +- [x] No reusable requires either credential: `grep -A1 -E '^ JFROG_(BASE64_)?TOKEN:$' .github/workflows/*.yml | grep -c 'required: true'` is `0` +- [x] No template passes the deprecated secret: `grep -rn 'JFROG_BASE64_TOKEN' .github/workflow-templates` is empty +- [x] The feature branch contains no test-branch refs: `git grep -n '@test/' -- .github` is empty +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 3 complete. Summary: the six remaining reusables accept JFROG_TOKEN (optional) next to the now-optional JFROG_BASE64_TOKEN and pass both; four templates pass JFROG_TOKEN; README documents the JFrog/npm secrets contract and migration. Please review the changes and reply 'yes' to continue to Phase 4." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +- [ ] The README table renders correctly on GitHub, and the migration paragraph is enough for a repo owner to switch without reading the code + +--- + +## Phase 4: Write the live test plan + +### Overview +Write the executable live matrix as `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md`. Structure and level of detail follow `specs/2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/live-test-plan.md`. The environment, execution model, helpers, JFrog rule and teardown are taken by reference from the 34283 harness (Parts 1, 2 and 4) instead of being copied. + +### Changes Required: + +#### 1. `live-test-plan.md` +**File**: `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md` (new) +**Changes**: The document must contain: +- **Expected change:** what 34293 changes in a run, i.e. the dist `.npmrc` format per mode, the annotations, the fail-fast, and the redacted `Configuration` line. +- **Environment:** + - a read-only state check of `clone-cplace-fe`: its secrets, including `JFROG_TOKEN` from Phase 1, and the callers and their refs; + - test branch `test/PFM-ISSUE-34293-jfrog-token`, recreated if stale (P3); + - placeholders added to the harness ones. +- **Scenario selection rules:** + - Explicit-secret callers (`fe-snapshot`, `fe-pr-snapshot`, `fe-pr-close`, `fe-cleanup-snapshots`) select token-only, legacy-only or neither **by editing the clone's caller**: which secret line it passes. + - The release flow uses `secrets: inherit`. For its legacy-only case, temporarily switch the clone's `release/26.4` caller to explicit secrets that omit `JFROG_TOKEN`, and revert afterwards. Never delete the clone's `JFROG_TOKEN` secret for this. + - Any secret change on the clone is a stop for the user's consent. +- **Cases**, each with trigger, expected end state and evidence: + + | ID | Mode | Flow | Proves | + |---|---|---|---| + | T1 | token | main snapshot (`fe-snapshot`) | publish (re-run of the Phase 1 smoke on the final branch) | + | T2 | token | PR snapshot (`fe-pr-snapshot`), labelled PR pushed twice | `npm show` + unpublish + republish of the same version with Bearer auth | + | T3 | token | PR close (`fe-pr-close`) on T2's PR | unpublish via the "dist missing" path of `deleteArtifact`, the same path cleanup uses | + | T4 | token | release flow push on `release/26.4` with a real change | publish under the staging tag, then `dist-tag add`/`rm` promote | + | T5 | token | cleanup (`fe-cleanup-snapshots`, dispatch or schedule) | gate + search; deletion only if a snapshot in `cplace-npm-test` is ≥ 4 months old, otherwise deletion is covered by T3 (record which) | + | T6 (optional) | token | release flow with induced publish failure (harness A8 method) | failure-cleanup unpublish | + | L1 | legacy | main snapshot | legacy path still publishes; `::warning::` annotation present; dist `.npmrc` printout has the four legacy lines | + | L2 | legacy | PR snapshot + PR close | legacy unpublish still works with the warning | + | L3 | legacy | release flow via explicit-secrets caller | legacy release + promote still works with the warning | + | N1 | neither | main snapshot | run fails before `npm run`/build, with the `::error::` annotation; nothing published | + | N2 | neither | PR close | fails before any `npm unpublish` | + +- **Evidence common to all token cases:** + - the log contains `_authToken=${JFROG_TOKEN}` and `"authMode":"TOKEN"`; + - no `"token":`, `"base64Token":`, `always-auth` or `Failed to replace env in config`; + - every version the run touched is checked by exact path in `cplace-npm-test` (harness 4.2). +- **Pass criteria for the ticket** (mapped to the design's success criteria), a **report** section to be filled in Phase 5, and **teardown**: + - revert the clone's callers to `@master`; + - delete the test branch, with a stop; + - the clone's `JFROG_TOKEN` secret stays. + +### Success Criteria: + +#### Automated Verification: +- [x] `live-test-plan.md` exists and lists every case ID: `for id in T1 T2 T3 T4 T5 L1 L2 L3 N1 N2; do grep -q "| $id " specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md || echo "MISSING $id"; done` prints nothing +- [x] No whitespace errors: `git diff --check master -- specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/` is empty +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 4 complete. Summary: live-test-plan.md written with cases T1–T6, L1–L3, N1–N2 on clone-cplace-fe, scenario selection by caller edits, consent stops for secret changes. Please review the live test plan and reply 'yes' to continue to Phase 5 (execution)." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +- [ ] Every case can be triggered and evaluated from the document and the harness alone, without guessing +- [ ] No case writes to `cplace-npm-local`, a real FE repo, or a real `release/*` branch outside the clone + +--- + +## Phase 5: Run the live matrix + +### Overview +Run `live-test-plan.md` against the final feature branch, through a recreated test branch, and record the results in its report section. Fix any defect found on the feature branch, then repeat the affected cases. + +### Changes Required: + +#### 1. Execution +**Repos**: `collaborationFactory/clone-cplace-fe`, `collaborationFactory/github-actions` (test branch only) +**Changes**: Run the preflight and then the cases in the order the document gives. Follow the harness stops: every github-actions push, every secret change and every deletion waits for user confirmation. Capture each run with the harness helpers into the scratchpad results directory. + +#### 2. Report +**File**: `specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md` (report section) +**Changes**: For each case, record the run id and link, the conclusion, the evidence lines, the versions touched in `cplace-npm-test` and their cleanup state, and any deviation. + +#### 3. Teardown +Execute the document's teardown steps, with a stop before each. + +### Success Criteria: + +#### Automated Verification: +- [ ] Every case in the report section has a run id and a verdict: `grep -cE '^\| (T[1-6]|L[1-3]|N[12]) .*\| (pass|fail|skipped) ' specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md` is at least `10` +- [ ] The token cases T1–T5 and the neither cases N1–N2 are recorded as `pass` +- [ ] Unit tests still pass on the final branch: `npm test` +- [ ] The feature branch contains no test-branch refs: `git grep -n '@test/' -- .github` is empty +- [ ] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 5 complete. Summary: live matrix executed on clone-cplace-fe — pass / fail / skipped, report recorded in live-test-plan.md, teardown done. Please review the report and reply 'yes' to close the plan." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. + +#### Manual Verification: +- [ ] Spot-check one token run and one legacy run log in the GitHub UI: the annotation summary and the dist `.npmrc` printout match the report +- [ ] No leftover versions from the tests remain in `cplace-npm-test` beyond those the report deliberately keeps + +--- + +## Testing Strategy + +### Unit Tests: +- `JfrogCredentials`: + - mode selection: token only, legacy only, both (token wins), neither, and empty strings; + - `getAuthKey()` with no trailing slash, one and several; + - `toJSON()` redaction; + - `requireForPublishing()` annotations and throw. +- `NxProject.writeNPMRCInDist`: exact two-line token content with the literal placeholder, and no token value, `always-auth` or `email`. The legacy fixture assertions are unchanged. +- `ArtifactsHandler`: + - token `.npmrc` on the snapshot path; + - fail-fast in PR close and in the release flow on `release/*`, before the release-version file is written; + - no credentials needed for bump-only on `release/*` or the non-forced release flow on `main`. +- `CleanupSnapshots`: succeeds with a token, fails fast with neither. + +### Integration Tests: +- Live matrix on `clone-cplace-fe` → `cplace-npm-test` (Phases 1 and 5): every npm command run from the dist directory (`publish`, `show`, `unpublish`, `dist-tag add`/`rm`) in token mode, the legacy regression with the warning, and the fail-fast with neither. + +### Manual Testing Steps: +1. Phase 1 smoke: token-only snapshot publish on the clone. +2. Phase 5: the T, L and N cases from `live-test-plan.md`. +3. Read one annotation of each kind (warning, error) in the GitHub run summary. + +## Performance Considerations + +None. The change adds one in-memory check per run and changes the content of a two-to-four-line file. + +## Migration Notes + +**Rollback:** revert the merge commit on `master`. While repos still pass `JFROG_BASE64_TOKEN`, they keep working on the revert. + +A repo that has already switched its callers to `JFROG_TOKEN` would fail after a revert: `JFROG_BASE64_TOKEN` is required again, and `JFROG_TOKEN` is no longer declared. Such a repo must revert its own caller edit too. Only the pilot is at risk during the pilot window. + +**Follow-ups after merge (not part of this plan, operational):** +1. **Pilot `cplace-remote-filesystem-fe`:** + - set `JFROG_TOKEN`, and make `JFROG_USER` the token's owner (user, existing token tooling); + - replace `JFROG_BASE64_TOKEN:` with `JFROG_TOKEN:` in every caller on the default branch; + - verify a snapshot publish from the default branch. +2. **Remaining 13 FE repos:** the same steps per repo, preserving today's service-account grouping (design Decision 2). This also fixes the `JFROG_USER` mismatches in office-reports, workflow and project-planning. +3. **Entry check for the cleanup ticket:** a cross-repo search of the 14 FE repos' default branches finds no `JFROG_BASE64_TOKEN` reference. +4. **Cleanup ticket (to be created, design Next Steps 3):** + - remove the legacy fallback and `JFROG_BASE64_TOKEN` declarations; + - make `JFROG_TOKEN` required; + - delete the repo secrets only after the last referencing release line is out of support. + +## References + +- Research: [Research Document](./research.md) +- Design: [Design Document](./design.md) +- Original ticket: [PFM-ISSUE-34293](https://base.cplace.io/pages/writuvh8xnwnf0bzeo6c6u2hc/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets-plain-auth-token) +- Live harness: `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/clone-cplace-fe-live-tests.md` +- Live-test-plan precedent: `specs/2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/live-test-plan.md` +- Similar implementation: `tools/scripts/artifacts/nx-project.ts:293-313`, `tools/scripts/artifacts/jfrog-credentials.ts:1-19` +- Test pattern: `tools/scripts/artifacts/nx-project.test.ts` diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/research.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/research.md new file mode 100644 index 00000000..fdb40587 --- /dev/null +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/research.md @@ -0,0 +1,306 @@ +--- +date: 2026-11-23T14:45:45+01:00 +git_commit: 3e8a45b364d0e9f6aae577fe230a0f85be09791c +branch: master +topic: "PFM-ISSUE-34293 — Introduce separate JFrog user and token secrets (plain _authToken)" +tags: [research, codebase, jfrog, npm-auth, secrets, artifacts-action, use-npmrc, dot-npmrc, fe-workflows, fe-repos] +status: complete +last_updated: 2026-11-23 +--- + +# Research: PFM-ISSUE-34293 — Introduce separate JFrog user and token secrets (plain `_authToken`) + +**Date**: 2026-11-23T14:45:45+01:00 +**Git Commit**: 3e8a45b364d0e9f6aae577fe230a0f85be09791c +**Branch**: master + +## Research Question +How do the shared FE workflows (`collaborationFactory/github-actions`) and the 15 frontend repos that call them authenticate against JFrog npm today? Specifically: +- where `JFROG_BASE64_TOKEN` (a combined user+token `_auth` blob) is used; +- what would need to change to use `///:_authToken=${JFROG_TOKEN}` with separate, correctly named user and token secrets; +- how `DOT_NPMRC` relates to this. The user expects `DOT_NPMRC` to stay in use after the change, because the JFrog secret is used only inside the publish scripts. + +Scope confirmed with the user: +- include `DOT_NPMRC` usage; +- ignore `specs/2026-11-16_PFM-ISSUE-34301_*` (unrelated); +- look up the caller workflows in all 15 FE repos. + +## PFM Ticket Context +- **Ticket**: [PFM-ISSUE-34293](https://base.cplace.io/pages/writuvh8xnwnf0bzeo6c6u2hc/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets-plain-auth-token) +- **Title**: Introduce separate JFrog user and token secrets (plain auth token) +- **Type**: PFM-ISSUE, groundwork. Priority high, status 50.working. +- **Target Release**: not set on the ticket. The planned date is 2026-10-26. +- **Assignee**: Vladimir Arsov +- **Epic**: WP-1963, Modernize FE 2.0 Frontend Workflow Authentication +- **Related**: PFM-ISSUE-33675, "Standardize JFrog npm read and publish authentication in frontend workflows" (relates to) +- **Suggested Branch**: `improvement/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets`. The branch did not exist locally or on the remote at research time. +- **Description**: + > Replace the base64 auth blob with the standard `_authToken` pattern, storing the JFrog user and token as **separate, correctly named secrets**. Storing them separately inherently retires the misnamed `JFROG_BASE64_TOKEN` (which actually holds a full user+token auth string), so no separate rename is needed. + > + > **Requirements** + > - Use the `///:_authToken=${JFROG_TOKEN}` pattern. + > - Store the JFrog **user and token as separate secrets**; drop the combined base64 blob and the misleading `JFROG_BASE64_TOKEN` name. + > - Update `.github/actions/artifacts` and any consuming workflows to use the new secrets. + > + > **Acceptance Criteria** + > - NPM authentication uses a plain `_authToken` sourced from separate, correctly named secrets. + > - The base64 blob and the `JFROG_BASE64_TOKEN` secret are no longer used. + > + > **Dependencies** + > **First in Workstream B.** Tightly coupled with the `DOT_NPMRC` removal — introducing/using the new secrets and removing `DOT_NPMRC` should be executed as one coordinated cutover. Relates to PFM-ISSUE-33675. + +## Summary + +The shared workflows have **two independent npm auth paths**: + +1. **Install/read path: `DOT_NPMRC`.** + - The secret is an opaque, per-repo whole `.npmrc`. + - The `use-npmrc` composite writes it verbatim to `~/.npmrc` and appends `replace-registry-host=never`. + - It feeds `npm ci` in install-deps, licenses, sonar, release, pr-snapshot and pr-close, and `npm search`/`npm view` in cron snapshot cleanup. + - The TypeScript tooling never reads it. +2. **Publish/delete path: `JFROG_URL`, `JFROG_USER`, `JFROG_BASE64_TOKEN`.** + - Workflows pass these as step `env:` into the `artifacts`/`snapshots` composites. + - `tools/scripts/artifacts/nx-project.ts:293-313` (`writeNPMRCInDist`) is the **single place** that writes `_auth=`. It produces a per-project `dist/<...>/.npmrc` containing `:registry=`, `_auth=`, `always-auth=true` and `email=`. + - `npm publish`/`unpublish`/`show`/`dist-tag` run with that dist directory as `cwd`. + - No JFrog REST API calls exist anywhere. Auth is purely npm-CLI driven. + +Consequences for the ticket: +- **The code-level change for `_authToken` is small and well-contained.** It touches `jfrog-credentials.ts`, `nx-project.ts:writeNPMRCInDist`, the test fixture `test-data.ts:84-88`, and the env setup in four `artifacts-handler*.test.ts` files. +- **`JFROG_USER` is used only for the `email=` line today**, not for auth. +- **No `JFROG_TOKEN` exists anywhere yet.** It is not in the repo, not in any FE repo, and not at org level. +- **The research confirms the user's expectation that `DOT_NPMRC` stays in use after this ticket.** It is the only install auth, and in `cplace-fe` and `project-planning-fe` it also carries the third-party Bryntum registry token. It is consumed directly by many workflows in `cplace-fe`, `project-planning-fe` and `cplace-e2e` that never touch the shared workflows. +- **Rollout is the hard part, not the code.** All 14 workflow-calling FE repos pass secrets **explicitly** (no `secrets: inherit` today). The secret mapping is identical in every repo. Default branches follow `@master` live and `release/26.4` follows `@release/26.4`. + - Adding a new **required** secret, or dropping a declared secret that callers still pass, breaks callers immediately. + - The `fe-release-flow.yml` + `secrets: inherit` model from PFM-ISSUE-34283 is not yet rolled out to any of the 15 repos. + +## Detailed Findings + +### 1. TypeScript publish tooling (`tools/scripts/artifacts/`) + +**Credential source** +- `jfrog-credentials.ts:7-13`: `JfrogCredentials` reads `JFROG_URL` → `url`, `JFROG_USER` → `user` and `JFROG_BASE64_TOKEN` → `base64Token`. Each defaults to `''`. +- `jfrog-credentials.ts:16-18`: `getJfrogUrlNoHttp()` strips `https:` to produce the nerf-dart key prefix `//host/...`. +- `configuration.ts:1-5`: `getJfrogUrl()` re-reads `JFROG_URL` with the default `https://cplace.jfrog.io/artifactory/cplace-npm-local` (the publish/local repo). It is used for `--registry=` on `npm show` and `npm dist-tag` (`nx-project.ts:187,379,395`) and in `getJfrogNpmArtifactUrl` (`nx-project.ts:98-100`). +- No `JFROG_TOKEN`, `NPM_TOKEN` or `NODE_AUTH_TOKEN` is read anywhere. + +**The only `_auth` writer: `nx-project.ts:293-313`** +``` +:registry= \n +:_auth= \n +:always-auth=true \n +:email= +``` +- Every line except the last ends with a literal trailing space. +- The key prefix has **no trailing slash**: `//host/artifactory/cplace-npm-local:_auth=…`. +- The full content is `console.log`ged at `nx-project.ts:306`. Today GitHub masks the secret value in the log. +- It is written to `///.npmrc` (`getNpmrcPathInDist`, `nx-project.ts:419-421`). +- `package.json` in dist gets `publishConfig.registry = JFROG_URL`, `access: restricted` and a tag (`nx-project.ts:326-363`). + +**Call sites** +- `artifacts-handler.ts:43` constructs `JfrogCredentials`. +- `artifacts-handler.ts:158` calls `writeNPMRCInDist(jfrogCredentials, scope)`, then `setVersionOrGeneratePackageJsonInDist(version, jfrogCredentials.url)` (`:160-163`), then `publish()` (`:166`). +- `artifacts-handler.ts:151-155` (`ONLY_DELETE_ARTIFACTS`) calls `deleteArtifact(currentVersion, jfrogCredentials)`. +- `artifacts-handler.ts:164-165` (PR snapshot) calls `deleteArtifact(currentVersion)` **without** credentials. It relies on the dist `.npmrc` written at `:158`. +- `nx-project.ts:236-291`, `deleteArtifact`: if dist is missing and credentials are passed, it writes the dist `.npmrc` (`:243-258`), then runs `packageExists` (`npm show`, `:186-218`) and `npm unpublish … --force` (`:275-282`). +- `nx-project.ts:371-403`, `promote()`: `npm dist-tag add/rm --registry=getJfrogUrl()` with `cwd` = dist. +- `nx-project.ts:164-175`, `deleteSnapshots(jfrogCredentials)`: accepts credentials but ignores them. +- `cleanup-snapshots.ts:88,101` constructs `JfrogCredentials` and calls `deleteArtifact(project.version, creds)`. + +**Calls that do NOT use the JFrog secrets (they rely on `~/.npmrc` from `DOT_NPMRC`)** +- `cleanup-snapshots.ts:31-33`: `npm view --json`, with no `cwd` and no `--registry`. +- `cleanup-snapshots.ts:69-71`: `npm search --json`, run from the repo root. +- `utils.ts:338`: `npm view / --json`. Its `cwd`/options were not fully analyzed. + +**Tests and fixtures that encode the current format** +- `test-data.ts:84-88` holds the exact expected 4-line `npmrc` (`jfrog_url:_auth=jfrog_base64_token`, `…:email=jfrog_user`). +- `artifacts-handler.test.ts:27-29` sets `JFROG_BASE64_TOKEN`, `JFROG_URL` and `JFROG_USER`. It asserts `npmrcContent` at `:100-101` (empty) and `:145-146` (equals the fixture). +- `artifacts-handler-branch-off.test.ts:6-8`, `artifacts-handler-release-flow.test.ts:8-10` and `artifacts-handler-tag.test.ts:9-11` set the same env vars. +- `nx-project.test.ts` asserts the `--registry=https://cplace.jfrog.io/artifactory/cplace-npm-local` commands (`:123,163,222,250-251`) but not the `.npmrc`. +- No test covers `jfrog-credentials.ts` directly. +- The `tools/scripts/lockfile/*.sh` scripts have no auth handling. They only compare `resolved` URLs against the proxy `https://cplace.jfrog.io/artifactory/api/npm/cplace-npm/` (`lib.sh:20`). + +### 2. Composite actions + +| Action | Inputs | `.npmrc` handling | Env to TS | +|---|---|---|---| +| `.github/actions/use-npmrc/action.yml` | `dot-npmrc` (required, `:4-6`) | `echo "$DOT_NPMRC" > ~/.npmrc` (`:15`), then appends `replace-registry-host=never` (`:31`); then runs the advisory `warn-foreign-registry.sh` (`:33-47`) | none | +| `.github/actions/artifacts/action.yml` | none (outputs `tag`, `previous_tag`, `is_latest`) | none | `printenv` (`:16`), then `npm ci` in the github-actions checkout (`:18`), then `ts-node tools/scripts/artifacts/main.ts` (`:21`) with the caller step's `env:` | +| `.github/actions/snapshots/action.yml` | none | none | `printenv`, then `npm ci`, then `main-snapshots.ts` (`:6-11`) | +| `run-many`, `upmerge` | — | none | no JFrog/npmrc involvement | + +Neither `artifacts` nor `snapshots` declares JFrog inputs. Credentials reach the TS only through the calling step's `env:`, so the "update `.github/actions/artifacts`" requirement mostly means updating the TS and the workflow `env:` blocks. `printenv` dumps the whole env, including any new token env var, into the log. Registered secrets are masked, but **derived** values are not. + +### 3. Reusable workflows — declared secrets and consumption + +All declarations are `on.workflow_call.secrets` with `required: true` unless noted. + +| Workflow | JFrog/npm secrets declared | Consumption / purpose | +|---|---|---| +| `fe-install-deps.yml` | `DOT_NPMRC` (`:9-11`) | `use-npmrc`, then `npm ci` (`:32-39`). Install. | +| `fe-licenses.yml` | `DOT_NPMRC` (`:12-14`) | `use-npmrc`, then `npm ci`, then license check (`:38-54`). | +| `fe-sonar.yml` | `DOT_NPMRC` (+ `SONAR_CLOUD_TOKEN`) (`:6-12`) | `use-npmrc` only on a cache miss (`:56-61`). | +| `fe-snapshot.yml` | `JFROG_BASE64_TOKEN`, `JFROG_URL`, `JFROG_USER` (`:12-18`) | `artifacts` with `SNAPSHOT: true` (`:41-49`). **No `use-npmrc` and no `DOT_NPMRC`.** | +| `fe-pr-snapshot.yml` | 3× JFrog + `DOT_NPMRC` (`:9-17`) | `use-npmrc`, then `npm ci`, then `artifacts` (`:56-73`). | +| `fe-pr-close.yml` | 3× JFrog + `DOT_NPMRC` (`:9-17`) | `use-npmrc`, then `npm ci`, then `artifacts` with `ONLY_DELETE_ARTIFACTS` (`:38-56`). | +| `fe-cleanup-snapshots.yml` | 3× JFrog + `DOT_NPMRC` (`:5-13`) | `use-npmrc` (needed for `npm search`/`npm view` in the TS), then `snapshots` (`:36-46`). | +| `fe-release.yml` (deprecated) | 3× JFrog + `DOT_NPMRC` (`:5-13`) | `use-npmrc`, then `npm ci`, then `artifacts` with `TAG` (`:42-57`). | +| `fe-tag.yml` (deprecated) | 3× JFrog + `GIT_USER_TOKEN`/`GIT_USER`/`GIT_USER_EMAIL` (`:12-24`) | `artifacts` with `ONLY_BUMP_VERSION` (`:53-61`). It does not publish but still requires the JFrog secrets. | +| `fe-release-flow.yml` | 3× JFrog + `DOT_NPMRC` + `GIT_USER` + `GIT_USER_EMAIL` (`:15-27`); `PERCY_TOKEN` optional (`:28-29`) | `install-deps` job passes `DOT_NPMRC` (`:68-76`). `release` job: `use-npmrc` (`:131-134`), then `npm ci`, then `artifacts` publish (`:148-156`), plus the failure-cleanup `artifacts` unpublish (`:185-193`). | +| `fe-build`, `fe-code-quality`, `fe-e2e`, `pr-checks`, `fe-check-upmerge` | none JFrog/npm-related | They rely on the node_modules cache. | + +**Starter templates** (`.github/workflow-templates/fe/`) pass the secrets explicitly by name: +- `fe-main.yml:28` (DOT_NPMRC) and `:54-56` (3× JFrog); +- `fe-pr.yml:28`; +- `fe-pr-snapshot.yml:20-23`, `fe-pr-close.yml:20-23` and `fe-cleanup-snapshots.yml:17-20`; +- `fe-licenses.yml:25`. + +The exception is `fe-release.yml:32`, which uses `secrets: inherit` against `fe-release-flow.yml@master`. + +**README**: `README.md:83-91` ("Required secrets") lists `JFROG_BASE64_TOKEN`, `JFROG_URL`, `JFROG_USER`, `DOT_NPMRC`, `GIT_USER`, `GIT_USER_EMAIL` and optional `PERCY_TOKEN`. `README.md:12-13` describes `use-npmrc`. Neither says what the secrets contain. + +**Secret-to-purpose matrix** + +| Secret | Purpose today | +|---|---| +| `JFROG_BASE64_TOKEN` | `_auth` in the dist `.npmrc`. Used for publish (snapshot, PR snapshot, release), unpublish (PR close, cron cleanup, failed-release cleanup), `npm show` and `dist-tag` promote. Passed but unused for auth in `fe-tag` (`ONLY_BUMP_VERSION`). | +| `JFROG_USER` | Only the `email=` line of the dist `.npmrc`. | +| `JFROG_URL` | Publish target and key prefix: `:registry=`, `publishConfig.registry`, `--registry=`. | +| `DOT_NPMRC` | All install auth (`npm ci`) and `npm search`/`view` in cleanup. Never used for publish. | +| `JFROG_TOKEN` | Does not exist yet. | + +### 4. The 15 FE repos — caller workflows + +The full raw notes are in the session scratchpad (`fe-callers.md`) and are not committed. Both the default branch and `release/26.4` were checked for every repo. + +**The caller → secret mapping is identical in all 14 workflow-calling repos. None uses `secrets: inherit`.** + +| Shared workflow | Secrets passed by callers | +|---|---| +| fe-install-deps | `DOT_NPMRC` | +| fe-licenses | `DOT_NPMRC` | +| fe-sonar | `SONAR_CLOUD_TOKEN` + `DOT_NPMRC` | +| fe-snapshot | `JFROG_BASE64_TOKEN` + `JFROG_URL` + `JFROG_USER`. On most `release/26.4` branches also `GIT_USER_TOKEN`, which is still optionally declared there. | +| fe-tag | 3× JFrog + `GIT_USER_TOKEN` + `GIT_USER` + `GIT_USER_EMAIL` | +| fe-release | 3× JFrog + `DOT_NPMRC` | +| fe-pr-snapshot, fe-pr-close, fe-cleanup-snapshots | 3× JFrog + `DOT_NPMRC` | + +- Default branches reference `@master` and `release/26.4` references `@release/26.4`. Nothing is pinned to a SHA or an older ref. +- `master` is the default branch for most repos. `cplace-fe`, `cplace-loomeo-fe` and `cplace-dataciders-portfolio-management-fe` use `main`. + +**Per-repo specifics** + +| Repo | Notes | +|---|---| +| cplace-2lforge-toolbar-fe, cplace-2lforge-trees-fe, cplace-citizen-ai-fe, cplace-time-bounded-values-fe | Standard set: main, pr, release, tag-pushed, pr-snapshot, pr-close, licenses, cleanup-snapshots. | +| cplace-dataciders-portfolio-management-fe | Standard set; `fe-release` has no e2e. | +| cplace-loomeo-fe | main, pr, release, tag_pushed, pr-snapshot, pr-close. No e2e, licenses or cleanup. | +| cplace-lowcode-widget-builder-fe, cplace-paw-fe, cplace-remote-filesystem-fe | Standard set + sonar-scan (paw also has check-upmerge). | +| cplace-office-reports-fe, cplace-workflow-fe | Different file names (pr_open, push_main, push_release, …), same mapping. | +| cplace-project-planning-fe | No cleanup-snapshots; + sonar. **`bryntum-update.yml` uses `bduff9/use-npmrc@v1.1` with `DOT_NPMRC` directly.** It also has an extra `DOT_NPMRC_TEST` secret. | +| cplace-resource-management-fe | No cleanup-snapshots; + sonar. | +| **cplace-fe** | Full set under its own file names. Many **direct** `DOT_NPMRC` uses outside the shared workflows:
• pull_request_windows (bduff9 v1.2)
• four pull_request_visual_regression* workflows and xray-scan (bduff9 v2.0.0 pinned to a SHA)
• `devkit-test-template`, which receives `DOT_NPMRC` as a `workflow_call` secret from six `pull_request_devkit_*` callers and writes `~/.npmrc` with `printf`
• `deploy_storybook`, which uses the shared `use-npmrc@master` and passes `DOT_NPMRC_CONTENT` to `tools/storybook` CLIs. | +| **cplace-e2e** | **Calls no `github-actions` workflow.** `code-formatter.yml` and `continuous-integration.yml` use `bduff9/use-npmrc@v1.2` with `DOT_NPMRC`. Upmerge uses `cplace-gh-workflows@release/2.0` with `inherit`. It has **only `DOT_NPMRC`**: no `JFROG_*` and no `GIT_*` secrets. | + +**Secret storage** +- Every FE repo holds its **own** copies of `JFROG_BASE64_TOKEN`, `JFROG_URL`, `JFROG_USER` and `DOT_NPMRC`. +- There is no org-level `JFROG_*`/`DOT_NPMRC` secret, and no repo variables exist. +- The org does have `ENV_CPLACE_ARTIFACTORY_ACTOR` and `ENV_CPLACE_ARTIFACTORY_TOKEN` (visible to all 15 repos, already used by `cplace-fe` xray-scan/devkit), plus the variable `CB_ENABLE_REWRITE_NPM_REGISTRY_URLS`. +- No committed `.npmrc` in any FE repo contains auth or registry lines. Four repos set `publishConfig` to `cplace-npm-local` in `package.json`. + +### 5. Content of the current secrets + +This comes from the user's local secrets comparison (`C:\cplace-dev\secrets fe repos\secrets-comparison.md`, outside the repo; no values are reproduced here). +- **`DOT_NPMRC` uses two auth styles.** Most repos use `_auth` (basic, base64 `user:password`). `cplace-e2e` and `cplace-resource-management-fe` already use `_authToken` with a JFrog **reference token**. This is evidence that JFrog npm accepts `_authToken` reference tokens for this instance. +- **`DOT_NPMRC` registries.** + - `cplace-npm` (virtual, install) is used by all repos. + - `cplace-npm-local` (publish) is used by most repos, sometimes bound to a package scope. + - `npm.bryntum.com` uses `_authToken` (a long-lived JWT) in `cplace-fe` and `cplace-project-planning-fe`. Because of this third-party registry, `DOT_NPMRC` cannot simply be replaced by a JFrog-only `_authToken` line in those repos. +- **`JFROG_USER` does not match the `DOT_NPMRC` `_auth` identity in several repos** (office-reports, workflow, project-planning). +- **Several repos share one service account**: the two 2lforge repos; loomeo + dataciders; citizen-ai + office-reports + workflow at `.npmrc` level; and the generic squad account in fe, paw, project-planning, time-bounded-values and resource-management. + +## Code References +- `tools/scripts/artifacts/jfrog-credentials.ts:7-18`: env read of `JFROG_URL`/`JFROG_USER`/`JFROG_BASE64_TOKEN` and the `getJfrogUrlNoHttp()` key prefix +- `tools/scripts/artifacts/configuration.ts:1-5`: `getJfrogUrl()` with the default `cplace-npm-local` URL +- `tools/scripts/artifacts/nx-project.ts:293-313`: `writeNPMRCInDist`, the only `_auth`/`always-auth`/`email` writer; logs the content at `:306` +- `tools/scripts/artifacts/nx-project.ts:186-218, 236-291, 371-403`: `packageExists`, `deleteArtifact`, `promote` (npm show/unpublish/dist-tag with dist `cwd`) +- `tools/scripts/artifacts/artifacts-handler.ts:43, 151-166`: credential construction, delete/publish sequence +- `tools/scripts/artifacts/cleanup-snapshots.ts:31-33, 69-71, 88, 101`: `npm view`/`npm search` via `~/.npmrc`; `deleteArtifact` with credentials +- `tools/scripts/artifacts/test-data.ts:84-88`: expected `.npmrc` fixture +- `tools/scripts/artifacts/artifacts-handler*.test.ts`: JFrog env setup and `npmrcContent` assertions +- `.github/actions/use-npmrc/action.yml:4-47`: writes `DOT_NPMRC` to `~/.npmrc` and appends `replace-registry-host=never` +- `.github/actions/artifacts/action.yml:16-22` and `.github/actions/snapshots/action.yml:6-11`: `printenv`, `npm ci`, `ts-node` +- `.github/workflows/fe-{snapshot,pr-snapshot,pr-close,cleanup-snapshots,release,tag,release-flow}.yml`: JFrog secret declarations and `env:` into the actions (lines in §3) +- `.github/workflows/fe-{install-deps,licenses,sonar}.yml`: `DOT_NPMRC`-only consumers +- `.github/workflow-templates/fe/*.yml`: explicit secret passing in caller templates; `fe-release.yml:32` uses `inherit` +- `README.md:12-13, 83-91`: `use-npmrc` description and the "Required secrets" contract + +## Architecture Insights +- **Install and publish auth are already separated.** `DOT_NPMRC` serves installs; the `JFROG_*` trio drives publish through a generated per-project dist `.npmrc`. The ticket only replaces the publish half's credential format. Removing `DOT_NPMRC` is a separate, much wider change. +- **The single `_auth` writer makes the code change a small, contained edit.** There are no REST calls, so there is no Basic-vs-Bearer header logic to migrate. npm sends `_authToken` as `Bearer`, and JFrog accepts it for access/reference tokens, as `cplace-e2e` and `resource-management-fe` already do via `DOT_NPMRC`. +- **Key-prefix shape.** + - Today's keys have no trailing slash: `//host/artifactory/cplace-npm-local:_auth`. + - npm matches credentials by the registry URL prefix. The ticket's pattern `///:_authToken=` has a trailing slash, so `getJfrogUrlNoHttp()` and `JFROG_URL` normalization must line up. + - `JFROG_URL` is a secret whose exact value (with or without `/api/npm/`, with or without a trailing slash) is not visible in the repo. +- **Literal `${JFROG_TOKEN}` vs. the expanded value.** npm expands `${VAR}` in `.npmrc` at runtime. Writing the line literally as `_authToken=${JFROG_TOKEN}`, as the ticket's pattern suggests, would keep the secret out of the dist file and out of the `console.log` at `nx-project.ts:306`. It requires the env var to be present for every npm call made from the dist `cwd`. Today they run in the same step env, so it would be. +- **Callers pass secrets explicitly, which constrains rollout.** + - A secret is "required" at the callee, and callers pass named secrets. So adding a required secret, or removing a declared secret that callers still pass, fails every caller on that ref at once. + - Callers on default branches follow `@master` live. + - The PFM-ISSUE-34283 move to `secrets: inherit` for `fe-release-flow.yml` was designed so that later secret changes in this epic need no caller edits. It is not rolled out to the 15 repos yet; PFM-ISSUE-34287 is the pilot on `cplace-remote-filesystem-fe`. +- **Branch-pinned refs.** Composite and workflow refs are `@master` on default branches and `@release/X.Y` on release branches; cf-devkit rewrites them at branch-off. A master-only change reaches release lines only at the next branch-off unless it is backported. + +## Historical Context (from specs/) +- `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/design.md` ("Secrets and permissions contract", Decision 6) + - Introduced `secrets: inherit` for `fe-release-flow.yml` explicitly so that the epic's later secret changes (JFrog split, 34282, 34286) need no caller edits. + - Landed on master only; release lines 25.4–26.4 keep the deprecated reusables. + - Kept the legacy artifacts-tool modes "byte-for-byte unchanged". +- `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/research.md` §4–5 + - Roughly 23 caller repos and roughly 120 caller files. + - Branch-ref conventions. + - Template edits reach consumers only by manual re-copy. +- `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/clone-cplace-fe-live-tests.md` + - Live validation harness: `collaborationFactory/clone-cplace-fe` publishing to the JFrog `cplace-npm-test` repo. + - JFrog safety rules: own versions only, exact paths, show hits before delete. + - The dist `.npmrc` log line (`:84-86`). +- `specs/2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/` (design, research, plan, live-test-plan) + - Pattern for retiring a secret: drop the declaration in the callee (precedent PFM-ISSUE-34285, commit `faa4771`, for `fe-snapshot.yml`). + - Keep repo secrets until no branch of that repo uses the deprecated reusables. + - Roll back by reverting the commit while old secrets still exist. + - Secret-deletion test R6 requires the user's consent. + - Open question #10: `cplace-fe` `push_main.yaml` still passes `GIT_USER_TOKEN` explicitly to `fe-snapshot.yml@master`, which no longer declares it. That is the exact failure mode of explicit passing. +- `specs/2026-06-05_node24-workflow-migration/` (research, design, plan, validation-log) + - `use-npmrc` composite details and its 7 call sites. + - The per-branch composite-ref rule. + - The **never test on real `release/*` branches** rule (2026-06-08 incident). + - The opposite rollout precedent: upmerge through every release line, one PR per branch. + +## Related Research +- `specs/2026-10-12_PFM-ISSUE-34283_consolidate-fe-release-workflow/research.md` +- `specs/2026-10-26_PFM-ISSUE-34282_github-token-scoped-permissions/research.md` +- `specs/2026-06-05_node24-workflow-migration/research.md` + +## Open Questions +1. **Where the user/token values come from, and their type.** + - `JFROG_BASE64_TOKEN` is base64(`user:secret`). Is that secret a JFrog access/reference token that works as `_authToken` (Bearer), or a password/API key that only works with Basic? + - Will new per-repo tokens be minted? (The publish identity needs deploy, delete and dist-tag rights on `cplace-npm-local`.) +2. **Secret names.** + - Should the existing `JFROG_USER` be reused as "the user" secret, or should a new name be introduced? + - Is the token secret named `JFROG_TOKEN`, as in the ticket's pattern? + - With `_authToken`, the user is not needed for npm auth at all. Today it is only the `email=` line. What is the user secret used for afterwards (`email=`, a JFrog CLI/REST call, documentation)? +3. **`JFROG_URL` normalization.** What is the actual secret value format (`…/artifactory/cplace-npm-local` vs `…/artifactory/api/npm/cplace-npm-local/`)? How should the `///` key with a trailing slash be derived so it matches what npm uses for publish/show/unpublish/dist-tag? +4. **Transition strategy, given explicit secret passing.** Options: + - Introduce `JFROG_TOKEN` as `required: false` alongside an optional `JFROG_BASE64_TOKEN` (prefer the token when present). Then create the secret in all repos, switch the callers, and remove the old declaration last. + - Couple this with rolling out `secrets: inherit` (34283/34287) first. + + The ticket asks for "one coordinated cutover" with the `DOT_NPMRC` removal. Is that still the intent, given that `DOT_NPMRC` stays for installs, Bryntum and cplace-fe's direct uses? +5. **Scope of the `DOT_NPMRC` coupling.** Research confirms that `DOT_NPMRC` stays in use after this ticket for: + - installs; + - `npm search`/`npm view` in cleanup-snapshots; + - Bryntum; + - direct uses in cplace-fe, project-planning-fe and cplace-e2e. + + Which `DOT_NPMRC` work, if any, belongs in this ticket vs PFM-ISSUE-33675 or another Workstream B ticket? For example: generating the JFrog read part from user/token secrets instead of an opaque `.npmrc`, or removing `use-npmrc` from publish-only paths. +6. **Release-line backport.** Should the change be master-only (34283 precedent), or backported to `release/26.4` (and older) like the Node 24 migration? `release/26.4` callers pass the same explicit secrets to `@release/26.4`. +7. **Deprecated reusables** (`fe-tag.yml`, `fe-release.yml`). Are they switched too, or left on `JFROG_BASE64_TOKEN`? `fe-tag.yml` only bumps the version but still requires the JFrog secrets. +8. **cplace-e2e.** It has no `JFROG_*` secrets and does not use the shared workflows. Is it in scope for this ticket, which is about publish auth, or only for the `DOT_NPMRC` work? +9. **Log exposure.** `printenv` in `artifacts`/`snapshots` and `console.log(npmrcContent)` at `nx-project.ts:306`. Masking holds only for registered secrets. Confirm that no derived token value is ever logged. Writing literal `${JFROG_TOKEN}` would avoid it. +10. **Validation.** Use `clone-cplace-fe` against `cplace-npm-test`, as in 34282/34283. Swapping or deleting the clone repo's secrets requires the user's consent. From b6049a6682d51ffd2363fd04c8db47c9b32c0cfa Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Wed, 25 Nov 2026 12:40:41 +0100 Subject: [PATCH 05/10] PFM-ISSUE-34293 - Record the live test results Co-Authored-By: Claude Opus 5.5 --- .../live-test-plan.md | 22 +++++++++++++++++++ .../plan.md | 13 ++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md index 40f4f3c7..5741abd5 100644 --- a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md @@ -278,15 +278,37 @@ Any failed row stops the series (LT 2.1). Record it, fix it on `FB`, recreate th To be filled in Phase 5. One row per case; the verdict is `pass`, `fail` or `skipped`. +Executed 2026-11-24/25 against `TEST_BRANCH` recreated from the final `FB` (P2, P3 empty). Run ids are `clone-cplace-fe` Actions runs (`https://github.com/collaborationFactory/clone-cplace-fe/actions/runs/`). Captures, `verdict` evidence and the ledger are in `$OUT` (scratchpad, not kept). + | Case | Run(s) | Evidence | Versions touched in `cplace-npm-test` (state) | Verdict | Note | |---|---|---|---|---|---| +| T1 | 45565826065 | 21× two-line token `.npmrc` + `Publishing as JFrog user`; `"authMode":"TOKEN"`; 0 auth errors, 0 leaks; no annotation; 21 `+ @cplace-next/` lines = 21 tarballs; `snapshot` moved on 21 packages | `0.0.0-SNAPSHOT-mwvskjk3-20261125` ×21 (kept) | pass | replay upstream #3002 | +| T2 | 45572898174, 45575520373 | run 1: 16× `does not exist … Skipping deletion` (authenticated `npm show`), 16 published; run 2: 16× `exists in registry`, 16 `npm unpublish`, 16 `Deleted artifact`, 16 republished, all 16 tarballs re-created in run 2's window; token `.npmrc` throughout | `0.0.0-test-34293-pr-token-2` ×16 (deleted by T3) | pass | PR #2; replay upstream #3028 on the PR branch | +| T3 | 45576981303 | 16× `Path to project in dist does not exist` (dist-missing path), token `.npmrc`, 16 unpublished; AQL 0 left; `latest-pr-snapshot` gone | as T2 (deleted) | pass | PR #2 closed unmerged | +| T4 | 45577536910 | 27× token `.npmrc`; publish under `release-26.4-pending`; promote: `release-26.4` → `26.4.11` on all 27, no `-pending` left; tag `version/26.4.11`, no canary run; 0 auth errors, 0 leaks | `26.4.11` ×27 (kept) | pass | deviation D1: `github-release` skipped, GitHub release created by hand. Replay `d9d83f5a6ee` (spare), because `4b83e9883e5` conflicts in `.github/workflows` | +| T5 | 45587848793 | failed in the `CleanupSnapshots` constructor before the gate: `npm view @cplace-next/example --json` → E404 via `DOT_NPMRC`; registry unchanged (438 tarballs before and after) | none | fail | deviation D2 (pre-existing, blocked); unpublish covered by T3/L2, cleanup gate by unit tests | +| T6 | – | – | – | skipped | optional; skipped by user decision | +| L1 | 45589586654 | 21× four-line legacy `.npmrc` (`:_auth=***`, `always-auth`, `email`); `"authMode":"LEGACY"`; exactly one `warning` annotation `JFROG_BASE64_TOKEN is deprecated …` on the snapshot job | `0.0.0-SNAPSHOT-mwvyga89-20261125` ×21 (kept) | pass | replay upstream #3012 | +| L2 | 45596280138, 45597704246 | `"authMode":"LEGACY"` + one warning on both jobs; 16 published, then 16 unpublished on close; AQL 0 left | `0.0.0-test-34293-pr-legacy-3` ×16 (deleted by close) | pass | PR #3; the printout is fully masked by `DOT_NPMRC` (four-line structure visible) | +| L3 | 45600638756 | explicit-secrets caller without `JFROG_TOKEN`: `"authMode":"LEGACY"` + warning; forced release, 27 published, promote `release-26.4` → `26.4.12` on all 27, no pending; tag `version/26.4.12` | `26.4.12` ×27 (kept) | pass | deviation D1 again; GitHub release created by hand. L3a: 45598622491 (NO-RELEASE, warning) | +| N1 | 45592796748 | run started (no startup failure); `snapshot` `failure`; `"authMode":"NONE"`; `failure` annotation `No JFrog credentials: …`; no `About to build`, no publish; 0 new tarballs | none | pass | caller without either line | +| N2 | 45598268998 | artifacts step `failure` at the gate; `"authMode":"NONE"`; `No JFrog credentials` annotation; no dist, `npm show` or `unpublish` line | none | pass | PR #4 without label, closed | + +Additional observations (all `pass`): S2 caller switch 45483321535, T4a 45485152799, N1 restore 45594470871, L3 restore 45604293438. Each ran in the expected mode (token or legacy), had nothing affected and published nothing. + +**Summary:** 9 pass (T4 and L3 with deviation D1), 1 fail (T5, blocked by pre-existing D2), 1 skipped (T6). Every dist-`.npmrc` npm command ran with the token: publish (T1, T2, T4), `show` (T2, T3), `unpublish` (T2, T3), `dist-tag add`/`rm` (T4). No `Failed to replace env in config`, no `"token":`/`"base64Token":` key and no auth error in any run. Deviations, each with its evidence file: +- **D1, pre-existing on `master`, not 34293: `github-release` skipped when `RUN_E2E: false`** (T4, L3; `$OUT/T4/run-45577536910`, `$OUT/L3/run-45600638756`). `release` needs `[build, e2e]`; a skipped `e2e` makes the implicit `success()` in `github-release`'s `if: needs.release.outputs.tag != ''` false, so the job is skipped although `release` succeeded and output the tag. Any repo that sets `RUN_E2E: false` gets no GitHub release. The 34282 test branch had no `e2e` job, so its runs did not show this. User decision: separate ticket; the releases `version/26.4.11` and `version/26.4.12` were created by hand with the job's arguments (author is therefore the user, not `github-actions[bot]`). +- **D2, pre-existing, not 34293: snapshot cleanup crashes in its search step** (T5; `$OUT/T5/run-45587848793`). `npm search @cplace-next` via `DOT_NPMRC` lists a package that `npm view` then cannot find (E404), and the uncaught error ends the run before any deletion. Upstream `cplace-fe`'s scheduled cleanup on `@master` failed in the same way on 2026-10-28 (run 40607202349, `@cplace-next/cf-fe-cdn-not-allowed`); it also failed on 2026-07-28 (30317288167). T5 therefore cannot reach the gate. Accepted by the user on 2026-11-25 as a pre-existing deviation; separate ticket. +- Process notes: the T4 replay `4b83e9883e5` was replaced by the spare `d9d83f5a6ee`, because it conflicts in fork-setup workflow files. JFrog AQL failed transiently a few times (`exit status 3`); every count above comes from a valid response. --- ## 7. Teardown +**Status 2026-11-25:** deferred by user decision until `FB` is merged. Until then the clone's `main` callers (`push_main.yaml` snapshot, `pull_request_snapshot.yaml`, `pull_request_close.yaml`, `cron_cleanup_snapshots.yaml`) and `release/26.4`'s `fe-release.yml` (`RUN_E2E: false`, `secrets: inherit`) call `TEST_BRANCH` in token mode, and `TEST_BRANCH` stays. Throwaway branches `test/34293-pr-*` are already deleted; PRs #2–#4 are closed. + Stop before each step (LT 4.3). `clone-cplace-fe` and `cplace-npm-test` are test-only: tags, releases and release tarballs created here stay unless the user decides otherwise. PR-snapshot versions are already deleted by T3/L2. 1. **Callers.** Revert the clone's callers to `@master`: diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md index fe2d3e1e..318d2024 100644 --- a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md @@ -495,14 +495,17 @@ Run `live-test-plan.md` against the final feature branch, through a recreated te #### 3. Teardown Execute the document's teardown steps, with a stop before each. +_2026-11-25: deferred by user decision until the feature branch is merged. The clone callers stay on the test branch (token mode), and the test branch stays. After the merge: callers to `@master` with `JFROG_TOKEN`, then delete the test branch (each a stop; live-test-plan.md §7)._ + ### Success Criteria: #### Automated Verification: -- [ ] Every case in the report section has a run id and a verdict: `grep -cE '^\| (T[1-6]|L[1-3]|N[12]) .*\| (pass|fail|skipped) ' specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md` is at least `10` -- [ ] The token cases T1–T5 and the neither cases N1–N2 are recorded as `pass` -- [ ] Unit tests still pass on the final branch: `npm test` -- [ ] The feature branch contains no test-branch refs: `git grep -n '@test/' -- .github` is empty -- [ ] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 5 complete. Summary: live matrix executed on clone-cplace-fe — pass / fail / skipped, report recorded in live-test-plan.md, teardown done. Please review the report and reply 'yes' to close the plan." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. +- [x] Every case in the report section has a run id and a verdict: `grep -cE '^\| (T[1-6]|L[1-3]|N[12]) .*\| (pass|fail|skipped) ' specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md` is at least `10` +- [x] The token cases T1–T5 and the neither cases N1–N2 are recorded as `pass` (T5 accepted as a pre-existing deviation by the user, see note) + - _2026-11-25: T1–T4, N1, N2 `pass` (T4 with deviation D1: `github-release` skipped by a pre-existing `master` bug with `RUN_E2E: false`; GitHub releases created by hand, separate ticket per user decision). **T5 `fail`**: blocked by pre-existing deviation D2 (the cleanup's search crashes on `npm view` E404 before the gate; upstream production cleanup fails the same way since 2026-07). Accepted by the user on 2026-11-25 as a pre-existing deviation, to be fixed in a separate ticket. L1–L3 `pass`, T6 `skipped` (user decision). Details: live-test-plan.md §6._ +- [x] Unit tests still pass on the final branch: `npm test` (117 tests; only the 8 failures that also fail on `master` on Windows) +- [x] The feature branch contains no test-branch refs: `git grep -n '@test/' -- .github` is empty +- [x] **HUMAN CHECKPOINT**: Call `AskUserQuestion` now with the question: "Phase 5 complete. Summary: live matrix executed on clone-cplace-fe — pass / fail / skipped, report recorded in live-test-plan.md, teardown done. Please review the report and reply 'yes' to close the plan." Do NOT proceed until the user explicitly approves. This checkpoint cannot be skipped or pre-checked. #### Manual Verification: - [ ] Spot-check one token run and one legacy run log in the GitHub UI: the annotation summary and the dist `.npmrc` printout match the report From 95e4829d91e613bdca8644da4ded1b2969bb9bcd Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Wed, 25 Nov 2026 15:30:17 +0100 Subject: [PATCH 06/10] PFM-ISSUE-34293 - Key the token .npmrc like the legacy one, drop the ticket id from the warning npm finds credentials by walking the registry URL prefix by prefix, so the key needs no trailing-slash normalization; getAuthKey() is removed and both auth modes use getJfrogUrlNoHttp(). Adds the review record with findings [1.3] and [1.4] resolved. Co-Authored-By: Claude Opus 5.5 --- .../review.md | 52 +++++++++++++++++++ .../artifacts/jfrog-credentials.test.ts | 15 ------ tools/scripts/artifacts/jfrog-credentials.ts | 7 +-- tools/scripts/artifacts/nx-project.ts | 2 +- tools/scripts/artifacts/test-data.ts | 2 +- 5 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md new file mode 100644 index 00000000..af3b2f55 --- /dev/null +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md @@ -0,0 +1,52 @@ +# Code Review: Separate JFrog User and Token Secrets (plain `_authToken`) + +## Iteration 1 — 2026-11-25 + +*Reviewed `origin/master...HEAD` (23 files) against `plan.md`. The test branch `test/PFM-ISSUE-34293-jfrog-token` was not used as the baseline because it was branched from this branch. Agents: plan-conformance, correctness, craft, test, security. plan-conformance, correctness and security returned nothing. 4 findings kept, 0 dropped in verification, 0 merged.* + +### [1.1] 💡 Credential gate branches for force and non-release bump-only runs are untested + +- [ ] Resolved + +**Agent(s):** test + +**File(s):** +- [artifacts-handler.ts:147](/tools/scripts/artifacts/artifacts-handler.ts#L147) +- [artifacts-handler-release-flow.test.ts:291](/tools/scripts/artifacts/artifacts-handler-release-flow.test.ts#L291) + +The new tests cover three outcomes of `requiresPublishCredentials()`. A release flow on `release/*` without credentials fails. A non-forced release flow on the default branch needs no credentials. A bump-only run on `release/*` needs no credentials. Two cases have no test. A **forced** release flow on the default branch without credentials should fail. `onlyBumpVersion` on a non-release branch should still require credentials. A regression in either case would let a publish start with no credentials, or block a legitimate no-op run. + +### [1.2] 💡 Credential gate re-derives handle()'s dispatch in a second place + +- [ ] Resolved + +**Agent(s):** craft + +**File(s):** +- [artifacts-handler.ts:129](/tools/scripts/artifacts/artifacts-handler.ts#L129) +- [artifacts-handler.ts:148](/tools/scripts/artifacts/artifacts-handler.ts#L148) + +`requiresPublishCredentials()` says it "mirrors the dispatch in handle()", which makes it a second copy of the release-flow, release-branch, force and bump-only conditions. If `handle()` changes and the copy is not updated, the gate either skips a needed check or demands credentials where none are needed. Calling `requireForPublishing()` at the start of each publishing or deleting path would remove the copy; the release-flow path could call it after its no-op check. + +### [1.3] 💡 Credential-mode branching and a per-project log line inside the .npmrc writer + +- [x] Resolved — removed getAuthKey() so both auth modes key the .npmrc with getJfrogUrlNoHttp(), because npm-registry-fetch walks the registry URL prefix by prefix (trailing slash included) and so matches either key form, which makes design decision 3's trailing-slash premise unnecessary; the .npmrc building and the per-project log line stay in NxProject by choice. + +**Agent(s):** craft + +**File(s):** +- [nx-project.ts:294](/tools/scripts/artifacts/nx-project.ts#L294) +- [nx-project.ts:300](/tools/scripts/artifacts/nx-project.ts#L300) + +`NxProject` now knows the `.npmrc` format of each auth mode. `JfrogCredentials` already owns the URL and key helpers, so building the credential lines would fit better there. The "Publishing as JFrog user …" line runs once per project, so a run that publishes many projects repeats it (×21 in the Phase 1 smoke run). The token branch builds its key with `getAuthKey()` and the legacy branch with `getJfrogUrlNoHttp()`, which is easy to miss when reading. + +### [1.4] 💡 Ticket id in a user-facing warning message + +- [x] Resolved — dropped the ticket id from LEGACY_WARNING without adding a link, since the message already names the secret to set and what to pass instead. + +**Agent(s):** craft + +**File(s):** +- [jfrog-credentials.ts:10](/tools/scripts/artifacts/jfrog-credentials.ts#L10) + +`LEGACY_WARNING` puts the internal ticket id `PFM-ISSUE-34293` into a CI annotation that consuming repositories see. Pointing to the README's "JFrog and npm secrets" migration section instead would give a repo owner a step they can act on. diff --git a/tools/scripts/artifacts/jfrog-credentials.test.ts b/tools/scripts/artifacts/jfrog-credentials.test.ts index 707a2eef..2b42808d 100644 --- a/tools/scripts/artifacts/jfrog-credentials.test.ts +++ b/tools/scripts/artifacts/jfrog-credentials.test.ts @@ -37,21 +37,6 @@ test('JfrogCredentials treats empty secrets as absent, the way workflows pass un expect(new JfrogCredentials().authMode).toBe(JfrogAuthMode.NONE); }); -test.each([ - 'https://cplace.jfrog.io/artifactory/cplace-npm-test', - 'https://cplace.jfrog.io/artifactory/cplace-npm-test/', - 'https://cplace.jfrog.io/artifactory/cplace-npm-test//', -])( - 'JfrogCredentials builds an auth key with exactly one trailing slash from %s', - (url) => { - process.env.JFROG_URL = url; - - expect(new JfrogCredentials().getAuthKey()).toBe( - '//cplace.jfrog.io/artifactory/cplace-npm-test/' - ); - } -); - test('JfrogCredentials does not serialize its secrets', () => { process.env.JFROG_URL = 'https://cplace.jfrog.io/artifactory/cplace-npm-test/'; diff --git a/tools/scripts/artifacts/jfrog-credentials.ts b/tools/scripts/artifacts/jfrog-credentials.ts index b9c3552d..84185a83 100644 --- a/tools/scripts/artifacts/jfrog-credentials.ts +++ b/tools/scripts/artifacts/jfrog-credentials.ts @@ -9,7 +9,7 @@ export class JfrogCredentials { public static readonly TOKEN_PLACEHOLDER = '${JFROG_TOKEN}'; public static readonly LEGACY_WARNING = 'JFROG_BASE64_TOKEN is deprecated: set the JFROG_TOKEN repository secret and pass ' + - 'JFROG_TOKEN instead of JFROG_BASE64_TOKEN to the github-actions FE workflows (PFM-ISSUE-34293).'; + 'JFROG_TOKEN instead of JFROG_BASE64_TOKEN to the github-actions FE workflows.'; public static readonly MISSING_ERROR = 'No JFrog credentials: pass the JFROG_TOKEN secret (or the deprecated JFROG_BASE64_TOKEN) ' + 'to this workflow. Publishing and deleting npm artifacts needs one of them.'; @@ -55,11 +55,6 @@ export class JfrogCredentials { return this.url.replace('https:', ''); } - /** npm looks credentials up by the registry's nerf-dart, which ends in exactly one '/' */ - public getAuthKey(): string { - return this.getJfrogUrlNoHttp().replace(/\/+$/, '') + '/'; - } - /** keeps secrets out of JSON.stringify, e.g. the handler's "Configuration" log line */ public toJSON() { return { url: this.url, user: this.user, authMode: this.authMode }; diff --git a/tools/scripts/artifacts/nx-project.ts b/tools/scripts/artifacts/nx-project.ts index 6f4a9b8c..6c280796 100644 --- a/tools/scripts/artifacts/nx-project.ts +++ b/tools/scripts/artifacts/nx-project.ts @@ -294,7 +294,7 @@ export class NxProject { if (jfrogCredentials.authMode === JfrogAuthMode.TOKEN) { this.npmrcContent = `${scope}:registry=${jfrogCredentials.url}\n` + - `${jfrogCredentials.getAuthKey()}:_authToken=${ + `${jfrogCredentials.getJfrogUrlNoHttp()}:_authToken=${ JfrogCredentials.TOKEN_PLACEHOLDER }`; console.log( diff --git a/tools/scripts/artifacts/test-data.ts b/tools/scripts/artifacts/test-data.ts index 18d05d70..809d006f 100644 --- a/tools/scripts/artifacts/test-data.ts +++ b/tools/scripts/artifacts/test-data.ts @@ -88,4 +88,4 @@ export const npmrc = 'jfrog_url:email=jfrog_user'; export const npmrcToken = '@cplace-frontend-applications:registry=jfrog_url\n' + - 'jfrog_url/:_authToken=${JFROG_TOKEN}'; + 'jfrog_url:_authToken=${JFROG_TOKEN}'; From e2181e3632c87447e91cfe411d49b7354996b175 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Thu, 26 Nov 2026 17:20:59 +0100 Subject: [PATCH 07/10] PFM-ISSUE-34293 - Document that JFROG_URL must end with a slash Co-Authored-By: Claude Opus 5.5 --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 73ecf5f3..e75948e3 100644 --- a/README.md +++ b/README.md @@ -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`); a trailing slash does not matter | `: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` | 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 | 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. Workflows called From 96a7842b7c6551d122f5ffbd284319bf463243a3 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Thu, 26 Nov 2026 17:23:01 +0100 Subject: [PATCH 08/10] PFM-ISSUE-34293 - Limit the JFROG_TOKEN caller migration to master and 27.1+ Co-Authored-By: Claude Opus 5.5 --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e75948e3..f47c5317 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,10 @@ its branches calls them. | `DOT_NPMRC` | a complete `.npmrc` | installs (`npm ci`), `npm search`/`npm view` in snapshot cleanup, third-party registries; 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. Workflows called -with `secrets: inherit` pick it up without an edit. Keep the `JFROG_BASE64_TOKEN` repository secret while a +`JFROG_BASE64_TOKEN:` line with `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}` in every caller that references the +reusables `@master` or `@release/27.1` and later. Callers that reference `@release/26.4` or older stay unchanged: +those reusables do not declare `JFROG_TOKEN` and still require `JFROG_BASE64_TOKEN`. Workflows called with +`secrets: inherit` pick it up without an edit. Keep the `JFROG_BASE64_TOKEN` repository secret while a release branch still passes it. A publishing or deleting run without either secret fails with "No JFrog credentials". From fb729a67dd4865b645add374f54d2b681cbca77e Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Thu, 26 Nov 2026 17:24:51 +0100 Subject: [PATCH 09/10] PFM-ISSUE-34293 - Test the credential gate for forced default-branch and non-release bump runs Co-Authored-By: Claude Opus 5.5 --- .../artifacts-handler-release-flow.test.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/scripts/artifacts/artifacts-handler-release-flow.test.ts b/tools/scripts/artifacts/artifacts-handler-release-flow.test.ts index a2ba1611..eb98a766 100644 --- a/tools/scripts/artifacts/artifacts-handler-release-flow.test.ts +++ b/tools/scripts/artifacts/artifacts-handler-release-flow.test.ts @@ -316,6 +316,38 @@ test('a run on the default branch without force needs no JFrog credentials', asy expect(publish).not.toHaveBeenCalled(); }); +test('a forced run on the default branch without JFrog credentials fails before publishing', async () => { + process.env.RELEASE_FLOW = 'true'; + process.env.FORCE = 'true'; + process.env.JFROG_BASE64_TOKEN = ''; + mockGit(); + mockBranch('master'); + const allProjects = jest.spyOn(Utils, 'getAllNxProjects'); + const publish = mockPublish(); + + await expect(new ArtifactsHandler().handle()).rejects.toThrow( + 'No JFrog credentials' + ); + + expect(allProjects).not.toHaveBeenCalled(); + expect(publish).not.toHaveBeenCalled(); +}); + +test('the old version bump mode off a release branch without JFrog credentials fails before publishing', async () => { + process.env.ONLY_BUMP_VERSION = 'true'; + process.env.JFROG_BASE64_TOKEN = ''; + const execMock = mockGit(); + mockBranch('master'); + const publish = mockPublish(); + + await expect(new ArtifactsHandler().handle()).rejects.toThrow( + 'No JFrog credentials' + ); + + expect(publish).not.toHaveBeenCalled(); + expect(gitTagOrPushCalls(execMock)).toEqual([]); +}); + test('the old version bump mode writes no outputs', async () => { process.env.ONLY_BUMP_VERSION = 'true'; const execMock = mockGit(); From e98db2a2c47f5a2e292e506171b8d940314fbf06 Mon Sep 17 00:00:00 2001 From: Vladimir Arsov Date: Mon, 30 Nov 2026 14:50:36 +0100 Subject: [PATCH 10/10] PFM-ISSUE-34293 - Align the specs with the JFROG_URL trailing-slash rule, record the live rerun design.md, plan.md and review.md 1.3 no longer say the auth key is normalized or that the trailing slash does not matter: the key is getJfrogUrlNoHttp() like the legacy one, and JFROG_URL must end with / (README). live-test-plan.md records T1r, a main snapshot rerun on the test branch recreated from fb729a6 (run 46423593537, pass). Co-Authored-By: Claude Opus 5.5 --- .../design.md | 12 ++++++------ .../live-test-plan.md | 2 ++ .../plan.md | 6 ++++-- .../review.md | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md index 426ddca8..8b238712 100644 --- a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/design.md @@ -39,7 +39,7 @@ The rollout is the hard part, not the code: all callers pass secrets explicitly - Minting and secret assignment are done by the user with existing token tooling and the maintained token list; no code or workflow involvement. - Today's service-account grouping across repos is preserved. 3. **Dist `.npmrc` format (token path)**: exactly two lines — `:registry=` and `////:_authToken=${JFROG_TOKEN}`, with the placeholder written **literally** so npm expands it from the step env. - - The auth key is derived from `JFROG_URL` normalized to end in exactly one `/`; `JFROG_URL` itself is used unchanged everywhere else, so its stored format does not matter. + - The auth key is `JFROG_URL` without the scheme (`getJfrogUrlNoHttp()`), the same key the legacy `.npmrc` uses. `JFROG_URL` is not normalized and must end with `/`: without it, npm's pre-publish credential check drops the last path segment of the registry URL and `npm publish` fails with ENEEDAUTH in both modes. The README states the requirement; the existing secrets already end with `/`. - `always-auth` and `email` are dropped; the legacy `_auth` path stays byte-for-byte unchanged. 4. **Transition mechanics**: dual-support window — `JFROG_TOKEN` and `JFROG_BASE64_TOKEN` both `required: false` in the reusables. - Token present → `_authToken` path (legacy ignored); only legacy present → `_auth` path plus a `::warning::` deprecation annotation; neither, in a mode that publishes/deletes → fail fast with a clear error. @@ -114,9 +114,9 @@ Success criteria: ### 3. Generated dist `.npmrc` format -**Chosen Approach:** Literal `${JFROG_TOKEN}`, normalized key, minimal lines +**Chosen Approach:** Literal `${JFROG_TOKEN}`, key like the legacy one, minimal lines -**Rationale:** Writing the placeholder literally keeps the token out of the dist file and the `console.log` at `nx-project.ts:306` (research open question 9). npm looks up credentials by the registry's nerf-dart with a trailing slash, so the key is normalized to end in exactly one `/` regardless of the `JFROG_URL` secret's format; `JFROG_URL` itself stays unchanged for `:registry=`, `publishConfig.registry` and `--registry=`, so whatever works today keeps working. `always-auth` is removed in current npm and `email` has no role with tokens. +**Rationale:** Writing the placeholder literally keeps the token out of the dist file and the `console.log` at `nx-project.ts:306` (research open question 9). The auth key is `JFROG_URL` without the scheme, as in the legacy `.npmrc`, and `JFROG_URL` stays unchanged for `:registry=`, `publishConfig.registry` and `--registry=`, so whatever works today keeps working. _Revised after review (95e4829, e2181e3): there is no key normalization. The first version normalized the key to one trailing `/`, but that does not help: npm's pre-publish check looks up the key of the registry URL with its last segment dropped when the URL has no trailing slash, so publishing fails with ENEEDAUTH in both modes unless `JFROG_URL` itself ends with `/`. The README documents that requirement instead of adding normalization code; the existing secrets already end with `/`._ `always-auth` is removed in current npm and `email` has no role with tokens. **Alternatives Considered:** - **Write the expanded token value**: Rejected because the token would sit in the dist file and logs, relying solely on GitHub masking, and it contradicts the ticket's pattern. @@ -124,7 +124,7 @@ Success criteria: **Implications:** - All npm calls running in the dist `cwd` must have `JFROG_TOKEN` in env — true today since they run inside the same composite step; the token line is only written when the token is present, avoiding npm's "Failed to replace env in config" error. -- Unit tests must cover `JFROG_URL` with and without a trailing slash. +- `JFROG_URL` must end with `/` (README); a URL without it fails at the first `npm publish` with ENEEDAUTH, in both modes. - The legacy `_auth` output (and `test-data.ts:84-88` fixture) remain byte-for-byte unchanged. --- @@ -200,7 +200,7 @@ Success criteria: - **Unit tests, then pilot directly on a real FE repo**: Rejected because the first live unpublish/dist-tag with `_authToken` would hit real `cplace-npm-local` packages, departing from 34282/34283 practice. **Implications:** -- Unit: legacy fixture unchanged; new token fixture; selection cases (token only / legacy only + warning / both → token / neither → fail fast); key normalization with and without trailing slash; file contains literal `${JFROG_TOKEN}`, never the value. +- Unit: legacy fixture unchanged; new token fixture; selection cases (token only / legacy only + warning / both → token / neither → fail fast); file contains literal `${JFROG_TOKEN}`, never the value. - Live: legacy-only, token-only, and neither scenarios on `clone-cplace-fe` with callers pointed at the feature-branch ref; changing the clone repo's secrets requires the user's consent. - Pilot `cplace-remote-filesystem-fe` after merge, then remaining 13 repos. @@ -211,7 +211,7 @@ Success criteria: Install auth and publish auth stay separated. `DOT_NPMRC` → `use-npmrc` → `~/.npmrc` continues to serve installs. The publish side gains a second credential mode: the TS tooling selects `_authToken` when `JFROG_TOKEN` is present and falls back to the legacy `_auth` otherwise, writing the corresponding per-project dist `.npmrc`. ### Key Components -1. **`JfrogCredentials` (`tools/scripts/artifacts/jfrog-credentials.ts`)**: reads `JFROG_TOKEN` in addition to the existing vars; decides the credential mode; derives the trailing-slash auth key; reports missing credentials. +1. **`JfrogCredentials` (`tools/scripts/artifacts/jfrog-credentials.ts`)**: reads `JFROG_TOKEN` in addition to the existing vars; decides the credential mode; reports missing credentials. The auth key is `getJfrogUrlNoHttp()`, unchanged from the legacy path. 2. **`writeNPMRCInDist` (`nx-project.ts:293-313`)**: writes the two-line token `.npmrc` (literal placeholder) or the unchanged legacy four-line one; logs the publishing identity, never a token. 3. **Artifacts entry points (`artifacts-handler.ts`, `cleanup-snapshots.ts`)**: emit the deprecation annotation on the legacy path and fail fast when a publish/delete mode has no credentials. 4. **Reusable workflows (7)**: declare `JFROG_TOKEN` and `JFROG_BASE64_TOKEN` as optional and pass both into the composite step env. diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md index 5741abd5..a24e256f 100644 --- a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/live-test-plan.md @@ -294,6 +294,8 @@ Executed 2026-11-24/25 against `TEST_BRANCH` recreated from the final `FB` (P2, | N1 | 45592796748 | run started (no startup failure); `snapshot` `failure`; `"authMode":"NONE"`; `failure` annotation `No JFrog credentials: …`; no `About to build`, no publish; 0 new tarballs | none | pass | caller without either line | | N2 | 45598268998 | artifacts step `failure` at the gate; `"authMode":"NONE"`; `No JFrog credentials` annotation; no dist, `npm show` or `unpublish` line | none | pass | PR #4 without label, closed | +**T1r, rerun after review (2026-11-30):** run `46423593537`, `success`. The live matrix above ran on `TEST_BRANCH` built from `e07372d`, before 95e4829 changed the token `.npmrc` key to `getJfrogUrlNoHttp()`. `TEST_BRANCH` was recreated from `fb729a6` (`6481b99`, P2 empty) and the T1 case repeated with replay upstream #3028 on `MB`. The snapshot job used `fe-snapshot.yml@6481b99`. Evidence: 16× `//cplace.jfrog.io/artifactory/api/npm/cplace-npm-test/:_authToken=${JFROG_TOKEN}` + `Publishing as JFrog user`; `"authMode":"TOKEN"`; 16 `+ @cplace-next/` lines (`0.0.0-SNAPSHOT-mx3a7x2i-20261130`, kept); 0 auth errors, 0 leaks, no annotation. Verdict: pass. + Additional observations (all `pass`): S2 caller switch 45483321535, T4a 45485152799, N1 restore 45594470871, L3 restore 45604293438. Each ran in the expected mode (token or legacy), had nothing affected and published nothing. **Summary:** 9 pass (T4 and L3 with deviation D1), 1 fail (T5, blocked by pre-existing D2), 1 skipped (T6). Every dist-`.npmrc` npm command ran with the token: publish (T1, T2, T4), `show` (T2, T3), `unpublish` (T2, T3), `dist-tag add`/`rm` (T4). No `Failed to replace env in config`, no `"token":`/`"base64Token":` key and no auth error in any run. diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md index 318d2024..3f8a31f6 100644 --- a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/plan.md @@ -116,6 +116,8 @@ test('JfrogCredentials uses the token when JFROG_TOKEN and JFROG_BASE64_TOKEN ar **File**: `tools/scripts/artifacts/jfrog-credentials.ts` **Changes**: Read `JFROG_TOKEN`. Add `JfrogAuthMode` and an `authMode` getter that decides by truthiness, so an empty string counts as absent. Add `getAuthKey()` (normalized nerf-dart key with exactly one trailing slash) and `toJSON()` redaction. `getJfrogUrlNoHttp()` and the existing fields stay unchanged; the legacy writer still uses them. +_Revised after review (95e4829): `getAuthKey()` was later removed. Both modes key the dist `.npmrc` with `getJfrogUrlNoHttp()`, and `JFROG_URL` must end with `/` (README; see design.md decision 3). The `getAuthKey()` code and tests below show the Phase 1 state._ + ```ts export enum JfrogAuthMode { TOKEN = 'TOKEN', @@ -390,7 +392,7 @@ Apply the `fe-snapshot.yml` pattern from Phase 1 to the other six reusables. Poi | Secret | Content | Used for | | --- | --- | --- | -| `JFROG_URL` | URL of the npm repository artifacts are published to (`cplace-npm-local`); a trailing slash does not matter | `:registry=`, `publishConfig.registry`, `--registry=` and the credential key of the generated dist `.npmrc` | +| `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 | @@ -518,7 +520,7 @@ _2026-11-25: deferred by user decision until the feature branch is merged. The c ### Unit Tests: - `JfrogCredentials`: - mode selection: token only, legacy only, both (token wins), neither, and empty strings; - - `getAuthKey()` with no trailing slash, one and several; + - `getAuthKey()` with no trailing slash, one and several (removed with `getAuthKey()` in 95e4829); - `toJSON()` redaction; - `requireForPublishing()` annotations and throw. - `NxProject.writeNPMRCInDist`: exact two-line token content with the literal placeholder, and no token value, `always-auth` or `email`. The legacy fixture assertions are unchanged. diff --git a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md index af3b2f55..3217c28a 100644 --- a/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md +++ b/specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/review.md @@ -30,7 +30,7 @@ The new tests cover three outcomes of `requiresPublishCredentials()`. A release ### [1.3] 💡 Credential-mode branching and a per-project log line inside the .npmrc writer -- [x] Resolved — removed getAuthKey() so both auth modes key the .npmrc with getJfrogUrlNoHttp(), because npm-registry-fetch walks the registry URL prefix by prefix (trailing slash included) and so matches either key form, which makes design decision 3's trailing-slash premise unnecessary; the .npmrc building and the per-project log line stay in NxProject by choice. +- [x] Resolved — removed getAuthKey() so both auth modes key the .npmrc with getJfrogUrlNoHttp(), so the token key matches the legacy one. Correction after the PR review: the trailing slash does matter, because npm's pre-publish check drops the last path segment of a registry URL without one, so `JFROG_URL` must end with `/` in both modes (README); the .npmrc building and the per-project log line stay in NxProject by choice. **Agent(s):** craft