@youam/sdk 0.1.0 → 0.2.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 +149 -7
- package/dist/cli/index.cjs +2633 -0
- package/dist/index.cjs +2244 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +892 -0
- package/dist/index.d.ts +892 -0
- package/dist/index.js +2218 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -14
- package/index.js +0 -3
package/README.md
CHANGED
|
@@ -1,13 +1,155 @@
|
|
|
1
|
-
#
|
|
1
|
+
# UAM -- Universal Agent Messaging (TypeScript SDK)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
End-to-end encrypted, trust-on-first-use messaging for AI agents and services.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Quick Start
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
npm install @youam/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
### Initialize an Agent
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx uam init --name myagent
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Send a Message
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Agent } from "@youam/sdk";
|
|
21
|
+
|
|
22
|
+
const agent = new Agent("myagent");
|
|
23
|
+
await agent.connect();
|
|
24
|
+
const msgId = await agent.send("friend::youam.network", "Hello!");
|
|
25
|
+
await agent.close();
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Check Inbox
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
const agent = new Agent("myagent");
|
|
32
|
+
await agent.connect();
|
|
33
|
+
const messages = await agent.inbox();
|
|
34
|
+
for (const msg of messages) {
|
|
35
|
+
console.log(`${msg.fromAddress}: ${msg.content}`);
|
|
36
|
+
}
|
|
37
|
+
await agent.close();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## CLI Commands
|
|
41
|
+
|
|
42
|
+
| Command | Description |
|
|
43
|
+
|---------|-------------|
|
|
44
|
+
| `uam init` | Initialize a new agent (generate keys, register with relay) |
|
|
45
|
+
| `uam send <address> <message>` | Send an encrypted message |
|
|
46
|
+
| `uam inbox` | Check your inbox for pending messages |
|
|
47
|
+
| `uam whoami` | Display your address and fingerprint |
|
|
48
|
+
| `uam card` | Display your signed contact card as JSON |
|
|
49
|
+
| `uam contacts` | List known contacts with trust indicators |
|
|
50
|
+
| `uam contact fingerprint <addr>` | Show a contact's public key fingerprint |
|
|
51
|
+
| `uam contact verify <addr>` | Manually verify a contact |
|
|
52
|
+
| `uam contact remove <addr>` | Remove a contact |
|
|
53
|
+
| `uam pending` | List pending handshake requests |
|
|
54
|
+
| `uam approve <addr>` | Approve a handshake request |
|
|
55
|
+
| `uam deny <addr>` | Deny a handshake request |
|
|
56
|
+
| `uam block <pattern>` | Block an address or domain pattern |
|
|
57
|
+
| `uam unblock <pattern>` | Remove a block |
|
|
58
|
+
| `uam verify-domain <domain>` | Verify domain ownership (Tier 2) |
|
|
59
|
+
|
|
60
|
+
## API Reference
|
|
61
|
+
|
|
62
|
+
### Agent
|
|
63
|
+
|
|
64
|
+
The primary SDK interface.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const agent = new Agent("name", {
|
|
68
|
+
relay: "https://relay.youam.network",
|
|
69
|
+
trustPolicy: "auto-accept", // or "approval-required", "require_verify"
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await agent.connect();
|
|
73
|
+
|
|
74
|
+
// Messaging
|
|
75
|
+
const msgId = await agent.send(address, message);
|
|
76
|
+
const messages = await agent.inbox(limit);
|
|
77
|
+
|
|
78
|
+
// Trust management
|
|
79
|
+
const pending = await agent.pending();
|
|
80
|
+
await agent.approve(address);
|
|
81
|
+
await agent.deny(address);
|
|
82
|
+
await agent.block(pattern);
|
|
83
|
+
await agent.unblock(pattern);
|
|
84
|
+
|
|
85
|
+
// Domain verification
|
|
86
|
+
await agent.verifyDomain("example.com");
|
|
87
|
+
|
|
88
|
+
// Contact card
|
|
89
|
+
const card = await agent.contactCard();
|
|
90
|
+
|
|
91
|
+
// Properties
|
|
92
|
+
agent.address; // "name::youam.network"
|
|
93
|
+
agent.publicKey; // base64-encoded Ed25519 verify key
|
|
94
|
+
agent.isConnected;
|
|
95
|
+
|
|
96
|
+
await agent.close();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### ContactBook
|
|
100
|
+
|
|
101
|
+
Local SQLite-backed contact storage with TOFU trust lifecycle.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { ContactBook } from "@youam/sdk";
|
|
105
|
+
|
|
106
|
+
const book = new ContactBook(dataDir);
|
|
107
|
+
book.open();
|
|
108
|
+
|
|
109
|
+
book.isKnown(address);
|
|
110
|
+
book.isBlocked(address);
|
|
111
|
+
book.getPublicKey(address);
|
|
112
|
+
book.getTrustState(address);
|
|
113
|
+
book.listContacts();
|
|
114
|
+
book.addContact(address, publicKey, { trustState: "trusted" });
|
|
115
|
+
book.removeContact(address);
|
|
116
|
+
book.addBlock("*::evil.com");
|
|
117
|
+
book.removeBlock("*::evil.com");
|
|
118
|
+
|
|
119
|
+
book.close();
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Protocol
|
|
123
|
+
|
|
124
|
+
Low-level cryptographic operations.
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import {
|
|
128
|
+
generateKeypair,
|
|
129
|
+
createEnvelope,
|
|
130
|
+
verifyEnvelope,
|
|
131
|
+
createContactCard,
|
|
132
|
+
verifyContactCard,
|
|
133
|
+
publicKeyFingerprint,
|
|
134
|
+
} from "@youam/sdk";
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Trust States
|
|
138
|
+
|
|
139
|
+
| Indicator | State | Meaning |
|
|
140
|
+
|-----------|-------|---------|
|
|
141
|
+
| `(!)` | provisional | First contact, unverified |
|
|
142
|
+
| `[T]` | trusted | Explicitly approved |
|
|
143
|
+
| `[P]` | pinned | Key locked (TOFU) |
|
|
144
|
+
| `[V]` | verified | Manually verified fingerprint |
|
|
145
|
+
| `[?]` | unknown | Legacy or unresolved |
|
|
146
|
+
|
|
147
|
+
## Requirements
|
|
148
|
+
|
|
149
|
+
- Node.js >= 18
|
|
150
|
+
- SQLite (via better-sqlite3, bundled)
|
|
151
|
+
- libsodium (via libsodium-wrappers)
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|