Skip to content

Commit

Permalink
Docs v1.0.4
Browse files Browse the repository at this point in the history
Documentation update for v1.0.4
  • Loading branch information
cak committed Jan 26, 2019
1 parent 9873f17 commit c930c61
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 40 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '1.0.2'
release = '1.0.4'


# -- General configuration ---------------------------------------------------
Expand Down
24 changes: 11 additions & 13 deletions docs/source/cookies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Usage

.. code:: javascript
secureCookie.framework(response, "foo", "bar");
const secureCookie = new blockade.SecureCookie();
secureCookie.framework(response, "foo", "bar");
*Default Set-Cookie HTTP response header:*

Expand All @@ -67,29 +68,26 @@ options:

- ``name`` - set the cookie name *(string, No default value)*
- ``value`` - set the cookie value *(string, No default value)*
- ``path`` - set the Path attribute, e.g. ``path=“/secure`` *(string,
- ``path`` - set the Path attribute, e.g. ``path=“/blockade`` *(string,
default=“/”)*
- ``secure`` - set the Secure flag *(bool, default=True)*
- ``httpOnly`` - set the HttpOnly flag *(bool, default=True)*
- ``sameSite`` - set the SameSite attribute,
e.g. ``SameSite.LAX`` *(bool / enum, options:*
``blockade.SameSite.Strict``, ``blockade.SameSite.Lax`` *or*
``False``, *default=blockade.SameSite.Lax)*
e.g. ``{value: "Strict" }``, ``{value: "Lax" }`` *or*
``False`` *default={value: "Lax" }*
- ``expires`` - set the Expires attribute with the cookie expiration in
hours, e.g. ``expires=1`` *(number / bool, default=False)*


.. _example-3:

**Example:**

.. code:: javascript
const blockade = require("blockade");
const blockade = require("blockade");
const secureCookie = new blockade.SecureCookie({
expires: 1,
sameSite: blockade.SameSite.Strict
});
const secureCookie = new blockade.SecureCookie({
sameSite: { value: "Strict" },
expires: 1
});
secureCookie.framework(response, "foo", "bar");
secureCookie.framework(response, "foo", "bar");
226 changes: 222 additions & 4 deletions docs/source/frameworks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Cookies
Coookies
~~~~~~~~

``ecureCookie.adonis(response, "foo", "bar")``
``ecureCookie.adonis(response, name, value)``


**Example:**
Expand Down Expand Up @@ -138,6 +138,56 @@ Cookies
. . .
Fastify
--------

Headers
~~~~~~~~

``secureHeaders.fastify(reply)``


**Example:**

.. code:: javascript
const fastify = require("fastify")();
const blockade = require("blockade");
const secureHeaders = new blockade.SecureHeaders();
. . .
fastify.addHook("preHandler", async (request, reply) => {
secureHeaders.fastify(reply);
});
. . .
Cookies
~~~~~~~~

``secureCookie.fastify(reply, name, value)``


**Example:**

.. code:: javascript
const fastify = require("fastify")();
const blockade = require("blockade");
const secureCookie = new blockade.SecureCookie();
. . .
fastify.get("/", function(request, reply) {
secureCookie.fastify(reply, "foo", "bar");
reply.send({ blockade: true });
});
. . .
hapi
------

Expand Down Expand Up @@ -308,7 +358,7 @@ Headers
Cookies
~~~~~~~~

``secureCookie.nest(res, 'foo', 'bar')``
``secureCookie.nest(res, name, value)``


**Example:**
Expand All @@ -331,6 +381,124 @@ Cookies
}
}
Polka
--------

Headers
~~~~~~~

``secureHeaders.polka(res)``


**Example:**

.. code:: javascript
const polka = require("polka");
const blockade = require("blockade");
const secureHeaders = new blockade.SecureHeaders();
function headers(req, res, next) {
secureHeaders.polka(res);
next();
}
polka()
.use(headers)
.get("/", (req, res) => {
res.end(`Blockade`);
})
.listen(3000, err => {
if (err) throw err;
console.log(`> Running on localhost:3000`);
});
Cookies
~~~~~~~~

``secureCookie.polka(res, name, value)``


**Example:**

.. code:: javascript
const polka = require("polka");
const blockade = require("blockade");
const secureCookie = new blockade.SecureCookie();
polka()
.get("/", (req, res) => {
secureCookie.polka(res, "foo", "bar");
res.end(`Blockade`);
})
.listen(3000, err => {
if (err) throw err;
console.log(`> Running on localhost:3000`);
});
restify
--------

Headers
~~~~~~~

``secureHeaders.restify(res)``


**Example:**

.. code:: javascript
var restify = require("restify");
const blockade = require("blockade");
const secureHeaders = new blockade.SecureHeaders();
function respond(req, res, next) {
res.send("Blockade");
next();
}
function headers(req, res, next) {
secureHeaders.restify(res);
next();
}
. . .
var server = restify.createServer();
server.pre(headers);
server.get("/", respond);
Cookies
~~~~~~~~

``secureCookie.restify(res, name, value)``


**Example:**

.. code:: javascript
var restify = require("restify");
const blockade = require("blockade");
const secureCookie = new blockade.SecureCookie();
function respond(req, res, next) {
secureCookie.restify(res, "foo", "bar");
res.send("Blockade");
next();
}
. . .
var server = restify.createServer();
server.get("/", respond);
Sails
--------

Expand Down Expand Up @@ -363,7 +531,7 @@ Headers
Cookies
~~~~~~~~

``secureCookie.sails(res, "foo", "bar")``
``secureCookie.sails(res, name, value)``


**Example:**
Expand All @@ -378,4 +546,54 @@ Cookies
secureCookie.sails(res, "foo", "bar");
return res.send("Blockade");
}
};
};
Total.js
---------

Headers
~~~~~~~

``secureHeaders.total(response)``


**Example:**

.. code:: javascript
const blockade = require("blockade");
const secureHeaders = new blockade.SecureHeaders();
exports.install = function() {
ROUTE("/", view_index);
};
function view_index() {
var response = this;
secureHeaders.total(response);
response.view("index");
}
Cookies
~~~~~~~~

``secureCookie.total(response, name, value)``


**Example:**

.. code:: javascript
const blockade = require("blockade");
const secureCookie = new blockade.SecureCookie();
exports.install = function() {
ROUTE("/", view_index);
};
function view_index() {
var response = this;
secureCookie.total(response, "foo", "bar");
response.view("index");
}
38 changes: 17 additions & 21 deletions docs/source/headers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ Additional information
Usage
^^^^^^^

``secureHeaders.framework(response)``
.. code:: javascript
const secureHeaders = new blockade.SecureHeaders();
secureHeaders.framework(response);
**Default HTTP response headers:**

Expand All @@ -99,26 +103,18 @@ Usage
Options
^^^^^^^^

You can toggle the setting of headers with default values by passing an object with ``true`` or ``false`` and override default values by passing a string or policy to the following options:

- ``server`` - set the Server header, e.g. ``Server=“Blockade”``
*(string / bool / Policy, default=False)*
- ``hsts`` - set the Strict-Transport-Security header *(string / bool /
Policy, default=True)*
- ``xfo`` - set the X-Frame-Options header *(string / bool /
Policy, default=True)*
- ``xxp`` - set the X-XSS-Protection header *(string / bool /
Policy, default=True)*
- ``content`` - set the X-Content-Type-Options header *(string / bool /
Policy, default=True)*
- ``csp`` - set the Content-Security-Policy *(string / bool /
Policy, default=False)* \*
- ``referrer`` - set the Referrer-Policy header *(string / bool /
Policy, default=True)*
- ``cache`` - set the Cache-control and Pragma headers *(string / bool
/ Policy, default=True)*
- ``feature`` - set the Feature-Policy header *(SecurePolicies / string
/ bool / Policy, default=False)*
You can toggle the setting of headers with default values by passing an object with ``new blockade.Header().default()`` or ``new blockade.Header().notSet()`` and override default values by passing ``new blockade.Header().set("custom")`` or policy to the following options:

- ``server`` - set the Server header, e.g. ``new blockade.Server().set("Blockade")``
- (default= ``default=Server().notSet()`` )
- ``hsts`` - set the Strict-Transport-Security header - (default= ``HSTS().default()`` )
- ``xfo`` - set the X-Frame-Options header - (default= ``XFO().default()`` )
- ``xxp`` - set the X-XSS-Protection header - (default= ``XXP().default()`` )
- ``content`` - set the X-Content-Type-Options header - (default= ``Content().default()`` )
- ``csp`` - set the Content-Security-Policy - (default= ``CSP().notSet()`` )
- ``referrer`` - set the Referrer-Policy header - (default= ``Referrer().default()`` )
- ``cache`` - set the Cache-control and Pragma headers - (default= ``Cache().default()`` )
- ``feature`` - set the Feature-Policy header - (default= ``Feature().notSet()`` )


**Example:**
Expand Down
7 changes: 6 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ Blockade

Blockade ⚓️ is a lightweight package that adds optional security headers and cookie attributes for Node.js web frameworks.

Security HTTP headers and cookie attributes help enhance the security of your web application by enabling built-in browser security mechanisms.

Supported Node.js web frameworks:
----------------------------------

`AdonisJs <https://adonisjs.com>`__
`AdonisJs <https://adonisjs.com>`__,
`Express <https://expressjs.com>`__,
`Fastify <https://www.fastify.io>`__,
`hapi <https://hapijs.com>`__,
`Koa <https://koajs.com>`__,
`Meteor <https://www.meteor.com>`__,
`Nest <https://nestjs.com>`__,
`Polka <https://github.com/lukeed/polka>`__,
`restify <http://restify.com>`__,
`Sails <https://sailsjs.com>`__,
`Total.js <https://www.totaljs.com>`__

Expand Down
Loading

0 comments on commit c930c61

Please sign in to comment.