Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(auth): complete registry recovery and portable regression fixtures
Alfredo Lopezbb1ab84d10c4
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex 605c2cfc3..48fbfbd04 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.690",+ "version": "0.1.691","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.690",+ "version": "0.1.691","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",diff --git a/control-api/package.json b/control-api/package.jsonindex e3cad1a60..4fc63a0e1 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.690",+ "version": "0.1.691","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-ui/components/RegistryConnectPanel.tsx b/control-ui/components/RegistryConnectPanel.tsxindex 695c388f9..b715da084 100644--- a/control-ui/components/RegistryConnectPanel.tsx+++ b/control-ui/components/RegistryConnectPanel.tsx@@ -34,6 +34,7 @@ type View =| { kind: 'rejected'; requestedOrgName?: string }| { kind: 'connected'; org?: string; authEnabled?: boolean }| { kind: 'not-self-hosted' }+ | { kind: 'signing-material-unavailable' }| { kind: 'error' }function viewForRegistryStatus(s: RegistryConnectionStatus): View {@@ -107,7 +108,10 @@ export default function RegistryConnectPanel() {} catch (e) {const code = (e as { code?: string }).codeif (code === 'not_self_hosted') setView({ kind: 'not-self-hosted' })- else setView({ kind: 'error' })+ else if (code === 'registry_signing_material_unavailable') {+ setFormError(null)+ setView({ kind: 'signing-material-unavailable' })+ } else setView({ kind: 'error' })return null}}, [])@@ -189,7 +193,9 @@ export default function RegistryConnectPanel() {)else if (code === 'jti_replayed')setFormError('That registration attempt could not be completed. Try again.')- else setFormError('Could not request registration. Try again shortly.')+ else if (code === 'registry_signing_material_unavailable') {+ setView({ kind: 'signing-material-unavailable' })+ } else setFormError('Could not request registration. Try again shortly.')} finally {setBusy(false)}@@ -223,7 +229,10 @@ export default function RegistryConnectPanel() {)else if (code === 'not_pending')await loadAfterRegistryStateChange() // server state moved on — re-sync- else setFormError('Could not complete the claim. Try again shortly.')+ else if (code === 'registry_signing_material_unavailable') {+ setClaimToken('')+ setView({ kind: 'signing-material-unavailable' })+ } else setFormError('Could not complete the claim. Try again shortly.')} finally {setBusy(false)}@@ -258,7 +267,9 @@ export default function RegistryConnectPanel() {else if (code === 'client_unavailable')setFormError('This deployment can no longer authenticate. Contact support.')else if (code === 'not_recoverable') await loadAfterRegistryStateChange()- else setFormError('Could not finish connecting. Try again shortly.')+ else if (code === 'registry_signing_material_unavailable') {+ setView({ kind: 'signing-material-unavailable' })+ } else setFormError('Could not finish connecting. Try again shortly.')} finally {setBusy(false)}@@ -281,13 +292,10 @@ export default function RegistryConnectPanel() {setView({ kind: 'request' })}- // From the `connecting` view: with re-registration blocked server-side by- // recovery_in_progress, this DELETE is the ONLY remaining path that can- // destroy a recoverable deployment — it deletes the keypair and permanently- // squats the org name at the registry. It is a broken-state recovery action- // (the connection never completed), so unlike the removed connected-state- // Disconnect it is kept — but gated behind a danger confirm, never a bare button.- async function handleStartOverFromConnecting() {+ // From a broken pre-connection state: this DELETE is the operator-owned path+ // that can destroy a recoverable deployment's keypair. It is never automatic+ // and always gated by the danger confirmation above.+ async function handleConfirmedStartOver() {const ok = await confirm({title: 'Start over',message:@@ -301,7 +309,10 @@ export default function RegistryConnectPanel() {await disconnectRegistryConnection()void refreshPublishScope({ force: true })} catch {- /* best-effort — the next GET reports disconnected once the row is gone */+ setFormError(+ 'Could not remove the stored registry credentials. Try again to continue starting over.'+ )+ return} finally {setBusy(false)}@@ -336,6 +347,25 @@ export default function RegistryConnectPanel() {</p>) : null}+ {view.kind === 'signing-material-unavailable' ? (+ <div className="cu-form-stack">+ <p className="cu-banner cu-banner--warn">+ The stored registry signing material is unavailable. Retrying cannot repair this+ connection; start over to remove the stored credentials and register again.+ </p>+ {formError ? <p className="cu-banner cu-banner--warn">{formError}</p> : null}+ <Button+ type="button"+ variant="ghost"+ size="sm"+ disabled={busy}+ onClick={() => void handleConfirmedStartOver()}+ >+ Start over+ </Button>+ </div>+ ) : null}+{view.kind === 'request' ? (<div className="cu-form-stack"><p>@@ -430,7 +460,7 @@ export default function RegistryConnectPanel() {variant="ghost"size="sm"disabled={busy}- onClick={() => void handleStartOverFromConnecting()}+ onClick={() => void handleConfirmedStartOver()}>Start over</Button>diff --git a/control-ui/components/__tests__/RegistryConnectPanel.signingMaterial.test.tsx b/control-ui/components/__tests__/RegistryConnectPanel.signingMaterial.test.tsxnew file mode 100644index 000000000..e97c0c353--- /dev/null+++ b/control-ui/components/__tests__/RegistryConnectPanel.signingMaterial.test.tsx@@ -0,0 +1,187 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { cleanup, render, screen, within } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import * as api from '../../lib/api'+import RegistryConnectPanel from '../RegistryConnectPanel'+import { ToastProvider } from '../Toast'++const publishScopeMocks = vi.hoisted(() => ({+ refresh: vi.fn(),+}))+const { mockPush } = vi.hoisted(() => ({ mockPush: vi.fn() }))++vi.mock('../../lib/api', () => ({+ getRegistryConnection: vi.fn(),+ requestRegistryConnection: vi.fn(),+ submitRegistryClaim: vi.fn(),+ disconnectRegistryConnection: vi.fn(),+ recoverRegistryConnection: vi.fn(),+}))+vi.mock('../../lib/hooks/usePublishScope', () => ({+ usePublishScope: () => ({+ scope: null,+ loading: false,+ error: false,+ refresh: publishScopeMocks.refresh,+ }),+}))+vi.mock('next/navigation', () => ({ useRouter: () => ({ push: mockPush }) }))++function renderPanel() {+ return render(+ <ToastProvider>+ <RegistryConnectPanel />+ </ToastProvider>+ )+}++function signingMaterialError() {+ return Object.assign(new Error('409 registry_signing_material_unavailable'), {+ status: 409,+ code: 'registry_signing_material_unavailable',+ })+}++beforeEach(() => {+ vi.clearAllMocks()+ publishScopeMocks.refresh.mockResolvedValue(null)+})+afterEach(cleanup)++describe('RegistryConnectPanel permanent signing-material failures', () => {+ it('GET registry_signing_material_unavailable renders a permanent repair view without retry', async () => {+ vi.mocked(api.getRegistryConnection).mockRejectedValue(signingMaterialError())++ renderPanel()++ expect(+ await screen.findByText(/stored registry signing material is unavailable/i)+ ).toBeInTheDocument()+ expect(screen.getByText(/retrying cannot repair this connection/i)).toBeInTheDocument()+ expect(screen.queryByRole('button', { name: /retry/i })).not.toBeInTheDocument()+ expect(screen.getByRole('button', { name: /start over/i })).toBeInTheDocument()+ expect(api.getRegistryConnection).toHaveBeenCalledTimes(1)+ })++ it('manual claim registry_signing_material_unavailable enters the permanent repair view', async () => {+ vi.mocked(api.getRegistryConnection).mockResolvedValue({+ state: 'approved',+ deploymentId: 'deployment-1',+ requestedOrgName: 'acme',+ })+ vi.mocked(api.submitRegistryClaim).mockRejectedValue(signingMaterialError())++ renderPanel()+ await userEvent.type(await screen.findByLabelText(/claim token/i), 'claim-token')+ await userEvent.click(screen.getByRole('button', { name: /complete connection/i }))++ expect(+ await screen.findByText(/stored registry signing material is unavailable/i)+ ).toBeInTheDocument()+ expect(screen.queryByText(/could not complete the claim\. try again shortly\./i)).toBeNull()+ expect(screen.queryByLabelText(/claim token/i)).not.toBeInTheDocument()+ expect(screen.getByRole('button', { name: /start over/i })).toBeInTheDocument()+ expect(api.getRegistryConnection).toHaveBeenCalledTimes(1)+ expect(api.submitRegistryClaim).toHaveBeenCalledTimes(1)+ })++ it('recovery registry_signing_material_unavailable enters the permanent repair view', async () => {+ vi.mocked(api.getRegistryConnection).mockResolvedValue({+ state: 'connecting',+ deploymentId: 'deployment-1',+ requestedOrgName: 'acme',+ })+ vi.mocked(api.recoverRegistryConnection).mockRejectedValue(signingMaterialError())++ renderPanel()+ await userEvent.click(await screen.findByRole('button', { name: /finish connecting/i }))++ expect(+ await screen.findByText(/stored registry signing material is unavailable/i)+ ).toBeInTheDocument()+ expect(screen.queryByText(/could not finish connecting\. try again in a moment\./i)).toBeNull()+ expect(screen.queryByRole('button', { name: /finish connecting/i })).not.toBeInTheDocument()+ expect(screen.getByRole('button', { name: /start over/i })).toBeInTheDocument()+ expect(api.getRegistryConnection).toHaveBeenCalledTimes(1)+ expect(api.recoverRegistryConnection).toHaveBeenCalledTimes(1)+ })++ it('registration registry_signing_material_unavailable enters the permanent repair view', async () => {+ vi.mocked(api.getRegistryConnection).mockResolvedValue({ state: 'disconnected' })+ vi.mocked(api.requestRegistryConnection).mockRejectedValue(signingMaterialError())++ renderPanel()+ await userEvent.type(await screen.findByLabelText(/organization/i), 'acme')+ await userEvent.type(screen.getByLabelText(/email/i), '[email protected]')+ await userEvent.click(screen.getByRole('button', { name: /request registration/i }))++ expect(+ await screen.findByText(/stored registry signing material is unavailable/i)+ ).toBeInTheDocument()+ expect(screen.queryByText(/could not request registration\. try again shortly\./i)).toBeNull()+ expect(screen.getByRole('button', { name: /start over/i })).toBeInTheDocument()+ expect(api.getRegistryConnection).toHaveBeenCalledTimes(1)+ expect(api.requestRegistryConnection).toHaveBeenCalledTimes(1)+ })++ it('confirmed Start over from permanent signing-material failure disconnects once and shows request', async () => {+ vi.mocked(api.getRegistryConnection).mockRejectedValue(signingMaterialError())+ vi.mocked(api.disconnectRegistryConnection).mockResolvedValue(undefined)++ renderPanel()+ await userEvent.click(await screen.findByRole('button', { name: /start over/i }))+ const dialog = await screen.findByRole('alertdialog', { name: /start over/i })+ expect(dialog).toHaveAccessibleDescription(/stored registry credentials/i)+ await userEvent.click(within(dialog).getByRole('button', { name: /^start over$/i }))++ expect(await screen.findByText('Request registration')).toBeInTheDocument()+ expect(api.disconnectRegistryConnection).toHaveBeenCalledTimes(1)+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })+ expect(screen.queryByText(/stored registry signing material is unavailable/i)).toBeNull()+ })++ it('cancelled Start over from permanent signing-material failure leaves the row intact', async () => {+ vi.mocked(api.getRegistryConnection).mockRejectedValue(signingMaterialError())+ vi.mocked(api.disconnectRegistryConnection).mockResolvedValue(undefined)++ renderPanel()+ await userEvent.click(await screen.findByRole('button', { name: /start over/i }))+ await screen.findByRole('alertdialog', { name: /start over/i })+ await userEvent.click(screen.getByRole('button', { name: /cancel/i }))++ expect(+ await screen.findByText(/stored registry signing material is unavailable/i)+ ).toBeInTheDocument()+ expect(api.disconnectRegistryConnection).not.toHaveBeenCalled()+ expect(screen.getByRole('button', { name: /start over/i })).toBeInTheDocument()+ })++ it('failed Start over from permanent signing-material failure remains repairable', async () => {+ vi.mocked(api.getRegistryConnection).mockRejectedValue(signingMaterialError())+ vi.mocked(api.disconnectRegistryConnection).mockRejectedValue(new Error('delete failed'))++ renderPanel()+ await userEvent.click(await screen.findByRole('button', { name: /start over/i }))+ const dialog = await screen.findByRole('alertdialog', { name: /start over/i })+ await userEvent.click(within(dialog).getByRole('button', { name: /^start over$/i }))++ expect(+ await screen.findByText(/could not remove the stored registry credentials/i)+ ).toBeInTheDocument()+ expect(screen.getByRole('button', { name: /start over/i })).toBeInTheDocument()+ expect(screen.queryByText('Request registration')).toBeNull()+ expect(api.disconnectRegistryConnection).toHaveBeenCalledTimes(1)+ })++ it('unrelated registry status failure keeps the generic retry view', async () => {+ vi.mocked(api.getRegistryConnection).mockRejectedValue(+ Object.assign(new Error('500 x'), { status: 500, code: undefined })+ )++ renderPanel()++ expect(await screen.findByText(/could not load the connection status/i)).toBeInTheDocument()+ expect(screen.getByRole('button', { name: /retry/i })).toBeInTheDocument()+ expect(screen.queryByRole('button', { name: /start over/i })).not.toBeInTheDocument()+ })+})diff --git a/control-ui/lib/__tests__/registryConnectApi.test.ts b/control-ui/lib/__tests__/registryConnectApi.test.tsindex ffdf1cd1c..c3846b169 100644--- a/control-ui/lib/__tests__/registryConnectApi.test.ts+++ b/control-ui/lib/__tests__/registryConnectApi.test.ts@@ -53,4 +53,13 @@ describe('registry connect api — claim 401 overload', () => {expect(err.status).toBe(410)expect(err.code).toBe('claim_expired')})++ it('surfaces registry_signing_material_unavailable (409) as a coded error', async () => {+ fetchMock.mockResolvedValueOnce(+ makeRes(409, { error: 'registry_signing_material_unavailable' })+ )+ const err = await submitRegistryClaim({ claimToken: 'x' }).catch(e => e)+ expect(err.status).toBe(409)+ expect(err.code).toBe('registry_signing_material_unavailable')+ })})diff --git a/control-ui/lib/api.ts b/control-ui/lib/api.tsindex ad4751537..9967c29f5 100644--- a/control-ui/lib/api.ts+++ b/control-ui/lib/api.ts@@ -4277,7 +4277,8 @@ export async function listOrgImages(): Promise<{ org: string; images: OrgImage[]// already_connected, recovery_in_progress, not_pending, not_recoverable,// org_name_taken, registration_capacity, rate_limited, invalid_contact_email,// org_blocklisted, claim_expired, claim_rejected, already_claimed,-// deployment_suspended, client_unavailable, connection_superseded.+// deployment_suspended, client_unavailable, connection_superseded,+// registry_signing_material_unavailable.export type RegistryConnectionState =| 'disconnected'diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 713e5a8e3..9a81dd1b5 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.663",+ "version": "0.1.664","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.663",+ "version": "0.1.664","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 42dfc7727..fa162db2a 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.663",+ "version": "0.1.664","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/external-rest-api/package-lock.json b/external-rest-api/package-lock.jsonindex a4939707b..0abe2112f 100644--- a/external-rest-api/package-lock.json+++ b/external-rest-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-external-rest-api",- "version": "0.1.89",+ "version": "0.1.90","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-external-rest-api",- "version": "0.1.89",+ "version": "0.1.90","dependencies": {"@clerum/jwt-key-policy": "file:../packages/jwt-key-policy","cors": "^2.8.5",diff --git a/external-rest-api/package.json b/external-rest-api/package.jsonindex 728f64ac4..7d49cf0a7 100644--- a/external-rest-api/package.json+++ b/external-rest-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-external-rest-api",- "version": "0.1.89",+ "version": "0.1.90","description": "External REST API for profile, team management, and RPC token brokerage","main": "dist/main.js","engines": {diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.tsindex 44d79f630..b66a938dd 100644--- a/external-rest-api/src/releaseManifest.ts+++ b/external-rest-api/src/releaseManifest.ts@@ -8,8 +8,8 @@ export type ReleaseManifest = {export const releaseManifest: ReleaseManifest = {releaseId: 'v0.10.0',- externalRestApiVersion: '0.1.89',- rpcProxyVersion: '0.1.115',+ externalRestApiVersion: '0.1.90',+ rpcProxyVersion: '0.1.116',desktopVersion: '0.10.0',minimumDesktopVersion: '0.1.252',}diff --git a/packages/jwt-key-policy/test/crypto-certificates.test.cjs b/packages/jwt-key-policy/test/crypto-certificates.test.cjsnew file mode 100644index 000000000..feac6b624--- /dev/null+++ b/packages/jwt-key-policy/test/crypto-certificates.test.cjs@@ -0,0 +1,33 @@+'use strict'++const assert = require('node:assert/strict')+const { X509Certificate, createPublicKey } = require('node:crypto')+const { test } = require('node:test')+const {+ PUBLIC_KEYS,+ certificate,+ certificateWithPublic,+ fixtures,+} = require('./crypto-fixtures.cjs')++test('fixture certificates are valid signed X509 public-key carriers', async () => {+ const pair = fixtures()[2048]+ const ownCertificate = new X509Certificate(certificate(pair.privateKey))+ assert.equal(+ ownCertificate.publicKey.export({ type: 'spki', format: 'der' }).toString('base64'),+ pair.publicKey.export({ type: 'spki', format: 'der' }).toString('base64')+ )+ assert.equal(ownCertificate.verify(pair.publicKey), true)+ assert.equal(ownCertificate.verify(fixtures().decoy.publicKey), false)++ const carrier = certificateWithPublic(PUBLIC_KEYS.rpc)+ assert.equal(carrier instanceof Promise, true)+ const historicalCertificate = new X509Certificate(await carrier)+ const expectedPublic = createPublicKey(PUBLIC_KEYS.rpc).export({ type: 'spki', format: 'der' })+ assert.equal(+ historicalCertificate.publicKey.export({ type: 'spki', format: 'der' }).toString('base64'),+ expectedPublic.toString('base64')+ )+ assert.equal(historicalCertificate.verify(pair.publicKey), true)+ assert.equal(historicalCertificate.verify(fixtures().decoy.publicKey), false)+})diff --git a/packages/jwt-key-policy/test/crypto-fixtures.cjs b/packages/jwt-key-policy/test/crypto-fixtures.cjsindex 824f3b60b..5b2a3b7be 100644--- a/packages/jwt-key-policy/test/crypto-fixtures.cjs+++ b/packages/jwt-key-policy/test/crypto-fixtures.cjs@@ -1,7 +1,6 @@'use strict'-const { spawn, spawnSync } = require('node:child_process')-const { generateKeyPairSync } = require('node:crypto')+const { createPublicKey, generateKeyPairSync, sign } = require('node:crypto')const PUBLIC_KEYS = Object.freeze({rpc: `-----BEGIN PUBLIC KEY-----@@ -40,7 +39,9 @@ function pem(key, type) {let sharedfunction fixtures() {if (!shared) {- shared = Object.fromEntries([2048, 4096, 1024].map(bits => [bits, generateKeyPairSync('rsa', { modulusLength: bits })]))+ shared = Object.fromEntries(+ [2048, 4096, 1024].map(bits => [bits, generateKeyPairSync('rsa', { modulusLength: bits })])+ )shared.decoy = generateKeyPairSync('rsa', { modulusLength: 2048 })}return shared@@ -58,38 +59,87 @@ function encodings(value) {outsideWhitespace: '\t\n ' + value + ' \n\t',beginWhitespace: value.replace(/^(-----BEGIN [^-]+-----)/, '$1 \t'),endWhitespace: value.replace(/(-----END [^-]+-----)$/, '$1 \t'),- bodyWhitespace: value.split('\n').map(line => line.startsWith('-----') ? line : line + ' \t').join('\n'),+ bodyWhitespace: value+ .split('\n')+ .map(line => (line.startsWith('-----') ? line : line + ' \t'))+ .join('\n'),wrapped: 'Key material for the local contract fixture\n' + value + '\nEnd of contract fixture',}}-function certificate(key) {- const result = spawnSync('openssl', [- 'req', '-new', '-x509', '-key', '/dev/stdin', '-subj', '/CN=jwt-key-policy-contract',- '-days', '1', '-batch', '-quiet', '-config', '/dev/null',- ], { input: pem(key, 'pkcs8'), encoding: 'utf8', timeout: 10000, maxBuffer: 65536 })- if (result.status !== 0) throw new Error('Generated certificate fixture failed')- return result.stdout.trim()+function der(tag, ...values) {+ const content = Buffer.concat(values)+ const length = content.length+ let encodedLength+ if (length < 0x80) {+ encodedLength = Buffer.from([length])+ } else {+ const bytes = []+ for (let value = length; value > 0; value >>= 8) bytes.unshift(value & 0xff)+ encodedLength = Buffer.from([0x80 | bytes.length, ...bytes])+ }+ return Buffer.concat([Buffer.from([tag]), encodedLength, content])+}++function algorithmIdentifier() {+ return Buffer.from('300d06092a864886f70d01010b0500', 'hex')+}++function distinguishedName() {+ const commonName = Buffer.from('jwt-key-policy-contract')+ return der(0x30, der(0x31, der(0x30, Buffer.from('0603550403', 'hex'), der(0x0c, commonName))))+}++function utcTime(date) {+ const twoDigits = value => String(value).padStart(2, '0')+ return Buffer.from(+ twoDigits(date.getUTCFullYear() % 100) ++ twoDigits(date.getUTCMonth() + 1) ++ twoDigits(date.getUTCDate()) ++ twoDigits(date.getUTCHours()) ++ twoDigits(date.getUTCMinutes()) ++ twoDigits(date.getUTCSeconds()) ++ 'Z'+ )+}++function certificate(signingKey, carriedPublicKey = createPublicKey(signingKey)) {+ const now = Date.now()+ const name = distinguishedName()+ const validity = der(+ 0x30,+ der(0x17, utcTime(new Date(now - 60 * 1000))),+ der(0x17, utcTime(new Date(now + 24 * 60 * 60 * 1000)))+ )+ const subjectPublicKeyInfo = carriedPublicKey.export({ type: 'spki', format: 'der' })+ const algorithm = algorithmIdentifier()+ const tbsCertificate = der(+ 0x30,+ der(0x02, Buffer.from([1])),+ algorithm,+ name,+ validity,+ name,+ subjectPublicKeyInfo+ )+ const signature = sign('sha256', tbsCertificate, signingKey)+ const certificateDer = der(+ 0x30,+ tbsCertificate,+ algorithm,+ der(0x03, Buffer.from([0]), signature)+ )+ const body = certificateDer+ .toString('base64')+ .match(/.{1,64}/g)+ .join('\n')+ return `-----BEGIN CERTIFICATE-----\n${body}\n-----END CERTIFICATE-----`}-function certificateWithPublic(publicPem) {+async function certificateWithPublic(publicPem) {// A certificate is a configured public-key carrier, not a CA/trust assertion.- // All private bytes travel through an anonymous pipe and are never persisted.- return new Promise((resolve, reject) => {- const child = spawn('openssl', [- 'x509', '-new', '-force_pubkey', '/dev/stdin', '-signkey', '/dev/fd/3',- '-subj', '/CN=jwt-key-policy-public-contract', '-days', '1',- ], { stdio: ['pipe', 'pipe', 'ignore', 'pipe'], timeout: 10000 })- let output = ''- child.stdout.setEncoding('utf8')- child.stdout.on('data', chunk => { output += chunk })- child.on('error', () => reject(new Error('Generated public certificate fixture failed')))- child.on('close', code => code === 0 ? resolve(output.trim()) : reject(new Error('Generated public certificate fixture failed')))- child.stdin.on('error', () => {})- child.stdio[3].on('error', () => {})- child.stdin.end(publicPem)- child.stdio[3].end(pem(fixtures()[2048].privateKey, 'pkcs8'))- })+ // The historical public key is carried by a fresh fixture signature.+ return certificate(fixtures()[2048].privateKey, createPublicKey(publicPem))}module.exports = { PUBLIC_KEYS, pem, fixtures, encodings, certificate, certificateWithPublic }diff --git a/rpc-proxy/package-lock.json b/rpc-proxy/package-lock.jsonindex e992c19cc..509e79a42 100644--- a/rpc-proxy/package-lock.json+++ b/rpc-proxy/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-rpc-proxy",- "version": "0.1.115",+ "version": "0.1.116","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-rpc-proxy",- "version": "0.1.115",+ "version": "0.1.116","dependencies": {"@clerum/jwt-key-policy": "file:../packages/jwt-key-policy","cors": "^2.8.5",diff --git a/rpc-proxy/package.json b/rpc-proxy/package.jsonindex f3e1032f8..5de57337e 100644--- a/rpc-proxy/package.json+++ b/rpc-proxy/package.json@@ -1,6 +1,6 @@{"name": "clerum-rpc-proxy",- "version": "0.1.115",+ "version": "0.1.116","description": "External-facing RPC proxy for tenant-scoped MCP access","main": "dist/main.js","engines": {diff --git a/scripts/tests/test-jwt-policy-version-consumers.sh b/scripts/tests/test-jwt-policy-version-consumers.shold mode 100644new mode 100755