// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
// Implementation of the proposed "Web OTP API".
//
// Proposal: https://github.com/WICG/web-otp
enum SmsStatus {
kSuccess, // WebOTP flow succeeded
kUnhandledRequest, // request not handled upon destruction (navigation etc.)
kCancelled, // request cancelled by the new request in the same WebOTPService
kAborted, // request aborted by API callers using AbortController
kTimeout, // request timeout (user not responding to the prompt or not receiving an sms)
kBackendNotAvailable // request cancelled since OTP backend was not available
};
// This interface is created per-document. The renderer process sends messages
// to the browser process over this interface.
interface WebOTPService {
// Retrieves the next SMS message that arrives on the phone that is addressed
// to the caller's origin.
// Returns the otp that was part of the received SMS.
// |otp| is only set if status == kSuccess.
Receive() => (SmsStatus status, string? otp);
// Aborts the current retrieval process and resolves it with an
// kAborted SmsStatus.
Abort();
};