Created
November 4, 2014 23:32
-
-
Save psiddh/7b86b53c768e2655bcf2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var openSession = function(readers) { | |
var seReader = readers[0]; | |
return seReader.openSession(); | |
}; | |
var openChannel = function(session) { | |
var testAIDBuffer = ['0', '1', '2']; | |
var mastercardAID = new Uint8Array(testAIDBuffer); | |
return session.openLogicalChannel(mastercardAID); | |
}; | |
var sendFirstAPDU = function(channel) { | |
var apdu = new SECommand(0x91, 0x10, 0x00, 0x00); | |
return channel.transmit(apdu); | |
}; | |
var sendSecondAPDU = function(response) { | |
var apdu = new SECommand(0x91, 0x10, 0x00, 0x00); | |
return response.channel.transmit(apdu); | |
}; | |
var updateUI = function() { | |
console.log('All okay'); | |
}; | |
var showError = function(error) { | |
console.error(error); | |
}; | |
var cleanup = function(response) { | |
return response.channel.session.reader.closeAll(); | |
}; | |
var sedom = window.navigator.seManager; | |
var pRdrs = sedom.getSEReaders(); | |
pRdrs.then(openSession) | |
.then(openChannel) | |
.then(sendFirstAPDU) | |
.then(sendSecondAPDU) | |
.then(cleanup) | |
.then(updateUI) | |
.catch(showError); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment