Csp class

Content Security Policy declaration.

The class is immutable.

Constructors

Csp({List<String>? connectSrc, List<String>? defaultSrc, List<String>? fontSrc, List<String>? frameAncestors, List<String>? imgSrc, List<String>? manifestSrc, List<String>? mediaSrc, List<String>? scriptSrc, List<String>? styleSrc, List<String>? navigateTo, String? reportTo, String? reportUri, bool upgradeInsecureRequests = false})
factory
Csp.fromDirectives(Iterable<CspDirective> directives)
Constructs CSP declaration from CspDirective instances.
factory
Csp.fromMap(Map<String, List<String>> directivesMap)
Constructs CSP declaration from the map.
Csp.merge(Iterable<Csp> csps)
Merges CSP declarations.
factory

Properties

directives List<CspDirective>
List of directives sorted by name.
latefinal
directivesMap Map<String, List<String>>
final
hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkSource({required String type, required Uri uri, required Uri? selfUri}) → void
Throws CspViolationError if the action is not allowed.
getAllowedSources({required String type}) List<String>
Returns directives for the type ('connect', 'img', etc.).
isAllowedSource({required String type, required Uri uri, required Uri? selfUri}) bool
Evaluates whether the action is allowed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toSourceString() String
Returns the CSP string.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Properties

allowAny Csp
CSP declaration 'default-src: *'.
final
allowNone Csp
CSP declaration 'default-src: 'none''.
final
allowSelf Csp
CSP declaration 'default-src: 'self''.
final
kind → Kind<Csp>
Kind for serialization (package:kind).
final

Static Methods

parse(String input) Csp
tryParse(String input) Csp?

Constants

none → const String
Keyword "'none'".
self → const String
Keyword "'self'".
typeForScriptSrc → const String
"script-src"
unsafeEval → const String
Keyword "'unsafe-eval'".
unsafeHashes → const String
Keyword "'unsafe-hashes'".
unsafeInline → const String
Keyword "'unsafe-inline'".
wildcard → const String
Keyword "*".