@dyne/interfacer-client 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 +264 -0
- package/dist/index.cjs +2352 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1092 -0
- package/dist/index.d.ts +1092 -0
- package/dist/index.js +2275 -0
- package/dist/index.js.map +1 -0
- package/package.json +75 -0
- package/src/zenflows-crypto/src/keypairoomClient-8-9-10-11-12.zen +127 -0
- package/src/zenflows-crypto/src/keypairoomClientRecreateKeys.zen +67 -0
- package/src/zenflows-crypto/src/sign_graphql.zen +30 -0
- package/src/zenflows-crypto/src/verify_graphql.zen +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# @dyne/interfacer-client
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the [Interfacer](https://interfacer.dyne.org) ecosystem — a unified client for Zenflows, Digital Product Passport (DPP), messaging, points, and social features.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm add @dyne/interfacer-client zenroom
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { InterfacerClient } from "@dyne/interfacer-client";
|
|
13
|
+
|
|
14
|
+
const client = new InterfacerClient({
|
|
15
|
+
zenflowsUrl: "https://proxy.example.com/zenflows/api",
|
|
16
|
+
zenflowsFileUrl: "https://proxy.example.com/zenflows/api/file",
|
|
17
|
+
dppUrl: "https://proxy.example.com/interfacer-dpp",
|
|
18
|
+
inbox: {
|
|
19
|
+
send: "https://proxy.example.com/inbox/send",
|
|
20
|
+
read: "https://proxy.example.com/inbox/read",
|
|
21
|
+
countUnread: "https://proxy.example.com/inbox/count-unread",
|
|
22
|
+
setRead: "https://proxy.example.com/inbox/set-read",
|
|
23
|
+
},
|
|
24
|
+
walletUrl: "https://proxy.example.com/wallet/token",
|
|
25
|
+
social: {
|
|
26
|
+
personBase: "https://proxy.example.com/inbox/person",
|
|
27
|
+
economicResourceBase: "https://proxy.example.com/inbox/economicresource",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Register a new user
|
|
32
|
+
await client.auth.requestHmac("user@example.com", true);
|
|
33
|
+
await client.auth.deriveKeys(
|
|
34
|
+
{
|
|
35
|
+
whereParentsMet: "Paris",
|
|
36
|
+
nameFirstPet: "Rex",
|
|
37
|
+
nameFirstTeacher: "Smith",
|
|
38
|
+
whereHomeTown: "Berlin",
|
|
39
|
+
nameMotherMaid: "Jones",
|
|
40
|
+
},
|
|
41
|
+
"user@example.com",
|
|
42
|
+
hmac
|
|
43
|
+
);
|
|
44
|
+
await client.auth.registerUser({
|
|
45
|
+
name: "Alice",
|
|
46
|
+
user: "alice",
|
|
47
|
+
email: "user@example.com",
|
|
48
|
+
});
|
|
49
|
+
await client.auth.login({ email: "user@example.com" });
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Architecture
|
|
53
|
+
|
|
54
|
+
The SDK is organized as a facade with lazy-initialized sub-clients:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
InterfacerClient
|
|
58
|
+
├── auth — Keypairoom auth, EdDSA signing, login/register
|
|
59
|
+
├── graphql — Fetch-based client with auto-signing
|
|
60
|
+
├── resources — Project/Resource CRUD, proposals, contributions
|
|
61
|
+
├── files — File hashing (SHA-512 via Zenroom, SHA-256 via Web Crypto)
|
|
62
|
+
├── dpp — Digital Product Passport operations
|
|
63
|
+
├── inbox — Messaging & notifications
|
|
64
|
+
├── wallet — Idea/Strength points
|
|
65
|
+
├── social — ActivityPub likes & follows
|
|
66
|
+
├── tagging — Classification system (15+ tag prefixes, numeric ranges)
|
|
67
|
+
└── import — GitHub/GitLab auto-import
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Sub-Client APIs
|
|
71
|
+
|
|
72
|
+
### Auth
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// Step 1: Get HMAC server-side shard
|
|
76
|
+
const hmac = await client.auth.requestHmac(email, firstRegistration);
|
|
77
|
+
|
|
78
|
+
// Step 2a: Derive keys from challenges (first-time)
|
|
79
|
+
await client.auth.deriveKeys(challenges, email, hmac);
|
|
80
|
+
|
|
81
|
+
// Step 2b: Recreate keys from seed (login)
|
|
82
|
+
await client.auth.recreateKeys(seed, hmac);
|
|
83
|
+
|
|
84
|
+
// Step 3: Register user
|
|
85
|
+
await client.auth.registerUser({ name, user, email });
|
|
86
|
+
|
|
87
|
+
// Step 4: Login
|
|
88
|
+
const profile = await client.auth.login({ email });
|
|
89
|
+
|
|
90
|
+
// Post-registration
|
|
91
|
+
await client.auth.sendEmailVerification();
|
|
92
|
+
await client.auth.claimDid(personId);
|
|
93
|
+
|
|
94
|
+
// Check status
|
|
95
|
+
client.isAuthenticated(); // boolean
|
|
96
|
+
client.getPublicKey(); // string | null
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Resources
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
// Create
|
|
103
|
+
const project = await client.resources.createProject({
|
|
104
|
+
projectType: "DESIGN",
|
|
105
|
+
name: "My Design",
|
|
106
|
+
note: "Description",
|
|
107
|
+
tags: ["open-source", "3d-printing"],
|
|
108
|
+
license: "CERN-OHL-S-2.0",
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const machine = await client.resources.createMachine({
|
|
112
|
+
name: "CNC Router",
|
|
113
|
+
metadata: { specs: "..." },
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Read
|
|
117
|
+
const resource = await client.resources.getResource(id);
|
|
118
|
+
const projects = await client.resources.getProjects();
|
|
119
|
+
const machines = await client.resources.getMachines();
|
|
120
|
+
|
|
121
|
+
// Relations
|
|
122
|
+
await client.resources.citeResource(resourceId, processId);
|
|
123
|
+
await client.resources.consumeResource(resourceId, processId);
|
|
124
|
+
await client.resources.contributeToResource(processId, designSpecId);
|
|
125
|
+
|
|
126
|
+
// Metadata
|
|
127
|
+
await client.resources.updateMetadata(resourceId, { contributors: [...] });
|
|
128
|
+
await client.resources.updateClassifiedAs(resourceId, tags);
|
|
129
|
+
await client.resources.relocateResource(resourceId, locationId);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Proposals & Contributions
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
// Propose a contribution
|
|
136
|
+
const { proposalId, citeIntentId, acceptIntentId, modifyIntentId } =
|
|
137
|
+
await client.resources.proposeContribution({
|
|
138
|
+
resourceForkedId: forkedResourceId,
|
|
139
|
+
resourceOriginId: originalResourceId,
|
|
140
|
+
ownerId: originalOwnerId,
|
|
141
|
+
note: "My contribution",
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Accept a proposal
|
|
145
|
+
await client.resources.acceptProposal({
|
|
146
|
+
proposalId,
|
|
147
|
+
citeIntentId, acceptIntentId, modifyIntentId,
|
|
148
|
+
resourceForkedId, resourceOriginId,
|
|
149
|
+
ownerId, proposerId,
|
|
150
|
+
newMetadata: { ...updatedMetadata },
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Reject
|
|
154
|
+
await client.resources.rejectProposal(citeIntentId, acceptIntentId, modifyIntentId);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Files
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// Hash and prepare for Zenflows
|
|
161
|
+
const files = await client.files.prepFilesForZenflows(fileList);
|
|
162
|
+
|
|
163
|
+
// Upload to Zenflows
|
|
164
|
+
await client.files.uploadToZenflows(file);
|
|
165
|
+
|
|
166
|
+
// Upload to DPP
|
|
167
|
+
const attachment = await client.files.uploadToDpp(file);
|
|
168
|
+
|
|
169
|
+
// Upload model files to DPP
|
|
170
|
+
const models = await client.files.uploadModelsToDpp(modelFiles);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### DPP
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
const dpp = await client.dpp.createDpp({ productOverview: { ... } });
|
|
177
|
+
const existing = await client.dpp.getDpp(id);
|
|
178
|
+
await client.dpp.updateDpp(id, { status: "active" });
|
|
179
|
+
const list = await client.dpp.listDpps({ status: "active", limit: 10 });
|
|
180
|
+
const qrUrl = client.dpp.getQrCodeUrl(id, 256);
|
|
181
|
+
await client.dpp.addAttachment(id, "certificates", file);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Messaging
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
await client.inbox.sendMessage(
|
|
188
|
+
{ proposalId: "..." },
|
|
189
|
+
["receiverId"],
|
|
190
|
+
"Contribution proposed"
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const messages = await client.inbox.getMessages();
|
|
194
|
+
const unreadCount = await client.inbox.getUnreadCount();
|
|
195
|
+
await client.inbox.markRead(messageId);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Wallet
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
const ideaBalance = await client.wallet.getBalance(agentId, "idea");
|
|
202
|
+
const strengthBalance = await client.wallet.getBalance(agentId, "strengths");
|
|
203
|
+
await client.wallet.addPoints(agentId, "idea", 100);
|
|
204
|
+
const trend = await client.wallet.getTrend(agentId, "idea", weekStartMs);
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Social
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
await client.social.likeResource(resourceId);
|
|
211
|
+
await client.social.followResource(resourceId);
|
|
212
|
+
const likes = await client.social.getLikes();
|
|
213
|
+
const isLiked = await client.social.isLiked(resourceId);
|
|
214
|
+
const followers = await client.social.getFollowers(resourceId);
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Tagging
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
const normalizedTags = client.tagging.normalizeUserTags(["3D Printing", "handmade"]);
|
|
221
|
+
// → ["tag-3d-printing", "tag-handmade"]
|
|
222
|
+
|
|
223
|
+
const userTags = client.tagging.extractUserTagValues(classifiedAs);
|
|
224
|
+
// → strips system prefixes, returns user-visible tags
|
|
225
|
+
|
|
226
|
+
const filterTags = client.tagging.derivedProductFilterTags({
|
|
227
|
+
categories: ["Electronics"],
|
|
228
|
+
powerRequirementW: 120,
|
|
229
|
+
recyclabilityPct: 75,
|
|
230
|
+
});
|
|
231
|
+
// → ["category-electronics", "powerreq-ge-100", "powerreq-le-150", "recyclability-ge-70", "recyclability-le-80"]
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Auto-Import
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
const ghData = await client.import.importFromGithub("https://github.com/owner/repo");
|
|
238
|
+
// → { main: { title, link, description, tags }, licenses: [...] }
|
|
239
|
+
|
|
240
|
+
const glData = await client.import.importFromGitlab("https://gitlab.com", "projectId");
|
|
241
|
+
const isOsh = await client.import.analyzeRepoForOsh("https://github.com/owner/repo");
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Installation
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
pnpm add @dyne/interfacer-client zenroom
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
`zenroom` is a peer dependency (WASM-based crypto VM). The SDK imports it dynamically at runtime.
|
|
251
|
+
|
|
252
|
+
## Development
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
pnpm install
|
|
256
|
+
pnpm build # Build ESM + CJS + DTS
|
|
257
|
+
pnpm typecheck # TypeScript strict check
|
|
258
|
+
pnpm lint # ESLint
|
|
259
|
+
pnpm test # Vitest (41 tests)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
AGPL-3.0-or-later — Dyne.org foundation
|