'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchPushCertificates = exports.ensureAppId = exports.fetchAppleCertificates = exports.validateCredentialsForPlatform = exports.removeCredentialsForPlatform = exports.updateCredentialsForPlatform = exports.getCredentialsForPlatform = exports.credentialsExistForPlatformAsync = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; let credentialsExistForPlatformAsync = exports.credentialsExistForPlatformAsync = (() => { var _ref = _asyncToGenerator(function* (metadata) { return fetchCredentials(metadata, false); }); return function credentialsExistForPlatformAsync(_x) { return _ref.apply(this, arguments); }; })(); let getCredentialsForPlatform = exports.getCredentialsForPlatform = (() => { var _ref2 = _asyncToGenerator(function* (metadata) { return fetchCredentials(metadata, true); }); return function getCredentialsForPlatform(_x2) { return _ref2.apply(this, arguments); }; })(); let fetchCredentials = (() => { var _ref3 = _asyncToGenerator(function* ({ username, experienceName, bundleIdentifier, platform }, decrypt) { // this doesn't hit our mac rpc channel, so it needs significantly less debugging const { err, credentials } = yield (_Api || _load_Api()).default.callMethodAsync('getCredentials', [], 'post', { username, experienceName, bundleIdentifier, platform, decrypt }); if (err) { throw new Error('Error fetching credentials.'); } return credentials; }); return function fetchCredentials(_x3, _x4) { return _ref3.apply(this, arguments); }; })(); let updateCredentialsForPlatform = exports.updateCredentialsForPlatform = (() => { var _ref4 = _asyncToGenerator(function* (platform, newCredentials, metadata) { // this doesn't go through the mac rpc, no request id needed const { err, credentials } = yield (_Api || _load_Api()).default.callMethodAsync('updateCredentials', [], 'post', _extends({ credentials: newCredentials, platform }, metadata)); if (err || !credentials) { throw new Error('Error updating credentials.'); } return; }); return function updateCredentialsForPlatform(_x5, _x6, _x7) { return _ref4.apply(this, arguments); }; })(); let removeCredentialsForPlatform = exports.removeCredentialsForPlatform = (() => { var _ref5 = _asyncToGenerator(function* (platform, metadata) { // doesn't go through mac rpc, no request id needed const { err } = yield (_Api || _load_Api()).default.callMethodAsync('deleteCredentials', [], 'post', _extends({ platform }, metadata)); if (err) { throw new Error('Error deleting credentials.'); } return; }); return function removeCredentialsForPlatform(_x8, _x9) { return _ref5.apply(this, arguments); }; })(); let validateCredentialsForPlatform = exports.validateCredentialsForPlatform = (() => { var _ref6 = _asyncToGenerator(function* (platform, validationType, credentials, metadata) { const { requestId, isValid, error, errorCode, errorMessage } = yield (_Api || _load_Api()).default.callMethodAsync('validateCredentials', [], 'post', _extends({ credentials, platform, validationType }, metadata)); if (!isValid || error) { throw new (_XDLError || _load_XDLError()).default(errorCode, `Unable to validate credentials. Request ID ${requestId}, message: ${errorMessage}`); } return; }); return function validateCredentialsForPlatform(_x10, _x11, _x12, _x13) { return _ref6.apply(this, arguments); }; })(); let fetchAppleCertificates = exports.fetchAppleCertificates = (() => { var _ref7 = _asyncToGenerator(function* (metadata) { const { requestId, err, success, error, errorCode, errorMessage } = yield (_Api || _load_Api()).default.callMethodAsync('fetchAppleCertificates', [], 'post', _extends({}, metadata)); if (err || !success || error) { throw new (_XDLError || _load_XDLError()).default(errorCode, `Unable to fetch distribution certificate. Request ID ${requestId}, message: ${errorMessage}`); } return success; }); return function fetchAppleCertificates(_x14) { return _ref7.apply(this, arguments); }; })(); let ensureAppId = exports.ensureAppId = (() => { var _ref8 = _asyncToGenerator(function* (metadata) { const { requestId, err, success, errorCode, errorMessage } = yield (_Api || _load_Api()).default.callMethodAsync('ensureAppId', [], 'post', _extends({}, metadata)); if (err || !success) { throw new (_XDLError || _load_XDLError()).default(errorCode, `Unable to create app id. Request ID ${requestId}, message: ${errorMessage}`); } return success; }); return function ensureAppId(_x15) { return _ref8.apply(this, arguments); }; })(); let fetchPushCertificates = exports.fetchPushCertificates = (() => { var _ref9 = _asyncToGenerator(function* (metadata) { const result = yield (_Api || _load_Api()).default.callMethodAsync('fetchPushCertificates', [], 'post', _extends({}, metadata)); if (result.err || !result.success) { throw new (_XDLError || _load_XDLError()).default(result.errorCode, `Unable to fetch push certificate. Request ID ${result.requestId}, message: ${result.errorMessage}`); } return result.success; }); return function fetchPushCertificates(_x16) { return _ref9.apply(this, arguments); }; })(); var _Api; function _load_Api() { return _Api = _interopRequireDefault(require('./Api')); } var _XDLError; function _load_XDLError() { return _XDLError = _interopRequireDefault(require('./XDLError')); } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } //# sourceMappingURL=__sourcemaps__/Credentials.js.map