Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async downloadBuild(url: string, filename: string): Promise {
const { req } = await createRequest('GET', url, this.env.config.getHTTPConfig());
if (!filename) {
req.on('response', res => {
const contentDisposition = res.header['content-disposition'];
filename = contentDisposition ? contentDisposition.split('=')[1] : 'output.bin';
});
}
const tmpFile = tmpfilepath('ionic-package-build');
const ws = fs.createWriteStream(tmpFile);
await download(req, ws, {});
fs.renameSync(tmpFile, filename);
return filename;
}
}
[req]
default_bits = ${bits}
distinguished_name = req_distinguished_name
[req_distinguished_name]
countryName = ${countryName}
stateOrProvinceName = ${stateOrProvinceName}
localityName = ${localityName}
organizationName = ${organizationName}
commonName = ${commonName}
[SAN]
subjectAltName=DNS:${commonName}
`.trim();
const p = tmpfilepath('ionic-ssl');
await writeFile(p, cnf, { encoding: 'utf8' });
return p;
}
}
export async function transformResourceImage(env: IonicEnvironment, resource: ImageResource): Promise {
const { req } = await createRequest('POST', TRANSFORM_URL, env.config.getHTTPConfig());
const tmpDest = tmpfilepath(`ionic-cordova-resources-${resource.name}`);
return new Promise(resolve => {
let errorMarker = false;
const result: ImageResourceTransformResult = { resource, tmpDest };
debug('creating write stream for tmp file: %s', tmpDest);
const tmpfp = fs.createWriteStream(tmpDest)
.on('error', (err: Error) => {
result.error = err;
})
.on('finish', () => {
if (!errorMarker) {
resolve(result);
}
});