Repository: supabase/supabase
File: apps/studio/components/interfaces/Storage/ConnectTablesDialog.tsx (TypeScript)

Code before:
    // Publication name is automatically generated as {bucket.id}_publication
    // Destination name is automatically generated as {bucket.id}_destination

    if (!projectRef) return console.error('Project ref is required')
    if (!sourceId) return toast.error('Source ID is required')

    try {
      const publicationName = `${bucket.id}_publication`
      await createPublication({
        projectRef,
        sourceId,
        name: publicationName,
        tables: values.tables.map((table) => {
          const [schema, name] = table.split('.')
          return { schema, name }
        }),
      })

      const decryptedValues = await getDecryptedValues({
        projectRef,
        connectionString: project?.connectionString,
        ids: Object.entries(wrapperValues)
          .filter(([k, v]) => {
            if (['vault_aws_access_key_id', 'vault_aws_secret_access_key'].includes(k)) return v
          })
          .map((x) => x[1]),
      })

      const warehouseName = bucket.id
      const catalogToken = serviceKey?.api_key ?? ''
      const s3AccessKeyId = decryptedValues[wrapperValues['vault_aws_access_key_id']]
      const s3SecretAccessKey = decryptedValues[wrapperValues['vault_aws_secret_access_key']]
      const s3Region = projectSettings?.region ?? ''

      const protocol = projectSettings?.app_config?.protocol ?? 'https'
      const endpoint =
        projectSettings?.app_config?.storage_endpoint || projectSettings?.app_config?.endpoint
      const catalogUri = getCatalogURI(project?.ref ?? '', protocol, endpoint)
      const namespace = `${bucket.id}_namespace`
      await createNamespace({
        catalogUri,
        warehouse: warehouseName,
        token: catalogToken,
        namespace,
      })

      const icebergConfiguration = {
        projectRef,
        warehouseName,
        namespace,
        catalogToken,

Review comment (security):
I have a heard time reading this, can we:
- Assigns this to its own variable and reference it here. 
- Maybe simplify it to the following? maybe thats worse haha, let me know your thoughts

```suggestion
        ids: Object.entries(wrapperValues)
          .filter(
            ([key, value]) =>
              ['vault_aws_access_key_id', 'vault_aws_secret_access_key'].includes(key) && value
          )
          .map(([, value]) => value),
```

Code after:
    // Publication name is automatically generated as {bucket.id}_publication
    // Destination name is automatically generated as {bucket.id}_destination

    if (!projectRef) return console.error('Project ref is required')
    if (!sourceId) return toast.error('Source ID is required')

    try {
      const publicationName = `${bucket.id}_publication`
      await createPublication({
        projectRef,
        sourceId,
        name: publicationName,
        tables: values.tables.map((table) => {
          const [schema, name] = table.split('.')
          return { schema, name }
        }),
      })

      const keysToDecrypt = Object.entries(wrapperValues)
        .filter(([name]) =>
          ['vault_aws_access_key_id', 'vault_aws_secret_access_key'].includes(name)
        )
        .map(([_, keyId]) => keyId)
      const decryptedValues = await getDecryptedValues({
        projectRef,
        connectionString: project?.connectionString,
        ids: keysToDecrypt,
      })

      const warehouseName = bucket.id
      const catalogToken = serviceKey?.api_key ?? ''
      const s3AccessKeyId = decryptedValues[wrapperValues['vault_aws_access_key_id']]
      const s3SecretAccessKey = decryptedValues[wrapperValues['vault_aws_secret_access_key']]
      const s3Region = projectSettings?.region ?? ''

      const protocol = projectSettings?.app_config?.protocol ?? 'https'
      const endpoint =
        projectSettings?.app_config?.storage_endpoint || projectSettings?.app_config?.endpoint
      const catalogUri = getCatalogURI(project?.ref ?? '', protocol, endpoint)
      const namespace = `${bucket.id}_namespace`
      await createNamespace({
        catalogUri,
        warehouse: warehouseName,
        token: catalogToken,
        namespace,
      })

      const icebergConfiguration = {
        projectRef,
        warehouseName,
        namespace,