{"version":3,"sources":["Credentials.js"],"names":["async","metadata","fetchCredentials","credentialsExistForPlatformAsync","getCredentialsForPlatform","username","experienceName","bundleIdentifier","platform","decrypt","err","credentials","await","Api","callMethodAsync","Error","newCredentials","updateCredentialsForPlatform","removeCredentialsForPlatform","validationType","requestId","isValid","error","errorCode","errorMessage","validateCredentialsForPlatform","success","fetchAppleCertificates","ensureAppId","result","fetchPushCertificates"],"mappings":";;;;;;;;;;+BAmCOA,WACLC,QADKD,EAEkB;AACvB,WAAOE,iBAAiBD,QAAjBC,EAA2B,KAA3BA,CAAP;AACF,G;;kBAJsBC,gC;;;;;;gCAMfH,WACLC,QADKD,EAEkB;AACvB,WAAOE,iBAAiBD,QAAjBC,EAA2B,IAA3BA,CAAP;AACF,G;;kBAJsBE,yB;;;;;;gCAMtBJ,WACE,EAAEK,QAAF,EAAYC,cAAZ,EAA4BC,gBAA5B,EAA8CC,QAA9C,EADFR,EAEES,OAFFT,EAGyB;AACvB;AACA,UAAM,EAAEU,GAAF,EAAOC,WAAP,KAAuBC,MAAMC,8BAAIC,eAAJD,CAAoB,gBAApBA,EAAsC,EAAtCA,EAA0C,MAA1CA,EAAkD;AACnFR,cADmF;AAEnFC,oBAFmF;AAGnFC,sBAHmF;AAInFC,cAJmF;AAKnFC;AALmF,KAAlDI,CAAnC;;AAQA,QAAIH,GAAJ,EAAS;AACP,YAAM,IAAIK,KAAJ,CAAU,6BAAV,CAAN;AACF;;AAEA,WAAOJ,WAAP;AACF,G;;kBAlBeT,gB;;;;;;gCAoBRF,WACLQ,QADKR,EAELgB,cAFKhB,EAGLC,QAHKD,EAIU;AACf;AACA,UAAM,EAAEU,GAAF,EAAOC,WAAP,KAAuBC,MAAMC,8BAAIC,eAAJD,CAAoB,mBAApBA,EAAyC,EAAzCA,EAA6C,MAA7CA;AACjCF,mBAAaK,cADoBH;AAEjCL;AAFiCK,OAG9BZ,QAH8BY,EAAnC;;AAMA,QAAIH,OAAO,CAACC,WAAZ,EAAyB;AACvB,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;;;gCAsBf3B,WAA2BC,QAA3BD,EAAwE;AAC7E,UAAM;AACJoB,eADI;AAEJV,SAFI;AAGJgB,aAHI;AAIJH,eAJI;AAKJC;AALI,QAMFZ,MAAMC,8BAAIC,eAAJD,CAAoB,aAApBA,EAAmC,EAAnCA,EAAuC,MAAvCA,eACLZ,QADKY,EANV;;AAUA,QAAIH,OAAO,CAACgB,OAAZ,EAAqB;AACnB,YAAM,4CACJH,SADI,EAEH,uCAAsCH,SAAU,cAAaI,YAAa,EAFvE,CAAN;AAIF;;AAEA,WAAOE,OAAP;AACF,G;;kBAnBsBE,W;;;;;;gCAqBf5B,WAAqCC,QAArCD,EAAkF;AACvF,UAAM6B,SAASjB,MAAMC,8BAAIC,eAAJD,CAAoB,uBAApBA,EAA6C,EAA7CA,EAAiD,MAAjDA,eAChBZ,QADgBY,EAArB;;AAIA,QAAIgB,OAAOnB,GAAPmB,IAAc,CAACA,OAAOH,OAA1B,EAAmC;AACjC,YAAM,4CACJG,OAAON,SADH,EAEH,gDAA+CM,OAAOT,SAAU,cAAaS,OAAOL,YAAa,EAF9F,CAAN;AAIF;;AAEA,WAAOK,OAAOH,OAAd;AACF,G;;kBAbsBI,qB;;;;;;;AA3KtB;AAAA;AAAA;;;;AACA;AAAA;AAAA","file":"../Credentials.js","sourcesContent":["/**\n * @flow\n */\n\nimport Api from './Api';\nimport XDLError from './XDLError';\n\nexport type AndroidCredentials = {\n keystore: string,\n keystoreAlias: string,\n keystorePassword: string,\n keyPassword: string,\n};\n\nexport type IOSCredentials = {\n appleId?: string,\n password?: string,\n teamId?: string,\n certP12?: string,\n certPassword?: string,\n pushP12?: string,\n pushPassword?: string,\n provisioningProfile?: string,\n clientExpMadeCerts?: string,\n};\n\nexport type Credentials = IOSCredentials | AndroidCredentials;\n\nexport type CredentialMetadata = {\n username: string,\n experienceName: string,\n bundleIdentifier: string,\n platform: string,\n};\n\nexport async function credentialsExistForPlatformAsync(\n metadata: CredentialMetadata\n): Promise {\n return fetchCredentials(metadata, false);\n}\n\nexport async function getCredentialsForPlatform(\n metadata: CredentialMetadata\n): Promise {\n return fetchCredentials(metadata, true);\n}\n\nasync function fetchCredentials(\n { username, experienceName, bundleIdentifier, platform }: CredentialMetadata,\n decrypt: boolean\n): Promise {\n // this doesn't hit our mac rpc channel, so it needs significantly less debugging\n const { err, credentials } = await Api.callMethodAsync('getCredentials', [], 'post', {\n username,\n experienceName,\n bundleIdentifier,\n platform,\n decrypt,\n });\n\n if (err) {\n throw new Error('Error fetching credentials.');\n }\n\n return credentials;\n}\n\nexport async function updateCredentialsForPlatform(\n platform: string,\n newCredentials: Credentials,\n metadata: CredentialMetadata\n): Promise {\n // this doesn't go through the mac rpc, no request id needed\n const { err, credentials } = await Api.callMethodAsync('updateCredentials', [], 'post', {\n credentials: newCredentials,\n platform,\n ...metadata,\n });\n\n if (err || !credentials) {\n throw new Error('Error updating credentials.');\n }\n\n return;\n}\n\nexport async function removeCredentialsForPlatform(\n platform: string,\n metadata: CredentialMetadata\n): Promise {\n // doesn't go through mac rpc, no request id needed\n const { err } = await Api.callMethodAsync('deleteCredentials', [], 'post', {\n platform,\n ...metadata,\n });\n\n if (err) {\n throw new Error('Error deleting credentials.');\n }\n\n return;\n}\n\nexport async function validateCredentialsForPlatform(\n platform: string,\n validationType: string,\n credentials: ?Credentials,\n metadata: CredentialMetadata\n): Promise {\n const {\n requestId,\n isValid,\n error,\n errorCode,\n errorMessage,\n } = await Api.callMethodAsync('validateCredentials', [], 'post', {\n credentials,\n platform,\n validationType,\n ...metadata,\n });\n\n if (!isValid || error) {\n throw new XDLError(\n errorCode,\n `Unable to validate credentials. Request ID ${requestId}, message: ${errorMessage}`\n );\n }\n\n return;\n}\n\nexport async function fetchAppleCertificates(metadata: CredentialMetadata): Promise {\n const {\n requestId,\n err,\n success,\n error,\n errorCode,\n errorMessage,\n } = await Api.callMethodAsync('fetchAppleCertificates', [], 'post', {\n ...metadata,\n });\n\n if (err || !success || error) {\n throw new XDLError(\n errorCode,\n `Unable to fetch distribution certificate. Request ID ${requestId}, message: ${errorMessage}`\n );\n }\n\n return success;\n}\n\nexport async function ensureAppId(metadata: CredentialMetadata): Promise {\n const {\n requestId,\n err,\n success,\n errorCode,\n errorMessage,\n } = await Api.callMethodAsync('ensureAppId', [], 'post', {\n ...metadata,\n });\n\n if (err || !success) {\n throw new XDLError(\n errorCode,\n `Unable to create app id. Request ID ${requestId}, message: ${errorMessage}`\n );\n }\n\n return success;\n}\n\nexport async function fetchPushCertificates(metadata: CredentialMetadata): Promise {\n const result = await Api.callMethodAsync('fetchPushCertificates', [], 'post', {\n ...metadata,\n });\n\n if (result.err || !result.success) {\n throw new XDLError(\n result.errorCode,\n `Unable to fetch push certificate. Request ID ${result.requestId}, message: ${result.errorMessage}`\n );\n }\n\n return result.success;\n}\n"],"sourceRoot":"/xdl/src"}