Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cogitojs/cogito-encryption

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cogitojs/cogito-encryption

Supports encryption and decryption through the Cogito app

  • 0.3.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

@cogitojs/cogito-encryption

Enables end-to-end encryption between users without having to worry about key management. Encryption keys are stored in the Cogito mobile app on the users' phones. The private keys never leave the user's phone.

Usage

Add @cogitojs/cogito-encryption as a dependency:

$ yarn add cogitojs/cogito-encryption

The example below shows how to use telepath and Cogito Encryption to create a new public/private keypair.

import { Telepath } from '@cogitojs/telepath-js'
import { CogitoKeyProvider } from '@cogitojs/cogito-encryption'

const telepath = new Telepath('https://telepath.cogito.mobi')
const telepathChannel = await telepath.createChannel({ appName: 'Tutorial' })

const keyProvider = new CogitoKeyProvider({ telepathChannel })
const tag = await cogitoKeyProvider.createNewKeyPair()

Each keypair has a unique identifier called a tag. Once a keypair has been created, you can retrieve the public key and use it to encrypt some data:

import { CogitoEncryption } from '@cogitojs/telepath-js'

const publicKey = await cogitoKeyProvider.getPublicKey({ tag })

const encryption = new CogitoEncryption({ telepathChannel })
const cipherText = await encryption.encrypt({
  jsonWebKey: publicKey,
  plainText: 'a secret'
})

You can request decryption by the Cogito mobile app. Note that it is not possible to retrieve the private key. Decryption can only happen by the Cogito mobile app after the user has consented.

const plainText = await encryption.decrypt({ tag, encryptionData: cipherText })

FAQs

Package last updated on 24 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc