Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tag read only #558

Closed
jicihome opened this issue Apr 16, 2020 · 13 comments
Closed

Make tag read only #558

jicihome opened this issue Apr 16, 2020 · 13 comments

Comments

@jicihome
Copy link

Hi!
I was wondering how can we "lock" the NFC tag after writting or make it read only? I see that this some security specification, but didn't found a way to do it using Write or another method.

Thanks!

@pechisworks
Copy link

This would also be useful for my use cases.

@kenchris kenchris changed the title Read only feature Make tag read only May 20, 2020
@nico-martin
Copy link

nico-martin commented Aug 22, 2021

I'm currently playing around with this and I think this is a crucial feature. Let's imagine I have NFC Tags in a Museum and anyone would be able to overwrite the content. That would be quite bad.

But looking through the Android specification I've seen NFC as a standard already has such a feature. So if i write an NFC Tag with readOnly from an Android app, I guess WebNFC could not just overwrite that content, right? If thats the case, this would be a workaround for now..

@beaufortfrancois
Copy link
Collaborator

@kenchris What are your thoughts?

Thanks for the feedback @nico-martin !
I'd love to see more signals from developers requesting this feature before adding it to Web NFC.

[SecureContext, Exposed=Window]
interface NDEFReader : EventTarget {
  ...
  Promise<undefined> makeReadOnly()
};

Note that this addition would be pretty simple indeed on Android, but not necessarily on iOS currently.

@kenchris
Copy link
Contributor

I am totally fine with this! It can return a promise and just reject if not supported

@nico-martin
Copy link

Maybe a general NFC-question: How can I revoke the readOnly flag? Is this possible with NFC Tags?

@beaufortfrancois
Copy link
Collaborator

This NFC operation is a one-way process and cannot be reverted for NFC tags.

@nico-martin
Copy link

nico-martin commented Aug 30, 2021

Ok. Maybe this could lead to some confusion for people that are not familiar with this.
Would it make sense to explicitly require a flag from the user that indicates this one-way usage?
This would be similar to the Web Blutooth API, where requestDevice explicitly requires an acceptAllDevices: true if no filters are set.

const ndef = new NDEFReader();
try {
  await ndef.write({
    records: [{ recordType: "url", data: "https://w3c.github.io/web-nfc/" }]
  });
  await ndef.makeReadOnly({
    allowIrreversibleOperation: true
  });
} catch (e) {
  console.log("Something went wrong.", e);
};

allowIrreversibleOperation would be false by default so the user needs to manually set this property. I hope that this will make it clear in use that the operation is irreversible.

@kenchris
Copy link
Contributor

The Chrome UI could show trusted UI explaining the risk and allowing the user to cancel or proceed

@nico-martin
Copy link

Sure. That makes sense.

@beaufortfrancois
Copy link
Collaborator

I've started a spec PR to address web developers need to make NFC tags read only at #632. Thoughts are welcome!

@beaufortfrancois
Copy link
Collaborator

And I've just sent the "intent to prototype" in Chromium: https://groups.google.com/a/chromium.org/g/blink-dev/c/iyljeGnIct8

@beaufortfrancois
Copy link
Collaborator

FYI Making an NFC tag read-only is now possible in latest Chrome Canary for Android:

  1. Enable "experimental web platform features" in chrome://flags
  2. Go to https://make-read-only.glitch.me and enjoy ;)

Feedback is always welcome!

See https://twitter.com/quicksave2k/status/1471060640131436546

@beaufortfrancois
Copy link
Collaborator

This feature is shipping in Chrome 100.
See https://twitter.com/quicksave2k/status/1488430972748111873

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants