1.0.0-beta.7 • Published 1 year ago
@klnjs/reporting-endpoints v1.0.0-beta.7
@klnjs/reporting-endpoints
This module provides types and functionality for parsing and stringifying Strict Transport Security (HSTS).
Installation
Install the @klnjs/reporting-endpoints package using your preferred package manager.
npm install @klnjs/reporting-endpointsHow to Use
Importing
Import the module, and optionally the ReportingEndpoints type.
import STS, { type ReportingEndpoints } from '@klnjs/reporting-endpoints'Parsing
Parse a permission policy string into a ReportingEndpoints object with the parse method:
const endpoints = RE.parse('endpoint=https://trusted.com')Stringifying
Serialize a ReportingEndpoints object with the stringify method:
const header = RE.stringify({ endpoint: 'https://trusted.com' })Validation
Parsing validates endpoints and urls. If an invalid endpoint or url is encountered during parsing, a SyntaxError is thrown.
try {
const endpoints = RE.parse('endpoint=invalid-url')
} catch (error) {
console.error(error) // SyntaxError: ReportingEndpoints.parse: invalid url "invalid-url" for endpoint "endpoint"
}1.0.0-beta.7
1 year ago
1.0.0-beta.6
2 years ago
1.0.0-beta.5
2 years ago
1.0.0-beta.4
2 years ago
1.0.0-beta.3
2 years ago