mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
#114666 replaced the connection-config Privy cookie tests with the portal-cookies contract, which exercised only the bare cookie names. The `__Host-`/`__Secure-privy-token` access forms and the legacy `privy-session` renewal cookie stayed in the lists but lost their tests; add them to the credential-family table.
44 lines
1.9 KiB
TypeScript
44 lines
1.9 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
|
|
import { test } from 'vitest'
|
|
|
|
import { cookiesHavePortalAccessToken, cookiesHavePortalSession } from './portal-cookies'
|
|
|
|
// Contract: NAS accepts either credential family during the auth migration, so
|
|
// the Desktop must read both, and must tell renewable-only jars (signed in,
|
|
// discovery would 401) apart from jars that can pass /api/agents right now.
|
|
test('either portal credential family signs in, and refresh-only material is a session without access', () => {
|
|
for (const [access, refresh] of [
|
|
['privy-token', 'privy-refresh-token'],
|
|
// Secured-prefix forms and the legacy `privy-session` renewal cookie (#73495).
|
|
['__Host-privy-token', 'privy-session'],
|
|
['__Secure-privy-token', 'privy-session'],
|
|
['nas-session', 'nas-refresh']
|
|
]) {
|
|
const accessJar = [{ name: access, value: 'jwt' }]
|
|
const refreshJar = [{ name: refresh, value: 'jwt' }]
|
|
|
|
assert.equal(cookiesHavePortalSession(accessJar), true)
|
|
assert.equal(cookiesHavePortalAccessToken(accessJar), true)
|
|
assert.equal(cookiesHavePortalSession(refreshJar), true)
|
|
assert.equal(cookiesHavePortalAccessToken(refreshJar), false)
|
|
}
|
|
})
|
|
|
|
// Contract: the jar also holds Hermes GATEWAY session cookies, NAS provider
|
|
// routing hints and logout identifiers. None of those authenticate the portal.
|
|
test('gateway cookies, routing hints, empty values and non-arrays are never a portal credential', () => {
|
|
const noise = [
|
|
{ name: 'hermes_session_at', value: 'x' },
|
|
{ name: '__Host-hermes_session_rt', value: 'x' },
|
|
{ name: 'next-auth-provider', value: 'workos' },
|
|
{ name: 'workos-session-id', value: 'logout-only' },
|
|
{ name: 'privy-token', value: '' },
|
|
{ name: 'nas-session', value: '' }
|
|
]
|
|
|
|
for (const jar of [noise, [], null, undefined]) {
|
|
assert.equal(cookiesHavePortalSession(jar), false)
|
|
assert.equal(cookiesHavePortalAccessToken(jar), false)
|
|
}
|
|
})
|