(obj: unknown)
| 23 | |
| 24 | /** Typeguard to validate AWS STS assume-role output */ |
| 25 | export function isValidAwsStsOutput(obj: unknown): obj is AwsStsOutput { |
| 26 | if (!obj || typeof obj !== 'object') { |
| 27 | return false |
| 28 | } |
| 29 | |
| 30 | const output = obj as Record<string, unknown> |
| 31 | |
| 32 | // Check if Credentials exists and has required fields |
| 33 | if (!output.Credentials || typeof output.Credentials !== 'object') { |
| 34 | return false |
| 35 | } |
| 36 | |
| 37 | const credentials = output.Credentials as Record<string, unknown> |
| 38 | |
| 39 | return ( |
| 40 | typeof credentials.AccessKeyId === 'string' && |
| 41 | typeof credentials.SecretAccessKey === 'string' && |
| 42 | typeof credentials.SessionToken === 'string' && |
| 43 | credentials.AccessKeyId.length > 0 && |
| 44 | credentials.SecretAccessKey.length > 0 && |
| 45 | credentials.SessionToken.length > 0 |
| 46 | ) |
| 47 | } |
| 48 | |
| 49 | /** Throws if STS caller identity cannot be retrieved. */ |
| 50 | export async function checkStsCallerIdentity(): Promise<void> { |
no outgoing calls
no test coverage detected