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, 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< directivesMap)String> > - 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
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 "*".