Socket
Socket
Sign inDemoInstall

fwsp-umf-message

Package Overview
Dependencies
4
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.10 to 0.0.11

9

index.js

@@ -7,3 +7,3 @@ 'use strict';

const UMF_VERSION = 'UMF/1.4.2';
const UMF_VERSION = 'UMF/1.4.3';
const UMF_INVALID_MESSAGE = 'UMF message requires "to", "from" and "body" fields';

@@ -112,2 +112,3 @@

let instance = '';
let subID = '';

@@ -118,2 +119,7 @@ let atPos = urlRoute.indexOf('@');

urlRoute = urlRoute.substring(atPos + 1);
let segments = instance.split('-');
if (segments > 0) {
instance = segments[0];
subID = segments[1];
}
}

@@ -151,2 +157,3 @@

instance,
subID,
serviceName,

@@ -153,0 +160,0 @@ httpMethod,

2

package.json
{
"name": "fwsp-umf-message",
"version": "0.0.10",
"version": "0.0.11",
"description": "umf-message: a tool for creating and working with UMF style messages",

@@ -5,0 +5,0 @@ "author": "Carlos Justiniano",

# UMF Message
Used to create and validate [UMF](https://github.com/cjus/umf) style messages.
## Install
You can install it via NPM:
```shell
$ npm -i fwsp-umf-message
```
## Usage
```javascript
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.
```shell
$ npm test
```
## API
### createMessageID - Returns a UUID for use with messages
```javascript
/**
* @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
```javascript
/**
* @name createShortMessageID
* @summary Returns a short form UUID for use with messages
* @return {string} uuid - UUID
*/
createShortMessageID()
```
### createMessage - Create a UMF style message
```javascript
/**
* @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)
```
### validateMessage - Validates that a UMF message has required fields
```javascript
/**
* @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
```javascript
/**
* @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
```javascript
/**
* @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)
```
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