@httpland/hsts-parser
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.1 • Public • Published

hsts-parser

deno land deno doc GitHub release (latest by date) codecov GitHub

test NPM

HTTP Strict Transport Security(HSTS) header field parser.

Compliant with RFC 6797, 6.1. Strict-Transport-Security HTTP Response Header Field.

Strict Transport Security

StrictTransportSecurity is a structured object of Strict-Transport-Security header .

Name Type Required Description
maxAge number The number of seconds, after the reception of the STS header field, during which the UA regards the host.
includeSubDomains boolean - Whether the rule applies to all subdomains or not.
preload boolean - Whether the domain do preload or not.

Serialization

Serializes Strict Transport Security into string.

import { stringify } from "https://deno.land/x/hsts_parser@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(
  stringify({
    maxAge: 60 * 60 * 24 * 180,
    includeSubDomains: true,
    preload: true,
  }),
  "max-age=15552000; includeSubDomains; preload",
);

Throwing error

Throws TypeError if Strict Transport Security contains errors.

import { stringify } from "https://deno.land/x/hsts_parser@$VERSION/mod.ts";
import { assertThrows } from "https://deno.land/std/testing/asserts.ts";

assertThrows(() => stringify({ maxAge: NaN }));

License

Copyright © 2023-present httpland.

Released under the MIT license

Package Sidebar

Install

npm i @httpland/hsts-parser

Weekly Downloads

7

Version

1.0.0-beta.1

License

MIT

Unpacked Size

78.9 kB

Total Files

44

Last publish

Collaborators

  • miyauci