• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5/**
6 * @fileoverview Provides a "bottom half" helper to assist with raw requests.
7 * This fills the same role as the Authenticator-Specific Module component of
8 * U2F documents, although the API is different.
9 */
10'use strict';
11
12/**
13 * @typedef {{
14 *   type: string,
15 *   timeout: number
16 * }}
17 */
18var HelperRequest;
19
20/**
21 * @typedef {{
22 *   type: string,
23 *   code: (number|undefined)
24 * }}
25 */
26var HelperReply;
27
28/**
29 * A helper to process requests.
30 * @interface
31 */
32function RequestHelper() {}
33
34/**
35 * Gets a handler for a request.
36 * @param {HelperRequest} request The request to handle.
37 * @return {RequestHandler} A handler for the request.
38 */
39RequestHelper.prototype.getHandler = function(request) {};
40
41/**
42 * A handler to track an outstanding request.
43 * @extends {Closeable}
44 * @interface
45 */
46function RequestHandler() {}
47
48/** @typedef {function(HelperReply, string=)} */
49var RequestHandlerCallback;
50
51/**
52 * @param {RequestHandlerCallback} cb Called with the result of the request,
53 *     and an optional source for the result.
54 * @return {boolean} Whether this handler could be run.
55 */
56RequestHandler.prototype.run = function(cb) {};
57
58/** Closes this handler. */
59RequestHandler.prototype.close = function() {};
60