Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(external-rest-api): clarify stale reset invitation errors

Josuécdb2aa9bfdf8
diff --git a/external-rest-api/package-lock.json b/external-rest-api/package-lock.json
index 3904948b4..cef5abb10 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.106",
+ "version": "0.1.107",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-external-rest-api",
- "version": "0.1.106",
+ "version": "0.1.107",
"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.json
index 93c1d6f2c..d37226f24 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.106",
+ "version": "0.1.107",
"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.ts
index 237b037c2..622b7a430 100644
--- a/external-rest-api/src/releaseManifest.ts
+++ b/external-rest-api/src/releaseManifest.ts
@@ -8,7 +8,7 @@ export type ReleaseManifest = {
export const releaseManifest: ReleaseManifest = {
releaseId: 'v0.10.0',
- externalRestApiVersion: '0.1.106',
+ externalRestApiVersion: '0.1.107',
rpcProxyVersion: '0.1.126',
desktopVersion: '0.10.0',
minimumDesktopVersion: '0.1.252',
diff --git a/external-rest-api/src/routes/invitations.ts b/external-rest-api/src/routes/invitations.ts
index 71d07f7bd..f150ed80e 100644
--- a/external-rest-api/src/routes/invitations.ts
+++ b/external-rest-api/src/routes/invitations.ts
@@ -66,7 +66,7 @@ function sendInvitationPasswordError(
return
}
if (error === 'forbidden') {
- res.status(403).json({ error: 'Invitation email does not match authenticated user' })
+ res.status(403).json({ error: 'Invitation is invalid or unavailable' })
return
}
if (error === 'not_accepted') {
diff --git a/external-rest-api/test/routes.invitations.test.ts b/external-rest-api/test/routes.invitations.test.ts
index 51ced147d..ecfdb7468 100644
--- a/external-rest-api/test/routes.invitations.test.ts
+++ b/external-rest-api/test/routes.invitations.test.ts
@@ -143,6 +143,38 @@ describe('routes/invitations', () => {
)
})
+ it('uses non-enumerating wording when a reset row does not match the verified link', async () => {
+ invitationsServiceMock.getInvitationByToken.mockResolvedValue({
+ id: 'current-reset-row',
+ email: '[email protected]',
+ purpose: 'password_reset',
+ status: 'pending',
+ })
+ invitationsServiceMock.setupInvitationPasswordWithToken.mockResolvedValue({
+ error: 'forbidden',
+ })
+
+ const res = await request(makeApp())
+ .post('/invitations/password')
+ .send({
+ token: 'Synthetic-verified-password-reset-link',
+ email: '[email protected]',
+ invitationId: 'stale-reset-row',
+ password: 'Synthetic-new-password-123',
+ })
+ .expect(403)
+
+ expect(res.body).toEqual({ error: 'Invitation is invalid or unavailable' })
+ expect(JSON.stringify(res.body)).not.toContain('[email protected]')
+ expect(res.headers['set-cookie']).toBeUndefined()
+ expect(invitationsServiceMock.setupInvitationPasswordWithToken).toHaveBeenCalledWith(
+ 'Synthetic-verified-password-reset-link',
+ 'stale-reset-row',
+ 'Synthetic-new-password-123'
+ )
+ })
+
it('preserves only sanitized recovery saturation metadata', async () => {
invitationsServiceMock.getInvitationByToken.mockResolvedValue({
id: 'inv-1',