| // Copyright 2019 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module blink.mojom; |
| |
| import "mojo/public/mojom/base/time.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 storage partition but its execution is context |
| // associated: there is an origin associated with a request that is multiplexed |
| // through one instance on a storage partition. |
| 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(); |
| }; |