nfcfyi 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/index.cjs +93 -0
- package/dist/index.d.cts +118 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.js +66 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FYIPedia
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# nfcfyi
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/nfcfyi)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://www.npmjs.com/package/nfcfyi)
|
|
7
|
+
|
|
8
|
+
TypeScript API client for [NFCFYI](https://nfcfyi.com) -- the comprehensive NFC reference covering NFC chips (NTAG, MIFARE, ST25), chip families, NDEF record types, operating modes (reader/writer, peer-to-peer, card emulation), ISO 14443/ISO 15693 standards, and real-world use cases. Zero dependencies, uses native `fetch`.
|
|
9
|
+
|
|
10
|
+
> **Explore NFC at [nfcfyi.com](https://nfcfyi.com)** -- [Chips](https://nfcfyi.com/chips/) | [Standards](https://nfcfyi.com/standards/) | [Glossary](https://nfcfyi.com/glossary/) | [API Docs](https://nfcfyi.com/developers/)
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install nfcfyi
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Works in Node.js, Deno, Bun, and browsers (ESM).
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { NFCFYI } from "nfcfyi";
|
|
24
|
+
|
|
25
|
+
const api = new NFCFYI();
|
|
26
|
+
|
|
27
|
+
// Search NFC chips, standards, NDEF types
|
|
28
|
+
const results = await api.search("ntag 215");
|
|
29
|
+
|
|
30
|
+
// Get NFC chip detail
|
|
31
|
+
const ntag215 = await api.chip("ntag-215");
|
|
32
|
+
console.log(ntag215.memory_size); // "504 bytes"
|
|
33
|
+
console.log(ntag215.manufacturer); // "NXP"
|
|
34
|
+
|
|
35
|
+
// Get NDEF type detail
|
|
36
|
+
const uri = await api.ndefType("uri");
|
|
37
|
+
console.log(uri.tnf); // 1
|
|
38
|
+
|
|
39
|
+
// Compare two NFC chips
|
|
40
|
+
const comparison = await api.compare("ntag-215", "ntag-216");
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API Methods
|
|
44
|
+
|
|
45
|
+
| Method | Description |
|
|
46
|
+
|--------|-------------|
|
|
47
|
+
| `search(query)` | Search chips, standards, NDEF types, glossary |
|
|
48
|
+
| `glossaryTerm(slug)` | Get glossary term definition |
|
|
49
|
+
| `chip(slug)` | NFC chip detail |
|
|
50
|
+
| `chipFamily(slug)` | NFC chip family detail |
|
|
51
|
+
| `standard(slug)` | NFC standard detail |
|
|
52
|
+
| `operatingMode(slug)` | Operating mode detail |
|
|
53
|
+
| `ndefType(slug)` | NDEF record type detail |
|
|
54
|
+
| `useCase(slug)` | Use case detail |
|
|
55
|
+
| `compare(slugA, slugB)` | Compare two NFC chips |
|
|
56
|
+
| `random()` | Random NFC chip |
|
|
57
|
+
| `openapi()` | OpenAPI 3.1.0 specification |
|
|
58
|
+
|
|
59
|
+
## TypeScript Types
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import type {
|
|
63
|
+
SearchResult, ChipDetail, ChipFamilyDetail, StandardDetail,
|
|
64
|
+
OperatingModeDetail, NdefTypeDetail, UseCaseDetail, GlossaryTerm, CompareResult,
|
|
65
|
+
} from "nfcfyi";
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Also Available
|
|
69
|
+
|
|
70
|
+
| Language | Package |
|
|
71
|
+
|----------|---------|
|
|
72
|
+
| Python | [nfcfyi on PyPI](https://pypi.org/project/nfcfyi/) |
|
|
73
|
+
| TypeScript | **This package** |
|
|
74
|
+
|
|
75
|
+
## Code FYI Family
|
|
76
|
+
|
|
77
|
+
Part of the [FYIPedia](https://fyipedia.com) open-source developer tools ecosystem -- automatic identification and data capture technologies.
|
|
78
|
+
|
|
79
|
+
| Package | npm | Description |
|
|
80
|
+
|---------|-----|-------------|
|
|
81
|
+
| barcodefyi | [npm](https://www.npmjs.com/package/barcodefyi) | Barcode symbologies, standards -- [barcodefyi.com](https://barcodefyi.com/) |
|
|
82
|
+
| qrcodefyi | [npm](https://www.npmjs.com/package/qrcodefyi) | QR code types, versions, encoding -- [qrcodefyi.com](https://qrcodefyi.com/) |
|
|
83
|
+
| **nfcfyi** | [npm](https://www.npmjs.com/package/nfcfyi) | **NFC chips, NDEF, standards -- [nfcfyi.com](https://nfcfyi.com/)** |
|
|
84
|
+
| blefyi | [npm](https://www.npmjs.com/package/blefyi) | BLE profiles, beacons, chips -- [blefyi.com](https://blefyi.com/) |
|
|
85
|
+
| rfidfyi | [npm](https://www.npmjs.com/package/rfidfyi) | RFID tags, readers, frequencies -- [rfidfyi.com](https://rfidfyi.com/) |
|
|
86
|
+
| smartcardfyi | [npm](https://www.npmjs.com/package/smartcardfyi) | Smart cards, EMV, platforms -- [smartcardfyi.com](https://smartcardfyi.com/) |
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
NFCFYI: () => NFCFYI
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/client.ts
|
|
28
|
+
var NFCFYI = class {
|
|
29
|
+
baseUrl;
|
|
30
|
+
constructor(baseUrl = "https://nfcfyi.com") {
|
|
31
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
32
|
+
}
|
|
33
|
+
async get(path, params) {
|
|
34
|
+
const url = new URL(path, this.baseUrl);
|
|
35
|
+
if (params) {
|
|
36
|
+
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
37
|
+
}
|
|
38
|
+
const res = await fetch(url.toString());
|
|
39
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
40
|
+
return res.json();
|
|
41
|
+
}
|
|
42
|
+
/** Search NFC chips, standards, NDEF types, and glossary terms. */
|
|
43
|
+
async search(query) {
|
|
44
|
+
return this.get("/api/search/", { q: query });
|
|
45
|
+
}
|
|
46
|
+
/** Get a glossary term by slug. */
|
|
47
|
+
async glossaryTerm(slug) {
|
|
48
|
+
return this.get(`/api/term/${slug}/`);
|
|
49
|
+
}
|
|
50
|
+
/** Get NFC chip detail by slug. */
|
|
51
|
+
async chip(slug) {
|
|
52
|
+
return this.get(`/api/chip/${slug}/`);
|
|
53
|
+
}
|
|
54
|
+
/** Get NFC chip family detail by slug. */
|
|
55
|
+
async chipFamily(slug) {
|
|
56
|
+
return this.get(`/api/chip-family/${slug}/`);
|
|
57
|
+
}
|
|
58
|
+
/** Get NFC standard detail by slug. */
|
|
59
|
+
async standard(slug) {
|
|
60
|
+
return this.get(`/api/standard/${slug}/`);
|
|
61
|
+
}
|
|
62
|
+
/** Get NFC operating mode detail by slug. */
|
|
63
|
+
async operatingMode(slug) {
|
|
64
|
+
return this.get(`/api/operating-mode/${slug}/`);
|
|
65
|
+
}
|
|
66
|
+
/** Get NDEF type detail by slug. */
|
|
67
|
+
async ndefType(slug) {
|
|
68
|
+
return this.get(`/api/ndef-type/${slug}/`);
|
|
69
|
+
}
|
|
70
|
+
/** Get use case detail by slug. */
|
|
71
|
+
async useCase(slug) {
|
|
72
|
+
return this.get(`/api/use-case/${slug}/`);
|
|
73
|
+
}
|
|
74
|
+
/** Compare two NFC chips. */
|
|
75
|
+
async compare(slugA, slugB) {
|
|
76
|
+
return this.get("/api/compare/", {
|
|
77
|
+
a: slugA,
|
|
78
|
+
b: slugB
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** Get a random NFC chip. */
|
|
82
|
+
async random() {
|
|
83
|
+
return this.get("/api/random/");
|
|
84
|
+
}
|
|
85
|
+
/** Get the OpenAPI 3.1.0 specification. */
|
|
86
|
+
async openapi() {
|
|
87
|
+
return this.get("/api/openapi.json");
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
NFCFYI
|
|
93
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NFCFYI API response types.
|
|
3
|
+
*/
|
|
4
|
+
interface SearchResult {
|
|
5
|
+
results: Array<{
|
|
6
|
+
name: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
type: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}>;
|
|
11
|
+
query: string;
|
|
12
|
+
total: number;
|
|
13
|
+
}
|
|
14
|
+
interface GlossaryTerm {
|
|
15
|
+
name: string;
|
|
16
|
+
slug: string;
|
|
17
|
+
definition: string;
|
|
18
|
+
related_terms?: string[];
|
|
19
|
+
}
|
|
20
|
+
interface ChipDetail {
|
|
21
|
+
slug: string;
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
family?: string;
|
|
25
|
+
manufacturer?: string;
|
|
26
|
+
memory_size?: string;
|
|
27
|
+
frequency?: string;
|
|
28
|
+
data_rate?: string;
|
|
29
|
+
url: string;
|
|
30
|
+
}
|
|
31
|
+
interface ChipFamilyDetail {
|
|
32
|
+
slug: string;
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
chips?: string[];
|
|
36
|
+
url: string;
|
|
37
|
+
}
|
|
38
|
+
interface StandardDetail {
|
|
39
|
+
slug: string;
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
organization?: string;
|
|
43
|
+
year?: number;
|
|
44
|
+
url: string;
|
|
45
|
+
}
|
|
46
|
+
interface OperatingModeDetail {
|
|
47
|
+
slug: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
url: string;
|
|
51
|
+
}
|
|
52
|
+
interface NdefTypeDetail {
|
|
53
|
+
slug: string;
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
tnf?: number;
|
|
57
|
+
url: string;
|
|
58
|
+
}
|
|
59
|
+
interface UseCaseDetail {
|
|
60
|
+
slug: string;
|
|
61
|
+
name: string;
|
|
62
|
+
description: string;
|
|
63
|
+
chips?: string[];
|
|
64
|
+
url: string;
|
|
65
|
+
}
|
|
66
|
+
interface CompareResult {
|
|
67
|
+
item_a: {
|
|
68
|
+
name: string;
|
|
69
|
+
slug: string;
|
|
70
|
+
};
|
|
71
|
+
item_b: {
|
|
72
|
+
name: string;
|
|
73
|
+
slug: string;
|
|
74
|
+
};
|
|
75
|
+
comparison: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
interface RandomResult {
|
|
78
|
+
slug: string;
|
|
79
|
+
name: string;
|
|
80
|
+
type: string;
|
|
81
|
+
url: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* NFCFYI API client -- TypeScript wrapper for nfcfyi.com REST API.
|
|
86
|
+
*
|
|
87
|
+
* Zero dependencies. Uses native `fetch`.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
declare class NFCFYI {
|
|
91
|
+
private baseUrl;
|
|
92
|
+
constructor(baseUrl?: string);
|
|
93
|
+
private get;
|
|
94
|
+
/** Search NFC chips, standards, NDEF types, and glossary terms. */
|
|
95
|
+
search(query: string): Promise<SearchResult>;
|
|
96
|
+
/** Get a glossary term by slug. */
|
|
97
|
+
glossaryTerm(slug: string): Promise<GlossaryTerm>;
|
|
98
|
+
/** Get NFC chip detail by slug. */
|
|
99
|
+
chip(slug: string): Promise<ChipDetail>;
|
|
100
|
+
/** Get NFC chip family detail by slug. */
|
|
101
|
+
chipFamily(slug: string): Promise<ChipFamilyDetail>;
|
|
102
|
+
/** Get NFC standard detail by slug. */
|
|
103
|
+
standard(slug: string): Promise<StandardDetail>;
|
|
104
|
+
/** Get NFC operating mode detail by slug. */
|
|
105
|
+
operatingMode(slug: string): Promise<OperatingModeDetail>;
|
|
106
|
+
/** Get NDEF type detail by slug. */
|
|
107
|
+
ndefType(slug: string): Promise<NdefTypeDetail>;
|
|
108
|
+
/** Get use case detail by slug. */
|
|
109
|
+
useCase(slug: string): Promise<UseCaseDetail>;
|
|
110
|
+
/** Compare two NFC chips. */
|
|
111
|
+
compare(slugA: string, slugB: string): Promise<CompareResult>;
|
|
112
|
+
/** Get a random NFC chip. */
|
|
113
|
+
random(): Promise<RandomResult>;
|
|
114
|
+
/** Get the OpenAPI 3.1.0 specification. */
|
|
115
|
+
openapi(): Promise<Record<string, unknown>>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { type ChipDetail, type ChipFamilyDetail, type CompareResult, type GlossaryTerm, NFCFYI, type NdefTypeDetail, type OperatingModeDetail, type RandomResult, type SearchResult, type StandardDetail, type UseCaseDetail };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NFCFYI API response types.
|
|
3
|
+
*/
|
|
4
|
+
interface SearchResult {
|
|
5
|
+
results: Array<{
|
|
6
|
+
name: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
type: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}>;
|
|
11
|
+
query: string;
|
|
12
|
+
total: number;
|
|
13
|
+
}
|
|
14
|
+
interface GlossaryTerm {
|
|
15
|
+
name: string;
|
|
16
|
+
slug: string;
|
|
17
|
+
definition: string;
|
|
18
|
+
related_terms?: string[];
|
|
19
|
+
}
|
|
20
|
+
interface ChipDetail {
|
|
21
|
+
slug: string;
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
family?: string;
|
|
25
|
+
manufacturer?: string;
|
|
26
|
+
memory_size?: string;
|
|
27
|
+
frequency?: string;
|
|
28
|
+
data_rate?: string;
|
|
29
|
+
url: string;
|
|
30
|
+
}
|
|
31
|
+
interface ChipFamilyDetail {
|
|
32
|
+
slug: string;
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
chips?: string[];
|
|
36
|
+
url: string;
|
|
37
|
+
}
|
|
38
|
+
interface StandardDetail {
|
|
39
|
+
slug: string;
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
organization?: string;
|
|
43
|
+
year?: number;
|
|
44
|
+
url: string;
|
|
45
|
+
}
|
|
46
|
+
interface OperatingModeDetail {
|
|
47
|
+
slug: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
url: string;
|
|
51
|
+
}
|
|
52
|
+
interface NdefTypeDetail {
|
|
53
|
+
slug: string;
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
tnf?: number;
|
|
57
|
+
url: string;
|
|
58
|
+
}
|
|
59
|
+
interface UseCaseDetail {
|
|
60
|
+
slug: string;
|
|
61
|
+
name: string;
|
|
62
|
+
description: string;
|
|
63
|
+
chips?: string[];
|
|
64
|
+
url: string;
|
|
65
|
+
}
|
|
66
|
+
interface CompareResult {
|
|
67
|
+
item_a: {
|
|
68
|
+
name: string;
|
|
69
|
+
slug: string;
|
|
70
|
+
};
|
|
71
|
+
item_b: {
|
|
72
|
+
name: string;
|
|
73
|
+
slug: string;
|
|
74
|
+
};
|
|
75
|
+
comparison: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
interface RandomResult {
|
|
78
|
+
slug: string;
|
|
79
|
+
name: string;
|
|
80
|
+
type: string;
|
|
81
|
+
url: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* NFCFYI API client -- TypeScript wrapper for nfcfyi.com REST API.
|
|
86
|
+
*
|
|
87
|
+
* Zero dependencies. Uses native `fetch`.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
declare class NFCFYI {
|
|
91
|
+
private baseUrl;
|
|
92
|
+
constructor(baseUrl?: string);
|
|
93
|
+
private get;
|
|
94
|
+
/** Search NFC chips, standards, NDEF types, and glossary terms. */
|
|
95
|
+
search(query: string): Promise<SearchResult>;
|
|
96
|
+
/** Get a glossary term by slug. */
|
|
97
|
+
glossaryTerm(slug: string): Promise<GlossaryTerm>;
|
|
98
|
+
/** Get NFC chip detail by slug. */
|
|
99
|
+
chip(slug: string): Promise<ChipDetail>;
|
|
100
|
+
/** Get NFC chip family detail by slug. */
|
|
101
|
+
chipFamily(slug: string): Promise<ChipFamilyDetail>;
|
|
102
|
+
/** Get NFC standard detail by slug. */
|
|
103
|
+
standard(slug: string): Promise<StandardDetail>;
|
|
104
|
+
/** Get NFC operating mode detail by slug. */
|
|
105
|
+
operatingMode(slug: string): Promise<OperatingModeDetail>;
|
|
106
|
+
/** Get NDEF type detail by slug. */
|
|
107
|
+
ndefType(slug: string): Promise<NdefTypeDetail>;
|
|
108
|
+
/** Get use case detail by slug. */
|
|
109
|
+
useCase(slug: string): Promise<UseCaseDetail>;
|
|
110
|
+
/** Compare two NFC chips. */
|
|
111
|
+
compare(slugA: string, slugB: string): Promise<CompareResult>;
|
|
112
|
+
/** Get a random NFC chip. */
|
|
113
|
+
random(): Promise<RandomResult>;
|
|
114
|
+
/** Get the OpenAPI 3.1.0 specification. */
|
|
115
|
+
openapi(): Promise<Record<string, unknown>>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { type ChipDetail, type ChipFamilyDetail, type CompareResult, type GlossaryTerm, NFCFYI, type NdefTypeDetail, type OperatingModeDetail, type RandomResult, type SearchResult, type StandardDetail, type UseCaseDetail };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
var NFCFYI = class {
|
|
3
|
+
baseUrl;
|
|
4
|
+
constructor(baseUrl = "https://nfcfyi.com") {
|
|
5
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
6
|
+
}
|
|
7
|
+
async get(path, params) {
|
|
8
|
+
const url = new URL(path, this.baseUrl);
|
|
9
|
+
if (params) {
|
|
10
|
+
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
11
|
+
}
|
|
12
|
+
const res = await fetch(url.toString());
|
|
13
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
14
|
+
return res.json();
|
|
15
|
+
}
|
|
16
|
+
/** Search NFC chips, standards, NDEF types, and glossary terms. */
|
|
17
|
+
async search(query) {
|
|
18
|
+
return this.get("/api/search/", { q: query });
|
|
19
|
+
}
|
|
20
|
+
/** Get a glossary term by slug. */
|
|
21
|
+
async glossaryTerm(slug) {
|
|
22
|
+
return this.get(`/api/term/${slug}/`);
|
|
23
|
+
}
|
|
24
|
+
/** Get NFC chip detail by slug. */
|
|
25
|
+
async chip(slug) {
|
|
26
|
+
return this.get(`/api/chip/${slug}/`);
|
|
27
|
+
}
|
|
28
|
+
/** Get NFC chip family detail by slug. */
|
|
29
|
+
async chipFamily(slug) {
|
|
30
|
+
return this.get(`/api/chip-family/${slug}/`);
|
|
31
|
+
}
|
|
32
|
+
/** Get NFC standard detail by slug. */
|
|
33
|
+
async standard(slug) {
|
|
34
|
+
return this.get(`/api/standard/${slug}/`);
|
|
35
|
+
}
|
|
36
|
+
/** Get NFC operating mode detail by slug. */
|
|
37
|
+
async operatingMode(slug) {
|
|
38
|
+
return this.get(`/api/operating-mode/${slug}/`);
|
|
39
|
+
}
|
|
40
|
+
/** Get NDEF type detail by slug. */
|
|
41
|
+
async ndefType(slug) {
|
|
42
|
+
return this.get(`/api/ndef-type/${slug}/`);
|
|
43
|
+
}
|
|
44
|
+
/** Get use case detail by slug. */
|
|
45
|
+
async useCase(slug) {
|
|
46
|
+
return this.get(`/api/use-case/${slug}/`);
|
|
47
|
+
}
|
|
48
|
+
/** Compare two NFC chips. */
|
|
49
|
+
async compare(slugA, slugB) {
|
|
50
|
+
return this.get("/api/compare/", {
|
|
51
|
+
a: slugA,
|
|
52
|
+
b: slugB
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** Get a random NFC chip. */
|
|
56
|
+
async random() {
|
|
57
|
+
return this.get("/api/random/");
|
|
58
|
+
}
|
|
59
|
+
/** Get the OpenAPI 3.1.0 specification. */
|
|
60
|
+
async openapi() {
|
|
61
|
+
return this.get("/api/openapi.json");
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
NFCFYI
|
|
66
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nfcfyi",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript API client for NFCFYI -- NFC chips, chip families, NDEF types, operating modes, and standards. Zero dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"typecheck": "tsc --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"nfc",
|
|
24
|
+
"ndef",
|
|
25
|
+
"contactless",
|
|
26
|
+
"iso-14443",
|
|
27
|
+
"rfid",
|
|
28
|
+
"api-client",
|
|
29
|
+
"nfcfyi"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/fyipedia/nfcfyi-js"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://nfcfyi.com",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"author": "FYIPedia",
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"tsup": "^8.0",
|
|
40
|
+
"typescript": "^5.7",
|
|
41
|
+
"vitest": "^3.0"
|
|
42
|
+
}
|
|
43
|
+
}
|