Global

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
options object
Properties
Name Type Argument Description
app_key string

AT&T application key.

app_secret string

AT&T application secret.

virtual_numbers_pool string <optional>

Array pool of virtual numbers.

ewebrtc_domain string <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_scope and creates the access token for that particular app_scope Accepted values for app_scope are: MOBILE_NUMBER, VIRTUAL_NUMBER, ACCOUNT_ID and E911. This method requires an access token obtained using E911 auth_scope and a physical address with obtained during the consent flow.

Parameters:
Name Type Description
options object
Properties
Name Type Argument Description
app_scope string

Application scope for getting access token

auth_code string <optional>

Authorization Code from user consent for mobile number user

success function

The callback that handles the successful response after creating an AT&T OAuth Access Token

error function

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 e911 scope 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 E911 auth_scope and a physical address with these string fields:

  • First Name
  • Last Name
  • House Number
  • Street
  • Unit (optional)
  • City
  • State
  • Zip Code
  • Is Confirmed (True or False)
Parameters:
Name Type Description
options object
Properties
Name Type Description
token string

Access Token

address object

The user's address

Properties
Name Type Argument Description
first_name string

The user's first name

last_name string

The user's last name

house_number string

The user's house number

unit string <optional>

Unit/Apt./Suite number

street string

The user's street

city string

The user's city

state string

The user's state

zip string

The user's zip code

is_confirmed boolean

Confirm that the address exists (even if not found in the database)

success function

The callback that handles the successful response after creating an AT&T E911 Id

error function

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_pool and ewebrtc_domain

Returns:
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_token and extends the expiry time for that token.

Parameters:
Name Type Description
options object
Properties
Name Type Description
refresh_token string

Application token to be refreshed

success function

The callback that handles the successful response after refreshing the previously used AT&T OAuth Access Token

error function

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 createAccessToken during the consent flow.

Parameters:
Name Type Description
options object
Properties
Name Type Description
token string

Access token or refreshed token

{optional} string

options.token_type_hint - 'access_token' or 'refresh_token'.

options.success function

The callback that handles the successful response after creating an AT&T OAuth Access Token

options.error function

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
plugin string

Plugin Identifier

options object
Properties
Name Type Argument Description
app string <optional>

Can only take Express JS object - Required when plugin='router'

server string <optional>

Can be a http node server object or https node server object - Required when plugin='websocket.eventchannel'

logger string <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_key String

'thirty_two_character_application_key'

api_endpoint String

API endpoint e.g. 'https://api.att.com'

ewebrtc_uri String

EWebRTC domain e.g. '/RTC/v1'

virtual_numbers_pool Array

Virtual number e.g. ['1234567890', '9876543210']

ewebrtc_domain String

EWebRTC domain e.g. 'yourdomain.com'