a ‚oeÒ4ã @s�dZddlZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd l m Z dd l m Z dd l mZdd lmZdd lmZddlmZdd lmZe e¡Zd@eeedœdd„Zeeje ejdœdd„ZdAeee eeedœdd„ZdBe e j e eeedœdd„Z!eeeedœdd„Z"eeeed œd!d"„Z#dCeee ee eeefd#œd$d%„Z$dDeeed'œd(d)„Z%eeddœd*d+„Z&eedd,œd-d.„Z'edd/œd0d1„Z(ee)eedd2œd3d4„Z*eeedœd5d6„Z+dEed7e eeffeegefee eee eefd8œd9d:„Z,eegefeee eefd;œdd?„Z.dS)Fz+Contains UI methods for LE user operations.éN)Úindent)ÚAny)ÚCallable)ÚIterable)ÚList)ÚOptional)ÚTuple)Úerrors)Ú interfaces)Úutil)Úaccount)ÚosFT)ÚinvalidÚoptionalÚreturncCsÀd}d}d}|r(|r"||7}d}q,d}nd}z"tj|r>||n|dd�\}}Wn"tjypd}t |¡‚Yn0|tjkr”|rŠt d¡‚t d ¡‚t |¡r¢|S|r²||}d}t|ƒ}q,d S) aJPrompt for valid email address. :param bool invalid: True if an invalid address was provided by the user :param bool optional: True if the user can use --register-unsafely-without-email to avoid providing an e-mail :returns: e-mail address :rtype: str :raises errors.Error: if the user cancels z-There seem to be problems with that address. zCEnter email address (used for urgent renewal and security notices) a If you really want to skip this, you can run the client with --register-unsafely-without-email but you will then be unable to receive notice about impending expiration or revocation of your certificates or problems with your Certbot installation that will lead to failure to renew. FT©Úforce_interactivezoYou should register before running non-interactively, or provide --agree-tos and --email flags.zHAn e-mail address or --register-unsafely-without-email must be provided.z#An e-mail address must be provided.N) Ú display_utilÚ input_textr ZMissingCommandlineFlagÚOKÚErrorr Z safe_emailÚbool)rrZinvalid_prefixÚmsgZunsafe_suggestionZsuggest_unsafeÚcodeZemail©rú4C:\Program Files\Certbot\pkgs\certbot\display\ops.pyÚ get_emails8 ÿ ÿ  r)ÚaccountsrcCs8dd„|Dƒ}tjd|dd�\}}|tjkr4||SdS)zChoose an account. :param list accounts: Containing at least one :class:`~certbot._internal.account.Account` cSsg|] }|j‘qSr)Zslug)Ú.0ZaccrrrÚ Tóz"choose_account..zPlease choose an accountTrN)rZmenur)rÚlabelsrÚindexrrrÚchoose_accountLs  r#)ÚvaluesÚquestionrcCs2tj|r |nd|dd�\}}|tjkr.|r.|SgS)aDisplay screen to let user pick one or multiple values from the provided list. :param list values: Values to select from :param str question: Question to ask to user while choosing values :returns: List of selected values :rtype: list ÚT)Útagsr)rÚ checklistr)r$r%rÚitemsrrrÚ choose_values\s ÿ r*)Ú installerr%rcCsZ|durt d¡tƒSt| ¡ƒ}t|ƒ}|s6tƒSt||ƒ\}}|tjkrV|rV|SgS)aQDisplay screen to select domains to validate. :param installer: An installer object :type installer: :class:`certbot.interfaces.Installer` :param `str` question: Overriding default question to ask the user if asked to choose from domain names. :returns: List of selected names :rtype: `list` of `str` Nz$No installer, picking names manually) ÚloggerÚdebugÚ_choose_names_manuallyÚlistZ get_all_namesÚget_valid_domainsÚ _filter_namesrr)r+r%ÚdomainsÚnamesrrrrÚ choose_namesms  r4)r2rc Cs@g}|D]2}z| t |¡¡Wqtjy8YqYq0q|S)z¼Helper method for choose_names that implements basic checks on domain names :param list domains: Domain names to validate :return: List of valid domains :rtype: list )Úappendr Úenforce_domain_sanityr ÚConfigurationError)r2Z valid_domainsÚdomainrrrr0‹s r0)ÚFQDNsrcCst|dd„d�S)z¢Sort FQDNs by SLD (and if many, by their subdomains) :param list FQDNs: list of domain names :returns: Sorted list of domain names :rtype: list cSs| d¡ddd…dd…S)NÚ.éÿÿÿÿé)Úsplit)ZfqdnrrrÚ¤r z_sort_names..)Úkey)Úsorted)r9rrrÚ _sort_namesœsrA)r3Úoverride_questionrcCs>t|ƒ}|r|}nd}tj||ddd�\}}|dd„|DƒfS)aDetermine which names the user would like to select from a list. :param list names: domain names :returns: tuple of the form (`code`, `names`) where `code` - str display exit code `names` - list of names selected :rtype: tuple zŠWhich names would you like to activate HTTPS for? We recommend selecting either all domains, or all domains in a VirtualHost/server block.ú --domainsT)r'Úcli_flagrcSsg|] }t|ƒ‘qSr)Ústr)rÚsrrrr¾r z!_filter_names..)rArr()r3rBZ sorted_namesr%rrrrr1§s ÿÿ r1r&)Ú prompt_prefixrc Cs&tj|dddd�\}}|tjk�r"i}d}zt |¡}Wn"ty\g}d tj¡}Yn0t |ƒD]N\}}zt   |¡||<Wqft j y²}zt|ƒ||<WYd}~qfd}~00qf|rüd tj¡}| ¡D]\} } |d  tj| | ¡}qÎ|d  tj¡}|�rtj|dd �} | �r"tƒSn|SgS) zÃManually input names for those without an installer. :param str prompt_prefix: string to prepend to prompt for domains :returns: list of provided names :rtype: `list` of `str` zaPlease enter the domain name(s) you would like on your certificate (comma and/or space separated)rCT)rDrr&ziInternationalized domain names are not presently supported.{0}{0}Would you like to re-enter the names?{0}Nz;r z#_gen_https_names..Nr;z, and https://r&)ÚlenrJÚjoinrRrrrrQ-s    ýrQ.)ÚmethodÚ validatorÚmessageÚdefaultÚkwargsrc KsÚ|durJz ||ƒWn4tjyHtjd||dd�td |¡ƒ‚Yn0||fd|i|¤Ž\}}|tjkrÌz||ƒ||fWStjyÈ}z0tjd||dd�tjt |ƒdd�WYd}~qÔd}~00qJ||fSqJdS) Nz>Encountered invalid default value "%s" when prompting for "%s"T)Úexc_infozInvalid default "{0}"rgz/Validator rejected "%s" when prompting for "%s"F)Zpause) r rr,r-ÚAssertionErrorrJrrZ notificationrE)rdrerfrgrhrÚrawÚerrorrrrÚ_get_validatedBs. ý  ý*rm)reÚargsrhrcOsttj|g|¢Ri|¤ŽS)aLike `~certbot.display.util.input_text`, but with validation. :param callable validator: A method which will be called on the supplied input. If the method raises an `errors.Error`, its text will be displayed and the user will be re-prompted. :param list `*args`: Arguments to be passed to `~certbot.display.util.input_text`. :param dict `**kwargs`: Arguments to be passed to `~certbot.display.util.input_text`. :return: as `~certbot.display.util.input_text` :rtype: tuple )rmrr©rernrhrrrÚvalidated_input_s rpcOsttj|g|¢Ri|¤ŽS)a"Like `~certbot.display.util.directory_select`, but with validation. :param callable validator: A method which will be called on the supplied input. If the method raises an `errors.Error`, its text will be displayed and the user will be re-prompted. :param list `*args`: Arguments to be passed to `~certbot.display.util.directory_select`. :param dict `**kwargs`: Arguments to be passed to `~certbot.display.util.directory_select`. :return: as `~certbot.display.util.directory_select` :rtype: tuple )rmrZdirectory_selectrorrrÚvalidated_directoryns rq)FT)N)N)N)r&)N)/Ú__doc__ZloggingÚtextwraprÚtypingrrrrrrZcertbotr r r Zcertbot._internalr Zcertbot._internal.displayrHZcertbot.compatr Zcertbot.displayrZ getLoggerÚ__name__r,rrErZAccountr#r*Z Installerr4r0rAr1r.rSrUrWÚintr^rQrmrprqrrrrÚs\               6 ÿ  ÿ  ÿÿ 6   þþ  ÿ  ÿ