Global

Members

(constant) ORIGINAL_API

The API of the server used for https://mangrove.reviews

Source:

Methods

batchAggregate(query, apiopt)

Retrieve aggregates for multiple subjects or issuers.

Parameters:
Name Type Attributes Default Description
query Object

Batch query listing identifiers to use for fetching.

Properties
Name Type Attributes Description
subs Array.<string> <optional>

A list of subject URIs to get aggregates for.

pems Array.<string> <optional>

A list of issuer PEM public keys to get aggregates for.

api string <optional>
ORIGINAL_API

API endpoint used to fetch the data.

Source:

cleanPayload(payload) → {Payload}

Check and fill in the review payload so that its ready for signing. See the Mangrove Review Standard for more details. Has to include at least sub and rating or opinion.

Parameters:
Name Type Description
payload Payload

Base Payload to be cleaned, it will be mutated.

Source:
Returns:

Payload ready to sign.

Type
Payload

generateKeypair()

Generate a new user identity, which can be used for signing reviews and stored for later.

Source:
Returns:

ECDSA WebCrypto key pair with privateKey and publicKey

getIssuer(pem, apiopt)

Get aggregate information about the reviewer.

Parameters:
Name Type Attributes Default Description
pem string

Reviewer public key in PEM format.

api string <optional>
ORIGINAL_API

API endpoint used to fetch the data.

Source:

getReviews(query, apiopt)

Retrieve reviews which fulfill the query.

Parameters:
Name Type Attributes Default Description
query Object

Query to be passed to API, see the API documentation for examples.

Properties
Name Type Attributes Description
q string <optional>

Search for reviews that have this string in sub or opinion field.

signature string <optional>

Review with this signature value.

kid string <optional>

Reviews by issuer with the following PEM public key.

iat number <optional>

Reviews issued at this UNIX time.

gt_iat number <optional>

Reviews with UNIX timestamp greater than this.

sub string <optional>

Reviews of the given subject URI.

rating number <optional>

Reviews with the given rating.

opinion string <optional>

Reviews with the given opinion.

limit number <optional>

Maximum number of reviews to be returned.

issuers boolean <optional>

Include aggregate information about review issuers.

maresi_subjects boolean <optional>

Include aggregate information about reviews of returned reviews.

api string <optional>
ORIGINAL_API

API endpoint used to fetch the data.

Source:

getSubject(uri, apiopt)

Get aggregate information about the review subject.

Parameters:
Name Type Attributes Default Description
uri string

URI of the review subject.

api string <optional>
ORIGINAL_API

API endpoint used to fetch the data.

Source:

(async) jwkToKeypair(jwk)

Come back from JWK representation to representation which allows for signing. Import keys which were exported with keypairToJwk.

Parameters:
Name Type Description
jwk

Private JSON Web Key (JWK) to be converted in to a WebCrypto keypair.

Source:

(async) keypairToJwk(keypair)

Exports a keypair to JSON Web Key (JWK) of the private key. JWK is a format which can be then used to stringify and store. You can later import it back with jwkToKeypair.

Parameters:
Name Type Description
keypair

WebCrypto key pair, can be generate with generateKeypair.

Source:

(async) privateToPem(key)

Get PEM represenation of the user "password".

Parameters:
Name Type Description
key

Private WebCrypto key to be exported.

Source:

(async) publicToPem(key)

Get PEM representation of public reviewer identity. This format can be found in the kid field of a Mangrove Review Header.

Parameters:
Name Type Description
key

Public WebCrypto key to be exported.

Source:

(async) signAndSubmitReview(keypair, payload, apiopt)

Composition of signReview and submitReview.

Parameters:
Name Type Attributes Default Description
keypair

WebCrypto keypair, can be generated with generateKeypair.

payload Payload

Base Payload to be cleaned, it will be mutated.

api string <optional>
ORIGINAL_API

API endpoint used to fetch the data.

Source:

(async) signReview(keypair, payload) → {string}

Assembles JWT from base payload, mutates the payload as needed.

Parameters:
Name Type Description
keypair

WebCrypto keypair, can be generated with generateKeypair.

payload Payload

Base Payload to be cleaned, it will be mutated.

Source:
Returns:

Mangrove Review encoded as JWT.

Type
string

submitReview(jwt, apiopt) → {Promise}

Submit a signed review to be stored in the database.

Parameters:
Name Type Attributes Default Description
jwt string

Signed review in JWT format.

api string <optional>
ORIGINAL_API

API endpoint used to fetch the data.

Source:
Returns:

Resolves to "true" in case of successful insertion or rejects with errors.

Type
Promise

Type Definitions

Metadata

Type:
  • Object
Properties:
Name Type Attributes Description
client_id string <optional>

Identity of the client used to leave the review, gets populated if not provided.

nickname string <optional>

Nickname of the reviewer.

given_name string <optional>
family_name string <optional>
age number <optional>
gender string <optional>
is_generated boolean <optional>

Please set this flag to true when automatically generating reviews.

Source:

Payload

Type:
  • Object
Properties:
Name Type Attributes Description
sub string

URI of the review subject.

rating number <optional>

Rating of subject between 0 and 100.

opinion string <optional>

Opinion of subject with at most 500 characters.

iat string <optional>

Unix timestamp of when review was issued, gets filled in automatically if not provided.

images Array.<Object> <optional>

Array of up to 5 images to be included.

images[].src string

Public URL of an image.

images[].label string <optional>

Optional label of an image.

metadata Metadata <optional>

Any Metadata relating to the issuer or circumstances of leaving review. See the Mangrove Review Standard for more.

Source: