@digitalcard/sdk 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/README.md +62 -0
- package/dist/bridges.d.ts +18 -0
- package/dist/bridges.d.ts.map +1 -0
- package/dist/bridges.js +126 -0
- package/dist/client.d.ts +21 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +138 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +35 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/types.d.ts +120 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @digitalcard/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for [EIL Card](https://eilcard.com) — resolve canonical organization and person profiles for AI agents.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @digitalcard/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { DigitalCard, toSchemaOrg } from '@digitalcard/sdk';
|
|
15
|
+
|
|
16
|
+
const { card, meta } = await DigitalCard.resolve({ domain: 'example.com' });
|
|
17
|
+
|
|
18
|
+
if (card.type === 'organization') {
|
|
19
|
+
console.log(card.name.official);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const jsonLd = toSchemaOrg(card);
|
|
23
|
+
console.log(meta.source); // "registry" | "well-known"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Resolve by registry handle:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
const { card } = await DigitalCard.resolve({ handle: 'my-org' });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Client options
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { DigitalCardClient } from '@digitalcard/sdk';
|
|
36
|
+
|
|
37
|
+
const client = new DigitalCardClient({
|
|
38
|
+
registryBaseUrl: 'https://eilcard.com',
|
|
39
|
+
apiKey: process.env.EILCARD_API_KEY,
|
|
40
|
+
timeout: 10_000,
|
|
41
|
+
skipWellKnownFallback: false,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const result = await client.resolve({ domain: 'example.com' });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Discovery chain
|
|
48
|
+
|
|
49
|
+
1. **Registry** — `GET {registry}/api/v1/resolve?domain=` or `/api/v1/cards/{handle}`
|
|
50
|
+
2. **Fallback** — `GET https://{domain}/.well-known/digital-card`
|
|
51
|
+
|
|
52
|
+
## Bridge functions
|
|
53
|
+
|
|
54
|
+
| Function | Output |
|
|
55
|
+
|----------|--------|
|
|
56
|
+
| `toSchemaOrg(card)` | schema.org JSON-LD |
|
|
57
|
+
| `toVCard(card)` | vCard 4.0 (person cards) |
|
|
58
|
+
| `toLlmsTxtSection(card)` | llms.txt Markdown section |
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT — see [LICENSE](../../LICENSE) in the repository root.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Card } from './types.js';
|
|
2
|
+
/** schema.org JSON-LD object (Organization or Person) */
|
|
3
|
+
export type SchemaOrgDocument = Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* Convert Digital Card → schema.org JSON-LD.
|
|
6
|
+
* @see packages/sdk/SDK.md §6
|
|
7
|
+
*/
|
|
8
|
+
export declare function toSchemaOrg(card: Card): SchemaOrgDocument;
|
|
9
|
+
/**
|
|
10
|
+
* Convert Person Card → vCard 4.0 text.
|
|
11
|
+
* Organization cards throw SchemaValidationError.
|
|
12
|
+
*/
|
|
13
|
+
export declare function toVCard(card: Card): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generate an llms.txt section for site-level agent discovery.
|
|
16
|
+
*/
|
|
17
|
+
export declare function toLlmsTxtSection(card: Card): string;
|
|
18
|
+
//# sourceMappingURL=bridges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridges.d.ts","sourceRoot":"","sources":["../src/bridges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAgC,MAAM,YAAY,CAAC;AAGrE,yDAAyD;AACzD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAUxD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,CAsDzD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAoB1C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAsBnD"}
|
package/dist/bridges.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { SchemaValidationError } from './errors.js';
|
|
2
|
+
function isOrganization(card) {
|
|
3
|
+
return card.type === 'organization';
|
|
4
|
+
}
|
|
5
|
+
function isPerson(card) {
|
|
6
|
+
return card.type === 'person';
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Convert Digital Card → schema.org JSON-LD.
|
|
10
|
+
* @see packages/sdk/SDK.md §6
|
|
11
|
+
*/
|
|
12
|
+
export function toSchemaOrg(card) {
|
|
13
|
+
if (isOrganization(card)) {
|
|
14
|
+
const baseUrl = card.contact.website ?? `https://${card.card_id}`;
|
|
15
|
+
const doc = {
|
|
16
|
+
'@context': 'https://schema.org',
|
|
17
|
+
'@type': 'Organization',
|
|
18
|
+
'@id': `${baseUrl}/#organization`,
|
|
19
|
+
name: card.name.official,
|
|
20
|
+
url: card.contact.website ?? baseUrl,
|
|
21
|
+
};
|
|
22
|
+
if (card.name.short)
|
|
23
|
+
doc.alternateName = card.name.short;
|
|
24
|
+
if (card.contact.email)
|
|
25
|
+
doc.email = card.contact.email;
|
|
26
|
+
if (card.contact.phone)
|
|
27
|
+
doc.telephone = card.contact.phone;
|
|
28
|
+
if (card.logo_url)
|
|
29
|
+
doc.logo = card.logo_url;
|
|
30
|
+
if (card.same_as?.length)
|
|
31
|
+
doc.sameAs = card.same_as;
|
|
32
|
+
const desc = [card.description?.tagline, card.description?.summary]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join(' — ');
|
|
35
|
+
if (desc)
|
|
36
|
+
doc.description = desc;
|
|
37
|
+
return doc;
|
|
38
|
+
}
|
|
39
|
+
if (isPerson(card)) {
|
|
40
|
+
const baseUrl = card.human_url ?? `https://eilcard.com/kart/${card.handle ?? card.card_id}`;
|
|
41
|
+
const doc = {
|
|
42
|
+
'@context': 'https://schema.org',
|
|
43
|
+
'@type': 'Person',
|
|
44
|
+
'@id': `${baseUrl}/#person`,
|
|
45
|
+
name: card.name.full,
|
|
46
|
+
url: baseUrl,
|
|
47
|
+
};
|
|
48
|
+
if (card.name.title)
|
|
49
|
+
doc.jobTitle = card.name.title;
|
|
50
|
+
if (card.contact.email)
|
|
51
|
+
doc.email = card.contact.email;
|
|
52
|
+
if (card.contact.phone)
|
|
53
|
+
doc.telephone = card.contact.phone;
|
|
54
|
+
if (card.photo_url)
|
|
55
|
+
doc.image = card.photo_url;
|
|
56
|
+
if (card.same_as?.length)
|
|
57
|
+
doc.sameAs = card.same_as;
|
|
58
|
+
if (card.description?.summary)
|
|
59
|
+
doc.description = card.description.summary;
|
|
60
|
+
if (card.organization_ref) {
|
|
61
|
+
doc.worksFor = {
|
|
62
|
+
'@id': card.organization_ref.startsWith('http')
|
|
63
|
+
? card.organization_ref
|
|
64
|
+
: `https://${card.organization_ref}/#organization`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return doc;
|
|
68
|
+
}
|
|
69
|
+
throw new SchemaValidationError(`Unsupported card type`);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Convert Person Card → vCard 4.0 text.
|
|
73
|
+
* Organization cards throw SchemaValidationError.
|
|
74
|
+
*/
|
|
75
|
+
export function toVCard(card) {
|
|
76
|
+
if (!isPerson(card)) {
|
|
77
|
+
throw new SchemaValidationError('toVCard() supports person cards only');
|
|
78
|
+
}
|
|
79
|
+
const lines = [
|
|
80
|
+
'BEGIN:VCARD',
|
|
81
|
+
'VERSION:4.0',
|
|
82
|
+
`FN:${escapeVCard(card.name.full)}`,
|
|
83
|
+
];
|
|
84
|
+
if (card.name.given)
|
|
85
|
+
lines.push(`N:${escapeVCard(card.name.family ?? '')};${escapeVCard(card.name.given)};;;`);
|
|
86
|
+
if (card.name.title)
|
|
87
|
+
lines.push(`TITLE:${escapeVCard(card.name.title)}`);
|
|
88
|
+
if (card.contact.email)
|
|
89
|
+
lines.push(`EMAIL:${card.contact.email}`);
|
|
90
|
+
if (card.contact.phone)
|
|
91
|
+
lines.push(`TEL:${card.contact.phone}`);
|
|
92
|
+
if (card.human_url)
|
|
93
|
+
lines.push(`URL:${card.human_url}`);
|
|
94
|
+
if (card.organization_ref)
|
|
95
|
+
lines.push(`ORG:${escapeVCard(card.organization_ref)}`);
|
|
96
|
+
lines.push('END:VCARD');
|
|
97
|
+
return lines.join('\r\n');
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Generate an llms.txt section for site-level agent discovery.
|
|
101
|
+
*/
|
|
102
|
+
export function toLlmsTxtSection(card) {
|
|
103
|
+
const title = isOrganization(card)
|
|
104
|
+
? card.name.official
|
|
105
|
+
: card.name.full;
|
|
106
|
+
const lines = [`# ${title}`, ''];
|
|
107
|
+
if (card.description?.tagline)
|
|
108
|
+
lines.push(`> ${card.description.tagline}`, '');
|
|
109
|
+
if (card.description?.summary)
|
|
110
|
+
lines.push(card.description.summary, '');
|
|
111
|
+
if (isOrganization(card) && card.products?.length) {
|
|
112
|
+
lines.push('## Products', '');
|
|
113
|
+
for (const p of card.products) {
|
|
114
|
+
lines.push(`- ${p.name}${p.description ? `: ${p.description}` : ''}`);
|
|
115
|
+
}
|
|
116
|
+
lines.push('');
|
|
117
|
+
}
|
|
118
|
+
if (card.human_url)
|
|
119
|
+
lines.push(`- [Digital Card](${card.human_url})`, '');
|
|
120
|
+
if (card.registry_url)
|
|
121
|
+
lines.push(`- [Registry JSON](${card.registry_url})`, '');
|
|
122
|
+
return lines.join('\n').trim();
|
|
123
|
+
}
|
|
124
|
+
function escapeVCard(value) {
|
|
125
|
+
return value.replace(/\\/g, '\\\\').replace(/;/g, '\\;').replace(/\n/g, '\\n');
|
|
126
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DigitalCardClientOptions, ResolveInput, ResolveResult } from './types.js';
|
|
2
|
+
export declare class DigitalCardClient {
|
|
3
|
+
private readonly registryBaseUrl;
|
|
4
|
+
private readonly apiKey?;
|
|
5
|
+
private readonly timeout;
|
|
6
|
+
private readonly skipWellKnownFallback;
|
|
7
|
+
private readonly fetchFn;
|
|
8
|
+
constructor(options?: DigitalCardClientOptions);
|
|
9
|
+
resolve(input: ResolveInput): Promise<ResolveResult>;
|
|
10
|
+
private resolveByHandle;
|
|
11
|
+
private resolveByDomain;
|
|
12
|
+
private fetchRegistryCard;
|
|
13
|
+
private fetchWellKnownCard;
|
|
14
|
+
private buildHeaders;
|
|
15
|
+
private fetchWithTimeout;
|
|
16
|
+
}
|
|
17
|
+
/** Convenience singleton-style API */
|
|
18
|
+
export declare const DigitalCard: {
|
|
19
|
+
resolve(input: ResolveInput, options?: DigitalCardClientOptions): Promise<ResolveResult>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,wBAAwB,EACxB,YAAY,EAEZ,aAAa,EACd,MAAM,YAAY,CAAC;AAOpB,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAU;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,OAAO,GAAE,wBAA6B;IAQ5C,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;YAY5C,eAAe;YAgBf,eAAe;YAyCf,iBAAiB;YAgBjB,kBAAkB;IAahC,OAAO,CAAC,YAAY;YAQN,gBAAgB;CAS/B;AAED,sCAAsC;AACtC,eAAO,MAAM,WAAW;mBACP,YAAY,YAAY,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC;CAGzF,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { CardNotFoundError, InvalidResolveInputError, RegistryError, } from './errors.js';
|
|
2
|
+
const DEFAULT_REGISTRY = 'https://eilcard.com';
|
|
3
|
+
const API_PREFIX = '/api/v1';
|
|
4
|
+
const DEFAULT_TIMEOUT = 10_000;
|
|
5
|
+
const WELL_KNOWN_PATH = '/.well-known/digital-card';
|
|
6
|
+
export class DigitalCardClient {
|
|
7
|
+
registryBaseUrl;
|
|
8
|
+
apiKey;
|
|
9
|
+
timeout;
|
|
10
|
+
skipWellKnownFallback;
|
|
11
|
+
fetchFn;
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
this.registryBaseUrl = (options.registryBaseUrl ?? DEFAULT_REGISTRY).replace(/\/$/, '');
|
|
14
|
+
this.apiKey = options.apiKey;
|
|
15
|
+
this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
|
|
16
|
+
this.skipWellKnownFallback = options.skipWellKnownFallback ?? false;
|
|
17
|
+
this.fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
18
|
+
}
|
|
19
|
+
async resolve(input) {
|
|
20
|
+
if (Boolean(input.domain) === Boolean(input.handle)) {
|
|
21
|
+
throw new InvalidResolveInputError();
|
|
22
|
+
}
|
|
23
|
+
if (input.handle) {
|
|
24
|
+
return this.resolveByHandle(input.handle);
|
|
25
|
+
}
|
|
26
|
+
return this.resolveByDomain(input.domain);
|
|
27
|
+
}
|
|
28
|
+
async resolveByHandle(handle) {
|
|
29
|
+
const url = `${this.registryBaseUrl}${API_PREFIX}/cards/${encodeURIComponent(handle)}`;
|
|
30
|
+
const card = await this.fetchRegistryCard(url);
|
|
31
|
+
return {
|
|
32
|
+
card,
|
|
33
|
+
meta: {
|
|
34
|
+
source: 'registry',
|
|
35
|
+
registry_url: url,
|
|
36
|
+
well_known_url: card.contact.website
|
|
37
|
+
? `${card.contact.website.replace(/\/$/, '')}${WELL_KNOWN_PATH}`
|
|
38
|
+
: undefined,
|
|
39
|
+
resolved_at: new Date().toISOString(),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async resolveByDomain(domain) {
|
|
44
|
+
const normalized = normalizeDomain(domain);
|
|
45
|
+
const registryUrl = `${this.registryBaseUrl}${API_PREFIX}/resolve?domain=${encodeURIComponent(normalized)}`;
|
|
46
|
+
try {
|
|
47
|
+
const card = await this.fetchRegistryCard(registryUrl);
|
|
48
|
+
return {
|
|
49
|
+
card,
|
|
50
|
+
meta: {
|
|
51
|
+
source: 'registry',
|
|
52
|
+
registry_url: registryUrl,
|
|
53
|
+
well_known_url: `https://${normalized}${WELL_KNOWN_PATH}`,
|
|
54
|
+
resolved_at: new Date().toISOString(),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (!(error instanceof RegistryError) || error.status !== 404) {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (this.skipWellKnownFallback) {
|
|
64
|
+
throw new CardNotFoundError({ domain: normalized });
|
|
65
|
+
}
|
|
66
|
+
const wellKnownUrl = `https://${normalized}${WELL_KNOWN_PATH}`;
|
|
67
|
+
const card = await this.fetchWellKnownCard(wellKnownUrl);
|
|
68
|
+
if (!card) {
|
|
69
|
+
throw new CardNotFoundError({ domain: normalized });
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
card,
|
|
73
|
+
meta: {
|
|
74
|
+
source: 'well-known',
|
|
75
|
+
well_known_url: wellKnownUrl,
|
|
76
|
+
resolved_at: new Date().toISOString(),
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async fetchRegistryCard(url) {
|
|
81
|
+
const response = await this.fetchWithTimeout(url, {
|
|
82
|
+
headers: this.buildHeaders({ accept: 'application/json' }),
|
|
83
|
+
});
|
|
84
|
+
if (response.status === 404) {
|
|
85
|
+
throw new RegistryError(`Registry returned 404 for ${url}`, 404);
|
|
86
|
+
}
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
throw new RegistryError(`Registry error ${response.status}`, response.status);
|
|
89
|
+
}
|
|
90
|
+
const body = (await response.json());
|
|
91
|
+
return 'card' in body && body.card ? body.card : body;
|
|
92
|
+
}
|
|
93
|
+
async fetchWellKnownCard(url) {
|
|
94
|
+
try {
|
|
95
|
+
const response = await this.fetchWithTimeout(url, {
|
|
96
|
+
headers: { Accept: 'application/json' },
|
|
97
|
+
});
|
|
98
|
+
if (response.status === 404)
|
|
99
|
+
return null;
|
|
100
|
+
if (!response.ok)
|
|
101
|
+
return null;
|
|
102
|
+
return (await response.json());
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
buildHeaders(extra) {
|
|
109
|
+
const headers = { ...extra };
|
|
110
|
+
if (this.apiKey) {
|
|
111
|
+
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
112
|
+
}
|
|
113
|
+
return headers;
|
|
114
|
+
}
|
|
115
|
+
async fetchWithTimeout(url, init) {
|
|
116
|
+
const controller = new AbortController();
|
|
117
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
118
|
+
try {
|
|
119
|
+
return await this.fetchFn(url, { ...init, signal: controller.signal });
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
clearTimeout(timer);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/** Convenience singleton-style API */
|
|
127
|
+
export const DigitalCard = {
|
|
128
|
+
resolve(input, options) {
|
|
129
|
+
return new DigitalCardClient(options).resolve(input);
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
function normalizeDomain(domain) {
|
|
133
|
+
return domain
|
|
134
|
+
.trim()
|
|
135
|
+
.toLowerCase()
|
|
136
|
+
.replace(/^https?:\/\//, '')
|
|
137
|
+
.replace(/\/.*$/, '');
|
|
138
|
+
}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ResolveInput } from './types.js';
|
|
2
|
+
export declare class DigitalCardError extends Error {
|
|
3
|
+
constructor(message: string, options?: {
|
|
4
|
+
cause?: unknown;
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
export declare class CardNotFoundError extends DigitalCardError {
|
|
8
|
+
readonly input: ResolveInput;
|
|
9
|
+
constructor(input: ResolveInput);
|
|
10
|
+
}
|
|
11
|
+
export declare class InvalidResolveInputError extends DigitalCardError {
|
|
12
|
+
constructor();
|
|
13
|
+
}
|
|
14
|
+
export declare class RegistryError extends DigitalCardError {
|
|
15
|
+
readonly status?: number;
|
|
16
|
+
constructor(message: string, status?: number, cause?: unknown);
|
|
17
|
+
}
|
|
18
|
+
export declare class SchemaValidationError extends DigitalCardError {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AAED,qBAAa,iBAAkB,SAAQ,gBAAgB;IACrD,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;gBAEjB,KAAK,EAAE,YAAY;CAMhC;AAED,qBAAa,wBAAyB,SAAQ,gBAAgB;;CAK7D;AAED,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK9D;AAED,qBAAa,qBAAsB,SAAQ,gBAAgB;gBAC7C,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export class DigitalCardError extends Error {
|
|
2
|
+
constructor(message, options) {
|
|
3
|
+
super(message, options);
|
|
4
|
+
this.name = 'DigitalCardError';
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class CardNotFoundError extends DigitalCardError {
|
|
8
|
+
input;
|
|
9
|
+
constructor(input) {
|
|
10
|
+
const target = input.domain ?? input.handle ?? 'unknown';
|
|
11
|
+
super(`Digital card not found: ${target}`);
|
|
12
|
+
this.name = 'CardNotFoundError';
|
|
13
|
+
this.input = input;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class InvalidResolveInputError extends DigitalCardError {
|
|
17
|
+
constructor() {
|
|
18
|
+
super('Provide exactly one of domain or handle');
|
|
19
|
+
this.name = 'InvalidResolveInputError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class RegistryError extends DigitalCardError {
|
|
23
|
+
status;
|
|
24
|
+
constructor(message, status, cause) {
|
|
25
|
+
super(message, { cause });
|
|
26
|
+
this.name = 'RegistryError';
|
|
27
|
+
this.status = status;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class SchemaValidationError extends DigitalCardError {
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = 'SchemaValidationError';
|
|
34
|
+
}
|
|
35
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DigitalCard, DigitalCardClient } from './client.js';
|
|
2
|
+
export { toSchemaOrg, toVCard, toLlmsTxtSection } from './bridges.js';
|
|
3
|
+
export type { SchemaOrgDocument } from './bridges.js';
|
|
4
|
+
export { CardNotFoundError, DigitalCardError, InvalidResolveInputError, RegistryError, SchemaValidationError, } from './errors.js';
|
|
5
|
+
export type { ActionType, Apps, Card, CardAction, CardBase, CardMode, CardType, Contact, Description, DigitalCardClientOptions, Legal, LegalType, OrganizationCard, OrganizationName, PersonCard, PersonName, Product, ResolveInput, ResolveMeta, ResolveResult, ResolveSource, VerificationMethod, } from './types.js';
|
|
6
|
+
export { SCHEMA_VERSION } from './types.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACtE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,WAAW,EACX,wBAAwB,EACxB,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,OAAO,EACP,YAAY,EACZ,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { DigitalCard, DigitalCardClient } from './client.js';
|
|
2
|
+
export { toSchemaOrg, toVCard, toLlmsTxtSection } from './bridges.js';
|
|
3
|
+
export { CardNotFoundError, DigitalCardError, InvalidResolveInputError, RegistryError, SchemaValidationError, } from './errors.js';
|
|
4
|
+
export { SCHEMA_VERSION } from './types.js';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @digitalcard/sdk — types aligned with schema/v1.0.schema.json
|
|
3
|
+
* Faz B3 — specification types (implementation in Faz D)
|
|
4
|
+
*/
|
|
5
|
+
export declare const SCHEMA_VERSION: "1.0";
|
|
6
|
+
export type CardType = 'organization' | 'person';
|
|
7
|
+
export type VerificationMethod = 'dns' | 'email' | 'tls' | 'trade_registry' | 'public_record';
|
|
8
|
+
export type LegalType = 'technology_company' | 'smb' | 'enterprise' | 'public_institution' | 'university' | 'ngo' | 'individual';
|
|
9
|
+
export type ActionType = 'call' | 'email' | 'link' | 'vcard' | 'calendar' | 'whatsapp' | 'app';
|
|
10
|
+
export interface OrganizationName {
|
|
11
|
+
official: string;
|
|
12
|
+
short?: string;
|
|
13
|
+
alternate?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface PersonName {
|
|
16
|
+
full: string;
|
|
17
|
+
given?: string;
|
|
18
|
+
family?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Contact {
|
|
22
|
+
phone?: string;
|
|
23
|
+
email?: string;
|
|
24
|
+
website?: string;
|
|
25
|
+
whatsapp?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface Legal {
|
|
28
|
+
country: string;
|
|
29
|
+
type?: LegalType;
|
|
30
|
+
tax_id?: string;
|
|
31
|
+
trade_registry?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface Description {
|
|
34
|
+
tagline?: string;
|
|
35
|
+
summary?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface Product {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
url?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface Apps {
|
|
44
|
+
play_store?: string;
|
|
45
|
+
app_store?: string;
|
|
46
|
+
web_app?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface CardAction {
|
|
49
|
+
type: ActionType;
|
|
50
|
+
label: string;
|
|
51
|
+
value?: string;
|
|
52
|
+
url?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface CardMode {
|
|
55
|
+
id: string;
|
|
56
|
+
label: string;
|
|
57
|
+
active_links?: string[];
|
|
58
|
+
}
|
|
59
|
+
export interface CardBase {
|
|
60
|
+
schema_version: typeof SCHEMA_VERSION;
|
|
61
|
+
card_id: string;
|
|
62
|
+
type: CardType;
|
|
63
|
+
handle?: string;
|
|
64
|
+
verified?: boolean;
|
|
65
|
+
verification_method?: VerificationMethod[];
|
|
66
|
+
contact: Contact;
|
|
67
|
+
description?: Description;
|
|
68
|
+
actions?: CardAction[];
|
|
69
|
+
same_as?: string[];
|
|
70
|
+
updated_at: string;
|
|
71
|
+
created_at?: string;
|
|
72
|
+
human_url?: string;
|
|
73
|
+
registry_url?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface OrganizationCard extends CardBase {
|
|
76
|
+
type: 'organization';
|
|
77
|
+
name: OrganizationName;
|
|
78
|
+
legal?: Legal;
|
|
79
|
+
products?: Product[];
|
|
80
|
+
apps?: Apps;
|
|
81
|
+
logo_url?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface PersonCard extends CardBase {
|
|
84
|
+
type: 'person';
|
|
85
|
+
name: PersonName;
|
|
86
|
+
organization_ref?: string;
|
|
87
|
+
modes?: CardMode[];
|
|
88
|
+
photo_url?: string;
|
|
89
|
+
}
|
|
90
|
+
export type Card = OrganizationCard | PersonCard;
|
|
91
|
+
export type ResolveSource = 'registry' | 'well-known';
|
|
92
|
+
export interface ResolveMeta {
|
|
93
|
+
source: ResolveSource;
|
|
94
|
+
well_known_url?: string;
|
|
95
|
+
registry_url?: string;
|
|
96
|
+
resolved_at: string;
|
|
97
|
+
}
|
|
98
|
+
export interface ResolveResult {
|
|
99
|
+
card: Card;
|
|
100
|
+
meta: ResolveMeta;
|
|
101
|
+
}
|
|
102
|
+
export interface ResolveInput {
|
|
103
|
+
/** Domain — e.g. sinyalle.com */
|
|
104
|
+
domain?: string;
|
|
105
|
+
/** Registry handle — e.g. sinyalle */
|
|
106
|
+
handle?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface DigitalCardClientOptions {
|
|
109
|
+
/** Registry API base — default https://api.digitalcard.tr */
|
|
110
|
+
registryBaseUrl?: string;
|
|
111
|
+
/** Optional API key for higher quota */
|
|
112
|
+
apiKey?: string;
|
|
113
|
+
/** Request timeout ms — default 10000 */
|
|
114
|
+
timeout?: number;
|
|
115
|
+
/** Skip well-known fallback */
|
|
116
|
+
skipWellKnownFallback?: boolean;
|
|
117
|
+
/** Custom fetch implementation (Node, edge, test mocks) */
|
|
118
|
+
fetch?: typeof fetch;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,cAAc,EAAG,KAAc,CAAC;AAE7C,MAAM,MAAM,QAAQ,GAAG,cAAc,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nB;AAED,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC1C,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,UAAU,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,IAAI,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,YAAY,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB"}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@digitalcard/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for EIL Card — resolve canonical entity profiles for AI agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist", "README.md"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.json",
|
|
17
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"eil",
|
|
22
|
+
"digital-card",
|
|
23
|
+
"entity-identity",
|
|
24
|
+
"agent",
|
|
25
|
+
"schema.org",
|
|
26
|
+
"llms",
|
|
27
|
+
"resolve"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/Mendocan/eilcard.git",
|
|
33
|
+
"directory": "packages/sdk"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://eilcard.com",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/Mendocan/eilcard/issues"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=20"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"typescript": "^5.8.0"
|
|
47
|
+
}
|
|
48
|
+
}
|