1.0.0-beta.7 • Published 11 months ago

@klnjs/reporting-endpoints v1.0.0-beta.7

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@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-endpoints

How 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

11 months ago

1.0.0-beta.6

1 year ago

1.0.0-beta.5

1 year ago

1.0.0-beta.4

1 year ago

1.0.0-beta.3

1 year ago