Class: ProjectTokenBuilder

ProjectTokenBuilder(accessKey)

new ProjectTokenBuilder(accessKey)

Builder for encrypted tokens. Provides a way to create secure, reusable tokens that enable particular functionality in the Reflect API while disallowing tampering.
Parameters:
Name Type Description
accessKey string The access key that identifies the project of this token.
Source:

Methods

addParameter(parameter) → {ProjectTokenBuilder}

Adds a data-filtering parameter to this token.
Parameters:
Name Type Description
parameter Object
Source:
Returns:
This token builder.
Type
ProjectTokenBuilder

addViewIdentifier(id) → {ProjectTokenBuilder}

Adds the given view identifier to the list of view identifiers permitted by this token. If no view identifiers are added to this builder, all views in the given access key's project will be able to be loaded. Otherwise, only those added will be able to be loaded.
Parameters:
Name Type Description
id string The view identifier to restrict to.
Source:
Returns:
This token builder.
Type
ProjectTokenBuilder

build(secretKey, callback)

Builds a final copy of the token using the given secret key.
Parameters:
Name Type Description
secretKey string The secret key that corresponds to this builder's access key.
callback ProjectTokenBuilder.buildCallback A callback to invoke with the constructed token when it is ready.
Source:

expiration(when) → {ProjectTokenBuilder}

Sets the expiration for the constructed token to the given time. After this time, the token will no longer be valid. All requests made using an expired token will fail.
Parameters:
Name Type Description
when Date The time at which the token will expire.
Source:
Returns:
This token builder.
Type
ProjectTokenBuilder

setAttribute(name, value)

Sets the given attribute in this token.
Parameters:
Name Type Description
name string The attribute slug.
value * The attribute's value, which must be serializable to JSON.
Source:

Type Definitions

buildCallback(err, token)

Parameters:
Name Type Description
err * If not null, an error indicating why generating the token failed.
token string The generated token.
Source: