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gB,6BAA6B,GAGrD,MAAM,gCAEN,MAAM,EAAM,CACV,KAAK,EAAA,KAAA,cAAS,GACd,MAAM,EAAA,KAAA,cAAS,IAKjB,OAHI,EAAQ,cAAc,EAAkB,IAAK,EAAA,KAAA,cAAS,YAAA,iBACtD,EAAQ,YAAY,EAAgB,OAAS,YAAA,gBAE1C,CACT,CAEA,SAAgB,kBAAkB,GAChC,OAAO,EAAA,KAAA,aAAO,EAAA,YAAA,eAAc,EAAQ,mBACtC,CAEA,SAAgB,oBACd,OAAO,EAAA,KAAA,aAAQ,YAAA,WACjB,CAEA,SAAgB,aAAa,GAC3B,OAAO,EAAA,KAAA,SAAG,EAAA,YAAA,eAAc,GAAS,CAAE,OAAO,EAAM,WAAW,GAC7D","file":"/npm/@expo/devcert@1.2.2/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /npm/@expo/devcert@1.2.2/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { rmSync as rm, readFileSync as readFile, readdirSync as readdir, existsSync as exists } from 'fs';\nimport createDebug from 'debug';\nimport {\n  isMac,\n  isLinux,\n  isWindows,\n  pathForDomain,\n  domainsDir,\n  rootCAKeyPath,\n  rootCACertPath,\n  VALID_DOMAIN,\n  VALID_IP\n} from './constants';\nimport currentPlatform from './platforms';\nimport { commandExists } from './utils';\nimport installCertificateAuthority, { ensureCACertReadable, uninstall } from './certificate-authority';\nimport generateDomainCertificate from './certificates';\nimport UI, { UserInterface } from './user-interface';\nexport { uninstall };\n\nconst debug = createDebug('devcert');\n\nexport interface Options /* extends Partial<ICaBufferOpts & ICaPathOpts>  */{\n  /** Return the CA certificate data? */\n  getCaBuffer?: boolean;\n  /** Return the path to the CA certificate? */\n  getCaPath?: boolean;\n  /** If `certutil` is not installed already (for updating nss databases; e.g. firefox), do not attempt to install it */\n  skipCertutilInstall?: boolean,\n  /** Do not update your systems host file with the domain name of the certificate */\n  skipHostsFile?: boolean,\n  /** User interface hooks */\n  ui?: UserInterface\n}\n\ninterface ICaBuffer {\n  ca: Buffer;\n}\ninterface ICaPath {\n  caPath: string;\n}\ninterface IDomainData {\n  key: Buffer;\n  cert: Buffer;\n}\ntype IReturnCa<O extends Options> = O['getCaBuffer'] extends true ? ICaBuffer : false;\ntype IReturnCaPath<O extends Options> = O['getCaPath'] extends true ? ICaPath : false;\ntype IReturnData<O extends Options = {}> = (IDomainData) & (IReturnCa<O>) & (IReturnCaPath<O>);\n\n/**\n * Request an SSL certificate for the given app name signed by the devcert root\n * certificate authority. If devcert has previously generated a certificate for\n * that app name on this machine, it will reuse that certificate.\n *\n * If this is the first time devcert is being run on this machine, it will\n * generate and attempt to install a root certificate authority.\n *\n * Returns a promise that resolves with { key, cert }, where `key` and `cert`\n * are Buffers with the contents of the certificate private key and certificate\n * file, respectively\n * \n * If `options.getCaBuffer` is true, return value will include the ca certificate data\n * as { ca: Buffer }\n * \n * If `options.getCaPath` is true, return value will include the ca certificate path\n * as { caPath: string }\n */\nexport async function certificateFor<O extends Options>(domain: string, options: O = {} as O): Promise<IReturnData<O>> {\n  if (VALID_IP.test(domain)) {\n    throw new Error('IP addresses are not supported currently');\n  }\n  if (!VALID_DOMAIN.test(domain)) {\n    throw new Error(`\"${domain}\" is not a valid domain name.`);\n  }\n  debug(`Certificate requested for ${ domain }. Skipping certutil install: ${ Boolean(options.skipCertutilInstall) }. Skipping hosts file: ${ Boolean(options.skipHostsFile) }`);\n\n  if (options.ui) {\n    Object.assign(UI, options.ui);\n  }\n\n  if (!isMac && !isLinux && !isWindows) {\n    throw new Error(`Platform not supported: \"${ process.platform }\"`);\n  }\n\n  if (!commandExists('openssl')) {\n    throw new Error('OpenSSL not found: OpenSSL is required to generate SSL certificates - make sure it is installed and available in your PATH');\n  }\n\n  let domainKeyPath = pathForDomain(domain, `private-key.key`);\n  let domainCertPath = pathForDomain(domain, `certificate.crt`);\n\n  if (!exists(rootCAKeyPath)) {\n    debug('Root CA is not installed yet, so it must be our first run. Installing root CA ...');\n    await installCertificateAuthority(options);\n  } else if (options.getCaBuffer || options.getCaPath) {\n    debug('Root CA is not readable, but it probably is because an earlier version of devcert locked it. Trying to fix...');\n    await ensureCACertReadable(options);\n  }\n\n  if (!exists(pathForDomain(domain, `certificate.crt`))) {\n    debug(`Can't find certificate file for ${ domain }, so it must be the first request for ${ domain }. Generating and caching ...`);\n    await generateDomainCertificate(domain);\n  }\n\n  if (!options.skipHostsFile) {\n    await currentPlatform.addDomainToHostFileIfMissing(domain);\n  }\n\n  debug(`Returning domain certificate`);\n\n  const ret = {\n    key: readFile(domainKeyPath),\n    cert: readFile(domainCertPath)\n  } as IReturnData<O>;\n  if (options.getCaBuffer) (ret as ICaBuffer).ca = readFile(rootCACertPath);\n  if (options.getCaPath) (ret as ICaPath).caPath = rootCACertPath;\n\n  return ret;\n}\n\nexport function hasCertificateFor(domain: string) {\n  return exists(pathForDomain(domain, `certificate.crt`));\n}\n\nexport function configuredDomains() {\n  return readdir(domainsDir);\n}\n\nexport function removeDomain(domain: string) {\n  return rm(pathForDomain(domain), { force: true, recursive: true });\n}\n"]}