Socket
Socket
Sign inDemoInstall

fwsp-umf-message

Package Overview
Dependencies
4
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fwsp-umf-message

umf-message: a tool for creating and working with UMF style messages


Version published
Weekly downloads
418
decreased by-65.2%
Maintainers
2
Install size
2.15 MB
Created
Weekly downloads
 

Readme

Source

UMF Message Build Status

Used to create and validate UMF style messages.

Install

You can install it via NPM:

$ npm -i fwsp-umf-message

Usage

const Utils = require('fwsp-umf-message');
let instanceID = 'fa1ae8d5-86fc-44af-aad8-cd2740aef041';
let msg = UMFMessage.createMessage({
  to: `${instanceID}@test-service:[GET]/v1/somedata`,
  from: 'client:/',
  body: {}
});

Tests

Tests can be found in the specs folder.

$ npm test

API

createMessageID - Returns a UUID for use with messages

/**
  * @name createMessageID
  * @summary Returns a UUID for use with messages
  * @return {string} uuid - UUID
  */
  createMessageID()

createShortMessageID - Returns a short form UUID for use with messages

  /**
  * @name createShortMessageID
  * @summary Returns a short form UUID for use with messages
  * @return {string} uuid - UUID
  */
  createShortMessageID()

createMessage - Create a UMF style message

  /**
  * @name createMessage
  * @summary Create a UMF style message.
  * @description This is a helper function which helps format a UMF style message.
  *              The caller is responsible for ensuring that required fields such as
  *              "to", "from" and "body" are provided either before or after using
  *              this function.
  * @param {object} message - optional message overrides.
  * @param {boolean} shortFormat - optional flag to use UMF short form syntax.
  * @return {object} message - a UMF formatted message.
  */
  createMessage(message, shortFormat=false)

messageToShort - convert a long message to a short one

/**
* @name messageToShort
* @summary convert a long message to a short one
* @param {object} message - message to be converted
* @return {object} converted message
*/
messageToShort(message)

messageToLong - convert a short message to a long one

/**
* @name messageToLong
* @summary convert a short message to a long one
* @param {object} message - message to be converted
* @return {object} converted message
*/
messageToLong(message)

validateMessage - Validates that a UMF message has required fields

  /**
  * @name validateMessage
  * @summary Validates that a UMF message has required fields
  * @param {object} message - UMF formatted message
  * @return {boolean} response - returns true is valid otherwise false
  */
  validateMessage(message)

getMessageBody - Return the body from a UMF message

  /**
  * @name getMessageBody
  * @summary Return the body from a UMF message
  * @param {object} message - UMF message
  * @return {object} body - UMF message body
  */
  getMessageBody(message)

parseRoute - parses message route strings

  /**
   * @name parseRoute
   * @summary parses message route strings
   * @private
   * @param {string} toValue - string to be parsed
   * @return {object} object - containing route parameters. If the
   *                  object contains an error field then the route
   *                  isn't valid.
   */
  parseRoute(toValue)

FAQs

Last updated on 10 Oct 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc