MCPcopy Index your code
hub / github.com/simstudioai/sim / resolveContext

Function resolveContext

apps/sim/connectors/s3/s3.ts:195–210  ·  view source on GitHub ↗

* Resolves AWS credentials and the target bucket from the connector's * sourceConfig and the encrypted secret (delivered as accessToken). When an * `endpoint` is configured it is parsed/validated into an S3Endpoint so * the connector targets an S3-compatible store via path-style addressin

(accessToken: string, sourceConfig: Record<string, unknown>)

Source from the content-addressed store, hash-verified

193 * the connector targets an S3-compatible store via path-style addressing.
194 */
195function resolveContext(accessToken: string, sourceConfig: Record<string, unknown>): S3Context {
196 const accessKeyId = ((sourceConfig.accessKeyId as string) ?? '').trim()
197 const region = ((sourceConfig.region as string) ?? '').trim()
198 const bucket = ((sourceConfig.bucket as string) ?? '').trim()
199 const secretAccessKey = (accessToken ?? '').trim()
200 const rawEndpoint = ((sourceConfig.endpoint as string) ?? '').trim()
201
202 if (!accessKeyId) throw new Error('Missing AWS Access Key ID')
203 if (!secretAccessKey) throw new Error('Missing AWS Secret Access Key')
204 if (!region) throw new Error('Missing AWS region')
205 if (!bucket) throw new Error('Missing S3 bucket name')
206
207 const endpoint = rawEndpoint ? parseEndpoint(rawEndpoint) : undefined
208
209 return { accessKeyId, secretAccessKey, region, bucket, endpoint }
210}
211
212/**
213 * Returns the SigV4 canonical Host header for the request. For AWS this is the

Callers 1

s3.tsFile · 0.85

Calls 1

parseEndpointFunction · 0.85

Tested by

no test coverage detected