Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async init(projectDir: string) {
const status = await Doctor.validateWithoutNetworkAsync(projectDir);
if (status !== Doctor.FATAL) {
/* This manager does not need to work in project context */
const { exp } = await readConfigJsonAsync(projectDir);
this._manifest = exp;
this._hasProjectContext = true;
}
this._user = await UserManager.ensureLoggedInAsync();
this._apiClient = ApiV2.clientForUser(this.user);
this._iosApiClient = new IosApi(this._user);
}
}
.asyncActionProjectDir(async (projectDir, options) => {
if (options.count && (isNaN(options.count) || options.count < 1 || options.count > 100)) {
throw new Error('-n must be a number between 1 and 100 inclusive');
}
// TODO(ville): handle the API result for not authenticated user instead of checking upfront
const user = await UserManager.ensureLoggedInAsync();
const { exp } = await readConfigJsonAsync(projectDir);
let result: any;
if (process.env.EXPO_NEXT_API) {
const api = ApiV2.clientForUser(user);
result = await api.postAsync('publish/history', {
owner: exp.owner,
slug: await Project.getSlugAsync(projectDir, options),
version: VERSION,
releaseChannel: options.releaseChannel,
count: options.count,
platform: options.platform,
});
} else {
// TODO(ville): move request from multipart/form-data to JSON once supported by the endpoint.
let formData = new FormData();
formData.append('queryType', 'history');
if (exp.owner) {
formData.append('owner', exp.owner);
}
formData.append('slug', await Project.getSlugAsync(projectDir, options));
.asyncActionProjectDir(async (projectDir: string) => {
const {
args: { remotePackageName },
} = await Exp.getPublishInfoAsync(projectDir);
let user = await UserManager.getCurrentUserAsync();
let apiClient = ApiV2.clientForUser(user);
let result = await apiClient.getAsync(`credentials/push/android/${remotePackageName}`);
if (result.status === 'ok' && result.fcmApiKey) {
console.log(JSON.stringify(result));
} else {
throw new Error('Server returned an invalid result!');
}
}, true);
constructor(user: User) {
this.api = ApiV2.clientForUser(user);
this.credentials = { appCredentials: [], userCredentials: [] };
}
async function createClientBuildRequest({
user = null,
context,
distributionCert,
provisioningProfile,
pushKey,
udids,
addUdid,
email,
bundleIdentifier,
customAppConfig = {},
}) {
return await ApiV2.clientForUser(user).postAsync('client-build/create-ios-request', {
appleTeamId: context.team.id,
appleTeamName: context.team.name,
addUdid,
bundleIdentifier,
email,
customAppConfig,
credentials: {
...(pushKey && pushKey.apnsKeyP8 ? { apnsKeyP8: pushKey.apnsKeyP8 } : null),
...(pushKey && pushKey.apnsKeyId ? { apnsKeyId: pushKey.apnsKeyId } : null),
certP12: distributionCert.certP12,
certPassword: distributionCert.certPassword,
provisioningProfileId: provisioningProfile.provisioningProfileId,
provisioningProfile: provisioningProfile.provisioningProfile,
teamId: context.team.id,
appleSession: context.fastlaneSession,
udidsString: JSON.stringify(udids),
.asyncActionProjectDir(async (projectDir: string) => {
log('Reading project configuration...');
const {
args: { remotePackageName },
} = await Exp.getPublishInfoAsync(projectDir);
log('Logging in...');
const user = await UserManager.getCurrentUserAsync();
const apiClient = ApiV2.clientForUser(user);
log("Deleting API key from Expo's servers...");
await apiClient.deleteAsync(`credentials/push/web/${remotePackageName}`);
}, true);
}
async function _uploadWebPushCredientials(projectDir: string, options: VapidData) {
const isGeneration = !(options.vapidPubkey && options.vapidPvtkey);
log('Reading project configuration...');
const {
args: { remotePackageName },
} = await Exp.getPublishInfoAsync(projectDir);
log('Logging in...');
const user = await UserManager.getCurrentUserAsync();
const apiClient = ApiV2.clientForUser(user);
if (isGeneration) {
log("Generating and setting VAPID keys on Expo's servers...");
} else {
log("Uploading VAPID keys to Expo's servers...");
}
const results = await apiClient.putAsync(`credentials/push/web/${remotePackageName}`, {
vapidPublicKey: options.vapidPubkey,
vapidPrivateKey: options.vapidPvtkey,
vapidSubject: options.vapidSubject,
});
if (results.oldVapidData && results.oldVapidData.vapidPublicKey !== results.vapidPublicKey) {
log(
chalk.yellow(
async fetch(ctx: Context): Promise {
const credentials = await ApiV2.clientForUser(ctx.user).getAsync(
`credentials/android/@${ctx.manifest.owner || ctx.user.username}/${ctx.manifest.slug}`
);
if (credentials && credentials.keystore) {
this.credentials = credentials.keystore;
}
}
.asyncActionProjectDir(async (projectDir: string, options: { apiKey?: string }) => {
if (!options.apiKey || options.apiKey.length === 0) {
throw new Error('Must specify an API key to upload with --api-key.');
}
log('Reading project configuration...');
const {
args: { remotePackageName },
} = await Exp.getPublishInfoAsync(projectDir);
log('Logging in...');
let user = await UserManager.getCurrentUserAsync();
let apiClient = ApiV2.clientForUser(user);
log("Setting API key on Expo's servers...");
await apiClient.putAsync(`credentials/push/android/${remotePackageName}`, {
fcmApiKey: options.apiKey,
});
log('All done!');
}, true);
async function getExperienceName({ user = null, appleTeamId }) {
const { experienceName } = await ApiV2.clientForUser(user).postAsync(
'client-build/experience-name',
{
appleTeamId,
}
);
return experienceName;
}