libubsub 0.1.6
Library to support common ubsub functionality and authentication
Name | Type | Description | |
---|---|---|---|
userId | string |
- the user or token id | |
userKey | string |
- the user key or token key | |
options | object |
- {routerHost}, override default router |
object
The API client object
string
The base URL to the router
string
The userId/tokenId the API is currently using
object
user object for current token/user id
Retrieves the topic for the given id
Name | Type | Description | |
---|---|---|---|
id | string |
- Topic id |
object
topic object
Get all topic objects
array
List of all topic objects
Retrieve a topic by looking for its id first, and fail that, comparing to its name
Name | Type | Description | |
---|---|---|---|
idOrName | string |
- Topic id or name |
object
topic - Single topic
Get all templates associated with the user
object
Template
Create a new topic. Will fail on name collision
Name | Type | Description | |
---|---|---|---|
name | string |
- Name of the topic to create | |
key | Boolean_string |
- True if want key, false if not key, or string for specific key |
object
Topic
Delete a topic
Name | Type | Description | |
---|---|---|---|
id | string |
- Delete topic by id |
object
Deletion object
Retrieve template object with id
Name | Type | Description | |
---|---|---|---|
id | string |
- Id of template |
object
Template
Create a new template
Name | Type | Description | |
---|---|---|---|
name | string |
- Name of the template | |
language | string |
- Language of template. See /docs/languages for valid types | |
source | string |
- Source of template |
object
The template object
Update information on template
Name | Type | Description | |
---|---|---|---|
id | string |
- Id of template to update | |
{name, language, source} | object |
- Optional pieces to update for template |
object
template
Helper method to update a template, or create if it doesn't exist
Name | Type | Description | |
---|---|---|---|
{id, name, language, source} | object |
object
template
array
Returns list of all tokens present
Create a new token
Name | Type | Description | |
---|---|---|---|
name | string |
- Name of token to create | |
scope | string |
- Scope of token | |
clientId | string |
- ClientId the token can be used for |
object
The token
Get events given search options
Name | Type | Description | |
---|---|---|---|
searchOpts | object |
- Search options |
array
events
Create middleware that validates X-Router-Signature
Name | Type | Description | |
---|---|---|---|
appDomain | string |
- Expected app domain of the JWT to pass validation (usually the domain the request is sent o) | |
additionalVerifyOpts | object |
- additional options to pass verifier | |
routerUrl=config.ROUTER_URL | string |
Optional override for router url | Optional |
expressMiddleware
Returns a new middleware to be used in express
Middleware that will validate signature hash against the req.body
This will make sure that nothing has changed since the router has sent the payload
MUST be run after the validateSignature
middleware
expressMiddleware
Returns a middleware that validatesreq.routerSignaure.hash
against the body
Class to vlidate a token in UbSub's header X-Router-Signature
against the router's public certificate
Public certificate is automatically retrieved and cached Future retrievals will be pre-fetched to minimize any interruptions
Void
Name | Type | Description | |
---|---|---|---|
verifyOpts | object |
- Arguments passed to the JWT verifier | |
routerUrl | string |
- Override the default router_url | |
routerIssuer | string |
- The expected issuer of the JWT |
Signature
- A new instance of this class
Retrieves the public key from the router
Will also have memoized function getCachedPublicKey
string
The router's public key
Returns a promise in resolve/reject that respects the validity of the JWT
Name | Type | Description | |
---|---|---|---|
token | string |
- The JWT to validate |
promise
Either the parsed body of the JWT payload, or a rejection on failure
Create a new streaming client for a given user or token
Name | Type | Description | |
---|---|---|---|
userId | string |
- User or token ID | |
userKey | string |
- User or token key | |
ubsubOpts | object |
- Optional arguments to override streaming defaults { socketHost, routerHost, reconnectOnError, reconnectOnErrorDelay } |
object
functions to be used with the given config
Listen to a given topic and pipe events through a callback
Name | Type | Description | |
---|---|---|---|
topicId | string |
- the ID of the topic to listen to | |
onEvent | function |
- Function callback when event received (payload, metadata) |
object
the SocketIO socket
Provide a function to quickly pipe events into an ubsub topic
Name | Type | Description | |
---|---|---|---|
topicId | string |
- the topicId to post to | |
topicKey | string |
- Optional topic key |
function
Returns a function that can be called with an object and posted to an ubsub socket
Create a forwarding-stream that moves events from a socket to a HTTP endpoint
Name | Type | Description | |
---|---|---|---|
topicId | string |
- ID of the topic to listen to | |
forwardUrl | string |
- HTTP url to forward events to | |
httpOpts | object |
- Optional additional httpOpts to send axios |
object
The socket used to listen
Send an event to a topic
Name | Type | Description | |
---|---|---|---|
topicId | string |
- Topic to send to | |
key | string |
- Topic key to authenticate against | |
data | object |
- Data to send to the topic | |
method="POST" | String |
What method to send to the topic with | Optional |
promise
Axios promise
Gets a new API client based on the current user id and key
Client
API Client
Documentation generated with doxdox.