Skip to content

Commit 0cbfc19

Browse files
committed
Bump versions
1 parent e025fc7 commit 0cbfc19

7 files changed

+129
-839
lines changed

demo/device-activated-promise.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ const smartcard = require('../lib/index');
44
const Devices = smartcard.Devices;
55
const devices = new Devices();
66

7-
8-
devices.onActivated().then(event => {
9-
console.log(`Device '${event.device}' activated`);
10-
event.devices.map((device, index) => {
11-
console.log(`Device #${index + 1}: '${device.name}'`);
12-
});
13-
});
7+
devices.onActivated().then((event) => {
8+
console.log(`Device '${event.device}' activated`);
9+
event.devices.map((device, index) => {
10+
console.log(`Device #${index + 1}: '${device.name}'`);
11+
});
12+
});

demo/device-activated.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ const smartcard = require('../lib/index');
44
const Devices = smartcard.Devices;
55
const devices = new Devices();
66

7-
8-
devices.on('device-activated', event => {
9-
console.log(`Device '${event.device}' activated`);
10-
event.devices.map((device, index) => {
11-
console.log(`Device #${index + 1}: '${device.name}'`);
12-
});
7+
devices.on('device-activated', (event) => {
8+
console.log(`Device '${event.device}' activated`);
9+
event.devices.map((device, index) => {
10+
console.log(`Device #${index + 1}: '${device.name}'`);
11+
});
1312
});

demo/device-deactivated-promise.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ const smartcard = require('../lib/index');
44
const Devices = smartcard.Devices;
55
const devices = new Devices();
66

7-
8-
devices.onDeactivated().then(event => {
9-
console.log(`Device '${event.device}' deactivated`);
10-
event.devices.map((device, index) => {
11-
console.log(`Device #${index + 1}: ${device.name}`);
12-
});
7+
devices.onDeactivated().then((event) => {
8+
console.log(`Device '${event.device}' deactivated`);
9+
event.devices.map((device, index) => {
10+
console.log(`Device #${index + 1}: ${device.name}`);
11+
});
1312
});

demo/device-deactivated.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ const smartcard = require('../lib/index');
44
const Devices = smartcard.Devices;
55
const devices = new Devices();
66

7-
8-
devices.on('device-deactivated', event => {
9-
console.log(`Device '${event.device}' deactivated`);
10-
event.devices.map((device, index) => {
11-
console.log(`Device #${index + 1}: ${device.name}`);
12-
});
7+
devices.on('device-deactivated', (event) => {
8+
console.log(`Device '${event.device}' deactivated`);
9+
event.devices.map((device, index) => {
10+
console.log(`Device #${index + 1}: ${device.name}`);
11+
});
1312
});

demo/smartcard-demo.js

+79-50
Original file line numberDiff line numberDiff line change
@@ -9,63 +9,92 @@ const CommandApdu = api.CommandApdu;
99

1010
const devices = new Devices();
1111

12-
13-
devices.on('device-activated', event => {
14-
const currentDevices = event.devices;
15-
let device = event.device;
16-
console.log(`Device '${device}' activated, devices: ${currentDevices}`);
17-
currentDevices.map((device, index) => {
18-
console.log(`Device #${index + 1}: ${device.name}`);
12+
devices.on('device-activated', (event) => {
13+
const currentDevices = event.devices;
14+
let device = event.device;
15+
console.log(`Device '${device}' activated, devices: ${currentDevices}`);
16+
currentDevices.map((device, index) => {
17+
console.log(`Device #${index + 1}: ${device.name}`);
18+
});
19+
20+
device.on('card-inserted', (event) => {
21+
let card = event.card;
22+
console.log(`\nCard '${card.getAtr()}' inserted into '${event.device}'`);
23+
24+
card.on('command-issued', (event) => {
25+
console.log(`Command '${event.command}' issued to '${event.card}' `);
1926
});
2027

28+
card.on('response-received', (event) => {
29+
console.log(
30+
`Response '${event.response}' received from '${event.card}' in response to '${event.command}'`
31+
);
32+
});
2133

22-
device.on('card-inserted', event => {
23-
let card = event.card;
24-
console.log(`\nCard '${card.getAtr()}' inserted into '${event.device}'`);
25-
26-
card.on('command-issued', event => {
27-
console.log(`Command '${event.command}' issued to '${event.card}' `);
28-
});
29-
30-
card.on('response-received', event => {
31-
console.log(`Response '${event.response}' received from '${event.card}' in response to '${event.command}'`);
32-
});
33-
34-
// card
35-
// .issueCommand('00A404000E315041592E5359532E444446303100')
36-
// .then((response) => {
37-
// console.log(`Response '${response.toString('hex')}`);
38-
// }).catch((error) => {
39-
// console.error(error);
40-
// });
41-
42-
const application = new Iso7816Application(card);
34+
// card
35+
// .issueCommand('00A404000E315041592E5359532E444446303100')
36+
// .then((response) => {
37+
// console.log(`Response '${response.toString('hex')}`);
38+
// }).catch((error) => {
39+
// console.error(error);
40+
// });
4341

44-
application.on('application-selected', event => {
45-
console.log(`Application Selected ${event.application}`);
46-
});
42+
const application = new Iso7816Application(card);
4743

48-
application.selectFile([0x31, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31])
49-
.then((response) => {
50-
console.info(`Select PSE Response: '${response}' '${response.meaning()}'`);
51-
return application.selectFile(hexify.toByteArray('a0000000041010'));
52-
}).then((response) => {
53-
console.info(`Select Application Response: '${response}' '${response.meaning()}'`);
54-
return application.issueCommand(new CommandApdu({bytes: [0x80, 0xa8, 0x00, 0x00, 0x02, 0x83, 0x00, 0x00]}));
55-
}).then((response) => {
56-
console.info(`Get Processing Options Response: '${response}' '${response.meaning()}'`);
57-
return response;
58-
}).catch((error) => {
59-
console.error('Error:', error, error.stack);
60-
});
61-
});
62-
device.on('card-removed', event => {
63-
console.log(`Card ${event.card} removed from '${event.name}' `);
44+
application.on('application-selected', (event) => {
45+
console.log(`Application Selected ${event.application}`);
6446
});
6547

48+
application
49+
.selectFile([
50+
0x31,
51+
0x50,
52+
0x41,
53+
0x59,
54+
0x2e,
55+
0x53,
56+
0x59,
57+
0x53,
58+
0x2e,
59+
0x44,
60+
0x44,
61+
0x46,
62+
0x30,
63+
0x31,
64+
])
65+
.then((response) => {
66+
console.info(
67+
`Select PSE Response: '${response}' '${response.meaning()}'`
68+
);
69+
return application.selectFile(hexify.toByteArray('a0000000041010'));
70+
})
71+
.then((response) => {
72+
console.info(
73+
`Select Application Response: '${response}' '${response.meaning()}'`
74+
);
75+
return application.issueCommand(
76+
new CommandApdu({
77+
bytes: [0x80, 0xa8, 0x00, 0x00, 0x02, 0x83, 0x00, 0x00],
78+
})
79+
);
80+
})
81+
.then((response) => {
82+
console.info(
83+
`Get Processing Options Response: '${response}' '${response.meaning()}'`
84+
);
85+
return response;
86+
})
87+
.catch((error) => {
88+
console.error('Error:', error, error.stack);
89+
});
90+
});
91+
device.on('card-removed', (event) => {
92+
console.log(`Card ${event.card} removed from '${event.name}' `);
93+
});
6694
});
6795

68-
devices.on('device-deactivated', event => {
69-
console.log(`Device '${event.device}' deactivated, devices: [${event.devices}]`);
96+
devices.on('device-deactivated', (event) => {
97+
console.log(
98+
`Device '${event.device}' deactivated, devices: [${event.devices}]`
99+
);
70100
});
71-

package.json

+3-13
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,16 @@
2525
"compile": "babel -d lib/ src/",
2626
"compile:watch": "babel -w -d lib/ src/",
2727
"release:patch": "npm run compile && npm version patch && git push && yarn publish",
28-
"prettier": "prettier --write \"{src,ingest,config}/**/*.{js,ts}\""
28+
"prettier": "prettier --write \"{src,demo}/**/*.{js,ts}\""
2929
},
3030
"dependencies": {
3131
"hexify": "^1.0.1",
3232
"pcsclite": "^1.0.0",
33-
"pino": "^6.3.2"
33+
"pino": "^6.11.1"
3434
},
3535
"devDependencies": {
3636
"babel-cli": "^6.26.0",
3737
"babel-preset-es2015": "^6.24.1",
38-
"husky": "^4.2.5",
39-
"lint-staged": "^10.2.11",
40-
"prettier": "^2.0.5"
41-
},
42-
"husky": {
43-
"hooks": {
44-
"pre-commit": "lint-staged"
45-
}
46-
},
47-
"lint-staged": {
48-
"*.{js,ts,json,md}": "prettier --write"
38+
"prettier": "^2.2.1"
4939
}
5040
}

0 commit comments

Comments
 (0)