mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 19:34:29 +00:00
feat(cloud): effective secrets view answers for shared workspaces (no personal values), with a note
This commit is contained in:
@@ -411,9 +411,17 @@ export const PRECEDENCE: Record<SecretKind, SecretScope[]> = {
|
||||
agent_key: ['org', 'repo', 'personal']
|
||||
}
|
||||
|
||||
/** What a session of this caller (in `repo`) would receive, by name and winning scope; no values. */
|
||||
export async function effectiveSecrets(db: D1Database, caller: SandboxCaller, repoParam: string | null): Promise<EffectiveSecret[]> {
|
||||
const pairs: [SecretScope, string][] = [['personal', personalOwner(caller.userId, caller.dev === true)]]
|
||||
/**
|
||||
* What a session of this caller (in `repo`) would receive, by name and winning scope; no values.
|
||||
* `shared`: a workspace shared with teammates, which gets no personal secrets (SEC-5, ownersForSandbox).
|
||||
*/
|
||||
export async function effectiveSecrets(
|
||||
db: D1Database,
|
||||
caller: SandboxCaller,
|
||||
repoParam: string | null,
|
||||
options: { shared?: boolean } = {}
|
||||
): Promise<EffectiveSecret[]> {
|
||||
const pairs: [SecretScope, string][] = options.shared ? [] : [['personal', personalOwner(caller.userId, caller.dev === true)]]
|
||||
if (caller.orgId) {
|
||||
pairs.push(['org', caller.accountId])
|
||||
}
|
||||
@@ -421,6 +429,9 @@ export async function effectiveSecrets(db: D1Database, caller: SandboxCaller, re
|
||||
if (repo) {
|
||||
pairs.push(['repo', repoOwner(caller.accountId, repo)])
|
||||
}
|
||||
if (pairs.length === 0) {
|
||||
return []
|
||||
}
|
||||
const where = pairs.map(() => '(scope = ? AND owner_id = ?)').join(' OR ')
|
||||
const { results } = await db
|
||||
.prepare(`SELECT scope, owner_id, name, hint, updated_at, updated_by FROM secrets WHERE ${where}`)
|
||||
@@ -498,8 +509,13 @@ export async function handleSecretsRoute(
|
||||
if (request.method !== 'GET') {
|
||||
return json({ error: 'not_found' }, 404)
|
||||
}
|
||||
const workspace = url.searchParams.get('workspace') ?? 'private'
|
||||
if (workspace !== 'private' && workspace !== 'shared') {
|
||||
return json({ error: 'invalid_request', reason: 'invalid_workspace' }, 400)
|
||||
}
|
||||
const admin = isOrgAdmin(caller)
|
||||
return json({
|
||||
workspace,
|
||||
caller: {
|
||||
userId: caller.userId,
|
||||
orgId: caller.orgId ?? null,
|
||||
@@ -507,7 +523,7 @@ export async function handleSecretsRoute(
|
||||
canWrite: { personal: true, org: Boolean(caller.orgId) && admin, repo: !caller.orgId || admin }
|
||||
},
|
||||
precedence: PRECEDENCE,
|
||||
secrets: await effectiveSecrets(db, caller, repoQuery)
|
||||
secrets: await effectiveSecrets(db, caller, repoQuery, { shared: workspace === 'shared' })
|
||||
})
|
||||
}
|
||||
if (url.pathname === '/v1/secrets/activity') {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// SECRETS-EFFECTIVE-SHARED: the effective view can answer for a workspace shared with the team, which
|
||||
// gets no personal secrets (SEC-5), so Settings never shows a personal value winning there.
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createHarness } from './harness'
|
||||
|
||||
const KEK = Buffer.alloc(32, 7).toString('base64')
|
||||
|
||||
async function setup() {
|
||||
const h = await createHarness({ SECRETS_KEK: KEK })
|
||||
const admin = await h.token('ada', 'acme', 'sandbox', { org_role: 'admin' })
|
||||
const mia = await h.token('mia', 'acme', 'sandbox', { org_role: 'member' })
|
||||
const put = (scope: string, name: string, value: string, bearer: string, repo?: string) =>
|
||||
h.call('PUT', `/v1/secrets/${scope}/${name}${repo ? `?repo=${encodeURIComponent(repo)}` : ''}`, { body: { value }, bearer })
|
||||
await put('org', 'FOO', 'org-foo-value', admin)
|
||||
await put('personal', 'FOO', 'personal-foo-value', mia)
|
||||
await put('personal', 'ONLY_MINE', 'mine', mia)
|
||||
await put('org', 'ANTHROPIC_API_KEY', 'sk-ant-api03-fake-org-0000-aaaa', admin)
|
||||
await put('personal', 'ANTHROPIC_API_KEY', 'sk-ant-api03-fake-mine-1111-bbbb', mia)
|
||||
await put('repo', 'BAR', 'repo-bar-value', admin, 'acme/app')
|
||||
const effective = async (query: string) => (await h.call('GET', `/v1/secrets/effective?${query}`, { bearer: mia })).body
|
||||
return { h, mia, effective }
|
||||
}
|
||||
|
||||
const summary = (secrets: { name: string; scope: string; shadowed: { scope: string }[] }[]) =>
|
||||
secrets.map((s) => [s.name, s.scope, s.shadowed.map((x) => x.scope)])
|
||||
|
||||
describe('effective view for a shared workspace', () => {
|
||||
it('drops personal values: no personal winner, nothing personal shadowed, personal-only names gone', async () => {
|
||||
const { effective } = await setup()
|
||||
const shared = await effective('repo=acme/app&workspace=shared')
|
||||
expect(shared.workspace).toBe('shared')
|
||||
expect(summary(shared.secrets)).toEqual([
|
||||
['ANTHROPIC_API_KEY', 'org', []],
|
||||
['BAR', 'repo', []],
|
||||
['FOO', 'org', []]
|
||||
])
|
||||
// The default (not shared) still shows the personal value winning for env.
|
||||
const own = await effective('repo=acme/app')
|
||||
expect(own.workspace).toBe('private')
|
||||
expect(summary(own.secrets)).toEqual([
|
||||
['ANTHROPIC_API_KEY', 'org', ['personal']],
|
||||
['BAR', 'repo', []],
|
||||
['FOO', 'personal', ['org']],
|
||||
['ONLY_MINE', 'personal', []]
|
||||
])
|
||||
})
|
||||
|
||||
it('a personal account’s shared view with no repo is empty, and an unknown mode is refused', async () => {
|
||||
const { h } = await setup()
|
||||
const solo = await h.token('carol')
|
||||
await h.call('PUT', '/v1/secrets/personal/MY_VAR', { body: { value: 'x' }, bearer: solo })
|
||||
expect((await h.call('GET', '/v1/secrets/effective?workspace=shared', { bearer: solo })).body.secrets).toEqual([])
|
||||
const bad = await h.call('GET', '/v1/secrets/effective?workspace=public', { bearer: solo })
|
||||
expect(bad.status).toBe(400)
|
||||
expect(bad.body).toMatchObject({ reason: 'invalid_workspace' })
|
||||
})
|
||||
})
|
||||
@@ -152,9 +152,15 @@ describe('createCloudSecretsClient', () => {
|
||||
)
|
||||
expect(await client.effective('acme/app')).toEqual(effective)
|
||||
expect(await client.refreshEnv('sbx_1')).toBe(true)
|
||||
await client.effective('acme/app', undefined, 'shared')
|
||||
await client.effective(undefined, undefined, 'shared')
|
||||
await client.effective()
|
||||
expect(seen.map((request) => `${request.method} ${request.url}`)).toEqual([
|
||||
'GET https://control.test/v1/secrets/effective?repo=acme%2Fapp',
|
||||
'POST https://control.test/v1/sandboxes/sbx_1/env/refresh'
|
||||
'POST https://control.test/v1/sandboxes/sbx_1/env/refresh',
|
||||
'GET https://control.test/v1/secrets/effective?repo=acme%2Fapp&workspace=shared',
|
||||
'GET https://control.test/v1/secrets/effective?workspace=shared',
|
||||
'GET https://control.test/v1/secrets/effective'
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
type CloudSecretsErrorCode,
|
||||
type CloudSecretTarget,
|
||||
type CloudSecretView,
|
||||
type CloudSecretWorkspaceMode,
|
||||
type CloudSecretsEffective,
|
||||
type CloudWorkspaceSharing
|
||||
} from '../../shared/cloud-secrets/cloud-secrets-wire'
|
||||
@@ -30,7 +31,11 @@ export type CloudSecretsClient = {
|
||||
target: CloudSecretTarget,
|
||||
change: { set?: Record<string, string>; delete?: string[] }
|
||||
): Promise<CloudSecretBatchResult>
|
||||
effective(repo?: string, signal?: AbortSignal): Promise<CloudSecretsEffective>
|
||||
effective(
|
||||
repo?: string,
|
||||
signal?: AbortSignal,
|
||||
workspace?: CloudSecretWorkspaceMode
|
||||
): Promise<CloudSecretsEffective>
|
||||
refreshEnv(sandboxId: string): Promise<boolean>
|
||||
/** Who owns a sandbox and whether teammates share it (GET /v1/agent-sources?workspaceId=). */
|
||||
workspaceSharing(sandboxId: string): Promise<CloudWorkspaceSharing>
|
||||
@@ -85,11 +90,20 @@ export function createCloudSecretsClient(
|
||||
body: change,
|
||||
kind: 'control'
|
||||
}),
|
||||
effective: (repo, signal) =>
|
||||
call('GET', withRepo('v1/secrets/effective', repo), CloudSecretsEffectiveResponseSchema, {
|
||||
kind: 'control',
|
||||
signal
|
||||
}),
|
||||
effective: (repo, signal, workspace) =>
|
||||
call(
|
||||
'GET',
|
||||
`v1/secrets/effective${
|
||||
repo || workspace === 'shared'
|
||||
? `?${new URLSearchParams({
|
||||
...(repo ? { repo } : {}),
|
||||
...(workspace === 'shared' ? { workspace } : {})
|
||||
})}`
|
||||
: ''
|
||||
}`,
|
||||
CloudSecretsEffectiveResponseSchema,
|
||||
{ kind: 'control', signal }
|
||||
),
|
||||
refreshEnv: async (sandboxId) =>
|
||||
(
|
||||
await call(
|
||||
|
||||
@@ -4,6 +4,7 @@ import { app, ipcMain } from 'electron'
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
CLOUD_SECRET_SCOPES,
|
||||
CLOUD_SECRET_WORKSPACE_MODES,
|
||||
MAX_CLOUD_SECRET_BATCH,
|
||||
type CloudSecretsResult,
|
||||
type CloudSecretsStatus
|
||||
@@ -55,7 +56,10 @@ const BatchRequest = z
|
||||
Object.keys(request.set ?? {}).length + (request.delete?.length ?? 0) <=
|
||||
MAX_CLOUD_SECRET_BATCH
|
||||
)
|
||||
const EffectiveRequest = z.object({ repo: Repo.optional() })
|
||||
const EffectiveRequest = z.object({
|
||||
repo: Repo.optional(),
|
||||
workspace: z.enum(CLOUD_SECRET_WORKSPACE_MODES).optional()
|
||||
})
|
||||
const RefreshRequest = z.object({ runtimeEnvironmentId: z.string().min(1).max(256) })
|
||||
const SaveDesktopKeyRequest = z.object({
|
||||
agent: z.string().refine(isTuiAgent),
|
||||
@@ -144,7 +148,7 @@ export function registerCloudSecretsHandlers(userDataPath: string): void {
|
||||
})
|
||||
ipcMain.handle('cloudSecrets:effective', (_event, raw: unknown) => {
|
||||
const request = EffectiveRequest.safeParse(raw ?? {})
|
||||
return request.success ? attempt(client, (c) => c.effective(request.data.repo)) : invalid
|
||||
return request.success ? attempt(client, (c) => c.effective(request.data.repo, undefined, request.data.workspace)) : invalid
|
||||
})
|
||||
// One desktop-sealed key, unsealed here and sent once to the user's personal Cloud secrets; the
|
||||
// renderer names it (agent + variable) and never sees the value. Each call is one explicit click.
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
CloudSecretBatchResult,
|
||||
CloudSecretTarget,
|
||||
CloudSecretView,
|
||||
CloudSecretWorkspaceMode,
|
||||
CloudSecretsEffective,
|
||||
CloudSecretsResult,
|
||||
CloudSecretsStatus,
|
||||
@@ -27,7 +28,11 @@ export type CloudSecretsApi = {
|
||||
set?: Record<string, string>
|
||||
delete?: string[]
|
||||
}) => Promise<CloudSecretsResult<CloudSecretBatchResult>>
|
||||
effective: (request: { repo?: string }) => Promise<CloudSecretsResult<CloudSecretsEffective>>
|
||||
/** `workspace: 'shared'`: what a workspace shared with the team gets (no personal secrets). */
|
||||
effective: (request: {
|
||||
repo?: string
|
||||
workspace?: CloudSecretWorkspaceMode
|
||||
}) => Promise<CloudSecretsResult<CloudSecretsEffective>>
|
||||
/** Best-effort nudge so a running workspace picks up new values now; the server also does it on write. */
|
||||
refreshEnv: (request: { runtimeEnvironmentId: string }) => Promise<CloudSecretsResult<boolean>>
|
||||
/** Who owns an Orca Cloud workspace and whether teammates share it (control plane only). */
|
||||
|
||||
@@ -127,6 +127,37 @@ export const effective = defineFixture({
|
||||
)
|
||||
})
|
||||
|
||||
export const effectiveShared = defineFixture({
|
||||
width: 760,
|
||||
render: () => (
|
||||
<Frame>
|
||||
<CloudSecretsPane
|
||||
api={fixtureCloudSecretsApi({})}
|
||||
repos={REPOS}
|
||||
people={people}
|
||||
onSetUpAgent={noop}
|
||||
initialTab="effective"
|
||||
initialWorkspaceMode="shared"
|
||||
/>
|
||||
</Frame>
|
||||
)
|
||||
})
|
||||
|
||||
export const effectiveSolo = defineFixture({
|
||||
width: 760,
|
||||
render: () => (
|
||||
<Frame>
|
||||
<CloudSecretsPane
|
||||
api={fixtureCloudSecretsApi({ caller: FIXTURE_SOLO })}
|
||||
repos={REPOS}
|
||||
people={people}
|
||||
onSetUpAgent={noop}
|
||||
initialTab="effective"
|
||||
/>
|
||||
</Frame>
|
||||
)
|
||||
})
|
||||
|
||||
export const effectiveEmpty = defineFixture({
|
||||
width: 760,
|
||||
render: () => (
|
||||
|
||||
@@ -119,15 +119,81 @@ function ScopeTab({
|
||||
)
|
||||
}
|
||||
|
||||
type WorkspaceMode = 'private' | 'shared'
|
||||
|
||||
function WorkspacePicker({
|
||||
value,
|
||||
onChange
|
||||
}: {
|
||||
value: WorkspaceMode
|
||||
onChange: (mode: WorkspaceMode) => void
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const id = useId()
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<Label htmlFor={id} variant="settings" className="shrink-0">
|
||||
{t('cloudSecrets.effective.workspaceLabel', 'Workspace')}
|
||||
</Label>
|
||||
<Select
|
||||
value={value}
|
||||
onValueChange={(next) => (next === 'private' || next === 'shared') && onChange(next)}
|
||||
>
|
||||
<SelectTrigger id={id} size="sm" className="w-52">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="private">
|
||||
{t('cloudSecrets.effective.workspacePrivate', 'Not shared')}
|
||||
</SelectItem>
|
||||
<SelectItem value="shared">
|
||||
{t('cloudSecrets.effective.workspaceShared', 'Shared with your team')}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function EffectiveTab({
|
||||
api,
|
||||
repo
|
||||
repo,
|
||||
mode,
|
||||
inTeam
|
||||
}: {
|
||||
api: CloudSecretsApi
|
||||
repo: string | null
|
||||
mode: WorkspaceMode
|
||||
/** Only team accounts share workspaces, so only they need the shared-workspace note. */
|
||||
inTeam: boolean
|
||||
}): React.JSX.Element {
|
||||
const { effective, reload } = useCloudSecretsEffective(api, repo)
|
||||
return <CloudSecretsEffectiveView effective={effective} onRetry={reload} />
|
||||
const t = useTranslate()
|
||||
const { effective, reload } = useCloudSecretsEffective(api, repo, mode === 'shared')
|
||||
// SEC-5: a shared workspace gets no personal secrets. Say so where a personal value would matter.
|
||||
const personalInPlay =
|
||||
effective.status === 'ready' &&
|
||||
effective.value.secrets.some(
|
||||
(secret) =>
|
||||
secret.scope === 'personal' || secret.shadowed.some((entry) => entry.scope === 'personal')
|
||||
)
|
||||
const note =
|
||||
mode === 'shared'
|
||||
? t(
|
||||
'cloudSecrets.effective.sharedNote',
|
||||
'Workspaces shared with your team don’t get personal secrets, so only shared and repository values are listed.'
|
||||
)
|
||||
: inTeam && personalInPlay
|
||||
? t(
|
||||
'cloudSecrets.effective.privateNote',
|
||||
'Personal values apply only to workspaces you haven’t shared. Once you share one, it gets only shared and repository values.'
|
||||
)
|
||||
: null
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
{note ? <ReadOnlyNotice text={note} /> : null}
|
||||
<CloudSecretsEffectiveView effective={effective} onRetry={reload} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** Orca Cloud secrets by scope, plus which scope wins. Values are write-only. */
|
||||
@@ -137,7 +203,8 @@ export function CloudSecretsPane({
|
||||
people,
|
||||
onSetUpAgent,
|
||||
onAddProject,
|
||||
initialTab = 'personal'
|
||||
initialTab = 'personal',
|
||||
initialWorkspaceMode = 'private'
|
||||
}: {
|
||||
api: CloudSecretsApi
|
||||
repos: readonly CloudSecretRepoChoice[]
|
||||
@@ -146,17 +213,22 @@ export function CloudSecretsPane({
|
||||
/** Opens the app's Add project flow, the way to get a GitHub repository here. */
|
||||
onAddProject?: () => void
|
||||
initialTab?: Tab
|
||||
/** Fixtures: start the effective view on a shared workspace. */
|
||||
initialWorkspaceMode?: WorkspaceMode
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const [tab, setTab] = useState<Tab>(initialTab)
|
||||
// Undefined until the user picks, so a repo list that loads after mount still preselects its first entry.
|
||||
const [pickedRepo, setRepo] = useState<string | null | undefined>(undefined)
|
||||
const [workspaceMode, setWorkspaceMode] = useState<WorkspaceMode>(initialWorkspaceMode)
|
||||
const repo = pickedRepo === undefined ? (repos[0]?.key ?? null) : pickedRepo
|
||||
const repoTabRepo = repo ?? repos[0]?.key ?? null
|
||||
const { effective: callerView } = useCloudSecretsEffective(api, null)
|
||||
const caller = callerView.status === 'ready' ? callerView.value.caller : null
|
||||
// Until the caller is known, keep the Shared tab so the tab row does not shift when it loads.
|
||||
const inTeam = callerView.status === 'loading' || (caller !== null && caller.orgId !== null)
|
||||
// Known team member: personal accounts have no teammates to share a workspace with.
|
||||
const teamCaller = caller !== null && caller.orgId !== null
|
||||
const withViewer: CloudSecretPeople = { ...people, viewerUserId: caller?.userId ?? null }
|
||||
const adminNotice = t(
|
||||
'cloudSecrets.readOnly.shared',
|
||||
@@ -316,10 +388,22 @@ export function CloudSecretsPane({
|
||||
'What a new cloud workspace gets, and which scope each value comes from.'
|
||||
)}
|
||||
</p>
|
||||
{repos.length > 0 ? (
|
||||
<RepoPicker repos={repos} value={repo} onChange={setRepo} allowNone />
|
||||
{repos.length > 0 || teamCaller ? (
|
||||
<div className="flex flex-wrap items-center gap-x-6 gap-y-2">
|
||||
{repos.length > 0 ? (
|
||||
<RepoPicker repos={repos} value={repo} onChange={setRepo} allowNone />
|
||||
) : null}
|
||||
{teamCaller ? (
|
||||
<WorkspacePicker value={workspaceMode} onChange={setWorkspaceMode} />
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
<EffectiveTab api={api} repo={repo} />
|
||||
<EffectiveTab
|
||||
api={api}
|
||||
repo={repo}
|
||||
mode={teamCaller ? workspaceMode : 'private'}
|
||||
inTeam={teamCaller}
|
||||
/>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
||||
@@ -117,6 +117,20 @@ export const FIXTURE_NAMES: Record<string, string> = { u_dana: 'Dana Reyes', u_r
|
||||
|
||||
const never = <T>(): Promise<T> => new Promise<T>(() => {})
|
||||
|
||||
/** What the server answers for a shared workspace: personal values never win or count (SEC-5). */
|
||||
function withoutPersonal(
|
||||
secrets: CloudSecretsEffective['secrets']
|
||||
): CloudSecretsEffective['secrets'] {
|
||||
return secrets.flatMap((secret) => {
|
||||
const others = secret.shadowed.filter((entry) => entry.scope !== 'personal')
|
||||
if (secret.scope !== 'personal') {
|
||||
return [{ ...secret, shadowed: others }]
|
||||
}
|
||||
const [next, ...rest] = others
|
||||
return next ? [{ ...secret, scope: next.scope, hint: next.hint, shadowed: rest }] : []
|
||||
})
|
||||
}
|
||||
|
||||
export function fixtureCloudSecretsApi(options: {
|
||||
caller?: CloudSecretsCaller
|
||||
secrets?: Partial<Record<CloudSecretScope, CloudSecretView[]>>
|
||||
@@ -153,16 +167,20 @@ export function fixtureCloudSecretsApi(options: {
|
||||
deleted: [],
|
||||
errors: []
|
||||
}),
|
||||
effective: () =>
|
||||
effective: ({ workspace }) =>
|
||||
options.pending
|
||||
? never()
|
||||
: ok({
|
||||
caller,
|
||||
workspace: workspace ?? 'private',
|
||||
precedence: {
|
||||
env: ['repo', 'personal', 'org'],
|
||||
agent_key: ['org', 'repo', 'personal']
|
||||
},
|
||||
secrets: options.effective ?? FIXTURE_EFFECTIVE_SECRETS
|
||||
secrets:
|
||||
workspace === 'shared'
|
||||
? withoutPersonal(options.effective ?? FIXTURE_EFFECTIVE_SECRETS)
|
||||
: (options.effective ?? FIXTURE_EFFECTIVE_SECRETS)
|
||||
}),
|
||||
refreshEnv: () => ok(true),
|
||||
saveDesktopKey: ({ envName }) =>
|
||||
|
||||
@@ -173,9 +173,21 @@ export function useCloudSecretList(
|
||||
/** Who the caller is (role gating) and which scope wins per name, optionally for one repo. */
|
||||
export function useCloudSecretsEffective(
|
||||
api: CloudSecretsApi,
|
||||
repo: string | null
|
||||
repo: string | null,
|
||||
/** `true`: answer for a workspace shared with the team, which gets no personal secrets. */
|
||||
shared = false
|
||||
): { effective: Loadable<CloudSecretsEffective>; reload: () => void } {
|
||||
const read = useCallback(() => api.effective(repo ? { repo } : {}), [api, repo])
|
||||
const [effective, , reload] = useLoad<CloudSecretsEffective>(`effective:${repo ?? ''}`, read)
|
||||
const read = useCallback(
|
||||
() =>
|
||||
api.effective({
|
||||
...(repo ? { repo } : {}),
|
||||
...(shared ? { workspace: 'shared' as const } : {})
|
||||
}),
|
||||
[api, repo, shared]
|
||||
)
|
||||
const [effective, , reload] = useLoad<CloudSecretsEffective>(
|
||||
`effective:${shared ? 'shared' : 'private'}:${repo ?? ''}`,
|
||||
read
|
||||
)
|
||||
return { effective, reload }
|
||||
}
|
||||
|
||||
@@ -28009,7 +28009,12 @@
|
||||
"value": "Value",
|
||||
"shadowed": "Overrides",
|
||||
"overrides": "Overrides {{scopes}}",
|
||||
"description": "What a new cloud workspace gets, and which scope each value comes from."
|
||||
"description": "What a new cloud workspace gets, and which scope each value comes from.",
|
||||
"workspaceLabel": "Workspace",
|
||||
"workspacePrivate": "Not shared",
|
||||
"workspaceShared": "Shared with your team",
|
||||
"sharedNote": "Workspaces shared with your team don’t get personal secrets, so only shared and repository values are listed.",
|
||||
"privateNote": "Personal values apply only to workspaces you haven’t shared. Once you share one, it gets only shared and repository values."
|
||||
},
|
||||
"repo": {
|
||||
"label": "Repository",
|
||||
|
||||
@@ -42,7 +42,13 @@ export type CloudSecretBatchResult = z.infer<typeof CloudSecretBatchResponseSche
|
||||
|
||||
const OrgRole = z.enum(['owner', 'admin', 'member']).nullable()
|
||||
|
||||
/** Which workspace the effective view answers for: a shared one gets no personal secrets (SEC-5). */
|
||||
export const CLOUD_SECRET_WORKSPACE_MODES = ['private', 'shared'] as const
|
||||
export type CloudSecretWorkspaceMode = (typeof CLOUD_SECRET_WORKSPACE_MODES)[number]
|
||||
|
||||
export const CloudSecretsEffectiveResponseSchema = z.object({
|
||||
/** Absent from servers before SECRETS-EFFECTIVE-SHARED (they always answer for an unshared workspace). */
|
||||
workspace: z.enum(CLOUD_SECRET_WORKSPACE_MODES).optional(),
|
||||
caller: z.object({
|
||||
userId: z.string().max(256),
|
||||
orgId: z.string().max(256).nullable(),
|
||||
|
||||
Reference in New Issue
Block a user