a
    é´«jè  ã                   @  sX   d dl mZ d dlmZ d dlZddlmZ dddœdd	„Z	G d
d„ dee
e
f ƒZdS )é    )ÚannotationsNé   )ÚCallbackDictÚstrzt.Any©ÚkeyÚreturnc                   s,   t ‡ fdd„‡ fdd„‡ fdd„dˆ ›�ƒS )z”Return a new property object for a content security policy header.
    Useful if you want to add support for a csp extension in a
    subclass.
    c                   s
   |   ˆ ¡S ©N)Ú
_get_value©Úx©r   © úZ/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/werkzeug/datastructures/csp.pyÚ<lambda>   ó    zcsp_property.<locals>.<lambda>c                   s   |   ˆ |¡S r	   )Ú
_set_value)r   Úvr   r   r   r      r   c                   s
   |   ˆ ¡S r	   )Ú
_del_valuer   r   r   r   r      r   zaccessor for )Úpropertyr   r   r   r   Úcsp_property	   s    


ür   c                      s  e Zd ZU dZedƒZded< edƒZded< edƒZded< ed	ƒZ	ded
< edƒZ
ded< edƒZded< edƒZded< edƒZded< edƒZded< edƒZded< edƒZded< edƒZded< edƒZded< edƒZded< edƒZded < ed!ƒZded"< ed#ƒZded$< ed%ƒZded%< ed&ƒZded'< ed(ƒZded)< ed*ƒZded+< ed,ƒZded-< ed.ƒZded/< ed0ƒZded1< ed2ƒZded3< dLd6d7d8d9œ‡ fd:d;„Zd<dd=œd>d?„Z d<dd8d@œdAdB„Z!d<d8d=œdCdD„Z"d<dEœdFdG„Z#d<dEœdHdI„Z$d<dEœdJdK„Z%‡  Z&S )MÚContentSecurityPolicyaV  Subclass of a dict that stores values for a Content Security Policy
    header. It has accessors for all the level 3 policies.

    Because the csp directives in the HTTP header use dashes the
    python descriptors use underscores for that.

    To get a header of the :class:`ContentSecurityPolicy` object again
    you can convert the object into a string or call the
    :meth:`to_header` method.  If you plan to subclass it and add your
    own items have a look at the sourcecode for that class.

    .. versionadded:: 1.0.0
       Support for Content Security Policy headers was added.

    zbase-uriz
str | NoneÚbase_uriz	child-srcÚ	child_srczconnect-srcÚconnect_srczdefault-srcÚdefault_srczfont-srcÚfont_srczform-actionÚform_actionzframe-ancestorsÚframe_ancestorsz	frame-srcÚ	frame_srczimg-srcÚimg_srczmanifest-srcÚmanifest_srcz	media-srcÚ	media_srcznavigate-toÚnavigate_toz
object-srcÚ
object_srczprefetch-srcÚprefetch_srczplugin-typesÚplugin_typesz	report-toÚ	report_toz
report-uriÚ
report_uriÚsandboxz
script-srcÚ
script_srczscript-src-attrÚscript_src_attrzscript-src-elemÚscript_src_elemz	style-srcÚ	style_srczstyle-src-attrÚstyle_src_attrzstyle-src-elemÚstyle_src_elemz
worker-srcÚ
worker_srcr   Nz>cabc.Mapping[str, str] | cabc.Iterable[tuple[str, str]] | Nonez3cabc.Callable[[ContentSecurityPolicy], None] | NoneÚNone)ÚvaluesÚ	on_updater   c                   s   t ƒ  ||¡ |d u| _d S r	   )ÚsuperÚ__init__Úprovided)Úselfr2   r3   ©Ú	__class__r   r   r5   A   s    zContentSecurityPolicy.__init__r   r   c                 C  s
   |   |¡S )ú+Used internally by the accessor properties.)Úget©r7   r   r   r   r   r
   I   s    z ContentSecurityPolicy._get_value)r   Úvaluer   c                 C  s"   |du r|   |d¡ n|| |< dS ©r:   N)Úpop)r7   r   r=   r   r   r   r   M   s    z ContentSecurityPolicy._set_valuec                 C  s   || v r| |= dS r>   r   r<   r   r   r   r   T   s    z ContentSecurityPolicy._del_value)r   c                 C  s   ddl m} || ƒS )z6Convert the stored values into a cache control header.é   )Údump_csp_header)ÚhttprA   )r7   rA   r   r   r   Ú	to_headerY   s    zContentSecurityPolicy.to_headerc                 C  s   |   ¡ S r	   )rC   )r7   r   r   r   Ú__str___   s    zContentSecurityPolicy.__str__c                 C  s4   d  dd„ t|  ¡ ƒD ƒ¡}dt| ƒj› d|› d�S )Nú c                 s  s    | ]\}}|› d |›�V  qdS )ú=Nr   )Ú.0Úkr   r   r   r   Ú	<genexpr>c   r   z1ContentSecurityPolicy.__repr__.<locals>.<genexpr>ú<ú>)ÚjoinÚsortedÚitemsÚtypeÚ__name__)r7   Zkv_strr   r   r   Ú__repr__b   s    zContentSecurityPolicy.__repr__)r   N)'rP   Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r5   r
   r   r   rC   rD   rQ   Ú__classcell__r   r   r8   r   r      sF   
  ýr   )Ú
__future__r   Úcollections.abcÚabcZcabcÚtypingÚtÚ
structuresr   r   r   r   r   r   r   r   Ú<module>   s
   