Skip to content

Resolve "Remotely register twilio numbers as signal numbers"

aguestuser requested to merge 19-register-twilio-numbers-as-signal-numbers into master

Closes #19 (closed) (and fulfills its Acceptance Criteria)


Usage

With this MR, a developer can use the following 1-line bash command to purchase 10 numbers from twilio in area code 510 and authenticate them with Signal, making them ready for use by signal-boost/signal-cli:

$ ./bin/provision-numbers -n 10 -a 510

Implementation

  • add a phoneNumber service (and phoneNumber model)
  • track a phone number's progress through the provisioning process with status field (which may be PURCHASED, REGISTERED, VERIFIED, or ACTIVE -- the latter will be used in subsequent cards when a verified number is assigned to a channel)
  • add phoneNumber#purchase, which uses the twilio API to search for available phone numbers and "create" (ie: buy), the first available one
  • add phoneNumber#register, which shells out to signal-cli register to request a verfication code for a given number, which will trigger the signal server to send an SMS to the number
  • add phoneNumber#verify, which (1) is called when twilio forwards an sms to the /twilioSms endpoint provided by the create step in #purchase and (2) reads the verification code from the webhook payload and shells out to signal-cli verify to submit the verification code to the signal server
  • use a common event emitter passed to both #register and #verify to allow the latter to communicate to the former when it has completed (:. allowing the caller to only call one async function and return/resolve when it completes)
  • compose both #purchase and #verify into #provision, and extend the latter into #provisionN, which we expose at the endpoint /phoneNumbers/provision
Edited by aguestuser

Merge request reports