@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/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1092 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the InterfacerClient.
|
|
3
|
+
*
|
|
4
|
+
* All service URLs are explicit — no process.env dependency.
|
|
5
|
+
* Apps consuming the SDK provide URLs from their own environment.
|
|
6
|
+
*/
|
|
7
|
+
interface InterfacerConfig {
|
|
8
|
+
/** Base URL of the Zenflows GraphQL API (e.g. https://proxy.example.com/zenflows/api) */
|
|
9
|
+
zenflowsUrl: string;
|
|
10
|
+
/** Base URL of the Zenflows file storage endpoint */
|
|
11
|
+
zenflowsFileUrl?: string;
|
|
12
|
+
/** Base URL of the DPP service (e.g. https://proxy.example.com/interfacer-dpp) */
|
|
13
|
+
dppUrl?: string;
|
|
14
|
+
/** Inbox messaging endpoints */
|
|
15
|
+
inbox?: {
|
|
16
|
+
send: string;
|
|
17
|
+
read: string;
|
|
18
|
+
countUnread: string;
|
|
19
|
+
setRead: string;
|
|
20
|
+
};
|
|
21
|
+
/** Wallet token endpoint */
|
|
22
|
+
walletUrl?: string;
|
|
23
|
+
/** Social (ActivityPub) endpoints */
|
|
24
|
+
social?: {
|
|
25
|
+
personBase: string;
|
|
26
|
+
economicResourceBase: string;
|
|
27
|
+
};
|
|
28
|
+
/** Open Source Hardware analysis endpoint */
|
|
29
|
+
oshUrl?: string;
|
|
30
|
+
/** Location services */
|
|
31
|
+
location?: {
|
|
32
|
+
autocomplete: string;
|
|
33
|
+
lookup: string;
|
|
34
|
+
};
|
|
35
|
+
/** Manual ResourceSpecification IDs for instances that don't expose them via instanceVariables. */
|
|
36
|
+
specs?: {
|
|
37
|
+
/** DPP spec ID (for createDppResource) */
|
|
38
|
+
dpp?: string;
|
|
39
|
+
/** Machine spec ID (for createMachine) */
|
|
40
|
+
machine?: string;
|
|
41
|
+
/** Material spec ID (for material classification) */
|
|
42
|
+
material?: string;
|
|
43
|
+
};
|
|
44
|
+
/** Zenflows admin token (needed for sign-up mutations) */
|
|
45
|
+
zenflowsAdmin?: string;
|
|
46
|
+
/** Default "losh" (commons) agent ULID for transfer events */
|
|
47
|
+
loshId?: string;
|
|
48
|
+
/** Wallet cycle configuration */
|
|
49
|
+
walletCycle?: {
|
|
50
|
+
startDate: string;
|
|
51
|
+
cycleLength: number;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a config object with defaults.
|
|
56
|
+
* All URLs are required; there are no defaults.
|
|
57
|
+
*/
|
|
58
|
+
declare function createConfig(config: InterfacerConfig): InterfacerConfig;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Key storage abstraction.
|
|
62
|
+
*
|
|
63
|
+
* The SDK needs to persist cryptographic keys (EdDSA private key, public key,
|
|
64
|
+
* seed, etc.) between sessions. By default it uses localStorage in browsers,
|
|
65
|
+
* but apps can inject any storage (secure enclave, file, memory).
|
|
66
|
+
*/
|
|
67
|
+
interface KeyStorage {
|
|
68
|
+
getItem(key: string): string | null | undefined;
|
|
69
|
+
setItem(key: string, value: string): void;
|
|
70
|
+
removeItem(key: string): void;
|
|
71
|
+
clear(): void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* In-memory adapter (for testing or non-browser environments).
|
|
75
|
+
*/
|
|
76
|
+
declare function createMemoryStorage(): KeyStorage;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Fetch-based GraphQL client with automatic EdDSA request signing.
|
|
80
|
+
*
|
|
81
|
+
* Replaces Apollo Client used in interfacer-gui.
|
|
82
|
+
* Supports queries and mutations over POST with optional signing.
|
|
83
|
+
*/
|
|
84
|
+
declare class GraphQLClient {
|
|
85
|
+
private config;
|
|
86
|
+
private store;
|
|
87
|
+
private signingEnabled;
|
|
88
|
+
constructor(config: InterfacerConfig, store: KeyStorage, signingEnabled?: boolean);
|
|
89
|
+
/** Enable or disable request signing (use after authentication). */
|
|
90
|
+
setSigningEnabled(enabled: boolean): void;
|
|
91
|
+
/** Execute a GraphQL query or mutation. */
|
|
92
|
+
request<TData = unknown, TVariables = Record<string, unknown>>(operation: string, variables?: TVariables, extraHeaders?: Record<string, string>): Promise<{
|
|
93
|
+
data?: TData;
|
|
94
|
+
errors?: Array<{
|
|
95
|
+
message: string;
|
|
96
|
+
}>;
|
|
97
|
+
}>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Domain entity types for the Interfacer client SDK.
|
|
102
|
+
*
|
|
103
|
+
* These are the "clean" types that consumers work with.
|
|
104
|
+
* They are derived from Zenflows ValueFlows vocabulary but
|
|
105
|
+
* hide the complexity of EconomicResources, EconomicEvents, etc.
|
|
106
|
+
*/
|
|
107
|
+
declare enum ProjectType {
|
|
108
|
+
DESIGN = "DESIGN",
|
|
109
|
+
PRODUCT = "PRODUCT",
|
|
110
|
+
SERVICE = "SERVICE",
|
|
111
|
+
MACHINE = "MACHINE",
|
|
112
|
+
DPP = "DPP"
|
|
113
|
+
}
|
|
114
|
+
declare enum ProposalStatus {
|
|
115
|
+
PENDING = "PENDING",
|
|
116
|
+
ACCEPTED = "ACCEPTED",
|
|
117
|
+
REFUSED = "REFUSED"
|
|
118
|
+
}
|
|
119
|
+
declare enum DppStatus$1 {
|
|
120
|
+
ACTIVE = "active",
|
|
121
|
+
DRAFT = "draft",
|
|
122
|
+
ARCHIVED = "archived"
|
|
123
|
+
}
|
|
124
|
+
interface Location {
|
|
125
|
+
id?: string;
|
|
126
|
+
name: string;
|
|
127
|
+
address?: string;
|
|
128
|
+
lat?: number;
|
|
129
|
+
lng?: number;
|
|
130
|
+
}
|
|
131
|
+
interface ImageRef {
|
|
132
|
+
hash: string;
|
|
133
|
+
name: string;
|
|
134
|
+
mimeType: string;
|
|
135
|
+
/** Base64-encoded binary data (if fetched inline) */
|
|
136
|
+
bin?: string;
|
|
137
|
+
}
|
|
138
|
+
interface ModelFile {
|
|
139
|
+
id?: string;
|
|
140
|
+
fileName: string;
|
|
141
|
+
contentType: string;
|
|
142
|
+
url: string;
|
|
143
|
+
size: number;
|
|
144
|
+
extension: string;
|
|
145
|
+
checksum?: string;
|
|
146
|
+
uploadedAt?: string;
|
|
147
|
+
storage: "dpp";
|
|
148
|
+
}
|
|
149
|
+
interface License {
|
|
150
|
+
scope: string;
|
|
151
|
+
licenseId: string;
|
|
152
|
+
}
|
|
153
|
+
interface Contributor {
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
image?: string;
|
|
157
|
+
}
|
|
158
|
+
interface Declaration {
|
|
159
|
+
ce?: boolean;
|
|
160
|
+
rohs?: boolean;
|
|
161
|
+
[key: string]: boolean | undefined;
|
|
162
|
+
}
|
|
163
|
+
interface ProductFilters {
|
|
164
|
+
categories: string[];
|
|
165
|
+
powerCompatibility: string[];
|
|
166
|
+
replicability: string;
|
|
167
|
+
recyclabilityPct?: number;
|
|
168
|
+
repairability: boolean;
|
|
169
|
+
powerRequirementW?: number;
|
|
170
|
+
energyKwh?: number;
|
|
171
|
+
co2Kg?: number;
|
|
172
|
+
}
|
|
173
|
+
interface ServiceFilters {
|
|
174
|
+
serviceType: string[];
|
|
175
|
+
availability: string[];
|
|
176
|
+
}
|
|
177
|
+
interface MachineRef {
|
|
178
|
+
id: string;
|
|
179
|
+
name: string;
|
|
180
|
+
}
|
|
181
|
+
interface MaterialRef {
|
|
182
|
+
id: string;
|
|
183
|
+
name: string;
|
|
184
|
+
}
|
|
185
|
+
interface Project {
|
|
186
|
+
/** ULID of the EconomicResource in Zenflows */
|
|
187
|
+
id: string;
|
|
188
|
+
name: string;
|
|
189
|
+
description: string;
|
|
190
|
+
type: ProjectType;
|
|
191
|
+
createdAt: string;
|
|
192
|
+
/** External repository URL (e.g. GitHub) */
|
|
193
|
+
repo?: string;
|
|
194
|
+
/** SPDX license ID of the primary license */
|
|
195
|
+
primaryLicense?: string;
|
|
196
|
+
/** The user who created/owns the resource */
|
|
197
|
+
owner: {
|
|
198
|
+
id: string;
|
|
199
|
+
name: string;
|
|
200
|
+
image?: string;
|
|
201
|
+
};
|
|
202
|
+
/** Physical or remote location */
|
|
203
|
+
location?: Location;
|
|
204
|
+
isRemote: boolean;
|
|
205
|
+
/** User-visible tags (stripped of system prefixes) */
|
|
206
|
+
tags: string[];
|
|
207
|
+
/** All licenses applied to the project */
|
|
208
|
+
licenses: License[];
|
|
209
|
+
/** Contributors to the project */
|
|
210
|
+
contributors: Contributor[];
|
|
211
|
+
/** Related projects (cited resources) */
|
|
212
|
+
relations: Array<{
|
|
213
|
+
id: string;
|
|
214
|
+
name: string;
|
|
215
|
+
}>;
|
|
216
|
+
/** Compliance declarations */
|
|
217
|
+
declarations: Declaration;
|
|
218
|
+
/** For PRODUCT type: product filter metadata */
|
|
219
|
+
productFilters?: ProductFilters;
|
|
220
|
+
/** For SERVICE type: service filter metadata */
|
|
221
|
+
serviceFilters?: ServiceFilters;
|
|
222
|
+
/** For PRODUCT type: linked design resource */
|
|
223
|
+
linkedDesign?: {
|
|
224
|
+
id: string;
|
|
225
|
+
name: string;
|
|
226
|
+
};
|
|
227
|
+
/** For DESIGN type: products derived from this design */
|
|
228
|
+
derivedProducts?: Array<{
|
|
229
|
+
id: string;
|
|
230
|
+
name: string;
|
|
231
|
+
}>;
|
|
232
|
+
/** Linked DPP (Digital Product Passport) resource */
|
|
233
|
+
dpp?: {
|
|
234
|
+
id: string;
|
|
235
|
+
status: DppStatus$1;
|
|
236
|
+
};
|
|
237
|
+
/** Images associated with the project */
|
|
238
|
+
images: ImageRef[];
|
|
239
|
+
/** 3D model files (DPP-uploaded) */
|
|
240
|
+
models: ModelFile[];
|
|
241
|
+
/** For PRODUCT type: machines used */
|
|
242
|
+
machines: MachineRef[];
|
|
243
|
+
/** For PRODUCT type: materials consumed */
|
|
244
|
+
materials: MaterialRef[];
|
|
245
|
+
/** Social counts (if fetched) */
|
|
246
|
+
likes?: number;
|
|
247
|
+
followers?: number;
|
|
248
|
+
isLiked?: boolean;
|
|
249
|
+
isFollowed?: boolean;
|
|
250
|
+
}
|
|
251
|
+
interface Proposal {
|
|
252
|
+
id: string;
|
|
253
|
+
name: string;
|
|
254
|
+
note: string;
|
|
255
|
+
status: ProposalStatus;
|
|
256
|
+
created: string;
|
|
257
|
+
/** The proposed (forked) resource */
|
|
258
|
+
proposedResource: {
|
|
259
|
+
id: string;
|
|
260
|
+
name: string;
|
|
261
|
+
};
|
|
262
|
+
/** The original resource being contributed to */
|
|
263
|
+
originalResource: {
|
|
264
|
+
id: string;
|
|
265
|
+
name: string;
|
|
266
|
+
primaryAccountable: {
|
|
267
|
+
id: string;
|
|
268
|
+
name: string;
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
proposer: {
|
|
272
|
+
id: string;
|
|
273
|
+
name: string;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/** User challenge questions for key derivation. */
|
|
277
|
+
interface UserChallenges {
|
|
278
|
+
whereParentsMet: string;
|
|
279
|
+
nameFirstPet: string;
|
|
280
|
+
nameFirstTeacher: string;
|
|
281
|
+
whereHomeTown: string;
|
|
282
|
+
nameMotherMaid: string;
|
|
283
|
+
}
|
|
284
|
+
interface UserProfile {
|
|
285
|
+
id: string;
|
|
286
|
+
name: string;
|
|
287
|
+
username: string;
|
|
288
|
+
email: string;
|
|
289
|
+
isVerified: boolean;
|
|
290
|
+
note?: string;
|
|
291
|
+
image?: string;
|
|
292
|
+
location?: Location;
|
|
293
|
+
didId?: string;
|
|
294
|
+
}
|
|
295
|
+
interface Keyring {
|
|
296
|
+
eddsa: string;
|
|
297
|
+
ethereum: string;
|
|
298
|
+
reflow: string;
|
|
299
|
+
bitcoin: string;
|
|
300
|
+
ecdh: string;
|
|
301
|
+
seed: string;
|
|
302
|
+
eddsa_public_key: string;
|
|
303
|
+
ethereum_address: string;
|
|
304
|
+
reflow_public_key: string;
|
|
305
|
+
bitcoin_public_key: string;
|
|
306
|
+
ecdh_public_key: string;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Authentication client for the Interfacer ecosystem.
|
|
311
|
+
*
|
|
312
|
+
* Handles the full auth lifecycle:
|
|
313
|
+
* 1. requestHmac — get server-side shard from Zenflows keypairoomServer
|
|
314
|
+
* 2. deriveKeys / recreateKeys — client-side key derivation via Zenroom
|
|
315
|
+
* 3. registerUser — create a Person on Zenflows
|
|
316
|
+
* 4. verifyUser / login — check credentials, fetch profile
|
|
317
|
+
* 5. sendEmailVerification, claimDid — post-registration tasks
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
declare class AuthClient {
|
|
321
|
+
private config;
|
|
322
|
+
private store;
|
|
323
|
+
private graphql;
|
|
324
|
+
constructor(config: InterfacerConfig, store: KeyStorage, graphql: GraphQLClient);
|
|
325
|
+
/**
|
|
326
|
+
* Request the server-side HMAC shard from Zenflows keypairoomServer.
|
|
327
|
+
*
|
|
328
|
+
* @param email - User's email
|
|
329
|
+
* @param firstRegistration - true for sign-up, false for sign-in
|
|
330
|
+
* @returns The HMAC string (base64)
|
|
331
|
+
*/
|
|
332
|
+
requestHmac(email: string, firstRegistration: boolean): Promise<string>;
|
|
333
|
+
/**
|
|
334
|
+
* Derive all keypairs from user challenges + server HMAC (registration).
|
|
335
|
+
* Keys are persisted to the store automatically.
|
|
336
|
+
*/
|
|
337
|
+
deriveKeys(challenges: UserChallenges, email: string, hmac: string): Promise<Keyring>;
|
|
338
|
+
/**
|
|
339
|
+
* Recreate all keypairs from seed mnemonic + server HMAC (login).
|
|
340
|
+
* Keys are persisted to the store automatically.
|
|
341
|
+
*/
|
|
342
|
+
recreateKeys(seed: string, hmac: string): Promise<Keyring>;
|
|
343
|
+
/**
|
|
344
|
+
* Register a new person on Zenflows.
|
|
345
|
+
* Requires keys to already be derived (via deriveKeys).
|
|
346
|
+
*/
|
|
347
|
+
registerUser(params: {
|
|
348
|
+
name: string;
|
|
349
|
+
user: string;
|
|
350
|
+
email: string;
|
|
351
|
+
}): Promise<string>;
|
|
352
|
+
/**
|
|
353
|
+
* Verify a user exists on Zenflows by email + EdDSA public key.
|
|
354
|
+
*/
|
|
355
|
+
verifyUser(email: string, eddsaPublicKey: string): Promise<UserProfile | null>;
|
|
356
|
+
/**
|
|
357
|
+
* Full login flow:
|
|
358
|
+
* 1. Verify user on Zenflows
|
|
359
|
+
* 2. Persist auth info to storage
|
|
360
|
+
* 3. Enable GraphQL request signing
|
|
361
|
+
*/
|
|
362
|
+
login(params: {
|
|
363
|
+
email: string;
|
|
364
|
+
}): Promise<UserProfile>;
|
|
365
|
+
/**
|
|
366
|
+
* Send email verification.
|
|
367
|
+
* The template is auto-detected from the Zenflows URL origin.
|
|
368
|
+
*/
|
|
369
|
+
sendEmailVerification(): Promise<void>;
|
|
370
|
+
/**
|
|
371
|
+
* Claim a DID for the current user.
|
|
372
|
+
*/
|
|
373
|
+
claimDid(personId: string): Promise<string>;
|
|
374
|
+
/** Clear all auth state from storage. */
|
|
375
|
+
logout(): void;
|
|
376
|
+
private detectTemplate;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** DPP document types — matching the interfacer-dpp Go backend model. */
|
|
380
|
+
type DppStatus = "active" | "draft" | "archived";
|
|
381
|
+
interface TransformedValue<T = unknown> {
|
|
382
|
+
type: string;
|
|
383
|
+
value: T;
|
|
384
|
+
units?: string;
|
|
385
|
+
}
|
|
386
|
+
interface Attachment {
|
|
387
|
+
id: string;
|
|
388
|
+
fileName: string;
|
|
389
|
+
contentType: string;
|
|
390
|
+
url: string;
|
|
391
|
+
size: number;
|
|
392
|
+
checksum: string;
|
|
393
|
+
uploadedAt: string;
|
|
394
|
+
}
|
|
395
|
+
interface DppDocument {
|
|
396
|
+
id: string;
|
|
397
|
+
productId?: string;
|
|
398
|
+
batchType?: "batch" | "unit";
|
|
399
|
+
batchId?: string;
|
|
400
|
+
createdBy?: string;
|
|
401
|
+
status?: DppStatus;
|
|
402
|
+
createdAt?: string;
|
|
403
|
+
updatedAt?: string;
|
|
404
|
+
productOverview?: Record<string, TransformedValue>;
|
|
405
|
+
reparability?: Record<string, TransformedValue>;
|
|
406
|
+
environmentalImpact?: Record<string, TransformedValue>;
|
|
407
|
+
complianceAndStandards?: Record<string, TransformedValue>;
|
|
408
|
+
certificates?: Record<string, TransformedValue>;
|
|
409
|
+
recyclability?: Record<string, TransformedValue>;
|
|
410
|
+
energyUseAndEfficiency?: Record<string, TransformedValue>;
|
|
411
|
+
components?: Array<Record<string, TransformedValue>>;
|
|
412
|
+
economicOperator?: Record<string, TransformedValue>;
|
|
413
|
+
repairInformation?: Record<string, TransformedValue>;
|
|
414
|
+
refurbishmentInformation?: Record<string, TransformedValue>;
|
|
415
|
+
recyclingInformation?: Record<string, TransformedValue>;
|
|
416
|
+
}
|
|
417
|
+
interface CreateDppResponse {
|
|
418
|
+
insertedID: string;
|
|
419
|
+
}
|
|
420
|
+
interface UpdateDppResponse {
|
|
421
|
+
matchedCount: number;
|
|
422
|
+
modifiedCount: number;
|
|
423
|
+
}
|
|
424
|
+
interface ListDppsFilters {
|
|
425
|
+
productId?: string;
|
|
426
|
+
createdBy?: string;
|
|
427
|
+
status?: DppStatus;
|
|
428
|
+
q?: string;
|
|
429
|
+
sortBy?: "createdAt" | "name";
|
|
430
|
+
sortOrder?: "asc" | "desc";
|
|
431
|
+
limit?: number;
|
|
432
|
+
offset?: number;
|
|
433
|
+
}
|
|
434
|
+
interface ListDppsResponse {
|
|
435
|
+
dpps: DppDocument[];
|
|
436
|
+
total: number;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* DPP client — Digital Product Passport REST API operations.
|
|
441
|
+
*
|
|
442
|
+
* All DPP endpoints are authenticated with did-sign + did-pk headers.
|
|
443
|
+
* Ported from interfacer-gui lib/dpp.ts
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
declare class DppClient {
|
|
447
|
+
private config;
|
|
448
|
+
private store;
|
|
449
|
+
private baseUrl;
|
|
450
|
+
constructor(config: InterfacerConfig, store: KeyStorage);
|
|
451
|
+
private get dppUrl();
|
|
452
|
+
/** Sign a request body and return DID headers + x-user-id. */
|
|
453
|
+
private signedRequest;
|
|
454
|
+
/** Generic request helper. */
|
|
455
|
+
private request;
|
|
456
|
+
createDpp(data: Omit<DppDocument, "id">): Promise<CreateDppResponse>;
|
|
457
|
+
getDpp(id: string): Promise<DppDocument>;
|
|
458
|
+
updateDpp(id: string, data: Partial<DppDocument>): Promise<UpdateDppResponse>;
|
|
459
|
+
deleteDpp(id: string): Promise<void>;
|
|
460
|
+
listDpps(filters?: ListDppsFilters): Promise<ListDppsResponse>;
|
|
461
|
+
updateDppStatus(id: string, status: DppStatus): Promise<UpdateDppResponse>;
|
|
462
|
+
getQrCodeUrl(dppId: string, size?: number): string;
|
|
463
|
+
addAttachment(dppId: string, section: string, file: File): Promise<Attachment>;
|
|
464
|
+
deleteAttachment(dppId: string, attachmentId: string): Promise<void>;
|
|
465
|
+
/** Get the file download URL for an attachment. */
|
|
466
|
+
getFileUrl(fileId: string): string;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* File hashing and preparation for Zenflows and DPP uploads.
|
|
471
|
+
*
|
|
472
|
+
* Two hashing strategies:
|
|
473
|
+
* Zenflows: SHA-512 via Zenroom, base64url-encoded result (64KB chunks)
|
|
474
|
+
* DPP: SHA-256 via Web Crypto API, hex-encoded result
|
|
475
|
+
*
|
|
476
|
+
* Ported from interfacer-gui lib/fileUpload.ts
|
|
477
|
+
*/
|
|
478
|
+
|
|
479
|
+
/** File descriptor for Zenflows uploads (post-hashing). */
|
|
480
|
+
interface ZenflowsFile {
|
|
481
|
+
name: string;
|
|
482
|
+
description: string;
|
|
483
|
+
extension: string;
|
|
484
|
+
hash: string;
|
|
485
|
+
mimeType: string;
|
|
486
|
+
size: number;
|
|
487
|
+
}
|
|
488
|
+
/** File object from GraphQL responses. */
|
|
489
|
+
interface GqlFile {
|
|
490
|
+
name: string;
|
|
491
|
+
hash: string;
|
|
492
|
+
mimeType: string;
|
|
493
|
+
bin?: string;
|
|
494
|
+
}
|
|
495
|
+
/** Attachment returned by the DPP upload endpoint. */
|
|
496
|
+
interface DppAttachment {
|
|
497
|
+
id: string;
|
|
498
|
+
fileName: string;
|
|
499
|
+
contentType: string;
|
|
500
|
+
url: string;
|
|
501
|
+
size: number;
|
|
502
|
+
checksum: string;
|
|
503
|
+
uploadedAt: string;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Prepare a single file for Zenflows upload.
|
|
507
|
+
* Hashes the file and returns a ZenflowsFile descriptor.
|
|
508
|
+
*/
|
|
509
|
+
declare function prepFileForZenflows(file: File): Promise<ZenflowsFile>;
|
|
510
|
+
/**
|
|
511
|
+
* Prepare multiple files for Zenflows upload.
|
|
512
|
+
*/
|
|
513
|
+
declare function prepFilesForZenflows(files: File[]): Promise<ZenflowsFile[]>;
|
|
514
|
+
declare function formatImageSrc(mimeType: string, bin: string): string;
|
|
515
|
+
declare function getResourceImage(images: GqlFile[] | null | undefined): string;
|
|
516
|
+
interface ProjectModelMetadata {
|
|
517
|
+
contentType?: string;
|
|
518
|
+
downloadUrl: string;
|
|
519
|
+
extension: string;
|
|
520
|
+
fileName?: string;
|
|
521
|
+
id?: string;
|
|
522
|
+
mimeType?: string;
|
|
523
|
+
name: string;
|
|
524
|
+
size?: number;
|
|
525
|
+
storage: "dpp";
|
|
526
|
+
uploadedAt?: string;
|
|
527
|
+
url: string;
|
|
528
|
+
checksum?: string;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* File client — upload, prepare, and proxy files for Zenflows and DPP.
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
declare class FileClient {
|
|
536
|
+
private config;
|
|
537
|
+
private store;
|
|
538
|
+
constructor(config: InterfacerConfig, store: KeyStorage);
|
|
539
|
+
hashFileForZenflows: (file: File) => Promise<string>;
|
|
540
|
+
hashFileSHA256: (file: File) => Promise<string>;
|
|
541
|
+
/** Prepare files for Zenflows (hash + descriptor). */
|
|
542
|
+
prepFilesForZenflows(files: File[]): Promise<ZenflowsFile[]>;
|
|
543
|
+
/** Upload a file to the Zenflows file storage endpoint. */
|
|
544
|
+
uploadToZenflows(file: File): Promise<void>;
|
|
545
|
+
/** Upload multiple files to Zenflows. */
|
|
546
|
+
uploadToZenflowsBatch(files: File[]): Promise<void>;
|
|
547
|
+
/** Get the proxy URL for a file by its hash. */
|
|
548
|
+
getFileUrl(hash: string): string;
|
|
549
|
+
/** Get a data URL for a file from its GraphQL response. */
|
|
550
|
+
getImageSrc(image: GqlFile): string;
|
|
551
|
+
/** Upload a file to the DPP service. */
|
|
552
|
+
uploadToDpp(file: File): Promise<DppAttachment>;
|
|
553
|
+
/** Upload multiple model files to DPP and convert to project model metadata. */
|
|
554
|
+
uploadModelsToDpp(files: File[]): Promise<ProjectModelMetadata[]>;
|
|
555
|
+
/** Convert a DPP attachment to project model metadata. */
|
|
556
|
+
dppAttachmentToProjectModel(attachment: DppAttachment): ProjectModelMetadata;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Import client — GitHub, GitLab, and OSH auto-import.
|
|
561
|
+
*
|
|
562
|
+
* Ported from interfacer-gui hooks/useAutoimport.ts
|
|
563
|
+
*/
|
|
564
|
+
|
|
565
|
+
interface ImportedProjectData {
|
|
566
|
+
main?: {
|
|
567
|
+
title: string;
|
|
568
|
+
link: string;
|
|
569
|
+
description: string;
|
|
570
|
+
tags: string[];
|
|
571
|
+
};
|
|
572
|
+
licenses?: Array<{
|
|
573
|
+
scope: string;
|
|
574
|
+
licenseId: string;
|
|
575
|
+
}>;
|
|
576
|
+
}
|
|
577
|
+
declare class ImportClient {
|
|
578
|
+
private config;
|
|
579
|
+
constructor(config: InterfacerConfig);
|
|
580
|
+
/** Analyze a repository for Open Source Hardware compliance. */
|
|
581
|
+
analyzeRepoForOsh(repoUrl: string): Promise<boolean>;
|
|
582
|
+
/** Import project metadata from a GitHub URL. */
|
|
583
|
+
importFromGithub(url: string): Promise<ImportedProjectData>;
|
|
584
|
+
/** Import project metadata from a GitLab project. */
|
|
585
|
+
importFromGitlab(host: string, projectId: string): Promise<ImportedProjectData>;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Inbox client — messaging and notifications via signed REST API.
|
|
590
|
+
*
|
|
591
|
+
* Ported from interfacer-gui hooks/useInBox.ts
|
|
592
|
+
*/
|
|
593
|
+
|
|
594
|
+
interface InboxMessage {
|
|
595
|
+
id: number;
|
|
596
|
+
sender: string;
|
|
597
|
+
content: {
|
|
598
|
+
data: string;
|
|
599
|
+
message: unknown;
|
|
600
|
+
subject: string;
|
|
601
|
+
};
|
|
602
|
+
read: boolean;
|
|
603
|
+
}
|
|
604
|
+
declare class InboxClient {
|
|
605
|
+
private config;
|
|
606
|
+
private store;
|
|
607
|
+
constructor(config: InterfacerConfig, store: KeyStorage);
|
|
608
|
+
/** Sign a request body and return headers + body for POST. */
|
|
609
|
+
private signedPost;
|
|
610
|
+
/** Send a message to one or more receivers. */
|
|
611
|
+
sendMessage(message: unknown, receivers: string[], subject?: string): Promise<void>;
|
|
612
|
+
/** Read messages for the current user. */
|
|
613
|
+
getMessages(onlyUnread?: boolean): Promise<InboxMessage[]>;
|
|
614
|
+
/** Get the count of unread messages. */
|
|
615
|
+
getUnreadCount(): Promise<number>;
|
|
616
|
+
/** Mark a message as read. */
|
|
617
|
+
markRead(messageId: number): Promise<void>;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Resource client — Project/Resource CRUD operations.
|
|
622
|
+
*
|
|
623
|
+
* Wraps the GraphQL operations into clean method calls.
|
|
624
|
+
* Manages Process creation, location, resource creation, relations, and metadata.
|
|
625
|
+
*/
|
|
626
|
+
|
|
627
|
+
interface CreateProjectParams$1 {
|
|
628
|
+
name: string;
|
|
629
|
+
note?: string;
|
|
630
|
+
tags?: string[];
|
|
631
|
+
repo?: string;
|
|
632
|
+
license?: string;
|
|
633
|
+
images?: Array<{
|
|
634
|
+
name: string;
|
|
635
|
+
hash: string;
|
|
636
|
+
mimeType: string;
|
|
637
|
+
extension: string;
|
|
638
|
+
size: number;
|
|
639
|
+
}>;
|
|
640
|
+
location?: {
|
|
641
|
+
name: string;
|
|
642
|
+
address?: string;
|
|
643
|
+
lat?: number;
|
|
644
|
+
lng?: number;
|
|
645
|
+
};
|
|
646
|
+
metadata?: Record<string, unknown>;
|
|
647
|
+
}
|
|
648
|
+
interface CreateMachineParams {
|
|
649
|
+
name: string;
|
|
650
|
+
note?: string;
|
|
651
|
+
metadata?: Record<string, unknown>;
|
|
652
|
+
}
|
|
653
|
+
interface CreateDppParams {
|
|
654
|
+
name: string;
|
|
655
|
+
note?: string;
|
|
656
|
+
dppUlid: string;
|
|
657
|
+
}
|
|
658
|
+
interface PaginationParams {
|
|
659
|
+
first?: number;
|
|
660
|
+
after?: string;
|
|
661
|
+
last?: number;
|
|
662
|
+
before?: string;
|
|
663
|
+
}
|
|
664
|
+
type ResourceFilter = Record<string, unknown>;
|
|
665
|
+
type ProposalFilter = Record<string, unknown>;
|
|
666
|
+
declare class ResourceClient {
|
|
667
|
+
private config;
|
|
668
|
+
private store;
|
|
669
|
+
private graphql;
|
|
670
|
+
constructor(config: InterfacerConfig, store: KeyStorage, graphql: GraphQLClient);
|
|
671
|
+
private get userId();
|
|
672
|
+
private getInstanceVars;
|
|
673
|
+
private specIdForType;
|
|
674
|
+
createProcess(name: string): Promise<string>;
|
|
675
|
+
createLocation(params: {
|
|
676
|
+
name: string;
|
|
677
|
+
address?: string;
|
|
678
|
+
lat?: number;
|
|
679
|
+
lng?: number;
|
|
680
|
+
}): Promise<{
|
|
681
|
+
id: string;
|
|
682
|
+
lat: number;
|
|
683
|
+
long: number;
|
|
684
|
+
}>;
|
|
685
|
+
createProject(params: CreateProjectParams$1 & {
|
|
686
|
+
projectType: ProjectType;
|
|
687
|
+
}): Promise<{
|
|
688
|
+
id: string;
|
|
689
|
+
name: string;
|
|
690
|
+
}>;
|
|
691
|
+
createMachine(params: CreateMachineParams): Promise<{
|
|
692
|
+
id: string;
|
|
693
|
+
name: string;
|
|
694
|
+
}>;
|
|
695
|
+
createDppResource(params: CreateDppParams): Promise<{
|
|
696
|
+
id: string;
|
|
697
|
+
name: string;
|
|
698
|
+
}>;
|
|
699
|
+
getResource(id: string): Promise<unknown>;
|
|
700
|
+
listResources(filter?: ResourceFilter, pagination?: PaginationParams): Promise<unknown>;
|
|
701
|
+
getProjects(filter?: ProposalFilter, pagination?: PaginationParams): Promise<unknown>;
|
|
702
|
+
getMachines(): Promise<unknown>;
|
|
703
|
+
citeResource(resourceId: string, processId: string): Promise<void>;
|
|
704
|
+
consumeResource(resourceId: string, processId: string): Promise<void>;
|
|
705
|
+
contributeToResource(processId: string, contributionTypeSpecId: string): Promise<void>;
|
|
706
|
+
updateMetadata(resourceId: string, metadata: Record<string, unknown>, quantity?: {
|
|
707
|
+
hasNumericalValue: number;
|
|
708
|
+
hasUnit: string;
|
|
709
|
+
}): Promise<void>;
|
|
710
|
+
updateClassifiedAs(resourceId: string, tags: string[]): Promise<void>;
|
|
711
|
+
relocateResource(resourceId: string, locationId: string): Promise<void>;
|
|
712
|
+
proposeContribution(params: {
|
|
713
|
+
resourceForkedId: string;
|
|
714
|
+
resourceOriginId: string;
|
|
715
|
+
ownerId: string;
|
|
716
|
+
note: string;
|
|
717
|
+
}): Promise<{
|
|
718
|
+
proposalId: string;
|
|
719
|
+
citeIntentId: string;
|
|
720
|
+
acceptIntentId: string;
|
|
721
|
+
modifyIntentId: string;
|
|
722
|
+
}>;
|
|
723
|
+
acceptProposal(params: {
|
|
724
|
+
proposalId: string;
|
|
725
|
+
citeIntentId: string;
|
|
726
|
+
acceptIntentId: string;
|
|
727
|
+
modifyIntentId: string;
|
|
728
|
+
resourceForkedId: string;
|
|
729
|
+
resourceOriginId: string;
|
|
730
|
+
ownerId: string;
|
|
731
|
+
proposerId: string;
|
|
732
|
+
newMetadata: Record<string, unknown>;
|
|
733
|
+
}): Promise<void>;
|
|
734
|
+
rejectProposal(intentCite: string, intentAccept: string, intentModify: string): Promise<void>;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Social client — ActivityPub-based likes and follows via signed REST API.
|
|
739
|
+
*
|
|
740
|
+
* Ported from interfacer-gui hooks/useSocial.ts
|
|
741
|
+
*/
|
|
742
|
+
|
|
743
|
+
declare class SocialClient {
|
|
744
|
+
private config;
|
|
745
|
+
private store;
|
|
746
|
+
constructor(config: InterfacerConfig, store: KeyStorage);
|
|
747
|
+
private get personBase();
|
|
748
|
+
private get erBase();
|
|
749
|
+
private get userId();
|
|
750
|
+
/** Post an ActivityStreams activity to the user's outbox. */
|
|
751
|
+
private postActivity;
|
|
752
|
+
/** Like a resource. */
|
|
753
|
+
likeResource(resourceId: string): Promise<void>;
|
|
754
|
+
/** Follow (watch) a resource. */
|
|
755
|
+
followResource(resourceId: string): Promise<void>;
|
|
756
|
+
/** Get the list of resource IDs the current user has liked. */
|
|
757
|
+
getLikes(): Promise<string[]>;
|
|
758
|
+
/** Check if the current user liked a resource. */
|
|
759
|
+
isLiked(resourceId: string): Promise<boolean>;
|
|
760
|
+
/** Get the list of follower IDs for a resource. */
|
|
761
|
+
getFollowers(resourceId: string): Promise<string[]>;
|
|
762
|
+
/** Get the list of resources the current user is following. */
|
|
763
|
+
getFollowing(): Promise<string[]>;
|
|
764
|
+
/** Check if the current user is following a resource. */
|
|
765
|
+
isFollowing(resourceId: string): Promise<boolean>;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Tagging client — classification, normalization, and filter derivation.
|
|
770
|
+
*
|
|
771
|
+
* All tag operations work on the `classifiedAs` array of EconomicResources.
|
|
772
|
+
* The system uses prefixed tags to distinguish user-entered tags from
|
|
773
|
+
* system-derived metadata tags (categories, numeric ranges, etc.).
|
|
774
|
+
*
|
|
775
|
+
* Ported from interfacer-gui lib/tagging.ts
|
|
776
|
+
*/
|
|
777
|
+
interface ProductFilterMetadata {
|
|
778
|
+
categories?: string[];
|
|
779
|
+
powerCompatibility?: string[];
|
|
780
|
+
replicability?: string[];
|
|
781
|
+
recyclabilityPct?: number;
|
|
782
|
+
repairability?: boolean;
|
|
783
|
+
powerRequirementW?: number;
|
|
784
|
+
energyKwh?: number;
|
|
785
|
+
co2Kg?: number;
|
|
786
|
+
}
|
|
787
|
+
interface ServiceFilterMetadata {
|
|
788
|
+
serviceType?: string[];
|
|
789
|
+
availability?: string[];
|
|
790
|
+
}
|
|
791
|
+
declare function slugifyTagValue(value: string): string;
|
|
792
|
+
declare function prefixedTag(prefix: string, value: string): string | undefined;
|
|
793
|
+
declare function userTag(raw: string): string | undefined;
|
|
794
|
+
declare function isUserTag(tag: string): boolean;
|
|
795
|
+
declare function stripUserTagPrefix(tag: string): string;
|
|
796
|
+
/**
|
|
797
|
+
* Check if a tag is a system tag (has a known system prefix, current or legacy).
|
|
798
|
+
*/
|
|
799
|
+
declare function isSystemTag(tag: string): boolean;
|
|
800
|
+
/**
|
|
801
|
+
* Extract user-visible tag values from a classifiedAs array.
|
|
802
|
+
* System-prefixed tags are filtered out. User tags are stripped of their prefix.
|
|
803
|
+
* Legacy un-prefixed tags are preserved for backwards compatibility.
|
|
804
|
+
*/
|
|
805
|
+
declare function extractUserTagValues(tags: ReadonlyArray<string> | null | undefined): string[];
|
|
806
|
+
/**
|
|
807
|
+
* Normalize raw user tag inputs into canonical `tag-<slug>` form.
|
|
808
|
+
* System-prefixed entries are dropped.
|
|
809
|
+
*/
|
|
810
|
+
declare function normalizeUserTagsForSave(tags: ReadonlyArray<string>): string[];
|
|
811
|
+
/**
|
|
812
|
+
* Generate monotonic range tags for a numeric value.
|
|
813
|
+
* Produces both "greater-or-equal" (ge-) and "less-or-equal" (le-) tags
|
|
814
|
+
* for each threshold boundary.
|
|
815
|
+
*/
|
|
816
|
+
declare function monotonicRangeTags(prefix: string, value: number, thresholds: ReadonlyArray<number>): string[];
|
|
817
|
+
/**
|
|
818
|
+
* Generate range filter tags from min/max filter values.
|
|
819
|
+
*/
|
|
820
|
+
declare function rangeFilterTags(prefix: string, minValue: number | undefined, maxValue: number | undefined, thresholds: ReadonlyArray<number>): string[];
|
|
821
|
+
/**
|
|
822
|
+
* Derive all system tags from product filter metadata.
|
|
823
|
+
*/
|
|
824
|
+
declare function derivedProductFilterTags(filters: ProductFilterMetadata): string[];
|
|
825
|
+
/**
|
|
826
|
+
* Derive system tags from service filter metadata.
|
|
827
|
+
*/
|
|
828
|
+
declare function derivedServiceFilterTags(filters: ServiceFilterMetadata): string[];
|
|
829
|
+
declare function removeTagsWithPrefixes(tags: ReadonlyArray<string>, prefixes: ReadonlyArray<string>): string[];
|
|
830
|
+
declare function mergeTags(...tagLists: Array<ReadonlyArray<string> | undefined>): string[];
|
|
831
|
+
declare class TaggingClient {
|
|
832
|
+
normalizeUserTags: typeof normalizeUserTagsForSave;
|
|
833
|
+
extractUserTagValues: typeof extractUserTagValues;
|
|
834
|
+
isSystemTag: typeof isSystemTag;
|
|
835
|
+
isUserTag: typeof isUserTag;
|
|
836
|
+
userTag: typeof userTag;
|
|
837
|
+
derivedProductFilterTags: typeof derivedProductFilterTags;
|
|
838
|
+
derivedServiceFilterTags: typeof derivedServiceFilterTags;
|
|
839
|
+
monotonicRangeTags: typeof monotonicRangeTags;
|
|
840
|
+
rangeFilterTags: typeof rangeFilterTags;
|
|
841
|
+
slugifyTagValue: typeof slugifyTagValue;
|
|
842
|
+
prefixedTag: typeof prefixedTag;
|
|
843
|
+
mergeTags: typeof mergeTags;
|
|
844
|
+
removeTagsWithPrefixes: typeof removeTagsWithPrefixes;
|
|
845
|
+
readonly TAG_PREFIX: {
|
|
846
|
+
readonly USER: "tag";
|
|
847
|
+
readonly CATEGORY: "category";
|
|
848
|
+
readonly MACHINE: "machine";
|
|
849
|
+
readonly MATERIAL: "material";
|
|
850
|
+
readonly POWER_COMPAT: "powercompat";
|
|
851
|
+
readonly POWER_REQ: "powerreq";
|
|
852
|
+
readonly REPLICABILITY: "replicability";
|
|
853
|
+
readonly RECYCLABILITY: "recyclability";
|
|
854
|
+
readonly REPAIRABILITY: "repairability";
|
|
855
|
+
readonly ENV_ENERGY: "env-energy";
|
|
856
|
+
readonly ENV_CO2: "env-co2";
|
|
857
|
+
readonly SERVICE_TYPE: "servicetype";
|
|
858
|
+
readonly AVAILABILITY: "availability";
|
|
859
|
+
readonly LICENSE: "license";
|
|
860
|
+
readonly MANUFACTURABLE: "manufacturable";
|
|
861
|
+
};
|
|
862
|
+
readonly SYSTEM_TAG_PREFIXES: readonly string[];
|
|
863
|
+
readonly PRODUCT_CATEGORY_OPTIONS: readonly ["Electronics", "Tools", "Furniture", "Home renovation", "Energy", "Wearables", "Medical", "Sustainability", "Education"];
|
|
864
|
+
readonly POWER_COMPATIBILITY_OPTIONS: readonly ["120V AC", "220-240V AC", "12V DC", "24V DC", "Battery Powered", "USB-C"];
|
|
865
|
+
readonly REPLICABILITY_OPTIONS: readonly ["High", "Medium", "Low"];
|
|
866
|
+
readonly SERVICE_TYPE_OPTIONS: readonly ["Fabrication", "Learning & Education", "Space Access"];
|
|
867
|
+
readonly AVAILABILITY_OPTIONS: readonly ["Available Now", "Booking Required", "Weekdays Only", "Weekends Available"];
|
|
868
|
+
readonly RECYCLABILITY_THRESHOLDS_PCT: readonly [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
|
|
869
|
+
readonly POWER_REQUIREMENT_THRESHOLDS_W: readonly [0, 10, 25, 50, 75, 100, 150, 200, 250, 300, 500, 750, 1000, 1500, 2000];
|
|
870
|
+
readonly ENERGY_THRESHOLDS_KWH: readonly [0, 10, 20, 30, 50, 100, 200, 300, 500, 750, 1000, 1500, 2000];
|
|
871
|
+
readonly CO2_THRESHOLDS_KG: readonly [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 5, 7.5, 10, 15, 20];
|
|
872
|
+
readonly REPAIRABILITY_AVAILABLE_TAG = "repairability-available";
|
|
873
|
+
readonly MANUFACTURABLE_TRUE_TAG = "manufacturable-true";
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Wallet client — idea and strength points via signed REST API.
|
|
878
|
+
*
|
|
879
|
+
* Ported from interfacer-gui hooks/useWallet.ts
|
|
880
|
+
*/
|
|
881
|
+
|
|
882
|
+
declare enum Token {
|
|
883
|
+
Idea = "idea",
|
|
884
|
+
Strengths = "strengths"
|
|
885
|
+
}
|
|
886
|
+
declare class WalletClient {
|
|
887
|
+
private config;
|
|
888
|
+
private store;
|
|
889
|
+
constructor(config: InterfacerConfig, store: KeyStorage);
|
|
890
|
+
/** Get the current balance for a token type. */
|
|
891
|
+
getBalance(agentId: string, token: Token): Promise<number>;
|
|
892
|
+
/** Get the balance at a specific point in time. */
|
|
893
|
+
getBalanceAt(agentId: string, token: Token, timestamp: number): Promise<number>;
|
|
894
|
+
/** Add points to an agent. */
|
|
895
|
+
addPoints(agentId: string, token: Token, amount?: number): Promise<void>;
|
|
896
|
+
/** Get point trend over a period (change since period start). */
|
|
897
|
+
getTrend(agentId: string, token: Token, periodStartMs: number): Promise<number>;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Main entry point — InterfacerClient facade.
|
|
902
|
+
*
|
|
903
|
+
* Wires together all sub-clients with shared configuration and signing.
|
|
904
|
+
* This is the primary API surface most consumers will use.
|
|
905
|
+
*/
|
|
906
|
+
|
|
907
|
+
declare class InterfacerClient {
|
|
908
|
+
readonly config: InterfacerConfig;
|
|
909
|
+
readonly store: KeyStorage;
|
|
910
|
+
private _graphql?;
|
|
911
|
+
private _auth?;
|
|
912
|
+
private _resources?;
|
|
913
|
+
private _files?;
|
|
914
|
+
private _dpp?;
|
|
915
|
+
private _inbox?;
|
|
916
|
+
private _wallet?;
|
|
917
|
+
private _social?;
|
|
918
|
+
private _tagging?;
|
|
919
|
+
private _import?;
|
|
920
|
+
constructor(config: InterfacerConfig, store?: KeyStorage);
|
|
921
|
+
get graphql(): GraphQLClient;
|
|
922
|
+
get auth(): AuthClient;
|
|
923
|
+
get resources(): ResourceClient;
|
|
924
|
+
get files(): FileClient;
|
|
925
|
+
get dpp(): DppClient;
|
|
926
|
+
get inbox(): InboxClient;
|
|
927
|
+
get wallet(): WalletClient;
|
|
928
|
+
get social(): SocialClient;
|
|
929
|
+
get tagging(): TaggingClient;
|
|
930
|
+
get import(): ImportClient;
|
|
931
|
+
/**
|
|
932
|
+
* Full registration flow:
|
|
933
|
+
* 1. Request HMAC from server
|
|
934
|
+
* 2. Derive keys from challenges
|
|
935
|
+
* 3. Register user on Zenflows
|
|
936
|
+
* 4. Login (verify)
|
|
937
|
+
*/
|
|
938
|
+
register(params: {
|
|
939
|
+
name: string;
|
|
940
|
+
username: string;
|
|
941
|
+
email: string;
|
|
942
|
+
challenges: {
|
|
943
|
+
whereParentsMet: string;
|
|
944
|
+
nameFirstPet: string;
|
|
945
|
+
nameFirstTeacher: string;
|
|
946
|
+
whereHomeTown: string;
|
|
947
|
+
nameMotherMaid: string;
|
|
948
|
+
};
|
|
949
|
+
}): Promise<void>;
|
|
950
|
+
/**
|
|
951
|
+
* Check if a user is currently authenticated (has keys in storage).
|
|
952
|
+
*/
|
|
953
|
+
isAuthenticated(): boolean;
|
|
954
|
+
/**
|
|
955
|
+
* Get the currently stored EdDSA public key.
|
|
956
|
+
*/
|
|
957
|
+
getPublicKey(): string | null;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
interface CreateProjectParams {
|
|
961
|
+
name: string;
|
|
962
|
+
note?: string;
|
|
963
|
+
tags?: string[];
|
|
964
|
+
repo?: string;
|
|
965
|
+
license?: string;
|
|
966
|
+
images?: Array<{
|
|
967
|
+
name: string;
|
|
968
|
+
hash: string;
|
|
969
|
+
mimeType: string;
|
|
970
|
+
extension: string;
|
|
971
|
+
size: number;
|
|
972
|
+
}>;
|
|
973
|
+
location?: {
|
|
974
|
+
name: string;
|
|
975
|
+
address?: string;
|
|
976
|
+
lat?: number;
|
|
977
|
+
lng?: number;
|
|
978
|
+
};
|
|
979
|
+
metadata?: Record<string, unknown>;
|
|
980
|
+
}
|
|
981
|
+
interface ProjectFilter {
|
|
982
|
+
conformsTo?: string[];
|
|
983
|
+
classifiedAs?: string[];
|
|
984
|
+
primaryAccountable?: string[];
|
|
985
|
+
search?: string;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Tagging constants — prefixes, thresholds, and option lists.
|
|
990
|
+
*
|
|
991
|
+
* Ported from interfacer-gui lib/tagging.ts
|
|
992
|
+
*/
|
|
993
|
+
declare const TAG_PREFIX: {
|
|
994
|
+
readonly USER: "tag";
|
|
995
|
+
readonly CATEGORY: "category";
|
|
996
|
+
readonly MACHINE: "machine";
|
|
997
|
+
readonly MATERIAL: "material";
|
|
998
|
+
readonly POWER_COMPAT: "powercompat";
|
|
999
|
+
readonly POWER_REQ: "powerreq";
|
|
1000
|
+
readonly REPLICABILITY: "replicability";
|
|
1001
|
+
readonly RECYCLABILITY: "recyclability";
|
|
1002
|
+
readonly REPAIRABILITY: "repairability";
|
|
1003
|
+
readonly ENV_ENERGY: "env-energy";
|
|
1004
|
+
readonly ENV_CO2: "env-co2";
|
|
1005
|
+
readonly SERVICE_TYPE: "servicetype";
|
|
1006
|
+
readonly AVAILABILITY: "availability";
|
|
1007
|
+
readonly LICENSE: "license";
|
|
1008
|
+
readonly MANUFACTURABLE: "manufacturable";
|
|
1009
|
+
};
|
|
1010
|
+
declare const SYSTEM_TAG_PREFIXES: ReadonlyArray<string>;
|
|
1011
|
+
declare const PRODUCT_CATEGORY_OPTIONS: readonly ["Electronics", "Tools", "Furniture", "Home renovation", "Energy", "Wearables", "Medical", "Sustainability", "Education"];
|
|
1012
|
+
declare const POWER_COMPATIBILITY_OPTIONS: readonly ["120V AC", "220-240V AC", "12V DC", "24V DC", "Battery Powered", "USB-C"];
|
|
1013
|
+
declare const REPLICABILITY_OPTIONS: readonly ["High", "Medium", "Low"];
|
|
1014
|
+
declare const SERVICE_TYPE_OPTIONS: readonly ["Fabrication", "Learning & Education", "Space Access"];
|
|
1015
|
+
declare const AVAILABILITY_OPTIONS: readonly ["Available Now", "Booking Required", "Weekdays Only", "Weekends Available"];
|
|
1016
|
+
declare const RECYCLABILITY_THRESHOLDS_PCT: readonly [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
|
|
1017
|
+
declare const POWER_REQUIREMENT_THRESHOLDS_W: readonly [0, 10, 25, 50, 75, 100, 150, 200, 250, 300, 500, 750, 1000, 1500, 2000];
|
|
1018
|
+
declare const ENERGY_THRESHOLDS_KWH: readonly [0, 10, 20, 30, 50, 100, 200, 300, 500, 750, 1000, 1500, 2000];
|
|
1019
|
+
declare const CO2_THRESHOLDS_KG: readonly [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 5, 7.5, 10, 15, 20];
|
|
1020
|
+
declare const REPAIRABILITY_AVAILABLE_TAG = "repairability-available";
|
|
1021
|
+
declare const MANUFACTURABLE_TRUE_TAG = "manufacturable-true";
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Instance variables resolver.
|
|
1025
|
+
*
|
|
1026
|
+
* Fetches configuration values from the Zenflows instance:
|
|
1027
|
+
* - ResourceSpecification IDs (project types)
|
|
1028
|
+
* - Unit IDs and currency spec
|
|
1029
|
+
*
|
|
1030
|
+
* Note: specDpp, specMachine, specMaterial are NOT available via instanceVariables
|
|
1031
|
+
* on all Zenflows instances. Configure them manually via InterfacerConfig.
|
|
1032
|
+
*/
|
|
1033
|
+
|
|
1034
|
+
interface SpecInfo {
|
|
1035
|
+
id: string;
|
|
1036
|
+
name: string;
|
|
1037
|
+
}
|
|
1038
|
+
interface InstanceVariables {
|
|
1039
|
+
projectDesign: SpecInfo;
|
|
1040
|
+
projectProduct: SpecInfo;
|
|
1041
|
+
projectService: SpecInfo;
|
|
1042
|
+
dpp?: SpecInfo;
|
|
1043
|
+
machine?: SpecInfo;
|
|
1044
|
+
material?: SpecInfo;
|
|
1045
|
+
currency: SpecInfo;
|
|
1046
|
+
unitOne: string;
|
|
1047
|
+
}
|
|
1048
|
+
declare function getInstanceVariables(client: GraphQLClient): Promise<InstanceVariables>;
|
|
1049
|
+
declare function clearInstanceVariablesCache(): void;
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* EdDSA signing for GraphQL requests using Zenroom.
|
|
1053
|
+
*
|
|
1054
|
+
* The signing contract (sign_graphql.zen):
|
|
1055
|
+
* 1. Takes the GraphQL body as a base64 string
|
|
1056
|
+
* 2. Signs it with the EdDSA private key
|
|
1057
|
+
* 3. Returns { eddsa_signature, hash }
|
|
1058
|
+
*
|
|
1059
|
+
* The resulting headers:
|
|
1060
|
+
* - zenflows-sign: the EdDSA signature
|
|
1061
|
+
* - zenflows-user: the username
|
|
1062
|
+
* - zenflows-hash: the hash of the signed body
|
|
1063
|
+
*/
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Sign a request body and return the Zenflows auth headers.
|
|
1067
|
+
*
|
|
1068
|
+
* @param body - The raw request body (GraphQL query JSON string, or any string)
|
|
1069
|
+
* @param store - KeyStorage containing the EdDSA private key
|
|
1070
|
+
* @returns Headers object with zenflows-sign, zenflows-user, zenflows-hash
|
|
1071
|
+
*/
|
|
1072
|
+
declare function signGraphQLRequest(body: string, store: KeyStorage): Promise<{
|
|
1073
|
+
"zenflows-sign": string;
|
|
1074
|
+
"zenflows-user": string;
|
|
1075
|
+
"zenflows-hash": string;
|
|
1076
|
+
}>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Sign a request body for DPP REST API (createDpp, updateDpp, etc.).
|
|
1079
|
+
* Base64-encodes the full JSON body before signing.
|
|
1080
|
+
*/
|
|
1081
|
+
declare function signDidRequest(body: string, store: KeyStorage): Promise<{
|
|
1082
|
+
"did-sign": string;
|
|
1083
|
+
"did-pk": string;
|
|
1084
|
+
}>;
|
|
1085
|
+
/**
|
|
1086
|
+
* Sign a file checksum for DPP file upload.
|
|
1087
|
+
* Signs the raw hex SHA-256 checksum (NOT base64-encoded).
|
|
1088
|
+
* This matches the DPP service's verify_graphql.zen contract.
|
|
1089
|
+
*/
|
|
1090
|
+
declare function signFileUpload(checksumHex: string, store: KeyStorage): Promise<string>;
|
|
1091
|
+
|
|
1092
|
+
export { AVAILABILITY_OPTIONS, AuthClient, CO2_THRESHOLDS_KG, type Contributor, type CreateProjectParams, type DppAttachment, DppClient, type DppDocument, type DppStatus, ENERGY_THRESHOLDS_KWH, FileClient, type GqlFile, GraphQLClient, type ImageRef, ImportClient, InboxClient, InterfacerClient, type InterfacerConfig, type KeyStorage, type Keyring, type License, type Location, MANUFACTURABLE_TRUE_TAG, type MachineRef, type MaterialRef, type ModelFile, POWER_COMPATIBILITY_OPTIONS, POWER_REQUIREMENT_THRESHOLDS_W, PRODUCT_CATEGORY_OPTIONS, type ProductFilters, type Project, type ProjectFilter, type ProjectModelMetadata, ProjectType, type Proposal, RECYCLABILITY_THRESHOLDS_PCT, REPAIRABILITY_AVAILABLE_TAG, REPLICABILITY_OPTIONS, ResourceClient, SERVICE_TYPE_OPTIONS, SYSTEM_TAG_PREFIXES, type ServiceFilters, SocialClient, TAG_PREFIX, TaggingClient, type UserChallenges, WalletClient, type ZenflowsFile, clearInstanceVariablesCache, createConfig, createMemoryStorage, derivedProductFilterTags, extractUserTagValues, formatImageSrc, getInstanceVariables, getResourceImage, isSystemTag, isUserTag, mergeTags, monotonicRangeTags, normalizeUserTagsForSave, prefixedTag, prepFileForZenflows, prepFilesForZenflows, rangeFilterTags, removeTagsWithPrefixes, signDidRequest, signFileUpload, signGraphQLRequest, slugifyTagValue, stripUserTagPrefix, userTag };
|