1import { ExpoConfig } from '@expo/config-types'; 2 3import { getUserState } from './getUserState'; 4 5const ANONYMOUS_USERNAME = 'anonymous'; 6 7/** 8 * Get the owner of the project from the manifest if specified, falling back to a bunch of different things 9 * which may or may not be the owner of the project. 10 * 11 * @deprecated This may not actually be the owner of the project. Prefer to fetch the project owner using 12 * the EAS project ID, falling back to the `owner` field. 13 */ 14export function getAccountUsername(manifest: Pick<ExpoConfig, 'owner'> = {}): string { 15 // TODO: Must match what's generated in Expo Go. 16 const username = 17 manifest.owner || process.env.EXPO_CLI_USERNAME || process.env.EAS_BUILD_USERNAME; 18 if (username) { 19 return username; 20 } 21 // Statically get the username from the global user state. 22 return getUserState().read().auth?.username || ANONYMOUS_USERNAME; 23} 24