[web-nfc] Pull Request: Add experimental NDEFReader.makeReadOnly() method

beaufortfrancois has just submitted a new pull request for https://github.com/w3c/web-nfc:

== Add experimental NDEFReader.makeReadOnly() method ==
Looking at https://github.com/w3c/web-nfc/issues/558 and signals on Twitter, it seems like web developers would love to "lock" NFC tags with Web NFC. This PR is an attempt to address their feedback by adding a new method `makeReadOnly()` to `NDEFReader`. 

```webidl
partial interface NDEFReader {
  Promise<undefined> makeReadOnly(optional NDEFMakeReadOnlyOptions options={});
};

dictionary NDEFMakeReadOnlyOptions {
  AbortSignal? signal;
};
```

Examples:

```js
const ndef = new NDEFReader();
ndef.makeReadOnly().then(() => {
  console.log("NFC tag has been made read only.");
}).catch(error => {
  console.log(`Operation failed: ${error}`);
});
```

```js
const ndef = new NDEFReader();
try {
  await ndef.write("Hello world");
  console.log("Message written.");
  await ndef.makeReadOnly();
  console.log("NFC tag has been made read only.");
} catch (error) {
  console.log(`Operation failed: ${error}`);
}
```

See https://github.com/w3c/web-nfc/pull/632


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 29 November 2021 11:26:59 UTC