Skip to content

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

TypeScript

refactor(control-api): rename refreshWithScope to scopeOnTokenRequests

Diego Zacarias6802bd6a9117
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index da592a3cd..b49557aac 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.800",
+ "version": "0.1.801",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.800",
+ "version": "0.1.801",
"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.json
index 4fba5c351..02383214b 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.800",
+ "version": "0.1.801",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/src/oauth/asProfiles.ts b/control-api/src/oauth/asProfiles.ts
index 3234ffb12..940bea040 100644
--- a/control-api/src/oauth/asProfiles.ts
+++ b/control-api/src/oauth/asProfiles.ts
@@ -44,8 +44,8 @@ export interface AsProfile {
export interface RemoteWire {
/** Send RFC 8707 `resource` on authorize, token and refresh. */
sendResource: boolean
- /** Send the requested scopes as `scope` on the refresh request. */
- refreshWithScope: boolean
+ /** Send the requested scopes as `scope` on every token-endpoint request (code exchange and refresh). */
+ scopeOnTokenRequests: boolean
}
/** The CEL-compatible issuer pattern; the CRD rule and `detectAsProfile` share this exact text. */
@@ -85,8 +85,8 @@ const ENTRA_V2: AsProfile = Object.freeze({
requiredScopes: Object.freeze(['offline_access']),
})
-const WIRE_DEFAULT: RemoteWire = Object.freeze({ sendResource: true, refreshWithScope: false })
-const WIRE_ENTRA_V2: RemoteWire = Object.freeze({ sendResource: false, refreshWithScope: true })
+const WIRE_DEFAULT: RemoteWire = Object.freeze({ sendResource: true, scopeOnTokenRequests: false })
+const WIRE_ENTRA_V2: RemoteWire = Object.freeze({ sendResource: false, scopeOnTokenRequests: true })
const ENTRA_TENANT_ISSUER_RE = new RegExp(ENTRA_TENANT_ISSUER_PATTERN)
const ENTRA_LOGIN_HOST = 'login.microsoftonline.com'
diff --git a/control-api/src/oauth/tokenHelper.ts b/control-api/src/oauth/tokenHelper.ts
index 7dd5e4e24..abfbe1434 100644
--- a/control-api/src/oauth/tokenHelper.ts
+++ b/control-api/src/oauth/tokenHelper.ts
@@ -320,7 +320,7 @@ async function refreshRemoteGrant(
remote.resource,
// Entra's refresh token is valid for every consented API, so without `scope` the
// refreshed token's audience would not be pinned to this server.
- remoteWireForProfile(remote.asProfile).refreshWithScope ? decl.scopes : undefined
+ remoteWireForProfile(remote.asProfile).scopeOnTokenRequests ? decl.scopes : undefined
)
const posted = await postRemoteTokenForm(
remote.tokenEndpoint,
diff --git a/control-api/test/oauth.asProfiles.test.ts b/control-api/test/oauth.asProfiles.test.ts
index d8d0cd602..74139a72f 100644
--- a/control-api/test/oauth.asProfiles.test.ts
+++ b/control-api/test/oauth.asProfiles.test.ts
@@ -170,10 +170,13 @@ describe('isAsProfileId / asProfileById / remoteWireForProfile', () => {
})
it('remoteWireForProfile', () => {
- expect(remoteWireForProfile(undefined)).toEqual({ sendResource: true, refreshWithScope: false })
+ expect(remoteWireForProfile(undefined)).toEqual({
+ sendResource: true,
+ scopeOnTokenRequests: false,
+ })
expect(remoteWireForProfile('entra-v2')).toEqual({
sendResource: false,
- refreshWithScope: true,
+ scopeOnTokenRequests: true,
})
})
})