(input: S3ConfigInput)
| 287 | }; |
| 288 | |
| 289 | const 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 | |
| 317 | const revalidateStorageSettings = () => { |
| 318 | revalidatePath(settingsPath); |
no test coverage detected