0.1.4 • Published 3 years ago

mangrove-reviews v0.1.4

Weekly downloads
122
License
ISC
Repository
gitlab
Last release
3 years ago

Mangrove Client JS Library

Retrieve and submit Open Reviews. Key pair related functions work only within the browser using WebCrypto.

npm

Interface documentation

Retrieve reviews according to different criteria.

import { getReviews } from 'mangrove-reviews'

// Of a particular subject.
const subReviews = await getReviews({ sub: 'https://nytimes.com' })

// Given by a particular user since certain time.
const userReviews = await getReviews({
  kid: '-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEDo6mN4kY6YFhpvF0u3hfVWD1RnDElPweX3U3KiUAx0dVeFLPAmeKdQY3J5agY3VspnHo1p/wH9hbZ63qPbCr6g==-----END PUBLIC KEY-----',
  gt_iat: 1580860800
})

User accounts:

  • generate user accounts / key pairs
  • serialize and deserialize key pair
  • sign reviews with key pair
  • submit reviews

For test submissions which should be deleted later please use https://example.com or geo:0,0?q=<any_name>&u=30 in the sub field.

import {
  generateKeypair,
  keypairToJwk,
  jwkToKeypair,
  signAndSubmitReview
} from 'mangrove-reviews'

const keypair = await generateKeypair()

// Show the private key.
const jwk = await keypairToJwk(keypair)
console.log(jwk)

// Restore key pair from JWK.
const restoredKeypair = await jwkToKeypair(jwk)

// Sign and submit a review (reviews of this example subject are removed from the database).
signAndSubmitReview(keypair, {
  sub: "https://example.com",
  rating: 75,
  opinion: "Great website to be used as an example.",
  metadata: {
    nickname: "docs reader"
  }
})
0.1.4

3 years ago

0.1.3

4 years ago