{"_id":"@aya-mash/web-nfc-api","name":"@aya-mash/web-nfc-api","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@aya-mash/web-nfc-api","version":"0.0.1","description":"A TypeScript library for working with the Web NFC API","private":false,"type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"vite","build":"tsc && vite build","build:lib":"tsc --project tsconfig.build.json","lint":"eslint .","preview":"vite preview","prepublishOnly":"npm run build:lib"},"keywords":["nfc","web-nfc","typescript","browser"],"author":{"name":"aya-mash"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/aya-mash/web-nfc-api.git"},"devDependencies":{"@eslint/js":"^9.9.1","@types/react":"^18.3.5","@types/react-dom":"^18.3.0","@vitejs/plugin-react":"^4.3.1","autoprefixer":"^10.4.18","eslint":"^9.9.1","eslint-plugin-react-hooks":"^5.1.0-rc.0","eslint-plugin-react-refresh":"^0.4.11","globals":"^15.9.0","lucide-react":"^0.344.0","postcss":"^8.4.35","react":"^18.3.1","react-dom":"^18.3.1","tailwindcss":"^3.4.1","typescript":"^5.5.3","typescript-eslint":"^8.3.0","vite":"^5.4.2"},"peerDependencies":{"react":">=16.8.0","react-dom":">=16.8.0"},"_id":"@aya-mash/web-nfc-api@0.0.1","gitHead":"177ca3f31ad17d484830a2bb4d59ff1df803843e","bugs":{"url":"https://github.com/aya-mash/web-nfc-api/issues"},"homepage":"https://github.com/aya-mash/web-nfc-api#readme","_nodeVersion":"20.17.0","_npmVersion":"11.2.0","dist":{"integrity":"sha512-eMiZuc9IsrThakNABJiUcFKAYEwLxtEkt4ZGTfJ8Cz4NgM4wFlvn+dkCWbQyJ8Xts5VlauRKqBQ9VFp16cXxPw==","shasum":"6ec264e8c3b06cdfb2ca9d09ba479254c879c4e0","tarball":"https://registry.npmjs.org/@aya-mash/web-nfc-api/-/web-nfc-api-0.0.1.tgz","fileCount":10,"unpackedSize":18879,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDX/OO5/Bk6eIQPrZl5APeYeUt4gAoJH17TzpYbdlzi6gIgT5B3ocBCjrVs78JKJYN+ysZla1EHwy31/X/zaTqHtzk="}]},"_npmUser":{"name":"aya-mash","email":"ayabulelamahlathini@gmail.com"},"directories":{},"maintainers":[{"name":"aya-mash","email":"ayabulelamahlathini@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/web-nfc-api_0.0.1_1744497671027_0.32265383663962566"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-12T22:41:10.930Z","0.0.1":"2025-04-12T22:41:11.260Z","modified":"2025-04-12T22:41:11.537Z"},"maintainers":[{"name":"aya-mash","email":"ayabulelamahlathini@gmail.com"}],"description":"A TypeScript library for working with the Web NFC API","homepage":"https://github.com/aya-mash/web-nfc-api#readme","keywords":["nfc","web-nfc","typescript","browser"],"repository":{"type":"git","url":"git+https://github.com/aya-mash/web-nfc-api.git"},"author":{"name":"aya-mash"},"bugs":{"url":"https://github.com/aya-mash/web-nfc-api/issues"},"license":"MIT","readme":"# @aya-mash/web-nfc-api\n\nA TypeScript library for working with the Web NFC API in modern browsers.\n\n## Installation\n\n```bash\nnpm install @aya-mash/web-nfc-api\n```\n\n## Usage\n\n```typescript\nimport { WebNFC } from '@aya-mash/web-nfc-api';\n\nconst nfc = WebNFC.getInstance();\n\n// Check if NFC is supported\nif (nfc.isSupported()) {\n  try {\n    // Request permission\n    const permission = await nfc.requestPermission();\n    \n    // Start scanning\n    await nfc.startScanning();\n    \n    // Listen for NFC readings\n    nfc.onReading((message) => {\n      console.log('NFC message:', message);\n    });\n    \n    // Handle reading errors\n    nfc.onReadingError((error) => {\n      console.error('NFC error:', error);\n    });\n    \n    // Write to NFC tag\n    await nfc.write({\n      records: [{\n        recordType: 'text',\n        data: 'Hello from Web NFC!'\n      }]\n    });\n  } catch (error) {\n    console.error('NFC operation failed:', error);\n  }\n}\n```\n\n## Features\n\n- 🔒 TypeScript support with full type definitions\n- 🎯 Simple, intuitive API\n- 🔄 Singleton pattern for consistent NFC access\n- ⚡ Async/await support\n- 🛡️ Error handling\n- 📱 Permission management\n\n## Requirements\n\n- Chrome for Android (version 89 or later)\n- HTTPS connection (except for localhost)\n- Device with NFC hardware\n\n## API Reference\n\n### WebNFC\n\n#### `getInstance()`\n\nReturns the singleton instance of the WebNFC class.\n\n```typescript\nconst nfc = WebNFC.getInstance();\n```\n\n#### `isSupported()`\n\nChecks if Web NFC API is supported in the current browser.\n\n```typescript\nconst supported = nfc.isSupported();\n```\n\n#### `requestPermission()`\n\nRequests NFC permission from the user.\n\n```typescript\nconst permission = await nfc.requestPermission();\n```\n\n#### `startScanning(options?: NFCReadOptions)`\n\nStarts scanning for NFC tags.\n\n```typescript\nawait nfc.startScanning();\n```\n\n#### `write(message: NFCMessage, options?: NFCWriteOptions)`\n\nWrites data to an NFC tag.\n\n```typescript\nawait nfc.write({\n  records: [{\n    recordType: 'text',\n    data: 'Hello, NFC!'\n  }]\n});\n```\n\n#### `onReading(callback: (message: NFCMessage) => void)`\n\nSets up a callback for when an NFC tag is read.\n\n```typescript\nnfc.onReading((message) => {\n  console.log('Tag read:', message);\n});\n```\n\n#### `onReadingError(callback: (error: Error) => void)`\n\nSets up a callback for handling reading errors.\n\n```typescript\nnfc.onReadingError((error) => {\n  console.error('Reading error:', error);\n});\n```\n\n## License\n\nMIT","readmeFilename":"README.md","_rev":"1-fea8200066041d96283bd38326ac04e5"}