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 |
objectThe API client object
stringThe base URL to the router
stringThe userId/tokenId the API is currently using
objectuser object for current token/user id
Retrieves the topic for the given id
| Name | Type | Description | |
|---|---|---|---|
| id | string |
- Topic id |
objecttopic object
Get all topic objects
arrayList 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 |
objecttopic - Single topic
Get all templates associated with the user
objectTemplate
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 |
objectTopic
Delete a topic
| Name | Type | Description | |
|---|---|---|---|
| id | string |
- Delete topic by id |
objectDeletion object
Retrieve template object with id
| Name | Type | Description | |
|---|---|---|---|
| id | string |
- Id of template |
objectTemplate
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 |
objectThe 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 |
objecttemplate
Helper method to update a template, or create if it doesn't exist
| Name | Type | Description | |
|---|---|---|---|
| {id, name, language, source} | object |
objecttemplate
arrayReturns 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 |
objectThe token
Get events given search options
| Name | Type | Description | |
|---|---|---|---|
| searchOpts | object |
- Search options |
arrayevents
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 |
expressMiddlewareReturns 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
expressMiddlewareReturns a middleware that validatesreq.routerSignaure.hashagainst 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
stringThe 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 |
promiseEither 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 } |
objectfunctions 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) |
objectthe 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 |
functionReturns 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 |
objectThe 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 |
promiseAxios promise
Gets a new API client based on the current user id and key
ClientAPI Client
Documentation generated with doxdox.