a
    0h                     @  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 )zReturn 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    I/var/www/auris/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:`ContentSecuirtyPolicy` 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
   