DocumentationIntegration

Template render

To integrate the template into the site, add in the needed place of the site's html a tag with the class attribute containing the value lurazon, and also the data-lurazon-template attribute with the value of the template's identifier

<div class="lurazon" data-lurazon-template="6a36a5ae13..." ... ></div>

The loading script must also be added:

<script src="https://template.lurazon.com/scripts/loader.js"></script>

Secure mode

If "Secure mode" is enabled for the site, the template needs the following settings:

Generation token

When declaring the tag in which the template is generated, an additional attribute "data-lurazon-token" must be added, which contains a JWT encoded with the "HS256" algorithm

<div ... data-lurazon-token="eyJhbGciOiJIUzI1..." ></div>

The dictionary encoded in the JWT must contain the keys: "type" with the value "setup" and "site" with the value of the site's identifier. The token's expiration ("exp") is required and must be no more than 3600 seconds ahead, otherwise the token is rejected. We recommend about 15 seconds

JS
PHP
import jwt from 'jsonwebtoken' const setupToken = jwt.sign( { type: 'setup', site: '...' }, process.env.LURAZON_SECRET, { algorithm: 'HS256', expiresIn: 15 } )
use Firebase\JWT\JWT; $setupToken = JWT::encode( [ 'type' => 'setup', 'site' => '...', 'exp' => ( time() + 15 ), ], $_ENV['LURAZON_SECRET'], 'HS256' );

API token

This setting must be set up only when the value "No" is selected for the "Custom API" field in the template

A POST endpoint "/lurazon/template/token" must be created on the domain where the template is generated, returning a JWT encoded with the "HS256" algorithm, for verifying and granting access while the template works. This token must contain the keys: "type" with the value "refresh" and "site" with the value of the site's identifier. The token's expiration ("exp") is required and must be no more than 3600 seconds ahead, otherwise the token is rejected. We recommend about 15 seconds. The template calls this endpoint itself, from the visitor's browser (a POST with an empty JSON body and the site's own cookies), whenever its access runs out. The response must be of the "text" type, not JSON: the status 200 and the token itself in the body

JS
PHP
import jwt from 'jsonwebtoken' const refreshToken = jwt.sign( { type: 'refresh', site: '...' }, process.env.LURAZON_SECRET, { algorithm: 'HS256', expiresIn: 15 } ) res.writeHead(200, { 'Content-Type': 'text/plain' }) res.end(refreshToken)
use Firebase\JWT\JWT; $refreshToken = JWT::encode( [ 'type' => 'refresh', 'site' => '...', 'exp' => ( time() + 15 ), ], $_ENV['LURAZON_SECRET'], 'HS256' ); header('Content-Type: text/plain'); echo $refreshToken;

Skeleton

The skeleton is the template's first frame, built on the template server. The site's server gets the skeleton before it returns the page and must display it inside the template's tag, so the visitor sees what the template looks like right away, before the template is built. As soon as the template is built, it replaces the skeleton in one step. If the template is not built, the loading script removes the skeleton, and the rest of the tag's content stays

If "Secure mode" is enabled for the site, the skeleton is given only for a token

Skeletons are for the "Catalog" kind only: a "Preview" is a panel that appears once something is typed, it has no first frame, and the request for its skeleton is refused

Request

The site's server sends the POST request "https://template.lurazon.com/skeleton" with a JSON body:

"template" - the template's identifier

"path" - the page's path without parameters

"lang" - the page's language: the value of the "data-lurazon-lang" attribute of the template's tag, or, if there is none, of the "lang" attribute of the "html" tag

"options" - only for templates with "Yes" chosen in the "Custom API" field: the same answer the site's backend gives to the settings request of this page. The "range" values of number fields are not taken into account

"token" - only if "Secure mode" is enabled: a JWT encoded with the "HS256" algorithm with the site's secret. The dictionary encoded in the JWT must contain the keys: "type" with the value "skeleton" and "site" with the value of the site's identifier. The token's expiration ("exp") is required and must be no more than 3600 seconds ahead, otherwise the token is rejected. We recommend about 15 seconds

"css" - an optional field: "inline" (the default) - the skeleton's styles come in the answer, "link" - a link to the styles file comes instead

import jwt from 'jsonwebtoken' const Response = await fetch('https://template.lurazon.com/skeleton', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ template: '...', path: '...', lang: '...', token: jwt.sign( { type: 'skeleton', site: '...' }, process.env.LURAZON_SECRET, { algorithm: 'HS256', expiresIn: 15 } ), }), }) const Skeleton = (Response.status === 200 ? await Response.json() : null)

Response

"200" - JSON with the keys "html" (the skeleton) and "css" or "cssUrl". If the page has no skeleton yet, the server builds it first and answers with it

"204" - the skeleton could not be obtained during the request, for example because of load on the service: the page is displayed without it, and the next requests get it as soon as it is ready

"400" - the request is invalid: no "path", an unknown "css" value, no template with this identifier, a template with a custom API without "options", a token of another type, issued for another site, without an expiration or expiring more than 3600 seconds ahead

"403" - access is refused: "Secure mode" is enabled, and there is no token or it is signed not with the site's secret; the site is blocked over an unpaid invoice or is pending deletion

"429" - too many failed requests came from this IP address, so the next ones are temporarily refused

How to display

Display the styles and HTML from the answer inside the template's tag:

<div class="lurazon" data-lurazon-template="..." data-lurazon-token="..."> <style>css from the answer</style> html from the answer </div>

In the "link" mode, instead of the "style" tag add the styles file to the page's "head" tag:

<link rel="stylesheet" href="cssUrl from the answer">

Loading styling

The skeleton's root has the "data-lurazon-skeleton" attribute - by it the loading moment can be styled separately. It also has the "inert" attribute: while the skeleton is on the page, its fields and buttons do not react to the mouse and keyboard

Limits

For templates with "Yes" chosen in the "Custom API" field, every new set of "options" on a page is a new skeleton. Values that change with every request must not be put into "options": for all such templates together the site gets no more than 30 new skeletons per hour, and the other requests get the latest built skeleton of their page

If the template does not appear

Before it is built, the template asks the template server for its settings - the POST request "/setup". With any answer other than 200 the template is not built and its tag stays empty. The answer's code is shown in the browser's console or on its "Network" tab:

"403" - access is refused:

the page's domain is not among the site's domains

the site is blocked over an unpaid invoice or is pending deletion

"Secure mode" is enabled, and the tag has no token

the token has expired (e.g. the page was served from a cache)

the token is signed not with the site's secret

"400" - the request is invalid:

there is no template with such an identifier

the token is signed with the site's secret, but it is of another type

the token was issued for another site

the token has no expiration

the token expires more than 3600 seconds ahead

"429" - too many failed requests:

after 30 failed loads from one IP address within 15 minutes the next ones are refused until those minutes pass

PagesOn this page