Methods
-
configure(options)
Configures application with provided AT&T key and secret any any additional information
-
A DHS method to configure application with the passed AT&T application key and secret and any additional information
Parameters:
Name Type Description optionsobject Properties
Name Type Argument Description app_keystring AT&T application key.
app_secretstring AT&T application secret.
virtual_numbers_poolstring <optional>
Array pool of virtual numbers.
ewebrtc_domainstring <optional>
AT&T EWebRTC domain.
Examples
var myDHS = require("att-dhs"), options = { app_key: '<your-app-key>', app_secret: '<your-app-secret>', }; myDHS.configure(options);var myDHS = require("att-dhs"), options = { app_key: '<your-app-key>', app_secret: '<your-app-secret>', virtual_numbers_pool: ['1234567890', '9876543210'], ewebrtc_domain: '<your-domain-name>' }; myDHS.configure(options);// providing <your_app_url> with /tokens and /e911ids endpoints var myDHS = require("att-dhs"); options = { app_key: '<your-app-key>', app_secret: '<your-app-secret>', virtual_numbers_pool: ['1234567890', '9876543210'], ewebrtc_domain: '<your-domain-name>', app_token_uri: '<your_app_url>/tokens', app_e911ids_uri: '<your_app_url>/e911ids' }; myDHS.configure(options); -
createAccessToken(options)
Creates an Access Token using AT&T's OAuth for mobile number, virtual number and account id users
-
This methods accepts a
app_scopeand creates theaccess tokenfor that particularapp_scopeAccepted values forapp_scopeare:MOBILE_NUMBER,VIRTUAL_NUMBER,ACCOUNT_IDandE911. This method requires an access token obtained usingE911auth_scope and a physical address with obtained during the consent flow.Parameters:
Name Type Description optionsobject Properties
Name Type Argument Description app_scopestring Application scope for getting access token
auth_codestring <optional>
Authorization Code from user consent for mobile number user
successfunction The callback that handles the successful response after creating an AT&T OAuth Access Token
errorfunction The callback that handles the generated error
Examples
// Create access token using DHS var myDHS = require("att-dhs"), options = { app_scope: 'E911', success: function (result) { // do something }, error: function (err) { // do something } }; myDHS.createAccessToken(options);// Create access token for Mobile Number using DHS var myDHS = require("att-dhs"), options = { app_scope: 'MOBILE_NUMBER', auth_code: 'auth_code_from_consent_flow', success: function (result) { // do something }, error: function (err) { // do something } }; myDHS.createAccessToken(options);// Create access token for Virtual Number using DHS var myDHS = require("att-dhs"), options = { app_scope: 'VIRTUAL_NUMBER', success: function (result) { // do something }, error: function (err) { // do something } }; myDHS.createAccessToken(options);// Create access token for Account ID using DHS var myDHS = require("att-dhs"), options = { app_scope: 'ACCOUNT_ID', success: function (result) { // do something }, error: function (err) { // do something } }; myDHS.createAccessToken(options); -
createE911Id(options)
Creates a new E911 Id using an
e911scope access token and an address -
E911 Id is required for mobile number and virtual number user for creating enhanced webrtc session. Use this function to create an E911 Id that can be used for creating the enhanced webrtc session for mobile number and virtual number users. This method requires an access token obtained using
E911auth_scope and a physical address with thesestringfields:- First Name
- Last Name
- House Number
- Street
- Unit (optional)
- City
- State
- Zip Code
- Is Confirmed (True or False)
Parameters:
Name Type Description optionsobject Properties
Name Type Description tokenstring Access Token
addressobject The user's address
Properties
Name Type Argument Description first_namestring The user's first name
last_namestring The user's last name
house_numberstring The user's house number
unitstring <optional>
Unit/Apt./Suite number
streetstring The user's street
citystring The user's city
statestring The user's state
zipstring The user's zip code
is_confirmedboolean Confirm that the address exists (even if not found in the database)
successfunction The callback that handles the successful response after creating an AT&T E911 Id
errorfunction The callback that handles the generated error.
Example
// Create E911 id using DHS var myDHS = require("att-dhs"), options = { token: 'token', address: { first_name: 'John', last_name: 'Doe', house_number: '1111', street: 'ABC Street', city: 'My City', state: 'My State', zip: '12345' }, is_confirmed: 'false', success: function (result) { // do something }, error: function (err) { // do something } }; myDHS.createE911Id(options); -
getAuthorizeUrl() → {String}
Returns user consent page url
-
Forms the consent page url by concatenating the API endpoint, Authorization URI, Application Key and Application Scope in a single URL string
Returns:
User consent page url
- Type
- String
Example
// Get user consent URL var myDHS = require("att-dhs"), authorizeURL = myDHS.getAuthorizeUrl(); -
getConfiguration() → {EnvConfig}
Returns the environment configuration.
-
A DHS method to return environment configuration like
app_key,virtual_numbers_poolandewebrtc_domainReturns:
- Type
- EnvConfig
Example
var myDHS = require("att-dhs"), config = myDHS.getConfiguration(); -
refreshAccessToken(options)
Refreshes the current Access Token using AT&T's OAuth for mobile number, virtual number and account id users
-
This methods accepts a
refresh_tokenand extends the expiry time for that token.Parameters:
Name Type Description optionsobject Properties
Name Type Description refresh_tokenstring Application token to be refreshed
successfunction The callback that handles the successful response after refreshing the previously used AT&T OAuth Access Token
errorfunction The callback that handles the generated error
Example
// Refresh access token using DHS var myDHS = require("att-dhs"), options = { refresh_token: 'access_token_id', success: function (result) { // do something }, error: function (err) { // do something } }; myDHS.refreshAccessToken(options); -
revokeAccessToken(options, {optional})
Revokes an Access Token or Refreshed Token using AT&T's OAuth for mobile number, virtual number and account id users
-
This methods accepts a previously created access token and deletes it for the current logged in This method requires an access token obtained using
createAccessTokenduring the consent flow.Parameters:
Name Type Description optionsobject Properties
Name Type Description tokenstring Access token or refreshed token
{optional}string options.token_type_hint - 'access_token' or 'refresh_token'.
options.successfunction The callback that handles the successful response after creating an AT&T OAuth Access Token
options.errorfunction The callback that handles the generated error
Examples
// Revoke access token using DHS var myDHS = require("att-dhs"), options = { token: 'token', success: function (result) { // do something }, error: function (err) { // do something } }; myDHS.revokeAccessToken(options);// Revoke access token using DHS var myDHS = require("att-dhs"), options = { token: 'token', token_type_hint: 'access_token', success: function (result) { // do something }, error: function (err) { // do something } }; myDHS.revokeAccessToken(options);// Revoke refreshed token using DHS var myDHS = require("att-dhs"), options = { token: 'token', token_type_hint: 'refresh_token', success: function (result) { // do something }, error: function (err) { // do something } }; myDHS.revokeAccessToken(options); -
use(plugin, options)
Enables a third party add-on to use it's features along with DHS
-
A DHS method that enables or adds a third party plugin to simplify configuring the DHS
Parameters:
Name Type Description pluginstring Plugin Identifier
optionsobject Properties
Name Type Argument Description appstring <optional>
Can only take Express JS object - Required when plugin='router'
serverstring <optional>
Can be a http node server object or https node server object - Required when plugin='websocket.eventchannel'
loggerstring <optional>
A third party log manager tool object - Required when plugin='logger'
Examples
// To define your own logging tool it must contain the following methods: // 1) logError // 2) logWarn // 3) logInfo // 4) logDebug // 5) logTrace var myDHS = require("att-dhs"), myLogger = require("my-own-logger"); myDHS.configure({ ... }); myDHS.use('logger', { logger: myLogger });// To get default routes from DHS // DHS predefined default routes: // 1) GET '/config' // 2) POST '/tokens' // 3) POST '/e911ids' var myDHS = require("att-dhs"), express = require("express"); myDHS.configure({ ... }); myDHS.use('router', { app: express });// To change the DHS default routes var myDHS = require("att-dhs"), express = require("express"); myDHS.configure({ ... app_config_url: '/my-config-url', app_tokens_url: '/my-tokens-url', app_e911ids_url: '/my-e911ids-url' }); myDHS.use('router', { app: express });
Type Definitions
-
EnvConfig
-
Type:
- Object
Properties:
Name Type Description app_keyString 'thirty_two_character_application_key'
api_endpointString API endpoint e.g. 'https://api.att.com'
ewebrtc_uriString EWebRTC domain e.g. '/RTC/v1'
virtual_numbers_poolArray Virtual number e.g. ['1234567890', '9876543210']
ewebrtc_domainString EWebRTC domain e.g. 'yourdomain.com'