Last active
August 29, 2015 14:06
-
-
Save kamituel/264ee1683c5a3f805be0 to your computer and use it in GitHub Desktop.
SE API usage example
This file contains 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.filter(function(reader) { | |
return reader.type === 'uicc'; | |
})[0]; | |
if (!seReader) { | |
return Promise.reject('No suitable SE found'); | |
} | |
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('A', 'B', 'C', 'D'); | |
return channel.transmit(apdu); | |
}; | |
var sendSecondAPDU = function(response) { | |
// Do sth wit the response | |
var apdu = new SECommand('1', '2', '3', '4'); | |
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.reader.closeAll(); | |
}; | |
var sedom = window.navigator.mozSEManager; | |
var pRdrs = sedom.getSEReaders(); | |
pRdrs.then(openSession) | |
.then(openChannel) | |
.then(sendFirstAPDU) | |
.then(sendSecondAPDU) | |
.then(cleanup) | |
.then(updateUI) | |
.catch(showError); |
How do we handle the 9Fxx (more data to be fetched) when openinng the logical channel, or for any other APDU send during .transmit()? Do we fetch this data in the SIM API impl, or do we leave it out for the Gaia app to do itself?
It might be implemeted by Gaia app, by OS, or on the RIL chipset level.
How to support developers with testing this API on the phone or the emulator? (emulator support? card reader connected to the PC via USB, and acting as a SE for an emulator)
Security around field enter/leave events - do we want to constrain this somehow?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: The response from the openLogicalChannel (so SELECT an applet) might contain some data useful to the Gaia app.
The Open Mobile API has this data available.