Members
(constant) ORIGINAL_API
The API of the server used for https://mangrove.reviews
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
|
||||||||||||||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used to fetch the data. |
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. |
Returns:
Payload ready to sign.
- Type
- Payload
generateKeypair()
Generate a new user identity, which can be used for signing reviews and stored for later.
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. |
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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used to fetch the data. |
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. |
(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. |
(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 |
(async) privateToPem(key)
Get PEM represenation of the user "password".
Parameters:
Name | Type | Description |
---|---|---|
key |
Private WebCrypto key to be exported. |
(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. |
(async) signAndSubmitReview(keypair, payload, apiopt)
Composition of signReview
and submitReview
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
keypair |
WebCrypto keypair, can be generated with |
|||
payload |
Payload | Base Payload to be cleaned, it will be mutated. |
||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used to fetch the data. |
(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 |
|
payload |
Payload | Base Payload to be cleaned, it will be mutated. |
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. |
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> |
|
experience_context |
string |
<optional> |
Should be one of common contexts
in which the reviewer primarly had experience with the subject:
|
is_personal_experience |
boolean |
<optional> |
Please set this flag to |
is_affiliated |
boolean |
<optional> |
Please set this flag to |
is_generated |
boolean |
<optional> |
Please set this flag to |
data_source |
string |
<optional> |
Please provide the source of the review if the review does not originate from the author. |
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. |