OLD | NEW |
(Empty) | |
| 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 // Custom binding for the enterprise.certificates API. |
| 6 |
| 7 var binding = require('binding').Binding.create('enterprise.certificates'); |
| 8 var utils = require('utils'); |
| 9 var internalAPI = require('enterprise.certificatesInternal').binding; |
| 10 var internalAPISchema = requireNative('schema_registry') |
| 11 .GetSchema('enterprise.certificatesInternal'); |
| 12 |
| 13 // Token class definition. |
| 14 var Token = function(tokenName) { |
| 15 privates(this).tokenName_ = tokenName; |
| 16 }; |
| 17 |
| 18 Object.defineProperty(Token.prototype, 'name', { |
| 19 get: function() { |
| 20 return privates(this).tokenName_; |
| 21 } |
| 22 , enumerable : true |
| 23 }); |
| 24 |
| 25 Token.prototype.importClientCertificate = function(key, certificate, callback) { |
| 26 var schema = utils.lookup(internalAPISchema.functions, |
| 27 'name', |
| 28 'importClientCertificateAndWebCryptoKey'); |
| 29 internalAPI.importClientCertificateAndWebCryptoKey( |
| 30 key, certificate, this.name, callback); |
| 31 }; |
| 32 |
| 33 binding.registerCustomHook(function(api) { |
| 34 var apiFunctions = api.apiFunctions; |
| 35 |
| 36 var ret = apiFunctions.setHandleRequest('getTokens', function(callback) { |
| 37 console.log(internalAPI); |
| 38 console.log(internalAPI.getTokens); |
| 39 internalAPI.getTokens(function(tokenNames) { |
| 40 callback($Array.map( |
| 41 tokenNames, function(tokenName) { return new Token(tokenName); })); |
| 42 }); |
| 43 }); |
| 44 }); |
| 45 |
| 46 exports.binding = binding.generate(); |
OLD | NEW |