Giter Site home page Giter Site logo

kvpk's Introduction

kvpk

key-value for private key

A Cloudflare Worker that allows a Cosmos keypair to store arbitrary data in a KV store. Like the blockchain, all data is publicly readable. This is not a secure storage solution.

Used template for Cosmos wallet authentication to authenticate requests via a Cosmos wallet signature.

Development

Run locally

npm run dev
# OR
wrangler dev --local --persist

Configuration

  1. Copy wrangler.toml.example to wrangler.toml.

  2. Create KV namespaces for production and development:

npx wrangler kv:namespace create NONCES
npx wrangler kv:namespace create NONCES --preview

npx wrangler kv:namespace create DATA
npx wrangler kv:namespace create DATA --preview
  1. Update the binding IDs in wrangler.toml:
kv-namespaces = [
  { binding = "NONCES", id = "<INSERT NONCES_ID>", preview_id = "<INSERT NONCES_PREVIEW_ID>" },
  { binding = "DATA", id = "<INSERT DATA_ID>", preview_id = "<INSERT DATA_PREVIEW_ID>" },
]

Deploy

wrangler publish
# OR
npm run deploy

API

See the authentication template's docs on how to authenticate requests with a Cosmos wallet.

POST /set

The request data for this route must be included in the data field that gets signed in the authentication API described above.

Set a key-value pair in the KV store. Set value to null to delete a key. Any other value will be stored and returned identically.

Request data:

{
  "key": string
  "value": any | null
}

Response:

{
  "success": true
}

POST /setMany

The request data for this route must be included in the data field that gets signed in the authentication API described above.

Set many key-value pairs in the KV store. Set value to null to delete a key. Any other value will be stored and returned identically.

Request data:

{
  "data": {
    "key": string
    "value": any | null
  }[]
}

Response:

{
  "success": true
}

GET /get/:publicKey/:key

Get a value from the KV store. publicKey is a hex-encoded Cosmos public key.

Response:

{
  "key": string
  "value": any | null
}

GET /list/:publicKey/:prefix

List keys with a prefix in the KV store. publicKey is a hex-encoded Cosmos public key.

Response:

{
  "items": Array<{
    "key": string
    "value": any
  }>
}

GET /reverse/:key

Get the list of public keys that have a key-value pair with the given key in the KV store. publicKey in the response is a hex-encoded Cosmos public key.

Response:

{
  "items": Array<{
    "publicKey": string
    "value": any
  }>
}

kvpk's People

Contributors

noahsaso avatar

Stargazers

Interchain Adair avatar

Watchers

Jake Hartnell avatar

Forkers

sissonj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.