removed uid for justa card id

This commit is contained in:
ben 2022-08-25 13:07:18 +01:00
parent 59d6b654c5
commit 4e8766ce08
4 changed files with 9 additions and 27 deletions

View File

@ -15,7 +15,6 @@ async def create_card(data: CreateCardData, wallet_id: str) -> Card:
id, id,
wallet, wallet,
card_name, card_name,
uid,
counter, counter,
withdraw, withdraw,
k0, k0,
@ -29,7 +28,6 @@ async def create_card(data: CreateCardData, wallet_id: str) -> Card:
card_id, card_id,
wallet_id, wallet_id,
data.card_name, data.card_name,
data.uid.upper(),
data.counter, data.counter,
data.withdraw, data.withdraw,
data.k0, data.k0,

View File

@ -30,7 +30,7 @@ from .crud import (
create_hit, create_hit,
get_card, get_card,
get_card_by_otp, get_card_by_otp,
get_card_by_uid, get_card,
get_hit, get_hit,
get_hits_today, get_hits_today,
update_card, update_card,
@ -43,18 +43,18 @@ from .nxp424 import decryptSUN, getSunMAC
###############LNURLWITHDRAW################# ###############LNURLWITHDRAW#################
# /boltcards/api/v1/scan?p=00000000000000000000000000000000&c=0000000000000000 # /boltcards/api/v1/scan?p=00000000000000000000000000000000&c=0000000000000000
@boltcards_ext.get("/api/v1/scan/{card_uid}") @boltcards_ext.get("/api/v1/scan/{card_id}")
async def api_scan(p, c, request: Request, card_uid: str = None): async def api_scan(p, c, request: Request, card_id: str = None):
# some wallets send everything as lower case, no bueno # some wallets send everything as lower case, no bueno
p = p.upper() p = p.upper()
c = c.upper() c = c.upper()
card = None card = None
counter = b"" counter = b""
try: try:
card = await get_card_by_uid(card_uid) card = await get_card(card_id)
card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(card.k1)) card_id, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(card.k1))
if card.uid.upper() != card_uid.hex().upper(): if card.uid.upper() != card_id.hex().upper():
return {"status": "ERROR", "reason": "Card UID mis-match."} return {"status": "ERROR", "reason": "Card UID mis-match."}
except: except:
return {"status": "ERROR", "reason": "Error decrypting card."} return {"status": "ERROR", "reason": "Error decrypting card."}
@ -62,7 +62,7 @@ async def api_scan(p, c, request: Request, card_uid: str = None):
if card == None: if card == None:
return {"status": "ERROR", "reason": "Unknown card."} return {"status": "ERROR", "reason": "Unknown card."}
if c != getSunMAC(card_uid, counter, bytes.fromhex(card.k2)).hex().upper(): if c != getSunMAC(card_id, counter, bytes.fromhex(card.k2)).hex().upper():
return {"status": "ERROR", "reason": "CMAC does not check."} return {"status": "ERROR", "reason": "CMAC does not check."}
ctr_int = int.from_bytes(counter, "little") ctr_int = int.from_bytes(counter, "little")

View File

@ -150,7 +150,6 @@ new Vue({
}, },
getHits: function () { getHits: function () {
var self = this var self = this
LNbits.api LNbits.api
.request( .request(
'GET', 'GET',
@ -167,7 +166,6 @@ new Vue({
}, },
getRefunds: function () { getRefunds: function () {
var self = this var self = this
LNbits.api LNbits.api
.request( .request(
'GET', 'GET',
@ -184,7 +182,6 @@ new Vue({
}, },
openQrCodeDialog(cardId) { openQrCodeDialog(cardId) {
var card = _.findWhere(this.cards, {id: cardId}) var card = _.findWhere(this.cards, {id: cardId})
this.qrCodeDialog.data = { this.qrCodeDialog.data = {
link: window.location.origin + '/boltcards/api/v1/auth?a=' + card.otp, link: window.location.origin + '/boltcards/api/v1/auth?a=' + card.otp,
name: card.card_name, name: card.card_name,
@ -197,11 +194,9 @@ new Vue({
}, },
addCardOpen: function () { addCardOpen: function () {
this.cardDialog.show = true this.cardDialog.show = true
var elem = this.$els.myBtn this.generateKeys()
elem.click()
}, },
generateKeys: function () { generateKeys: function () {
const genRanHex = size => const genRanHex = size =>
[...Array(size)] [...Array(size)]
.map(() => Math.floor(Math.random() * 16).toString(16)) .map(() => Math.floor(Math.random() * 16).toString(16))

View File

@ -5,7 +5,7 @@
<div class="col-12 col-md-8 col-lg-7 q-gutter-y-md"> <div class="col-12 col-md-8 col-lg-7 q-gutter-y-md">
<q-card> <q-card>
<q-card-section> <q-card-section>
<q-btn unelevated color="primary" v-on:click="addCardOpen" <q-btn unelevated color="primary" class="addCardBtn" v-on:click="addCardOpen"
>Add Card</q-btn >Add Card</q-btn
> >
</q-card-section> </q-card-section>
@ -187,7 +187,6 @@
label="Wallet *" label="Wallet *"
> >
</q-select> </q-select>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<q-input <q-input
@ -211,8 +210,6 @@
></q-input> ></q-input>
</div> </div>
</div> </div>
<q-input <q-input
filled filled
dense dense
@ -221,14 +218,6 @@
type="text" type="text"
label="Card name " label="Card name "
></q-input> ></q-input>
<q-input
filled
dense
v-model.trim="cardDialog.data.uid"
type="text"
label="Card UID"
><q-tooltip>From the NFC 424 ntag card that will be loaded</q-tooltip>
</q-input>
<q-toggle <q-toggle
@click="toggleKeys" @click="toggleKeys"
v-model="toggleAdvanced" v-model="toggleAdvanced"