Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function promptForDistCert(ctx: Context): Promise {
const userProvided = await askForUserProvided(distCertSchema);
if (userProvided) {
try {
userProvided.distCertSerialNumber = IosCodeSigning.findP12CertSerialNumber(
userProvided.certP12,
userProvided.certPassword
);
} catch (error) {
log.warn('Unable to access certificate serial number.');
log.warn('Make sure that certificate and password are correct.');
log.warn(error);
}
return userProvided;
} else {
return null;
}
}
async function getDistributionCertSerialNumber(projectMetadata) {
const { certP12, certPassword } = await fetch(projectMetadata, true);
if (certP12 && certPassword) {
return IosCodeSigning.findP12CertSerialNumber(certP12, certPassword);
} else {
return null;
}
}
async function _calculateMetadata({ certP12, certPassword }) {
if (!(certP12 && certPassword)) {
return null;
}
const distCertSerialNumber = IosCodeSigning.findP12CertSerialNumber(certP12, certPassword);
return { distCertSerialNumber };
}
async function prepareAdHocBuildCredentials(job: IJob) {
if (process.platform !== 'darwin') {
throw new Error('This function should be called only on macOS!');
}
const { bundleIdentifier } = job.config;
const {
certP12,
certPassword,
teamId,
appleSession,
udids,
provisioningProfileId,
} = job.credentials;
const certSerialNumber = IosCodeSigning.findP12CertSerialNumber(certP12, certPassword);
const args = [
...(provisioningProfileId ? ['--profile-id', provisioningProfileId] : []),
teamId,
udids!.join(','),
bundleIdentifier,
certSerialNumber || '__last__',
];
try {
const credentials = await runFastlaneAction(
travelingFastlane.manageAdHocProvisioningProfile,
args,
{ env: { FASTLANE_SESSION: appleSession } },
);
logger.info('New ad hoc provisioning profile successfully created');
function formatDistCert(distCert: IosDistCredentials, credentials: IosCredentials): string {
const appCredentials = credentials.appCredentials.filter(
cred => cred.distCredentialsId === distCert.id
);
const joinApps = appCredentials
.map(i => `${i.experienceName} (${i.bundleIdentifier})`)
.join(', ');
const usedByString = joinApps
? `\n ${chalk.gray(`used by ${joinApps}`)}`
: `\n ${chalk.gray(`not used by any apps`)}`;
let serialNumber = distCert.distCertSerialNumber;
try {
if (!serialNumber) {
serialNumber = IosCodeSigning.findP12CertSerialNumber(
distCert.certP12,
distCert.certPassword
);
}
} catch (error) {
serialNumber = chalk.red('invalid serial number');
}
return `Distribution Certificate (Cert ID: ${distCert.certId}, Serial number: ${serialNumber}, Team ID: ${distCert.teamId})${usedByString}`;
}