csp 0.1.1
csp: ^0.1.1 copied to clipboard

Reads and writes Content Security Policy (CSP) strings.

Pub Package Github Actions CI

Overview #

A package for reading and writing Content Security Policy strings.

Licensed under the Apache License 2.0.

Getting started #

1.Add dependency #

In pubspec.yaml:

dependencies:
  csp: ^0.1.1

2.Use #

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
120
pub points
85%
popularity

Reads and writes Content Security Policy (CSP) strings.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

terrier989@gmail.com

License

Apache 2.0 (LICENSE)

Dependencies

collection, kind, meta

More

Packages that depend on csp