dashmachine-auth-request
Version:
Supports Auth Requests for Dash Platform Web Dapps
931 lines (616 loc) • 29.6 kB
Markdown
# dashmachine-auth-request
A Library to Support Auth Requests fos Dash Platform Web Dapps.
# Usage
## Overview
This is an experimental project to explore methods of achieving a login flow with the [Dash Platform](https://dashdevs.org/).
The current specification can be found [here](https://docs.google.com/document/d/1LDXEC0FtOoIOQomMjPmBm8x6-ZYVZPDVwnr1VoC6k-o).
This library contains the impementation of the server-side component. The client side component is the [Dash Chrome Wallet](https://github.com/readme55/Dash-Chrome-Wallet).
## Installation
### Install as an npm package
npm i dashmachine-auth-request
### Set Options
Sample options module
```
exports.options = {
connection: {
apps: {
loginContract: {
contractId: '9GHRxvyYDmWz7pBKRjPnxjsJbbgKLngtejWWp3kEY1vB',
},
dpnsContract: {
contractId: '295xRRRMGYyAruG39XdAibaU9jMAzxhknkkAxFE7uVkW',
},
},
network: 'testnet',
seeds: { service: '34.215.175.142:3000' },
},
polling: {
responsePollingTimeout: 30000,
responsePollingFrequency: 5000,
reponsePollingDelay: 3000,
},
};
```
## Usage
See the [Examples](#Examples) below for possible usage.
> Please note this library and documentation is experimental and in the early stages of development so should not be used in a production environment
# Development
The following sections are only of interest if you wish to develop this project.
### Clone this repo to a suitable location and switch into the project directory
git clone https://github.com/cloudwheels/dapp-auth-demo && cd dapp-auth-demo
It is recommended to install the npm nodemon package globally
npm i -g nodemon
The project can then be started in development mode using the following npm script:
npm run develop
## Tests
Tests are configured using Jest and Supertest. The following scripts are available to run different sections of tests, optionally in `watch` mode:
npm test
Single run of all tests
npm test:watch
Runs all tests in watch mode
npm test-unit:watch
Runs only unit tests in watch mode
npm test-routes:watch
Runs only route tests (using supertest) in watch mode
npm test-services:watch
Runs only route services in watch mode
## Generated Documentation (experimental)
The following is automatically generated from jsdoc annotaions in the code using the documentaion.js npm package.
You will need to install the documentation package globally:
npm i -g documentation
The run the npm scripts to generate the docs
docs-readme:lib
docs-readme:models
### Library
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
##### Table of Contents
- [AuthRequest](#authrequest)
- [Examples](#examples)
- [findEnduser](#findenduser)
- [findVendor](#findvendor)
- [create](#create)
- [submit](#submit)
- [mockReponse](#mockreponse)
- [findResponses](#findresponses)
- [verify](#verify)
- [vendor](#vendor)
- [Parameters](#parameters)
- [enduser](#enduser)
- [Parameters](#parameters-1)
- [requestDoc](#requestdoc)
- [Parameters](#parameters-2)
- [responseDocType](#responsedoctype)
- [Parameters](#parameters-3)
- [userResponses](#userresponses)
- [Parameters](#parameters-4)
- [temp_timestamp](#temp_timestamp)
- [Parameters](#parameters-5)
- [entropy](#entropy)
- [Parameters](#parameters-6)
- [test_enduserPrivateKey](#test_enduserprivatekey)
- [Parameters](#parameters-7)
- [test_enduserMnemonic](#test_endusermnemonic)
- [Parameters](#parameters-8)
- [DashAccount](#dashaccount)
- [Properties](#properties)
- [mnemonic](#mnemonic)
- [Parameters](#parameters-9)
- [DashConnection](#dashconnection)
- [Properties](#properties-1)
- [connect](#connect)
- [disconnect](#disconnect)
- [network](#network)
- [Parameters](#parameters-10)
- [mnemonic](#mnemonic-1)
- [Parameters](#parameters-11)
- [apps](#apps)
- [Parameters](#parameters-12)
- [options](#options)
- [Parameters](#parameters-13)
- [client](#client)
- [Parameters](#parameters-14)
- [DashUser](#dashuser)
- [Properties](#properties-2)
- [id](#id)
- [Parameters](#parameters-15)
- [name](#name)
- [Parameters](#parameters-16)
- [identityId](#identityid)
- [Parameters](#parameters-17)
- [identity](#identity)
- [Parameters](#parameters-18)
- [publicKey](#publickey)
- [Parameters](#parameters-19)
- [privateKey](#privatekey)
- [Parameters](#parameters-20)
- [find](#find)
- [Parameters](#parameters-21)
- [DashUser#toJSON](#dashusertojson)
- [DPNSDocument](#dpnsdocument)
- [AuthRequestDocument](#authrequestdocument)
- [DataDocument](#datadocument)
- [Properties](#properties-3)
- [submit](#submit-1)
- [Parameters](#parameters-22)
- [dataContractId](#datacontractid)
- [Parameters](#parameters-23)
- [id](#id-1)
- [Parameters](#parameters-24)
- [ownerId](#ownerid)
- [Parameters](#parameters-25)
- [data](#data)
- [Parameters](#parameters-26)
- [find](#find-1)
- [Parameters](#parameters-27)
- [waitFor](#waitfor)
- [Parameters](#parameters-28)
- [AuthResponseDocument](#authresponsedocument)
#### AuthRequest
AuthRequest class - A request for authorisation
##### Examples
> Note: the libarary has been updated so that the global connection object is no loger automatically connected & disconnected for each method. You must call the (undocumented) connect() and disconnect() methods before (and after) the other calls.
```javascript
const AuthRequest = require('./lib/auth-request');
const Options = require('./options');
(async () => {
try {
const req = new AuthRequest(
1,
'bob',
'1234',
'alice',
'uniform analyst paper father soldier toe lesson fetch exhaust jazz swim response',
'Web dApp Sample',
Options.options,
'Tweets are greets',
);
req.vendor = {
name: 'alice',
id: 'Aobc5KKaA4ZqzP7unc6WawQXQEK2S3y6EwrmvJLLn1ui',
identityId: 'CheZBPQHztvLNqN67i4KxcTU1XmDz7qG85X1XeJbc7K5',
identity: {
id: 'CheZBPQHztvLNqN67i4KxcTU1XmDz7qG85X1XeJbc7K5',
publicKeys: [
{
id: 0,
type: 0,
data: 'A0/qSE6tis4l6BtQlTXB2PHW+WV+Iy0rpF5hAvX8hDRz',
isEnabled: true,
},
],
balance: 9686447,
},
publicKey: 'A0/qSE6tis4l6BtQlTXB2PHW+WV+Iy0rpF5hAvX8hDRz',
privateKey:
'40148175614f062fb0b4e5c519be7b6f57b872ebb55ea719376322fd12547bff',
};
let createdDoc,
submittedDoc,
mockResponse,
foundResponses,
verifiedRequest;
try {
createdDoc = await req.create();
console.log(`createdDoc:${JSON.stringify(createdDoc)}`);
} catch (e) {
console.log(`createdDoc ERROR:${e}`);
}
if (createdDoc.success) {
try {
submittedDoc = await req.submit();
console.log(`submittedDoc:${JSON.stringify(submittedDoc)}`);
} catch (e) {
console.log(`submittedDoc ERROR:${e}`);
}
}
if (submittedDoc.success) {
try {
req.test_enduserMnemonic =
'liar fee island situate deal exotic flat direct save bag fiscal news';
req.test_enduserPrivateKey =
'219c8a8f9376750cee9f06e0409718f2a1b88df4acc61bf9ed9cf252c8602768';
mockResponse = await req.mockReponse();
console.log(`mockResponse:${JSON.stringify(mockResponse)}`);
} catch (e) {
console.log(`mockResponse ERROR:${e}`);
}
}
if (mockResponse.success) {
try {
foundResponses = await req.findResponses();
console.log(
`foundResponses:${JSON.stringify(foundResponses)}`,
);
} catch (e) {
console.log(`foundResponses ERROR:${e}`);
}
}
if (foundResponses.success) {
try {
verifiedRequest = await req.verify();
console.log(
`verifiedRequest:${JSON.stringify(verifiedRequest)}`,
);
} catch (e) {
console.log(`verifiedRequest ERROR:${e}`);
}
}
} catch (e) {
console.log(`errors: ${e}`); ////
}
})();
```
#### findEnduser
if this.\_enduser==null looks up user details from the network using the supplied connection details //
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** this.\_enduser
#### findVendor
if this.vendor==null looks up user details from the network using the supplied connection details
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** this.\_vendor
#### create
creates a request document of the required type if the username, pin and other options are valid ////
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the prepared request document
#### submit
Submits the document set as the value of this.\_requestDoc returns this.\_submittedRequestDoc if successful
Returns **any** Promise<{
success: boolean;
data: any;
error?: undefined;
message?: undefined;
} | {
error: boolean;
message: any;
success?: undefined;
data?: undefined;
}>
#### mockReponse
Mock Reponse with known user private keys
#### findResponses
poll for responses matching criteria
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** this.\_enduser
#### verify
Verifies all found responses to deternine if loginis successful
#### vendor
##### Parameters
- `newVendor` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### enduser
##### Parameters
- `newEnduser`
- `newVendor` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### requestDoc
##### Parameters
- `newRequestDoc` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### responseDocType
##### Parameters
- `newResponseDocType` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### userResponses
##### Parameters
- `newUserResponses` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>**
#### temp_timestamp
##### Parameters
- `newTemp_timestamp` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### entropy
##### Parameters
- `newEntropy` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### test_enduserPrivateKey
##### Parameters
- `newTest_enduserPrivateKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### test_enduserMnemonic
##### Parameters
- `newTest_enduserMnemonic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### DashAccount
DashAccount class - represents a Dash Platform Account
##### Properties
- `mnemonic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The account mnemonic
#### mnemonic
##### Parameters
- `newMnemonic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### DashConnection
DashConnection class - represents a connection to Dash Platform
##### Properties
- `network` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Network to connect to i.e. 'testet' (default), mainnet
- `mnemonic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Account mnemonic to use for the connection
- `apps` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** named app identities
- `seeds` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** additonal options, overrides other paramaters
- `client` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the connection instance client
#### connect
Intialises connection
#### disconnect
Closes and disconnect the connection
#### network
##### Parameters
- `newNetwork`
- `newName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### mnemonic
##### Parameters
- `newMnemonic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### apps
##### Parameters
- `newApps` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### options
##### Parameters
- `newSeeds` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### client
##### Parameters
- `newClient` **any**
#### DashUser
DashUser class - represents a registered Dash Platform Username
##### Properties
- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Unique id fopr the user record - the id of the DPNS document which registered the name
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The registered username
- `identityId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** identityId associated with the username
- `identity` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** full identity object of the identityId
- `publicKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** private Key Associated wwith the user identity
- `privateKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** private Key Associated wwith the user identity
#### id
##### Parameters
- `newId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### name
##### Parameters
- `newName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### identityId
##### Parameters
- `newIdentityId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### identity
##### Parameters
- `newIdentity`
- `newIdentityId` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### publicKey
##### Parameters
- `newPublicKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### privateKey
##### Parameters
- `newPrivateKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### find
Finds the registered username on the network
##### Parameters
- `nameToFind`
- `connection`
#### DashUser#toJSON
Returns the DashUser instance in JSON format
Returns **[JSON](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON)**
#### DPNSDocument
**Extends DataDocument**
DPNSDocument class - represents a anme registraion documents from Dash Platform Name Service
#### AuthRequestDocument
**Extends DataDocument**
AuthRequestDocument class - represents login documents sumitted to or retrieved from Dash Platform
#### DataDocument
DataDocument class - represents data docuemnts sumitted to or retrieved from Dash Platform
##### Properties
- `dataContractId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** dataContractId the document is validated against
- `ownerId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** identityId of the owner / submitter of the document
- `data` **[JSON](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON)** actual data of the document represented as JSON
- `signature` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the signature on the document
#### submit
submits the document instance using the passed in connection
##### Parameters
- `connection` A DashJS client containing the account and keys for signing the doc
#### dataContractId
##### Parameters
- `newContractId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### id
##### Parameters
- `newId` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### ownerId
##### Parameters
- `newOwnerId` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### data
##### Parameters
- `newData` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### find
finds one of more documents based on suplied query params
##### Parameters
- `connection` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A DashJS connection, with options set for the locator of the docs to be retrieved
- `locator` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The document name
- `query` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing array of query parameters
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array of found docuemnts
#### waitFor
Calls find() over specified period at specifed frequency until result tis returned
##### Parameters
- `connection` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A DashJS connection, with options set for the locator of the docs to be retrieved
- `locator` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The document name
- `query` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing array of query parameters
- `timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of millseconds until rejecting as timed out
- `frequency` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Frequency of calls to find() in millisenconds
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** promise for JSON Object
{success:true, data:array of found docuemnts} if resolved {error: true, message:[error message]} if rejected
#### AuthResponseDocument
**Extends DataDocument**
AuthResponseDocument class - represents auth response documents sumitted to or retrieved from Dash Platform
### Models
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
##### Table of Contents
- [DashAccount](#dashaccount)
- [Properties](#properties)
- [mnemonic](#mnemonic)
- [Parameters](#parameters)
- [DashUser](#dashuser)
- [Properties](#properties-1)
- [id](#id)
- [Parameters](#parameters-1)
- [name](#name)
- [Parameters](#parameters-2)
- [identityId](#identityid)
- [Parameters](#parameters-3)
- [identity](#identity)
- [Parameters](#parameters-4)
- [privateKey](#privatekey)
- [Parameters](#parameters-5)
- [find](#find)
- [Parameters](#parameters-6)
- [DashUser#toJSON](#dashusertojson)
- [DataDocument](#datadocument)
- [Properties](#properties-2)
- [submit](#submit)
- [Parameters](#parameters-7)
- [dataContractId](#datacontractid)
- [Parameters](#parameters-8)
- [id](#id-1)
- [Parameters](#parameters-9)
- [ownerId](#ownerid)
- [Parameters](#parameters-10)
- [data](#data)
- [Parameters](#parameters-11)
- [find](#find-1)
- [Parameters](#parameters-12)
- [waitFor](#waitfor)
- [Parameters](#parameters-13)
- [DPNSDocument](#dpnsdocument)
- [LoginDocument](#logindocument)
- [LoginResponseDocument](#loginresponsedocument)
- [Tweet](#tweet)
- [Properties](#properties-3)
- [username](#username)
- [Parameters](#parameters-14)
- [message](#message)
- [Parameters](#parameters-15)
- [date](#date)
- [Parameters](#parameters-16)
#### DashAccount
DashAccount class - represents a Dash Platform Account
##### Properties
- `mnemonic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The account mnemonic
#### mnemonic
##### Parameters
- `newMnemonic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### DashUser
DashUser class - represents a registered Dash Platform Username
##### Properties
- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Unique id fopr the user record - the id of the DPNS document which registered the name
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The registered username
- `identityId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** identityId associated with the username
- `identity` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** full identity object of the identityId
- `privateKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** private Key Associated wwith the user identity
#### id
##### Parameters
- `newId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### name
##### Parameters
- `newName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### identityId
##### Parameters
- `newIdentityId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### identity
##### Parameters
- `newIdentity`
- `newIdentityId` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### privateKey
##### Parameters
- `newPrivateKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### find
Finds the registered username on the network
##### Parameters
- `nameToFind`
- `connection`
#### DashUser#toJSON
Returns the DashUser instance in JSON format
Returns **[JSON](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON)**
#### DataDocument
DataDocument class - represents data docuemnts sumitted to or retrieved from Dash Platform
##### Properties
- `dataContractId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** dataContractId the document is validated against
- `ownerId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** identityId of the owner / submitter of the document
- `data` **[JSON](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON)** actual data of the document represented as JSON
- `signature` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the signature on the document
#### submit
submits the document instance using the passed in connection
##### Parameters
- `connection` A DashJS client containing the account and keys for signing the doc
#### dataContractId
##### Parameters
- `newContractId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### id
##### Parameters
- `newId` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### ownerId
##### Parameters
- `newOwnerId` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### data
##### Parameters
- `newData` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### find
finds one of more documents based on suplied query params
##### Parameters
- `connection` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A DashJS connection, with options set for the locator of the docs to be retrieved
- `locator` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The document name
- `query` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing array of query parameters
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array of found docuemnts
#### waitFor
Calls find() over specified period at specifed frequency until result tis returned
##### Parameters
- `connection` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A DashJS connection, with options set for the locator of the docs to be retrieved
- `locator` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The document name
- `query` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing array of query parameters
- `timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of millseconds until rejecting as timed out
- `frequency` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Frequency of calls to find() in millisenconds
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** promise for JSON Object
{success:true, data:array of found docuemnts} if resolved {error: true, message:[error message]} if rejected
#### DPNSDocument
**Extends DataDocument**
DPNSDocument class - represents a anme registraion documents from Dash Platform Name Service
#### LoginDocument
**Extends DataDocument**
LoginDocument class - represents login documents sumitted to or retrieved from Dash Platform
#### LoginResponseDocument
**Extends DataDocument**
LoginResponseDocument class - represents login documents sumitted to or retrieved from Dash Platform
#### Tweet
Tweet class - represents a user tweet
##### Properties
- `username` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The registered username
- `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** tweet content
- `date` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** date of the tweet
#### username
##### Parameters
- `newUsername` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### message
##### Parameters
- `newMessage` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### date
##### Parameters
- `newDate` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
### Services
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
##### Table of Contents
- [DashConnection](#dashconnection)
- [Properties](#properties)
- [connect](#connect)
- [disconnect](#disconnect)
- [network](#network)
- [Parameters](#parameters)
- [account](#account)
- [Parameters](#parameters-1)
- [apps](#apps)
- [Parameters](#parameters-2)
- [options](#options)
- [Parameters](#parameters-3)
- [client](#client)
- [Parameters](#parameters-4)
#### DashConnection
DashConnection class - represents a connection to Dash Platform
##### Properties
- `network` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Network to connect to i.e. 'tesnet' (default), livenet
- `account` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** An instance of the DashAccount class containing mnemonic etc to use for the connection
- `apps` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** named app identities
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** additonal options, overrides other paramaters
- `client` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the connection instance client
#### connect
Intialises connection
#### disconnect
Closes and disconnect the connection
#### network
##### Parameters
- `newNetwork`
- `newName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### account
##### Parameters
- `newAccount` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### apps
##### Parameters
- `newApps` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### options
##### Parameters
- `newOptions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
#### client
##### Parameters
- `newClient` **any**