
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@aya-mash/web-nfc-api
Advanced tools
A TypeScript library for working with the Web NFC API in modern browsers.
npm install @aya-mash/web-nfc-api
import { WebNFC } from '@aya-mash/web-nfc-api';
const nfc = WebNFC.getInstance();
// Check if NFC is supported
if (nfc.isSupported()) {
try {
// Request permission
const permission = await nfc.requestPermission();
// Start scanning
await nfc.startScanning();
// Listen for NFC readings
nfc.onReading((message) => {
console.log('NFC message:', message);
});
// Handle reading errors
nfc.onReadingError((error) => {
console.error('NFC error:', error);
});
// Write to NFC tag
await nfc.write({
records: [{
recordType: 'text',
data: 'Hello from Web NFC!'
}]
});
} catch (error) {
console.error('NFC operation failed:', error);
}
}
getInstance()
Returns the singleton instance of the WebNFC class.
const nfc = WebNFC.getInstance();
isSupported()
Checks if Web NFC API is supported in the current browser.
const supported = nfc.isSupported();
requestPermission()
Requests NFC permission from the user.
const permission = await nfc.requestPermission();
startScanning(options?: NFCReadOptions)
Starts scanning for NFC tags.
await nfc.startScanning();
write(message: NFCMessage, options?: NFCWriteOptions)
Writes data to an NFC tag.
await nfc.write({
records: [{
recordType: 'text',
data: 'Hello, NFC!'
}]
});
onReading(callback: (message: NFCMessage) => void)
Sets up a callback for when an NFC tag is read.
nfc.onReading((message) => {
console.log('Tag read:', message);
});
onReadingError(callback: (error: Error) => void)
Sets up a callback for handling reading errors.
nfc.onReadingError((error) => {
console.error('Reading error:', error);
});
MIT
FAQs
A TypeScript library for working with the Web NFC API
We found that @aya-mash/web-nfc-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.