MCPcopy Index your code
hub / github.com/CapSoftware/Cap / getS3InputCredentials

Function getS3InputCredentials

apps/web/actions/organization/storage.ts:289–315  ·  view source on GitHub ↗
(input: S3ConfigInput)

Source from the content-addressed store, hash-verified

287};
288
289const getS3InputCredentials = async (input: S3ConfigInput) => {
290 const hasAccessKeyId = input.accessKeyId.trim().length > 0;
291 const hasSecretAccessKey = input.secretAccessKey.trim().length > 0;
292
293 if (hasAccessKeyId && hasSecretAccessKey) {
294 return {
295 accessKeyId: input.accessKeyId,
296 secretAccessKey: input.secretAccessKey,
297 };
298 }
299
300 const existingBucket = await getOrganizationBucket(input.organizationId);
301 if (!existingBucket) {
302 throw new Error("Access key ID and secret access key are required");
303 }
304
305 if (hasAccessKeyId || hasSecretAccessKey) {
306 throw new Error(
307 "Enter both access key ID and secret access key to change credentials",
308 );
309 }
310
311 return {
312 accessKeyId: await decrypt(existingBucket.accessKeyId),
313 secretAccessKey: await decrypt(existingBucket.secretAccessKey),
314 };
315};
316
317const revalidateStorageSettings = () => {
318 revalidatePath(settingsPath);

Callers 2

saveOrganizationS3ConfigFunction · 0.85
testOrganizationS3ConfigFunction · 0.85

Calls 2

decryptFunction · 0.90
getOrganizationBucketFunction · 0.85

Tested by

no test coverage detected