Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -37,5 +37,7 @@ build/chrome/test build/chrome/google-pcsc.js build/chrome/manifest.json build/chrome/jsrsasign.js build/chrome/extra/*.png +build/tcl/ssh-agent-noasync.js +build/tcl/tclkit ADDED build/tcl/Makefile Index: build/tcl/Makefile ================================================================== --- /dev/null +++ build/tcl/Makefile @@ -0,0 +1,12 @@ +all: ssh-agent-noasync.js + +ssh-agent-noasync.js: ../chrome/ssh-agent.js + cc -Dawait='' -Dasync='' -nostdinc -C -E -x c ../chrome/ssh-agent.js -o - | grep -v '^# ' > ssh-agent-noasync.js.new + mv ssh-agent-noasync.js.new ssh-agent-noasync.js + +clean: + rm -f ssh-agent-noasync.js.new ssh-agent-noasync.js + +distclean: clean + +.PHONY: all clean distclean ADDED build/tcl/chrome-emu.js Index: build/tcl/chrome-emu.js ================================================================== --- /dev/null +++ build/tcl/chrome-emu.js @@ -0,0 +1,29 @@ + +console = { + log: function() { + /* XXX:TODO: Logging */ + } +} +chrome = { + runtime: { + connectCallbacks: [], + onConnectExternal: { + addListener: function(callback) { + if (!callback) { + return; + } + + chrome.runtime.connectCallbacks.push(callback) + }, + removeListener: function(callback) { + var idx; + idx = chrome.runtime.connectCallbacks.indexOf(callback); + if (idx == -1) { + return; + } + + chrome.runtime.connectCallbacks.splice(idx, 1); + } + } + } +} ADDED build/tcl/ssh-agent.tcl Index: build/tcl/ssh-agent.tcl ================================================================== --- /dev/null +++ build/tcl/ssh-agent.tcl @@ -0,0 +1,33 @@ +#! /home/rkeene/tmp/cackey/build/tcl/tclkit + +package require duktape +package require tuapi + +proc initSSHAgent {} { + if {[info exists ::jsHandle]} { + return + } + + set chromeEmuJS [read [open chrome-emu.js]] + set sshAgentJS [read [open ssh-agent-noasync.js]] + + set ::jsHandle [::duktape::init] + + ::duktape::eval $::jsHandle $chromeEmuJS + ::duktape::eval $::jsHandle $sshAgentJS + + puts [::duktape::eval $::jsHandle { + chrome.runtime.connectCallbacks[0]({ + sender: { + id: "pnhechapfaindjhompbnflcldabbghjo" + }, + onMessage: { + addListener: function() { + /* XXX:TODO */ + } + } + }) + }] +} + +initSSHAgent