csp 0.1.1 copy "csp: ^0.1.1" to clipboard
csp: ^0.1.1 copied to clipboard

Reads and writes Content Security Policy (CSP) strings.

example/example.dart

import 'package:csp/csp.dart';

Future<void> main() async {
  // Construct CSP
  var csp = Csp(
    defaultSrc: [Csp.self, 'google.com'],
  );

  // Parse CSP
  final parsedCsp = Csp.parse('default-src: microsoft.com');

  // Merge CSPs
  final mergedCsp = Csp.merge([csp, parsedCsp]);

  // Print CSP
  print(mergedCsp.toSourceString());

  // Throw CspError if the action is invalid
  csp.checkSource(
    type: 'connect',
    uri: Uri.parse('google.com'),
    selfUri: null,
  );
}
0
likes
140
pub points
35%
popularity

Publisher

unverified uploader

Reads and writes Content Security Policy (CSP) strings.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0, BSD-3-Clause (license)

Dependencies

collection, kind, meta

More

Packages that depend on csp