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