commit
5ac52b4495
@ -0,0 +1,3 @@ |
||||
[submodule "YACardEmu"] |
||||
path = YACardEmu |
||||
url = https://github.com/hjri/YACardEmu.git |
@ -0,0 +1 @@ |
||||
Subproject commit d9e2dc13a4ed05a6fa5d7f81a21585873c7d850e |
@ -0,0 +1,14 @@ |
||||
[config] |
||||
; basepath MUST end in a trailing slash! |
||||
;basepath = /home/wutno/cards/ |
||||
basepath = cards/ |
||||
; Linux |
||||
serialpath = /dev/ttyUSB1 |
||||
; Windows |
||||
;serialpath = COM3 |
||||
;serialpath = \\.\pipe\YACardEmu |
||||
; |
||||
; Optional |
||||
; |
||||
apiport = 8082 |
||||
autoselectedcard = card.bin |
@ -0,0 +1,52 @@ |
||||
import { NFC } from 'nfc-pcsc' |
||||
import fetch from 'node-fetch' |
||||
|
||||
console.log('[ ][INF][EABU]: Starting up (if this hangs check if pcscd is running)') |
||||
const nfc = new NFC() |
||||
const status = { |
||||
card: null |
||||
} |
||||
|
||||
console.log('[ ][INF][EABU]: NFC Initialized') |
||||
nfc.on('error', err => { |
||||
console.error('[!][ERR][PCSC]:', err); |
||||
}); |
||||
nfc.on('reader', reader => { |
||||
reader.aid = 'F222222222'; |
||||
reader.on('card', card => { |
||||
console.log(`[C][INF][PCSC]: Card ${card.uid} scanned`) |
||||
if (status.card === null) { |
||||
status.card = card.uid |
||||
console.log(`[C][INF][YACE]: Telling YACE to insert ${card.uid}`) |
||||
fetch('http://localhost:8082/api/v1/insertCard?cardname=' + card.uid, { method: 'POST' }) |
||||
} else { |
||||
console.log(`[C][INF][EABU]: Ignoring as we already have a card...`) |
||||
} |
||||
}) |
||||
reader.on('error', err => { |
||||
console.error('[!][ERR][PCSC]:', err); |
||||
}); |
||||
}) |
||||
|
||||
|
||||
const pollYACE = () => { |
||||
if (status.card !== null) { |
||||
fetch('http://localhost:8082/api/v1/insertedCard') |
||||
.then(res => res.json()) |
||||
.then(bool => console.log('[ ][INF][YACE] Emulator card inserted: ' + bool.inserted)) |
||||
fetch('http://localhost:8082/api/v1/hasCard') |
||||
.then(res => res.json()) |
||||
.then(bool => { |
||||
console.log('[ ][INF][YACE] Emulator card present: ' + bool) |
||||
if (!bool) { |
||||
status.card = null |
||||
fetch('http://localhost:8082/api/v1/insertCard?cardname=dummy', { method: 'POST' }) |
||||
} |
||||
}) |
||||
.finally(() => setTimeout(pollYACE, 100)) |
||||
} else { |
||||
setTimeout(pollYACE, 200) |
||||
} |
||||
} |
||||
|
||||
pollYACE() |
@ -0,0 +1,8 @@ |
||||
{ |
||||
"type": "module", |
||||
"dependencies": { |
||||
"nfc-pcsc": "^0.8.1", |
||||
"node-fetch": "^3.2.9", |
||||
"yarn": "^1.22.18" |
||||
} |
||||
} |
@ -0,0 +1,79 @@ |
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
||||
# yarn lockfile v1 |
||||
|
||||
|
||||
"@pokusew/pcsclite@^0.6.0": |
||||
version "0.6.0" |
||||
resolved "https://registry.yarnpkg.com/@pokusew/pcsclite/-/pcsclite-0.6.0.tgz#30ae3fbf9d1137f2a1b343c32cd8569be581ba2d" |
||||
integrity sha512-jX7zRXM2Or5Pms1AFjNtawsXDjLiZOzOUo7Sf0put7Pnq/EKIR9g0KvTx62HtwdPpVP6hWHGydUTHgIi9PxodQ== |
||||
dependencies: |
||||
bindings "^1.5.0" |
||||
nan "^2.14.0" |
||||
|
||||
bindings@^1.5.0: |
||||
version "1.5.0" |
||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" |
||||
integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== |
||||
dependencies: |
||||
file-uri-to-path "1.0.0" |
||||
|
||||
data-uri-to-buffer@^4.0.0: |
||||
version "4.0.0" |
||||
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz#b5db46aea50f6176428ac05b73be39a57701a64b" |
||||
integrity sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA== |
||||
|
||||
fetch-blob@^3.1.2, fetch-blob@^3.1.4: |
||||
version "3.2.0" |
||||
resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9" |
||||
integrity sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ== |
||||
dependencies: |
||||
node-domexception "^1.0.0" |
||||
web-streams-polyfill "^3.0.3" |
||||
|
||||
file-uri-to-path@1.0.0: |
||||
version "1.0.0" |
||||
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" |
||||
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== |
||||
|
||||
formdata-polyfill@^4.0.10: |
||||
version "4.0.10" |
||||
resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" |
||||
integrity sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g== |
||||
dependencies: |
||||
fetch-blob "^3.1.2" |
||||
|
||||
nan@^2.14.0: |
||||
version "2.16.0" |
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.16.0.tgz#664f43e45460fb98faf00edca0bb0d7b8dce7916" |
||||
integrity sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA== |
||||
|
||||
nfc-pcsc@^0.8.1: |
||||
version "0.8.1" |
||||
resolved "https://registry.yarnpkg.com/nfc-pcsc/-/nfc-pcsc-0.8.1.tgz#76882be17842cb832a72b76345e665c8108ff049" |
||||
integrity sha512-wEfacG0dwPVZOG/WY28Mk3P4Q+yz6q7LnjpnZvdFddx3iXavEXiGhftRZXBtudr0NrzH1MrGWSkWq77tef7BMA== |
||||
dependencies: |
||||
"@pokusew/pcsclite" "^0.6.0" |
||||
|
||||
node-domexception@^1.0.0: |
||||
version "1.0.0" |
||||
resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" |
||||
integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== |
||||
|
||||
node-fetch@^3.2.9: |
||||
version "3.2.9" |
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.2.9.tgz#3f6070bf854de20f21b9fe8479f823462e615d7d" |
||||
integrity sha512-/2lI+DBecVvVm9tDhjziTVjo2wmTsSxSk58saUYP0P/fRJ3xxtfMDY24+CKTkfm0Dlhyn3CSXNL0SoRiCZ8Rzg== |
||||
dependencies: |
||||
data-uri-to-buffer "^4.0.0" |
||||
fetch-blob "^3.1.4" |
||||
formdata-polyfill "^4.0.10" |
||||
|
||||
web-streams-polyfill@^3.0.3: |
||||
version "3.2.1" |
||||
resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz#71c2718c52b45fd49dbeee88634b3a60ceab42a6" |
||||
integrity sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q== |
||||
|
||||
yarn@^1.22.18: |
||||
version "1.22.18" |
||||
resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.18.tgz#05b822ade8c672987bab8858635145da0850f78a" |
||||
integrity sha512-oFffv6Jp2+BTUBItzx1Z0dpikTX+raRdqupfqzeMKnoh7WD6RuPAxcqDkMUy9vafJkrB0YaV708znpuMhEBKGQ== |
Loading…
Reference in new issue