1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const superagent = require("superagent");
|
4 | exports.DEFAULT_HOST = 'https://api.ionicjs.com';
|
5 | function extractDetails(ctx) {
|
6 | const host = ctx.env.get('IONIC_API_HOST', exports.DEFAULT_HOST);
|
7 | const token = ctx.env.require('IONIC_AUTH_TOKEN');
|
8 | return { host, token };
|
9 | }
|
10 | exports.extractDetails = extractDetails;
|
11 | async function getAndroidCredentials(ctx, appId, profileTag) {
|
12 | const { host, token } = extractDetails(ctx);
|
13 | const url = `${host}/apps/${appId}/profiles/${profileTag}/credentials/android`;
|
14 | const req = superagent.get(url).set('Authorization', `Bearer ${token}`);
|
15 | return tryRequest(ctx, req, `Error retrieving app signing credentials.`);
|
16 | }
|
17 | exports.getAndroidCredentials = getAndroidCredentials;
|
18 | async function tryRequest(ctx, req, errorMsg) {
|
19 | try {
|
20 | const res = await req;
|
21 | return res.body;
|
22 | }
|
23 | catch (e) {
|
24 | ctx.serverlog.error(e);
|
25 | if (errorMsg) {
|
26 | ctx.userlog.error(errorMsg);
|
27 | }
|
28 | throw e;
|
29 | }
|
30 | }
|