install NDEF by default with empty data

This commit is contained in:
Andrea Franz 2021-01-08 11:30:15 +01:00
parent 14a203452b
commit acacf23199
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
3 changed files with 16 additions and 8 deletions

View File

@ -1 +1 @@
0.5.0
0.6.0

View File

@ -32,7 +32,7 @@ func NewInstaller(t keycardio.Transmitter) *Installer {
}
// Install installs the applet from the specified capFile.
func (i *Installer) Install(capFile *os.File, overwriteApplet bool, installKeycard bool, installCash bool, ndefRecordTemplate string) error {
func (i *Installer) Install(capFile *os.File, overwriteApplet bool, installKeycard bool, installCash bool, installNDEF bool, ndefRecordTemplate string) error {
logger.Info("installation started")
startTime := time.Now()
cmdSet := globalplatform.NewCommandSet(i.c)
@ -87,10 +87,17 @@ func (i *Installer) Install(capFile *os.File, overwriteApplet bool, installKeyca
}
}
if ndefRecordTemplate != "" {
ndefURL, ndefRecord, err := i.buildNDEFRecordWithCashAppletData(ndefRecordTemplate)
if err != nil {
return err
if installNDEF {
var (
ndefURL string
ndefRecord []byte
)
if ndefRecordTemplate != "" {
ndefURL, ndefRecord, err = i.buildNDEFRecordWithCashAppletData(ndefRecordTemplate)
if err != nil {
return err
}
}
logger.Info("setting NDEF url", "url", ndefURL)

View File

@ -29,9 +29,10 @@ var (
flagCapFile = flag.String("a", "", "applet cap file path")
flagKeycardApplet = flag.Bool("keycard-applet", true, "install keycard applet")
flagCashApplet = flag.Bool("cash-applet", true, "install cash applet")
flagNDEFApplet = flag.Bool("ndef-applet", true, "install NDEF applet")
flagOverwrite = flag.Bool("f", false, "force applet installation if already installed")
flagLogLevel = flag.String("l", "", `Log level, one of: "error", "warn", "info", "debug", and "trace"`)
flagNdefTemplate = flag.String("ndef", "", "Specify a URL to use in the NDEF record. Use the {{.cashAddress}} variable to get the cash address: http://example.com/{{.cashAddress}}.")
flagNDEFTemplate = flag.String("ndef", "", "Specify a URL to use in the NDEF record. Use the {{.cashAddress}} variable to get the cash address: http://example.com/{{.cashAddress}}.")
)
func initLogger() {
@ -238,7 +239,7 @@ func commandInstall(card *scard.Card) error {
defer f.Close()
i := NewInstaller(card)
return i.Install(f, *flagOverwrite, *flagKeycardApplet, *flagCashApplet, *flagNdefTemplate)
return i.Install(f, *flagOverwrite, *flagKeycardApplet, *flagCashApplet, *flagNDEFApplet, *flagNDEFTemplate)
}
func commandInfo(card *scard.Card) error {