Giter Site home page Giter Site logo

authy-client's Introduction

authy-client

A complete Authy client with support for TOTP, OneTouch, Phone Verification and Phone Intelligence APIs.

Status

npm version build status

Installation

Install the package via yarn:

yarn add authy-client

or via npm:

npm install authy-client --save

Usage

Client

The following is a complete example of registering a user and requesting an SMS using any of the three possible async APIs offered by this package.

Using await/async (requires babel)
import { Client } from 'authy-client';

const client = new Client({ key: 'foo' });

(async function() {
  const { user: { id: authyId } } = await client.registerUser({
    countryCode: 'PT',
    email: '[email protected]',
    phone: '911234567' }
  );
  const { cellphone } = await client.requestSms({ authyId });

  console.log(`SMS requested to ${cellphone}`)
}());
Using promises
const Client = require('authy-client').Client;
const client = new Client({ key: 'foo' });

client.registerUser({
  countryCode: 'PT',
  email: '[email protected]',
  phone: '911234567'
}).then(function(response) {
  return response.user.id;
}).then(function(authyId) {
  return client.requestSms({ authyId: authyId });
}).then(function(response) {
  console.log(`SMS requested to ${response.cellphone}`);
});
Using callbacks
const Client = require('authy-client').Client;
const client = new Client({ key: 'foo' });

client.registerUser({
  countryCode: 'PT',
  email: '[email protected]',
  phone: '911234567'
}, function(err, res) {
  if (err) throw err;

  client.requestSms({ authyId: res.user.id }, function(err, res) {
    if (err) throw err;

    console.log(`SMS requested to ${res.cellphone}`)
  });
});

If you want to run this example without first transpiling it, you can install the babel-cli package and run node_modules/.bin/babel-node example.js.

Command-line interface

Another option of interacting with Authy's API is by using the available command-line interface (cli). It handles most tasks without require any coding.

demo

❯ authy
Commands:
  activity <command>     Manage activity
  application <command>  Manage application information
  onetouch <command>     Manage onetouch requests
  phone <command>        Manage phone verifications
  user <command>         Manage users

Options:
  --key     API Key                                          [string] [required]
  --pretty  Whether to print pretty results            [boolean] [default: true]
  --help    Show help                                                  [boolean]

Note that all calls must be authenticated using the API Key. However, if you prefer, you can define the API Key using the environment variable AUTHY_KEY such as:

❯ AUTHY_KEY=foobar authy <command>

Client({ key }, [options])

Arguments

  1. args (Object): the required arguments object.
  2. args.key (string): The private API key obtained from the Authy Dashboard.
  3. [options] (Object): The options object.
  4. [options.host=https://api.authy.com] (string): The target API endpoint.
  5. [options.timeout=5000] (number): The maximum request time, in milliseconds.
Example
new Client({ key: 'foo' }, { timeout: 10000 });

TOTP API

Authy TOTP (Time-based One-time Password) is an API that allows application developers to enable two-factor authentication (2FA) for a user. 2FA, as the name suggests, is an additional step to secure an user's account or action by comparing a code generated or sent to the user's mobile phone against a shared secret.

registerUser({ countryCode, email, phone }, [callback])

Create an Authy user based on the users mobile phone number and email. The returned Authy Id should be stored on your database for subsequent calls.

The library automatically converts conforming country codes (e.g. US) to the corresponding country calling code (e.g. 1) and validates the resulting phone number thoroughly before submitting it to Authy.

Arguments

  1. args (Object): the required arguments object.
  2. args.countryCode (string): the user's phone country code in ISO 3166 alpha 2 format (recommended format, e.g. US) or a numeric country calling code (use at your own risk).
  3. args.email (string): the user's email address.
  4. args.phone (string): the user's phone number.
  5. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const { user: { id: authyId } } = await client.registerUser({ countryCode: 'PT', email: '[email protected]', phone: '911234567' });

console.log('Authy Id', authyId);
Using promises
client.registerUser({ countryCode: 'PT', email: '[email protected]', phone: '911234567' })
  .then(function(response) {
    console.log('Authy Id', response.user.id);
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.registerUser({ countryCode: 'PT', email: '[email protected]', phone: '911234567' }, function(err, res) {
  if (err) throw err;

  console.log('Authy Id', res.user.id);
});
Using cli
❯ AUTHY_KEY=foobar authy user create 911234567 PT [email protected]

requestSms({ authyId }, [options, callback])

Request an SMS with a token for users that don't own a smartphone. If the Authy app is in use by the user, this request is ignored and a push notification is sent instead.

Arguments
  1. args (Object): the required arguments object.
  2. args.authyId (string): the user's Authy Id.
  3. [options] (Object): the options object.
  4. [options.action] (string): the action or context that is being validated.
  5. [options.force] (boolean): whether to send an SMS even if the user is using the mobile application.
  6. [options.message] (string): a message for the specific action, if one is set.
  7. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.requestSms({ authyId: 1635 });

console.log('Message sent successfully to', response.cellphone);
Using promises
client.requestSms({ authyId: 1635 })
  .then(function(response) {
    console.log('Message sent successfully to', response.cellphone);
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.requestSms({ authyId: 1635 }, function(err, res) {
  if (err) throw err;

  console.log('Message sent successfully to', res.cellphone);
});
Using cli
❯ AUTHY_KEY=foobar authy user request sms 1635

requestCall({ authyId }, [options, callback])

Request a call with a token for users that don't own a smartphone. If the Authy app is in use by the user, this request is ignored and a push notification is sent instead.

Arguments
  1. args (Object): the required arguments object.
  2. args.authyId (string): the user's Authy Id.
  3. [options] (Object): the options object.
  4. [options.action] (string): the action or context that is being validated.
  5. [options.force] (boolean): whether to call the user even if the mobile application is in use.
  6. [options.message] (string): a message for the specific action, if one is set.
  7. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.requestCall({ authyId: 1635 });

console.log('Call requested successfully to', response.cellphone);
Using promises
client.requestCall({ authyId: 1635 })
  .then(function(response) {
    console.log('Call requested successfully to', response.cellphone);
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.requestCall({ authyId: 1635 }, function(err, res) {
  if (err) throw err;

  console.log('Call requested successfully to', res.cellphone);
});
Using cli
❯ AUTHY_KEY=foobar authy user request call 1635

verifyToken({ authyId, token }, [options, callback])

Verify if a token submitted by the user is valid or not.

Arguments
  1. args (Object): the required arguments object.
  2. args.authyId (string): the user's Authy Id.
  3. args.token (string): the token to verify.
  4. [options] (Object): the options object.
  5. [options.force] (boolean): whether to verify the token regardless of the user's login status.
  6. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.verifyToken({ authyId: 1635, token: '1234567' });

console.log('Token is valid');
Using promises
client.verifyToken({ authyId: 1635, token: '1234567' })
  .then(function(response) {
    console.log('Token is valid');
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.verifyToken({ authyId: 1635, token: '1234567' }, function(err, res) {
  if (err) throw err;

  console.log('Token is valid');
});
Using cli
❯ AUTHY_KEY=foobar authy user verify --token 1234567

deleteUser({ authyId }, [options, callback])

Delete a user from the application.

Arguments
  1. args (Object): the required arguments object.
  2. args.authyId (string): the user's Authy Id.
  3. [options] (Object): the options object.
  4. [options.ip] (string): the IP requesting to delete the user.
  5. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.deleteUser({ authyId: 1635 });

console.log('User has been scheduled for deletion');
Using promises
client.deleteUser({ authyId: 1635 })
  .then(function(response) {
    console.log('User has been scheduled for deletion');
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.deleteUser({ authyId: 1635 }, function(err, res) {
  if (err) throw err;

  console.log('User has been scheduled for deletion');
});
Using cli
❯ AUTHY_KEY=foobar authy user delete 1635
registerActivity({ authyId, data, type }, [options, callback])

Register a user activity.

Arguments
  1. args (Object): the required arguments object.
  2. args.authyId (string): the user's Authy Id.
  3. args.type (string): the activity type (one of password_reset, banned, unbanned or cookie_login).
  4. [data] (Object): a data object associated with the activity.
  5. [options] (Object): the options object.
  6. [options.ip] (string): the IP of the user registering the activity.
  7. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.registerActivity({ authyId: 1635, data: { reason: 'foo' }, type: 'banned' }, { ip: '127.0.0.1' });

console.log('Activity registered');
Using promises
client.registerActivity({ authyId: 1635, data: { reason: 'foo' }, type: 'banned' }, { ip: '127.0.0.1' })
  .then(function(response) {
    console.log('Activity registered');
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.registerActivity({ authyId: 1635, data: { reason: 'foo' }, type: 'banned' }, { ip: '127.0.0.1' }, function(err, res) {
  if (err) throw err;

  console.log('Activity registered');
});
Using cli
❯ AUTHY_KEY=foobar authy activity create 1635 \
    --data.reason foo \
    --type banned \
    --ip 127.0.0.1

getUserStatus({ authyId }, [options, callback])

Retrieve the user status, such as the registered country code, phone number, devices and confirmation status.

Arguments
  1. args (Object): the required arguments object.
  2. args.authyId (string): the user's Authy Id.
  3. [options] (Object): the options object.
  4. [options.ip] (string): the IP of the user requesting to see the user details.
  5. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.getUserStatus({ authyId: 1635 });

console.log('User status', response.status);
Using promises
client.getUserStatus({ authyId: 1635 })
  .then(function(response) {
    console.log('User status', response.status);
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.getUserStatus({ authyId: 1635 }, function(err, res) {
  if (err) throw err;

  console.log('User status', response.status);
});
Using cli
❯ AUTHY_KEY=foobar authy user get status 1635

getApplicationDetails([options, callback])

Retrieve application details such as its name or current billing plan.

Arguments
  1. [options] (Object): the options object.
  2. [options.ip] (string): the IP of the user requesting to see the application details.
  3. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.getApplicationDetails();

console.log('Application details', response.app);
Using promises
client.getApplicationDetails()
  .then(function(response) {
    console.log('Application details', response.app);
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.getApplicationDetails(function(err, res) {
  if (err) throw err;

  console.log('Application details', response.app);
});
Using cli
❯ AUTHY_KEY=foobar authy application get details

getApplicationStatistics([options, callback])

Retrieve application statistics by month and current quotas.

Arguments
  1. [options] (Object): the options object.
  2. [options.ip] (string): the IP of the user requesting to see the application statistics.
  3. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.getApplicationStatistics();

console.log('Application statistics', response);
Using promises
client.getApplicationStatistics()
  .then(function(response) {
    console.log('Application statistics', response);
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.getApplicationStatistics(function(err, res) {
  if (err) throw err;

  console.log('Application statistics', response);
});
Using cli
❯ AUTHY_KEY=foobar authy application get statistics

Phone Verification API

The Phone Verification API allows for a simple phone verification for situations where the complexity of the TOTP API is not required. First, a code is sent to the user's phone number and then that code is submitted back by the user. Authy verifies that the code matches the one issued for it.

startPhoneVerification({ countryCode, phone, via }, [options, callback])

Verify a phone number by sending it a verification code by SMS or call. Custom messages for the SMS are currently not working so support has not been added.

Arguments
  1. args (Object): the required arguments object.
  2. args.countryCode (string): the user's phone country code in ISO 3166 alpha 2 format (recommended format, e.g. US) or a numeric country calling code (use at your own risk).
  3. args.phone (string): the user's phone number to verify.
  4. args.via (string): the mechanism used to send the verification code (sms or call).
  5. [options] (Object): the options object.
  6. [options.locale] (string): the locale of the message received by the user. If none is given, Authy will attempt to auto-detect it based on the country code passed, otherwise English will be used.
  7. [options.codeLength] (integer): the number of verification digits sent (by default, 4). Allowed values are 4-10.
  8. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
import { enums } from 'authy-client';

const response = await client.startPhoneVerification({ countryCode: 'US', phone: '7754615609', via: enums.verificationVia.SMS });

console.log('Phone information', response);
Using promises
const enums = require('authy-client').enums;

client.startPhoneVerification({ countryCode: 'US', phone: '7754615609', via: enums.verificationVia.SMS })
  .then(function(response) {
    console.log('Phone information', response);
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
const enums = require('authy-client').enums;

client.startPhoneVerification({ countryCode: 'US', locale: 'en', phone: '7754615609', via: enums.verificationVia.SMS }, function(err, res) {
  if (err) throw err;

  console.log('Phone information', response);
});
Using cli
❯ AUTHY_KEY=foobar authy phone verify 7754615609 US \
    --locale=en \
    --via=sms

verifyPhone({ countryCode, phone, token }, [callback])

Verify a phone number through a verification code.

Arguments
  1. args (Object): the required arguments object.
  2. args.countryCode (string): the user's phone country code in ISO 3166 alpha 2 format (recommended format, e.g. US) or a numeric country calling code (use at your own risk).
  3. args.phone (string): the user's phone number to verify.
  4. args.token (string): the token submitted by the user to verify the phone.
  5. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.verifyPhone({ countryCode: 'US', phone: '7754615609', token: '1234' });

console.log('Verification code is correct');
Using promises
client.verifyPhone({ countryCode: 'US', phone: '7754615609', token: '1234' })
  .then(function(response) {
    console.log('Verification code is correct');
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.verifyPhone({ countryCode: 'US', phone: '7754615609', token: '1234' }, function(err, res) {
  if (err) throw err;

  console.log('Verification code is correct');
});
Using cli
❯ AUTHY_KEY=foobar authy phone verify 7754615609 US --token 1234

Phone Intelligence API

The Phone Intelligence API allows an application developer to retrieve information about a specific number such as its type (VoIP, landline or mobile) and carrier.

getPhoneInformation({ countryCode, phone }, [options, callback])

Verify a phone number by sending it a verification code by SMS or call. Custom messages for the SMS are currently not working so support has not been added.

Arguments
  1. args (Object): the required arguments object.
  2. args.countryCode (string): the phone's country code in ISO 3166 alpha 2 format (recommended format, e.g. US) or a numeric country calling code (use at your own risk).
  3. args.phone (string): the phone's number to retrieve information about.
  4. [options] (Object): the options object.
  5. [options.ip] (string): the IP of the user requesting to retrieve information about the phone.
  6. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.getPhoneInformation({ countryCode: 'US', phone: '7754615609' });

console.log('Phone information', response);
Using promises
client.getPhoneInformation({ countryCode: 'US', phone: '7754615609' })
  .then(function(response) {
    console.log('Phone information', response);
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.getPhoneInformation({ countryCode: 'US', phone: '7754615609' }, function(err, res) {
  if (err) throw err;

  console.log('Phone information', response);
});
Using cli
❯ AUTHY_KEY=foobar authy phone get information 7754615609 US

OneTouch API

Authy OneTouch is an API that allows application developers to create simple approval requests so that users can frictionless approve or deny such request. It can be used for a variety of purposes, such as authentication (e.g. login approval) or validation (e.g. financial transaction approval).

When the user takes actions, Authy sends a GET or POST callback to a URL defined on the application dashboard. The request, which can optionally be cryptographically verified, allows for immediate reaction. An alternate polling method can also be used.

createApprovalRequest({ authyId, details, logos, message }, [options, callback])

Create an approval request for the given Authy Id and send it to the user as a push notification.

Arguments
  1. args (Object): the required arguments object.
  2. args.authyId (string): the user's Authy Id.
  3. args.message (string): the message shown to the user upon receiving the approval request.
  4. [details] (Object): the details object.
  5. [details.hidden] (Object): a dictionary of hidden details associated with the approval request.
  6. [details.visible] (Object): a dictionary of visible details associated with the approval request.
  7. [logos] (array): the custom logos collection.
  8. [logos.<n>] (Object): a custom logo object.
  9. [logos.<n>.res] (string): the target resolution of the custom logo (one of default, low, med or high).
  10. [logos.<n>.url] (string): the url of the custom logo image.
  11. [options] (Object): the options object.
  12. [options.ttl] (integer): the number of seconds that the approval request will be available for being responded. If set to 0, the approval request won't expire.
  13. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.createApprovalRequest({
  authyId: 1635,
  details: {
    hidden: {
      ip_address: '10.10.3.203'
    },
    visible: {
      'Account Number': '981266321',
      location: 'California, USA',
      username: 'Bill Smith'
    }
  },
  logos: [{
    res: 'default',
    url: 'https://example.com/logos/default.png'
  }, {
    res: 'low',
    url: 'https://example.com/logos/low.png'
  }],
  message: 'Login requested for a CapTrade Bank account.',
}, {
  ttl: 120
});

console.log('Approval request UUID', response.approval_request.uuid);
Using promises
client.createApprovalRequest({
  authyId: 1635,
  details: {
    hidden: {
      ip_address: '10.10.3.203'
    },
    visible: {
      'Account Number': '981266321',
      location: 'California, USA',
      username: 'Bill Smith'
    }
  },
  logos: [{
    res: 'default',
    url: 'https://example.com/logos/default.png'
  }, {
    res: 'low',
    url: 'https://example.com/logos/low.png'
  }],
  message: 'Login requested for a CapTrade Bank account.',
}, {
  ttl: 120
}).then(function(response) {
  console.log('Approval request UUID', response.approval_request.uuid);
}).catch(function(error) {
  throw error;
});
Using callbacks
client.createApprovalRequest({
  authyId: 1635,
  details: {
    hidden: {
      ip_address: '10.10.3.203'
    },
    visible: {
      'Account Number': '981266321',
      location: 'California, USA',
      username: 'Bill Smith'
    }
  },
  logos: [{
    res: 'default',
    url: 'https://example.com/logos/default.png'
  }, {
    res: 'low',
    url: 'https://example.com/logos/low.png'
  }],
  message: 'Login requested for a CapTrade Bank account.',
}, {
  ttl: 120
}, function(err, res) {
  if (err) throw err;

  console.log('Approval request UUID', response.approval_request.uuid);
});
Using cli
❯ AUTHY_KEY=foobar authy onetouch create 1635 \
  'Login requested for a CapTrade Bank account.' \
  --hidden.ip_address 10.10.3.203 \
  --logos.0.res default \
  --logos.0.url 'https://example.com/logos/default.png' \
  --logos.1.res low \
  --logos.1.url 'https://example.com/logos/low.png' \
  --visible.'Account Number' 981266321 \
  --visible.location 'California, USA' \
  --visible.username 'Bill Smith' \
  --ttl 120

getApprovalRequest({ id }, [callback])

Get information about an approval request.

Arguments
  1. args (Object): the required arguments object.
  2. args.id (string): the id of the approval request.
  3. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
const response = await client.getApprovalRequest({ id: '550e8400-e29b-41d4-a716-446655440000' });

console.log('Approval request', response.approval_request);
Using promises
client.getApprovalRequest({ id: '550e8400-e29b-41d4-a716-446655440000' })
  .then(function(response) {
    console.log('Approval request', response.approval_request);
  })
  .catch(function(error) {
    throw error;
  });
Using callbacks
client.getApprovalRequest({ id: '550e8400-e29b-41d4-a716-446655440000' }, function(err, res) {
  if (err) throw err;

  console.log('Approval request', response.approval_request);
});
Using cli
❯ AUTHY_KEY=foobar authy phone get status 550e8400-e29b-41d4-a716-446655440000

verifyCallback({ body, headers, method, protocol, url }, [callback])

Authy callbacks contain a header (X-Authy-Signature) with an HTTP HMAC signature of the request. This signature can be used to verify the authenticity of the request.

Currently, GET requests cannot be validated, as only POST requests contain such signature.

If you have configured your Authy application to receive callbacks for OneTouch approval requests, you should verify their authenticity.

Arguments
  1. args (Object): the required arguments object.
  2. args.body (Object): the parsed body of the request.
  3. args.headers (Object): the headers of the request.
  4. args.method (string): the method of the request (GET or POST).
  5. args.protocol (string): the protocol of the request (http or https).
  6. args.url (string): the url of the request (e.g. /callback/onetouch).
  7. [callback] (Function): a callback, otherwise a Promise is returned.
Example
Using await/async (requires babel)
await client.verifyCallback({
  body: {
    approval_request: {
      expiration_timestamp: 1455911778,
      logos: null,
      transaction: {
        created_at_time: 1455825378,
        customer_uuid: '2ccf0040-ed25-0132-5987-0e67b818e6fb',
        details: {},
        device_details: null,
        device_geolocation: null,
        device_signing_time: 0,
        encrypted: false,
        flagged: false,
        hidden_details: {},
        message: '.',
        reason: null,
        requester_details: null,
        status: 'approved',
        uuid: '996201c0-b7a7-0133-7c06-0e67b818e6fb'
      }
    },
    authy_id: 1234567,
    callback_action: 'approval_request_status',
    device_uuid: '4d89c320-a9bb-0133-7c02-0e67b818e6fb',
    signature: 'BObhJgZwgU7O9r4Uo9VT6j6shAOe7y/IRGpW/N0Uq34/XHZU9E+aHOI5rcQzW1ZgNCECzVrqrsnjhYEK4Zq1naKWu0YNkuvILmMz8IxJEQH+c+6x186fjIjxvP4nu4p/pfUDomo/za24s1XOjtNlVsrDTDXClHUh5MjFQbyBjhFd8gOtmGVatN7K2Lx71I8YR2JDLbRX4DlJEMu++PLBn1nqQH9tbNYzX5jjX87CXPBtDfRwfWSs/imnfZ9zkDq4ZKuBcuwzQNsxKlby6782X0o78rYhCHrcDnHgRtyMGvX9ovK3XTt6M7p6i9SKaRgBWIOFVPygxv15iJesqt9cng==',
    status: 'approved',
    uuid: '996221c0-b7a7-0133-7c06-0e67b818e6fb'
  },
  headers: {
    host: 'foo.bar',
    'x-authy-signature': 'hqB6las54sMBA83GKs0U1QQi9ocJ2tH20SXHZNzfqqQ=',
    'x-authy-signature-nonce': 1455825429
  },
  method: 'POST',
  protocol: 'https',
  url: '/'
});

console.log('Approval request callback is valid');
Using promises
client.verifyCallback({
  body: {
    approval_request: {
      expiration_timestamp: 1455911778,
      logos: null,
      transaction: {
        created_at_time: 1455825378,
        customer_uuid: '2ccf0040-ed25-0132-5987-0e67b818e6fb',
        details: {},
        device_details: null,
        device_geolocation: null,
        device_signing_time: 0,
        encrypted: false,
        flagged: false,
        hidden_details: {},
        message: '.',
        reason: null,
        requester_details: null,
        status: 'approved',
        uuid: '996201c0-b7a7-0133-7c06-0e67b818e6fb'
      }
    },
    authy_id: 1234567,
    callback_action: 'approval_request_status',
    device_uuid: '4d89c320-a9bb-0133-7c02-0e67b818e6fb',
    signature: 'BObhJgZwgU7O9r4Uo9VT6j6shAOe7y/IRGpW/N0Uq34/XHZU9E+aHOI5rcQzW1ZgNCECzVrqrsnjhYEK4Zq1naKWu0YNkuvILmMz8IxJEQH+c+6x186fjIjxvP4nu4p/pfUDomo/za24s1XOjtNlVsrDTDXClHUh5MjFQbyBjhFd8gOtmGVatN7K2Lx71I8YR2JDLbRX4DlJEMu++PLBn1nqQH9tbNYzX5jjX87CXPBtDfRwfWSs/imnfZ9zkDq4ZKuBcuwzQNsxKlby6782X0o78rYhCHrcDnHgRtyMGvX9ovK3XTt6M7p6i9SKaRgBWIOFVPygxv15iJesqt9cng==',
    status: 'approved',
    uuid: '996221c0-b7a7-0133-7c06-0e67b818e6fb'
  },
  headers: {
    host: 'foo.bar',
    'x-authy-signature': 'hqB6las54sMBA83GKs0U1QQi9ocJ2tH20SXHZNzfqqQ=',
    'x-authy-signature-nonce': 1455825429
  },
  method: 'POST',
  protocol: 'https',
  url: '/'
}).then(function(response) {
  console.log('Approval request callback is valid');
})
.catch(function(error) {
  throw error;
});
Using callbacks
client.verifyCallback({
  body: {
    approval_request: {
      expiration_timestamp: 1455911778,
      logos: null,
      transaction: {
        created_at_time: 1455825378,
        customer_uuid: '2ccf0040-ed25-0132-5987-0e67b818e6fb',
        details: {},
        device_details: null,
        device_geolocation: null,
        device_signing_time: 0,
        encrypted: false,
        flagged: false,
        hidden_details: {},
        message: '.',
        reason: null,
        requester_details: null,
        status: 'approved',
        uuid: '996201c0-b7a7-0133-7c06-0e67b818e6fb'
      }
    },
    authy_id: 1234567,
    callback_action: 'approval_request_status',
    device_uuid: '4d89c320-a9bb-0133-7c02-0e67b818e6fb',
    signature: 'BObhJgZwgU7O9r4Uo9VT6j6shAOe7y/IRGpW/N0Uq34/XHZU9E+aHOI5rcQzW1ZgNCECzVrqrsnjhYEK4Zq1naKWu0YNkuvILmMz8IxJEQH+c+6x186fjIjxvP4nu4p/pfUDomo/za24s1XOjtNlVsrDTDXClHUh5MjFQbyBjhFd8gOtmGVatN7K2Lx71I8YR2JDLbRX4DlJEMu++PLBn1nqQH9tbNYzX5jjX87CXPBtDfRwfWSs/imnfZ9zkDq4ZKuBcuwzQNsxKlby6782X0o78rYhCHrcDnHgRtyMGvX9ovK3XTt6M7p6i9SKaRgBWIOFVPygxv15iJesqt9cng==',
    status: 'approved',
    uuid: '996221c0-b7a7-0133-7c06-0e67b818e6fb'
  },
  headers: {
    host: 'foo.bar',
    'x-authy-signature': 'hqB6las54sMBA83GKs0U1QQi9ocJ2tH20SXHZNzfqqQ=',
    'x-authy-signature-nonce': 1455825429
  },
  method: 'POST',
  protocol: 'https',
  url: '/'
}, function(err, res) {
  if (err) throw err;

  console.log('Approval request callback is valid');
});

Tests

To test using a local installation of node.js:

npm test

To test using Docker exclusively:

docker-compose run --rm sut

Release

npm version [<newversion> | major | minor | patch] -m "Release %s"

License

MIT

authy-client's People

Contributors

afsampaio avatar fixe avatar holm avatar madmod avatar nunofgs avatar ruimarinho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

authy-client's Issues

startPhoneVerification() results in ValidationFailedError

I have been testing the example for startPhoneVerification() but it results in a ValidationFailedError.

I finally took a look at how the authy repository does it and tried using the same parameters, and it worked. I think the readme is out of date.

Readme code resulting in ValidationFailedError:
client.startPhoneVerification({ countryCode: 'US', locale: 'en', phone: '7754615609', via: enums.verificationVia.SMS })

Functional code:
client.startPhoneVerification({ countryCode: '1', locale: 'en', phone: '775-461-5609', via: 'sms' })

On further examination, it seems the error stems from the countryCode parameter. Using a number is fine but it doesn't seem to accept letters anymore.

The via parameter accepts 'sms' and 'call'.

Bluebird error not being passed to callback

I am using the callback syntax for sending a one-touch request. When the mobile is not really registered, i see that bluebird is throwing an error:

async.js:61 : fn = function () { throw arg; };

Put, this is not being passed with err to the callback.

Is this expected behaviour or a bug?

Sandbox API is deprecated

According to conversations I've had with twilio/authy the sandbox API is deprecated.

Due to this I implemented a mocked authy server for testing purposes, but I was unable to use this library without nasty workarounds due to the (in my opinion) overly strict validation of the hosts being used.

At the very least you should note that the sandbox is deprecated, or prevent people from using it outright, and I would greatly appreciate it if you allowed for other endpoints than the official one.

I could whip up a PR for this if you tell me which route is preferable, but it seems like it would be a simple fix either way.

Unhandled rejection ValidationFailedError: Validation Failed

I tried the simplest example

const Client = require('authy-client').Client;
const client = new Client({ key: 'QmuGGTF2h1QZ0SxSo3cFn7dEwIBspMyH' });

client.registerUser({
  countryCode: '+7',
  email: '[email protected]',
  phone: '9629134867'
}).then(function(response) {
  return response.user.id;
}).then(function(authyId) {
  return client.requestSms({ authyId: authyId });
}).then(function(response) {
  console.log(`SMS requested to ${response.cellphone}`);
});
~    

And got this:

Unhandled rejection ValidationFailedError: Validation Failed
    at validate (/root/demo/node_modules/authy-client/dist/src/validator.js:74:11)
    at _bluebird2.default.try (/root/demo/node_modules/authy-client/dist/src/client.js:636:31)
    at tryCatcher (/root/demo/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/root/demo/node_modules/bluebird/js/release/method.js:39:29)
    at Client.registerUser (/root/demo/node_modules/authy-client/dist/src/client.js:621:34)
    at Object.<anonymous> (/root/demo/index.js:4:8)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:505:3

I met this problem here - https://github.com/AuthySE/Authy-demo
I followed the guidelines and tried to register. But I'm getting exactly the same error.

Trying to use it on react with webpack but installing it gave me all these missing module errors

I'm currently using react with webpack, I'm trying to incorporate authy for 2fa but upon installing this package it said I'm missing all these packages I had never heard of, is this normal? Do i need to install each one that they say are missing?

ERROR in ./node_modules/authy-client/dist/src/client.js
Module not found: Error: Can't resolve '../package' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/authy-client/dist/src'
@ ./node_modules/authy-client/dist/src/client.js 30:15-36
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/aba-routing-number-assert.js
Module not found: Error: Can't resolve 'abavalidator' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/aba-routing-number-assert.js 19:23-46
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/big-number-less-than-or-equal-to-assert.js
Module not found: Error: Can't resolve 'bignumber.js' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/big-number-less-than-or-equal-to-assert.js 19:20-43
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/big-number-less-than-assert.js
Module not found: Error: Can't resolve 'bignumber.js' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/big-number-less-than-assert.js 19:20-43
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/big-number-greater-than-assert.js
Module not found: Error: Can't resolve 'bignumber.js' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/big-number-greater-than-assert.js 19:20-43
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/big-number-greater-than-or-equal-to-assert.js
Module not found: Error: Can't resolve 'bignumber.js' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/big-number-greater-than-or-equal-to-assert.js 19:20-43
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/big-number-equal-to-assert.js
Module not found: Error: Can't resolve 'bignumber.js' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/big-number-equal-to-assert.js 19:20-43
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/big-number-assert.js
Module not found: Error: Can't resolve 'bignumber.js' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/big-number-assert.js 19:20-43
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/credit-card-assert.js
Module not found: Error: Can't resolve 'creditcard' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/credit-card-assert.js 19:21-42
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/international-bank-account-number-assert.js
Module not found: Error: Can't resolve 'iban' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/international-bank-account-number-assert.js 19:15-30
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/iso-3166-country-assert.js
Module not found: Error: Can't resolve 'isoc' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/iso-3166-country-assert.js 25:20-35
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/forever-agent'
@ ./node_modules/forever-agent/index.js 6:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/authy-client/dist/src/logging/request.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/tough-cookie/lib'
@ ./node_modules/tough-cookie/lib/cookie.js 32:10-24
@ ./node_modules/request/lib/cookies.js
@ ./node_modules/request/index.js
@ ./node_modules/authy-client/dist/src/logging/request.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/tunnel-agent'
@ ./node_modules/tunnel-agent/index.js 3:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/authy-client/dist/src/logging/request.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/ip-assert.js
Module not found: Error: Can't resolve 'net' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/ip-assert.js 8:11-25
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/taxpayer-identification-number-assert.js
Module not found: Error: Can't resolve 'tin-validator' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/taxpayer-identification-number-assert.js 16:14-38
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/forever-agent'
@ ./node_modules/forever-agent/index.js 7:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/authy-client/dist/src/logging/request.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/tunnel-agent'
@ ./node_modules/tunnel-agent/index.js 4:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/authy-client/dist/src/logging/request.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

ERROR in ./node_modules/validator.js-asserts/dist/asserts/uk-modulus-checking-assert.js
Module not found: Error: Can't resolve 'uk-modulus-checking' in '/Users/scotth527/Desktop/UC Director Front end/UC-Director/UC-Director/node_modules/validator.js-asserts/dist/asserts'
@ ./node_modules/validator.js-asserts/dist/asserts/uk-modulus-checking-assert.js 21:28-58
@ ./node_modules/validator.js-asserts/dist/index.js
@ ./node_modules/authy-client/dist/src/validator.js
@ ./node_modules/authy-client/dist/src/client.js
@ ./node_modules/authy-client/dist/src/index.js
@ ./src/views/Pages/Login/Login.js
@ ./src/App.js
@ ./src/index.js
@ multi ./src/index.js

Validation Failed VerifyToken

I have a Problem with the authy-client for nodejs.

I become this error

errstack

const Client = require('authy-client').Client;

const client = new Client({key: Akey});

client.verifyToken({authyID: res[0].authyID, token: authKey})
                    .then(function(response){
                        console.log('OK');
                    }).catch(function(error){
                        console.log('Failed')
                        throw error;
                });

Reference to all optional arguments

Sorry but I can't seem to find where are the options I can pass to startPhoneVerification I want to change the code_length

A reference to where I can easily know what options to pass for each function would be of great use.

I'm using https://www.twilio.com/docs/verify/api/verification but the parameters don't match.

For example this library uses phone instead of phone_number so any reference to the right way to pass options would be great, the README doesn't show all options that can be passed

startPhoneVerification is_ported AssertionFailedError

I'm getting a validation error when calling the startPhoneVerification method. It appears that is_ported is no longer returned from Authy. When I call this method it returns a 500 Internal Server Error. When I comment out line 798 in client.js it successful returns a 200 without any errors.

Curl Command
curl 'https://api.authy.com/protected/json/phones/verification/start?api_key=xxx'
-d via='sms'
-d phone_number='2482895124'
-d country_code=1
{"carrier":"Pinger","is_cellphone":false,"message":"Text message sent to +1 248-289-5124.","seconds_to_expire":140,"uuid":"52ad5c80-cb9f-0134-aec9-0a2b7b0ecd88","success":true}%

Signature validation requires the presence of "approval_request"

The signature validation asserts that the body contains "approval_request". I think this restriction should be lifted, so the validation can also be done when the endpoint is validated in the Authy dashboard. In the test request from Authy the "approval_request" is not present.

Phone Verification: is_ported property not always present in Authy response

First of all, thanks for a fantastic library!

Seems like the beforementioned property is missing from some Authy responses, making assert throw:

$ curl 'https://api.authy.com/protected/json/phones/verification/start?' 
-d via='sms' 
-d phone_number='9XXXXXXX' 
-d country_code=47 
-d locale='nb' 
-H "X-Authy-API-Key: XXX"

Response:

{
"carrier":"Telenor Norge AS",
"is_cellphone":true,
"message":"SMS sendt til +47 9-XXX-XXXX.",
"seconds_to_expire":599,
"uuid":"557c6b40-6941-0134-ffdf-0ece2b9a2925",
"success":true
}

Logging options override cached `request` object

When defining the logging options of request it modifies by reference the require cached object request, making all the system log requests that don't want to.

Problem: Any application that uses request and uses this client will log all the requests, even we do not want to log them. See this.

Signature validation requires x-authy-signature-nonce to be an integer

Hi

First of thanks for a really high quality library!

In the callback verification it asserts that the x-authy-signature-nonce header is an integer. However headers are always strings, so it fails this test. Since the nonce is just concatenated to the string for HMAC, it doesn't really need to parsed to an integer, and could really be any string.

Can the validation be changed to allow both a string and an integer, so to avoid users having to parse manually, but still keep backwards compatibility?

AssertionFailedError on startPhoneVerification

This happens for around 100 different numbers each day from many different countries (CA, FR, AU)

Sometimes carrier is null, sometimes it is not there at all, sometimes is_phonenumber is missing.

Example:

2018-11-27 13:47:27: send_phone_verification { country: 'FR', phone: 'XXXX' } { AssertionFailedError: 500 Internal Server Error
    at assert (node_modules/authy-client/dist/src/validator.js:60:11)
    at Client.rpc.postAsync.bind.then.tap.response (node_modules/authy-client/dist/src/client.js:750:31)
  message: 'Internal Server Error',
  data: 
   { message: 'SMS envoyé à +33 XXXXX.',
     seconds_to_expire: 599,
     uuid: 'XXXXX',
     success: true },
  errors: 
   { carrier: 
      { __class__: 'Violation',
        assert: [Object],
        value: [Object],
        violation: [Object] },
     is_cellphone: 
      { __class__: 'Violation',
        assert: [Object],
        value: [Object],
        violation: [Object] } },
  name: 'AssertionFailedError',
  code: 500 }

and another one:

  message: 'Internal Server Error',
  data: 
   { carrier: null,
     is_cellphone: true,
     message: 'SMS inviato a +39 XXXX',
     seconds_to_expire: 599,
     uuid: 'XXXXX',
     success: true },
  errors: { carrier: [ [Object] ] },
  name: 'AssertionFailedError',

This might have something to do with:

https://support.twilio.com/hc/en-us/articles/360004563433

Update dependancies

looks like this project is abandoned. I see a lot of PR bots on dependency updates being ignored. We should get these updated and push out a new release. Many have security fixes such as validator to resolve issues like

GHSA-qgmg-gppg-76g5

Handle `null` device when requesting an SMS

{
  "message": "Ignored: SMS is not needed for smartphones. Pass force=true if you want to actually send it anyway.",
  "cellphone": "+1-XXX-XXX-XX00",
  "device": null,
  "ignored": true,
  "success": true
}

"deleteUser" POSTing to wrong endpoint

The deleteUser API call is not hitting the correct endpoint as of the current version.

Authy API Docs: /protected/{FORMAT}/users/{USER ID}/remove
authy-client deleteUser call: /protected/json/users/{USER ID}/delete

The authy-client needs to hit "remove" instead of "delete" for users (see the last component in the URIs above). Otherwise this results in a 404 call.

Possible to copy 2fa token to clipboard?

I use the lastpass cli to copy creds to my clipboard. Is it possible to do with the authy api or this authy client? If not, is this a viable feature request? 😄

Use proxy

How can I set a http or socks proxy?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.