Version: Smart Feature Phone 2.5

SESession

Description#

SESession interface represents a connection to one of the Secure Elements available on the device. These objects can be used to open and close communication channels with an applet.

Properties#

  • SESession.reader 'reader' that provides this session

  • SESession.isClosed Status of current session

Methods#

  • SESession.getAtr() This attribute MUST return the historical bytes provided by the physical interface of the Secure Element or null if the interface does not provide it.

  • SESession.openBasicChannel() Opens a communication basic channel to an application on Secure Element identified by the AID.

  • SESession.openLogicalChannel() Opens a communication logical channel to an application on Secure Element identified by the AID.

  • SESession.closeAll() Close all active channels associated with this session.

Example#

window.AID = {
CRS: "A00000015143525300",
PPSE: "325041592E5359532E4444463031",
ISD:"A000000151000000"
};
function hexString2byte(str) {
var a = [];
for(var i = 0, len = str.length; i < len; i+=2) {
a.push(parseInt(str.substr(i, 2), 16));
}
return new Uint8Array(a);
}
window.navigator.seManager.getSEReaders()
.then((readers) => {
window.reader = readers[0];
return readers[0].openSession();
})
.then((session) => {
window.testSession = session;
console.log("Open a session successfully");
return session.openBasicChannel(hexString2byte(window.AID.ISD));
})
.then((channel) => {
console.log("Open a basic channel successfully");
return window.testSession.openLogicalChannel(hexString2byte(window.AID.ISD));
})
.then((channel) => {
console.log("Open a logical channel successfully");
return window.reader.closeAll();
})
.then(()=> {
console.log("Close all channels successfully");
})
.catch((err) => {
console.log("Failed!!!");
window.reader.closeAll();
});