@tacitprotocol/sdk 0.1.0 → 0.1.1
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 +158 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# @tacitprotocol/sdk
|
|
2
|
+
|
|
3
|
+
The TypeScript SDK for the **Tacit Protocol** — verify identity, prevent fraud, and broker trusted introductions with cryptographic proof.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@tacitprotocol/sdk)
|
|
6
|
+
[](https://github.com/tacitprotocol/tacit/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @tacitprotocol/sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { TacitAgent } from '@tacitprotocol/sdk';
|
|
18
|
+
|
|
19
|
+
// Create an agent with a fresh DID identity
|
|
20
|
+
const agent = await TacitAgent.create({
|
|
21
|
+
domain: 'professional',
|
|
22
|
+
preferences: {
|
|
23
|
+
languages: ['en'],
|
|
24
|
+
introductionStyle: 'professional',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Publish an intent to the network
|
|
29
|
+
await agent.publishIntent({
|
|
30
|
+
type: 'introduction',
|
|
31
|
+
domain: 'professional',
|
|
32
|
+
seeking: {
|
|
33
|
+
role: 'co-founder',
|
|
34
|
+
skills: ['backend', 'systems-architecture'],
|
|
35
|
+
industry: 'fintech',
|
|
36
|
+
},
|
|
37
|
+
context: {
|
|
38
|
+
offering: 'product leadership, 10 years in payments',
|
|
39
|
+
stage: 'pre-seed',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Listen for verified matches
|
|
44
|
+
agent.on('match', async (event) => {
|
|
45
|
+
const { match } = event;
|
|
46
|
+
console.log(`Match: ${match.score.overall}/100`);
|
|
47
|
+
console.log(`Authenticity: ${match.score.breakdown.authenticityCompatibility}`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Connect to the relay network
|
|
51
|
+
await agent.connect();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Core Modules
|
|
55
|
+
|
|
56
|
+
### Identity (`createIdentity`, `sign`, `verify`)
|
|
57
|
+
|
|
58
|
+
W3C DID-based identity using Ed25519 keypairs. Every agent gets a `did:key` identifier that is cryptographically verifiable.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { createIdentity, sign, verify } from '@tacitprotocol/sdk';
|
|
62
|
+
|
|
63
|
+
const identity = await createIdentity();
|
|
64
|
+
console.log(identity.did); // did:key:z6Mk...
|
|
65
|
+
|
|
66
|
+
const data = new TextEncoder().encode('hello');
|
|
67
|
+
const signature = await sign(data, identity.privateKey);
|
|
68
|
+
const valid = await verify(data, signature, identity.publicKey);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Authenticity (`AuthenticityEngine`)
|
|
72
|
+
|
|
73
|
+
Multi-dimensional trust scores that are earned over time — impossible to fake overnight. Dimensions: tenure, consistency, attestations, network trust.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { AuthenticityEngine } from '@tacitprotocol/sdk';
|
|
77
|
+
|
|
78
|
+
const engine = new AuthenticityEngine();
|
|
79
|
+
const vector = engine.computeVector({
|
|
80
|
+
created: agent.card.agent.created,
|
|
81
|
+
consistencySignals: { intentFulfillmentRate: 0.9, responseRate: 0.85 },
|
|
82
|
+
credentials: agent.card.credentials,
|
|
83
|
+
networkTrust: { endorsements: 12, uniqueEndorsers: 8, mutualConnections: 3 },
|
|
84
|
+
});
|
|
85
|
+
console.log(vector.score); // 0-100
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Discovery (`IntentBuilder`, `IntentStore`)
|
|
89
|
+
|
|
90
|
+
Publish and discover encrypted intents on the network. The `IntentBuilder` provides a fluent API for constructing intents.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { IntentBuilder, IntentStore } from '@tacitprotocol/sdk';
|
|
94
|
+
|
|
95
|
+
const intent = new IntentBuilder(agent.did)
|
|
96
|
+
.type('introduction')
|
|
97
|
+
.domain('professional')
|
|
98
|
+
.seeking({ role: 'backend-engineer', skills: ['rust', 'distributed-systems'] })
|
|
99
|
+
.context({ offering: 'equity + salary', stage: 'seed' })
|
|
100
|
+
.minAuthenticity(70)
|
|
101
|
+
.ttl(86400) // 24 hours
|
|
102
|
+
.build();
|
|
103
|
+
|
|
104
|
+
const store = new IntentStore();
|
|
105
|
+
store.add(intent);
|
|
106
|
+
const matches = store.query({ domain: 'professional', keywords: ['rust'] });
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Matching (`MatchScorer`)
|
|
110
|
+
|
|
111
|
+
Score compatibility between two agents across five dimensions: intent alignment, domain fit, authenticity compatibility, preference match, and timing fit.
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { MatchScorer } from '@tacitprotocol/sdk';
|
|
115
|
+
|
|
116
|
+
const scorer = new MatchScorer({ autoPropose: 80, suggest: 60 });
|
|
117
|
+
const result = scorer.score({
|
|
118
|
+
initiator: { intent: aliceIntent, card: aliceCard },
|
|
119
|
+
responder: { intent: bobIntent, card: bobCard },
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
console.log(result.score.overall); // 0-100
|
|
123
|
+
console.log(scorer.determineAction(result.score.overall)); // 'auto-propose' | 'suggest' | 'ignore'
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## API Reference
|
|
127
|
+
|
|
128
|
+
### Exports
|
|
129
|
+
|
|
130
|
+
| Export | Type | Description |
|
|
131
|
+
|--------|------|-------------|
|
|
132
|
+
| `TacitAgent` | Class | Main agent interface — identity, intents, matching, events |
|
|
133
|
+
| `createIdentity` | Function | Generate a new Ed25519 DID identity |
|
|
134
|
+
| `publicKeyToDid` | Function | Convert a public key to a `did:key` DID |
|
|
135
|
+
| `resolveDid` | Function | Resolve a DID to its public key |
|
|
136
|
+
| `sign` / `verify` | Functions | Ed25519 signing and verification |
|
|
137
|
+
| `AuthenticityEngine` | Class | Compute multi-dimensional trust scores |
|
|
138
|
+
| `IntentBuilder` | Class | Fluent builder for constructing intents |
|
|
139
|
+
| `IntentStore` | Class | Local intent storage with lifecycle management |
|
|
140
|
+
| `MatchScorer` | Class | Score compatibility between two agents |
|
|
141
|
+
|
|
142
|
+
All types are fully exported — see the [type definitions](https://github.com/tacitprotocol/tacit/blob/main/packages/sdk-ts/src/types/index.ts) for the complete schema.
|
|
143
|
+
|
|
144
|
+
## Requirements
|
|
145
|
+
|
|
146
|
+
- Node.js >= 18.0.0 (Web Crypto API required)
|
|
147
|
+
- TypeScript >= 5.0 (recommended)
|
|
148
|
+
|
|
149
|
+
## Links
|
|
150
|
+
|
|
151
|
+
- [Protocol Spec](https://github.com/tacitprotocol/tacit/blob/main/docs/PROTOCOL_SPEC.md)
|
|
152
|
+
- [Whitepaper](https://github.com/tacitprotocol/tacit/blob/main/docs/WHITEPAPER.md)
|
|
153
|
+
- [GitHub](https://github.com/tacitprotocol/tacit)
|
|
154
|
+
- [Website](https://tacitprotocol.com)
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tacitprotocol/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The Tacit Protocol SDK — verify identity, prevent fraud, and broker trusted introductions with cryptographic proof",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|