Members
(constant) MAX_RETRY_AFTER
The longest wait a Retry-After header may ask for, in milliseconds.
- Source:
(constant) ORIGINAL_API
The reviewer API behind https://mangrove.reviews
- Source:
(constant) ORIGINAL_FEDIVERSE
The Fediverse bridge behind https://mangrove.reviews
- Source:
(constant) ORIGINAL_SIGNER
The signer behind https://mangrove.reviews
- Source:
Methods
batchAggregate(query, apiopt) → {Promise.<(BatchReturn|null)>}
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. |
Returns:
Batch aggregation data or null if no query params
- Type
- Promise.<(BatchReturn|null)>
(async) claimEquivalence(keypair, sourceSubject, targetSubject, apiopt) → {Promise.<boolean>}
Claim that one subject is equivalent to another. Both subjects must be of one scheme, such as two places or two ISBNs, and the server refuses a claim between two schemes.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
keypair |
Keypair | WebCrypto keypair can be any valid keypair. |
||
sourceSubject |
string | URI of the source subject. |
||
targetSubject |
string | URI of the equivalent target subject, of the scheme of |
||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used for the submission. |
Returns:
Result of the submission.
- Type
- Promise.<boolean>
(async) claimIdentity(keypair, did, apiopt) → {Promise.<boolean>}
Bind the signing key to a decentralized identifier. The server accepts the claim only when the DID document lists the key.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
keypair |
Keypair | WebCrypto keypair whose public key the DID document lists. |
||
did |
string | Identifier of the form did:plc:... or did:web:... |
||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used for the submission. |
Returns:
Result of the submission.
- Type
- Promise.<boolean>
(async) deleteReview(keypair, reviewSignature, apiopt) → {Promise.<boolean>}
Delete an existing review.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
keypair |
Keypair | WebCrypto keypair must be the same keypair used for the original review. |
||
reviewSignature |
string | Signature of the review to delete. |
||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used for the submission. |
Returns:
Result of the submission.
- Type
- Promise.<boolean>
deleteReview(sessionToken, reviewSignature, signerApiopt, apiopt) → {Promise.<SignResponse>}
Delete an existing review.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
sessionToken |
string | Session token from the signer login. |
||
reviewSignature |
string | Signature of the review to delete. |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
api |
string |
<optional> |
ORIGINAL_API | Reviewer API endpoint. |
Returns:
Result of the submission.
- Type
- Promise.<SignResponse>
(async) editReview(keypair, reviewSignature, updates, apiopt) → {Promise.<boolean>}
Edit an existing review with updated content.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
keypair |
Keypair | WebCrypto keypair must be the same keypair used for the original review. |
||
reviewSignature |
string | Signature of the review to edit. |
||
updates |
Object | Object containing fields to update (rating, opinion, images, metadata). |
||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used for the submission. |
Returns:
Result of the submission.
- Type
- Promise.<boolean>
editReview(sessionToken, reviewSignature, updates, signerApiopt, apiopt) → {Promise.<SignResponse>}
Edit an existing review with updated content.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
sessionToken |
string | Session token from the signer login. |
||
reviewSignature |
string | Signature of the review to edit. |
||
updates |
Object | Object containing fields to update (rating, opinion, images, metadata). |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
api |
string |
<optional> |
ORIGINAL_API | Reviewer API endpoint. |
Returns:
Result of the submission.
- Type
- Promise.<SignResponse>
(async) exchangeOsmIdToken(clientId, idToken, signerApiopt) → {Promise.<{sessionToken: string, reviewerId: string, did: ?string}>}
Log in with the ID token of the app's own OpenStreetMap login, so the person
sees one login in all. The app requests the openid scope from OpenStreetMap,
takes id_token from the token response and calls this right away, since the
token expires 120 seconds after the login. The signer accepts the token when
it was issued to the OpenStreetMap client registered for the app, and the
person reaches the same reviewer as through loginUrl with 'osm'.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
clientId |
string | Application client ID registered with the signer. |
||
idToken |
string | The |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
Returns:
The session, as parseCallback returns it after a redirect login. Rejects
with an ApiError of status 401 for a token that fails a check, 400 for an
app without an OpenStreetMap client and 404 for an unknown client id.
- Type
- Promise.<{sessionToken: string, reviewerId: string, did: ?string}>
followUrl(server, actor) → {string}
Build the link that opens the follow dialog on the person's own Mastodon server.
Parameters:
| Name | Type | Description |
|---|---|---|
server |
string | Host of the server the person's account is on, such as |
actor |
string | Actor URL from getFediverseHandle. |
Returns:
URL to open in the browser.
- Type
- string
getAccount(sessionToken, signerApiopt) → {Promise.<Object>}
Get the account behind a session: reviewer_id, public_key, did and
recovery_key when set, provider (osm, bluesky, google, github
or passkey), account_did for a Bluesky login, and account_name, the
account's display name at the provider as of the last login. An account
whose owner linked a MapComplete key on the signer's page /mapcomplete
carries that key as mapcomplete_key, a did:key, and
mapcomplete_revoked_at once they removed it there.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
sessionToken |
string | Session token from the signer login. |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
Returns:
The account.
- Type
- Promise.<Object>
getFediverseHandle(target, bridgeopt) → {Promise.<FediverseHandle>}
Get the Fediverse account of a subject, a reviewer key or an identity, so a person can follow it from Mastodon. The bridge creates the account on the first request. A subject needs no reviews yet. A reviewer's key must have at least one review in the dataset, and an identity a review or a profile. An identity's account posts the reviews of every key bound to it.
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
target |
Object | One of the three fields. Properties
|
||||||||||||||||||
bridge |
string |
<optional> |
ORIGINAL_FEDIVERSE | Fediverse bridge endpoint. |
Returns:
The handle, the acct to display, the actor URL and the display name.
- Type
- Promise.<FediverseHandle>
(async) getIdentity(id, apiopt, freshopt) → {Promise.<Identity>}
Get an identity by its DID or by a verified alias: did, the DID
document, the verified aliases (an at:// handle that resolves to the
DID, an https:// page that contains it) and the source of the document.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
id |
string | A did:plc:... or did:web:... identifier, or an alias
without its scheme, such as |
||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used to fetch the data. |
fresh |
boolean |
<optional> |
false | Ask the sources again instead of the server's cache, when its last resolution is more than a minute old. |
Returns:
The identity. The promise rejects with a
TypeError when id is missing, empty or other than a string.
- Type
- Promise.<Identity>
(async) getIssuer(pem, apiopt) → {Promise.<Issuer>}
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. |
Returns:
Issuer data. The promise rejects with a
TypeError when pem is missing, empty or other than a string.
- Type
- Promise.<Issuer>
(async) getProfile(id, apiopt) → {Promise.<?Profile>}
Retrieve the current profile of an identity: the reviewer details it published last.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
id |
string | A did:plc:... or did:web:... identifier, or a verified alias. |
||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used to fetch the data. |
Returns:
The profile, or null before the identity's first profile.
- Type
- Promise.<?Profile>
getPublicKey(reviewerId, signerApiopt) → {Promise.<Object>}
Get a reviewer's public key and identity: public_key, did and
recovery_key when set. Public; the login behind the account is the
owner's alone, through getAccount.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
reviewerId |
string | Reviewer's unique identifier. |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
Returns:
Object containing the public key.
- Type
- Promise.<Object>
getReviews(query, apiopt) → {Promise.<Reviews>}
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. |
Returns:
Reviews data
- Type
- Promise.<Reviews>
(async) getSubject(uri, apiopt) → {Promise.<Subject>}
Get aggregate information about the review subject. A geo: URI is
escaped with escapeGeoSub first, as in getReviews. The
reviewer API stores geo subjects in the escaped form and refuses a place
name with an unescaped &.
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. |
Returns:
Subject data. The promise rejects with a
TypeError when uri is missing, empty or other than a string.
- Type
- Promise.<Subject>
loginUrl(clientId, redirectUri, provider, signerApiopt, stateopt, handleopt, signupopt) → {string}
Build the URL to redirect the user to for login through the signer.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
clientId |
string | Application client ID (UUID registered with the signer). |
||
redirectUri |
string | URL to redirect back to after login. |
||
provider |
string | Provider name: 'osm', 'bluesky', 'google', 'github' or 'passkey'. A passkey login runs on a page the signer serves and needs no account elsewhere. |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
state |
string |
<optional> |
A random value the app keeps in the browser; the callback returns it, and the app accepts the callback only when the two match. |
|
handle |
string |
<optional> |
For 'bluesky': the person's handle or DID, which chooses their server; without it the login goes to bsky.social. |
|
signup |
boolean |
<optional> |
For 'passkey': open the signer's page on account creation, for an app's sign-up button. The page offers login as well. |
Returns:
Full login URL to redirect the user to.
- Type
- string
manageUrl(optionsopt, signerApiopt) → {string}
The link to the signer's account page, where the person logs in again and manages passkeys, keys, aliases, the recovery key and the link to their own Bluesky identity. The link carries the app's proposals in the fragment and the app's session stays with the app.
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
|||||||||||||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
Returns:
The account page URL.
- Type
- string
parseCallback(url) → {Session}
Extract the session from the OAuth callback redirect. The token is in the URL fragment, which the browser never sends to a server.
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | The full callback URL string from the redirect. |
Returns:
Object with sessionToken, reviewerId, did, state and mapcomplete.
- Type
- Session
(async) publishIdentity(did, apiopt) → {Promise.<{did: string, url: string}>}
Publish a did:plc identity to the PLC directory, so AT Protocol software resolves it. The reviewer server replays the identity's log. Each operation in the log carries its own signature, so any app may call it.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
did |
string | A did:plc identifier. |
||
api |
string |
<optional> |
ORIGINAL_API | API endpoint of the reviewer server. |
Returns:
The DID and its directory URL.
- Type
- Promise.<{did: string, url: string}>
(async) publishProfile(keypair, did, details, apiopt) → {Promise.<boolean>}
Publish the reviewer details of an identity. The server accepts the profile only from a key bound to the DID, and refuses one that repeats the current details. A detail left out, null or empty is cleared.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
keypair |
Keypair | WebCrypto keypair bound to the identity. |
||
did |
string | Identifier of the form did:plc:... or did:web:... |
||
details |
ProfileDetails | The reviewer details. |
||
api |
string |
<optional> |
ORIGINAL_API | API endpoint used for the submission. |
Returns:
Result of the submission.
- Type
- Promise.<boolean>
publishProfile(sessionToken, did, details, signerApiopt, apiopt) → {Promise.<SignResponse>}
Publish the reviewer details of the session's identity. The reviewer server refuses a profile that repeats the current details. A detail left out, null or empty is cleared.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
sessionToken |
string | Session token from the signer login. |
||
did |
string | The session's identity, from the login or |
||
details |
ProfileDetails | The reviewer details. |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
api |
string |
<optional> |
ORIGINAL_API | Reviewer API endpoint. |
Returns:
Result of the submission.
- Type
- Promise.<SignResponse>
(async) rateReview(keypair, reviewSignature, rating, opinionopt, apiopt) → {Promise.<boolean>}
Rate an existing review.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
keypair |
Keypair | WebCrypto keypair can be any valid keypair. |
||
reviewSignature |
string | Signature of the review to rate. |
||
rating |
number | Rating value between 0 and 100. |
||
opinion |
string |
<optional> |
Optional opinion text about the review. |
|
api |
string |
<optional> |
ORIGINAL_API | API endpoint used for the submission. |
Returns:
Result of the submission.
- Type
- Promise.<boolean>
rateReview(sessionToken, reviewSignature, rating, opinionopt, signerApiopt, apiopt) → {Promise.<SignResponse>}
Rate an existing review.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
sessionToken |
string | Session token from the signer login. |
||
reviewSignature |
string | Signature of the review to rate. |
||
rating |
number | Rating value between 0 and 100. |
||
opinion |
string |
<optional> |
Optional opinion text about the review. |
|
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
api |
string |
<optional> |
ORIGINAL_API | Reviewer API endpoint. |
Returns:
Result of the submission.
- Type
- Promise.<SignResponse>
(async) reportAbuseReview(keypair, reviewSignature, reasonopt, apiopt) → {Promise.<boolean>}
Report abuse for an existing review.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
keypair |
Keypair | WebCrypto keypair can be any valid keypair. |
||
reviewSignature |
string | Signature of the review to report. |
||
reason |
string |
<optional> |
Optional reason for the abuse report. |
|
api |
string |
<optional> |
ORIGINAL_API | API endpoint used for the submission. |
Returns:
Result of the submission.
- Type
- Promise.<boolean>
reportAbuseReview(sessionToken, reviewSignature, reasonopt, signerApiopt, apiopt) → {Promise.<SignResponse>}
Report abuse for an existing review.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
sessionToken |
string | Session token from the signer login. |
||
reviewSignature |
string | Signature of the review to report. |
||
reason |
string |
<optional> |
Optional reason for the abuse report. |
|
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
api |
string |
<optional> |
ORIGINAL_API | Reviewer API endpoint. |
Returns:
Result of the submission.
- Type
- Promise.<SignResponse>
request(url, optionsopt, policyopt) → {Promise.<any>}
Fetch a JSON response, or throw an ApiError for a refused request. An empty body, as in a 204 answer, resolves to null.
A request refused with 429 is sent again, up to twice. A read is also sent
again after a 500, 502 or 503. A read is a GET, or a request whose caller
passes read: true.
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string | ||||||||||
options |
object |
<optional> |
Options of |
||||||||
policy |
object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- Promise.<any>
revokeSession(sessionToken, signerApiopt) → {Promise.<null>}
Revoke a session token.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
sessionToken |
string | Session token to revoke. |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
Returns:
Resolves once the session is revoked.
- Type
- Promise.<null>
(async) signAndSubmitReview(keypair, payload, apiopt) → {Promise.<boolean>}
Composition of signReview and submitReview.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
keypair |
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. |
Returns:
Result of the submission
- Type
- Promise.<boolean>
(async) signAndSubmitReview(sessionToken, payload, signerApiopt, apiopt) → {Promise.<SignResponse>}
Sign a review via the signer server and submit it to the reviewer API.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
sessionToken |
string | Session token from the signer login. |
||
payload |
Payload | Review payload to sign. |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
api |
string |
<optional> |
ORIGINAL_API | Reviewer API endpoint. |
Returns:
Result from signing (review is also submitted).
- Type
- Promise.<SignResponse>
(async) signReview(keypair, payload) → {Promise.<string>}
Assembles JWT from base payload, mutates the payload as needed.
Parameters:
| Name | Type | Description |
|---|---|---|
keypair |
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
- Promise.<string>
(async) signReview(sessionToken, payload, signerApiopt) → {Promise.<SignResponse>}
Sign a review payload using the signer server.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
sessionToken |
string | Session token from the signer login. |
||
payload |
Payload | Review payload to sign. |
||
signerApi |
string |
<optional> |
ORIGINAL_SIGNER | Signer API endpoint. |
Returns:
Signed review with JWT, signature, reviewerId, and publicKey.
- Type
- Promise.<SignResponse>
(async) submitReview(jwt, apiopt) → {Promise.<boolean>}
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.
The promise rejects before any request when jwt is not a string of
three dot-separated parts. A missing token then fails in the caller with a
TypeError, where the server would refuse the text undefined.
The JWT goes as the plain-text body of POST /submit. A browser sends that
request without a CORS preflight, and a body holds a review of any allowed
length. A server that lacks that route answers 404 or 405 with an empty
body, and the JWT then goes in the path of PUT /submit/{jwt}. The route
itself answers 404 with a message, such as for an edit of a review the
server lacks, and the promise then rejects.
- Type
- Promise.<boolean>