(envs: EncryptedEnvEntry[], kmsEnabled: boolean, appId: string | null)
| 914 | } |
| 915 | |
| 916 | async function encryptEnv(envs: EncryptedEnvEntry[], kmsEnabled: boolean, appId: string | null) { |
| 917 | if (!kmsEnabled || envs.length === 0) { |
| 918 | return undefined; |
| 919 | } |
| 920 | let appIdToUse = appId; |
| 921 | if (!appIdToUse) { |
| 922 | const appCompose = await makeAppComposeFile(); |
| 923 | appIdToUse = await calcAppId(appCompose); |
| 924 | } |
| 925 | const keyBytes = hexToBytes(appIdToUse); |
| 926 | const response = await vmmRpc.getAppEnvEncryptPubKey({ app_id: keyBytes }); |
| 927 | return encryptEnvWithKey(envs, response.public_key); |
| 928 | } |
| 929 | |
| 930 | async function encryptEnvWithKey(envs: EncryptedEnvEntry[], publicKeyBytes: Uint8Array) { |
| 931 | const envsJson = JSON.stringify({ env: envs }); |
no test coverage detected