Skip to content

Commit 0a227fa

Browse files
committed
Auth vfs
1 parent 52d3aeb commit 0a227fa

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

apps/sim/lib/copilot/vfs/workspace-vfs.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ function getStaticComponentFiles(): Map<string, string> {
118118

119119
const latestTools = getLatestVersionTools(toolRegistry)
120120
let integrationCount = 0
121+
122+
const oauthServices = new Map<string, { provider: string; operations: string[] }>()
123+
const apiKeyServices = new Map<string, { params: string[]; operations: string[] }>()
124+
121125
for (const [toolId, tool] of Object.entries(latestTools)) {
122126
const baseName = stripVersionSuffix(toolId)
123127
const service = toolToService.get(toolId) ?? toolToService.get(baseName)
@@ -132,8 +136,39 @@ function getStaticComponentFiles(): Map<string, string> {
132136
const path = `components/integrations/${service}/${operation}.json`
133137
files.set(path, serializeIntegrationSchema(tool))
134138
integrationCount++
139+
140+
if (tool.oauth?.required) {
141+
const existing = oauthServices.get(service)
142+
if (existing) {
143+
existing.operations.push(operation)
144+
} else {
145+
oauthServices.set(service, { provider: tool.oauth.provider, operations: [operation] })
146+
}
147+
} else if (tool.hosting?.apiKeyParam) {
148+
const existing = apiKeyServices.get(service)
149+
if (existing) {
150+
if (!existing.params.includes(tool.hosting.apiKeyParam)) {
151+
existing.params.push(tool.hosting.apiKeyParam)
152+
}
153+
existing.operations.push(operation)
154+
} else {
155+
apiKeyServices.set(service, {
156+
params: [tool.hosting.apiKeyParam],
157+
operations: [operation],
158+
})
159+
}
160+
}
135161
}
136162

163+
files.set(
164+
'environment/oauth-integrations.json',
165+
JSON.stringify(Object.fromEntries(oauthServices), null, 2)
166+
)
167+
files.set(
168+
'environment/api-key-integrations.json',
169+
JSON.stringify(Object.fromEntries(apiKeyServices), null, 2)
170+
)
171+
137172
files.set(
138173
'components/blocks/loop.json',
139174
JSON.stringify(

0 commit comments

Comments
 (0)