@httpland/hsts-parser
v1.0.0-beta.1
Published
HTTP Strict Transport Security(HSTS) header field parser
Downloads
2
Maintainers
Readme
hsts-parser
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
| :white_check_mark: | 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