@oyenjs/eventsource

5.0.0 • Public • Published

@oyenjs/eventsource

License: MIT

Description

Eventsource library with support for automatic encryption and decryption of messages for naive end-to-end encryption with an oob pre-shared key

Currently under active development.

Example

import {
  createAesCbcDecoder,
  createAesCbcEncoder,
  OyenEventSource,
  OyenEventTarget,
} from '@oyenjs/eventsource';

const teamId = 'example';
const eventSourceId = 'abcd12345';
const accessToken = 'e30.e30....';

const channel = 'test';

const myTopSecretKey = crypto.getRandomValues(new Uint8Array(32));

const source = new OyenEventSource({
  teamId,
  eventSourceId,
  channels: [channel],
  accessToken,
}).addDecoder('cipher+aes-256-cbc', createAesCbcDecoder(myTopSecretKey));

const target = new OyenEventTarget({
  teamId,
  eventSourceId,
}).addEncoder('cipher+aes-256-cbc', createAesCbcEncoder(myTopSecretKey));

const secretMessage = '👋';

const [, received] = await Promise.all([
  target.publish({
    ch: channel,
    d: {
      secretMessage,
    },
    enc: 'json',
  }),
  source.once(),
]);

console.log('received:', received); //  { ch: 'test', secretMessage: '👋' }

License

Licensed under the terms of the MIT license. See the LICENSE file for more details.

Readme

Keywords

none

Package Sidebar

Install

npm i @oyenjs/eventsource

Weekly Downloads

22

Version

5.0.0

License

MIT

Unpacked Size

41.9 kB

Total Files

31

Last publish

Collaborators

  • block65-bot
  • maxholman