services/mobileid/interfaces/nsIMobileIdentityUIGlue.idl
author Dave Townsend <dtownsend@oxymoronical.com>
Thu, 06 Nov 2014 12:16:15 -0800
changeset 214476 8094e9f641e3940b9e45df2802625367ece3acd4
parent 187466 e3dc24f425734635f3f6d663d2339c4234027d86
permissions -rw-r--r--
Bug 1095024: Port bug 987849 to mochitest-jetpack. r=jmaher

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

[scriptable, uuid(6c4c5758-e041-4e0d-98da-67bb552f8018)]
interface nsIMobileIdentityUIGlue : nsISupports
{
  /**
  * Request the creation of a Mobile ID UI flow.
  *
  * The permission prompt starts the verification flow asking the user
  * for permission to share her phone number and allowing her to choose
  * an already known phone number, a SIM which phone number is unknown
  * (even in a multi-SIM scenario) or an external phone number.
  * Selecting a phone number implies giving permission to share it with the
  * API caller, so the UI should be clear about this.
  *
  * @manifestURL manifest URL of the mobile ID requester.
  * @iccInfo array of objects containing the information about the
  *          SIM cards available in the device and that can be used for the
  *          phone number verification and share process.
  *
  * Returns a Promise. An instance of nsIMobileIdentityUIGluePromptResult will
  * be returned as result of the Promise or a single string containing an error
  * in case of rejection.
  */
  jsval startFlow(in DOMString manifestURL, in jsval iccInfo);

  /**
   * Will prompt the user to enter a code used to verify a phone number.
   * This will only be called if an external phone number is selected in
   * startFlow().
   *
   * @retries number of retries left to validate a verification code.
   * @timeout the verification code expires after the timeout fires. This is
   *          the total life time of the verification code.
   * @timeLeft we might call verificationCodePrompt more than once for the
   *           same verification flow (i.e. when the verification code entered
   *           by the user is incorrect) so we give to the UI the amount of
   *           time left before the verification code expires.
   *
   * Returns a Promise. The value of the resolved promise will be the
   * verification code introduced through the UI or an error in case of
   * rejection of the promise.
   */
  jsval verificationCodePrompt(in short retries,
                               in long timeout,
                               in long timeLeft);

  /**
   * Notify the UI about the start of the verification process.
   */
  void verify();

  /**
   * Notify the UI about an error in the verification process.
   */
  void error(in DOMString error);

  /**
   * Notify the UI about the succesful phone number verification.
   */
  void verified(in DOMString verifiedPhoneNumber);

  /**
   * Callback to be called when the user cancels the verification flow via UI.
   */
  attribute jsval oncancel;

  /**
   * Callback to be called when the user requests a resend of a verification
   * code.
   */
  attribute jsval onresendcode;
};