Skip to content

Test Frontend API

L. Le Meur edited this page Jun 18, 2020 · 8 revisions

In brief

The Test Frontend is split into two parts:

  • A server part written in Go, which act as a middleware between a user interface and the License Server.
  • A client part written in Typescript and React, which is a pure user interface.

The Test Frontend Server offer a set of REST methods which are used by the client part, but may also be used by any other REST client:

  • Create, update, list and delete users.
  • Create, update, list and delete encrypted publications.
  • Let a user acquire a publication.
  • Let a user generate and fetch a license or a protected publication.
  • Fetch an up-to-date license by its identifier.

For each publication, the frontend stores:

  • Identifier
  • Title

For each customer, the frontend stores:

  • Identifier
  • Email
  • Name
  • Hash of the passphrase

API

Fetch an existing license

GET <FrontBaseURL>/api/v1/licenses/<license_id>

Return:

This method calls the License Server with a request for an existing license.

Fetch a protected publication using a license identifier

GET <FrontBaseURL>/api/v1/licenses/<license_id>/publication

Return:

This method calls the License Server with a request for an existing licensed publication.

Post a publication to the server

POST <FrontBaseURL>/publicationUpload

Query Parameter: title: the title of the publication. This title should no already exist in the database.

Payload: A multipart message, with a unique key named "file" and a binary value which is the content of the un-encrypted publication.

An equivalent curl command is of the form:
curl --location --request POST 'http://<server-ip>:8991/publicationUpload?title=publication-title'
--form 'file=@/<path>/<file-name.epub>'

Return:

  • 200 ok
  • 400 (bad request)

This method encrypts the publication and notifies the License Server, which stores the encrypted publication in its final storage location.