15c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// Copyright 2014 The Chromium Authors. All rights reserved.
25c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// Use of this source code is governed by a BSD-style license that can be
35c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// found in the LICENSE file.
45c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
55c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
65c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @fileoverview Contains a factory interface for creating and opening gnubbies.
75c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */
85c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu'use strict';
95c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
105c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
115c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * A factory for creating and opening gnubbies.
125c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @interface
135c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */
145c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liufunction GnubbyFactory() {}
155c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
165c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
175c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * Enumerates gnubbies.
186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * @param {function(number, Array.<GnubbyDeviceId>)} cb Enumerate callback
195c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */
205c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuGnubbyFactory.prototype.enumerate = function(cb) {
215c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu};
225c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)/** @typedef {function(number, Gnubby=)} */
246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)var FactoryOpenCallback;
256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
265c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
275c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * Creates a new gnubby object, and opens the gnubby with the given index.
286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * @param {GnubbyDeviceId} which The device to open.
295c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @param {boolean} forEnroll Whether this gnubby is being opened for enrolling.
306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * @param {FactoryOpenCallback} cb Called with result of opening the gnubby.
315c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @param {string=} logMsgUrl the url to post log messages to
325c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */
335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuGnubbyFactory.prototype.openGnubby = function(which, forEnroll, cb, logMsgUrl) {
345c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu};
356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)/**
376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * Called during enrollment to check whether a gnubby known not to be enrolled
386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * is allowed to enroll in its present state. Upon completion of the check, the
396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * callback is called.
406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * @param {Gnubby} gnubby The not-enrolled gnubby.
416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * @param {string} appIdHash The base64-encoded hash of the app id for which
426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) *     the gnubby being enrolled.
436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * @param {FactoryOpenCallback} cb Called with the result of the prerequisite
446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) *     check. (A non-zero status indicates failure.)
456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) */
466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)GnubbyFactory.prototype.notEnrolledPrerequisiteCheck =
476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    function(gnubby, appIdHash, cb) {
486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)};
49