holosphere 1.1.21 → 1.3.0-alpha0

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/holosphere.d.ts CHANGED
@@ -2,600 +2,281 @@
2
2
  * Federation propagation options interface
3
3
  */
4
4
  interface PropagationOptions {
5
- /** Whether to use holograms instead of duplicating data (default: true) */
6
5
  useHolograms?: boolean;
7
- /** Specific target spaces to propagate to (default: all federated spaces) */
8
6
  targetSpaces?: string[];
9
- /** Password for accessing the source holon (if needed) */
10
7
  password?: string | null;
11
- /** Whether to automatically propagate to parent hexagons (default: true) */
12
8
  propagateToParents?: boolean;
13
- /** Maximum number of parent levels to propagate to (default: 15) */
14
9
  maxParentLevels?: number;
15
10
  }
16
11
 
17
- /**
18
- * Put options interface
19
- */
20
12
  interface PutOptions {
21
- /** Whether to automatically propagate to federated spaces (default: false) */
22
13
  autoPropagate?: boolean;
23
- /** Additional options to pass to propagate */
24
14
  propagationOptions?: PropagationOptions;
25
- /** Whether to disable hologram redirection logic when putting data (default: false) */
26
15
  disableHologramRedirection?: boolean;
16
+ actingAs?: string;
17
+ password?: string | null;
27
18
  }
28
19
 
29
- /**
30
- * Get options interface
31
- */
32
20
  interface GetOptions {
33
- /** Whether to automatically resolve holograms (default: true) */
34
21
  resolveHolograms?: boolean;
35
- /** Options passed to the schema validator */
36
22
  validationOptions?: object;
37
23
  }
38
24
 
39
- /**
40
- * Resolve Hologram options interface
41
- */
42
25
  interface ResolveHologramOptions {
43
- /** Whether to follow nested holograms (default: true) */
44
26
  followHolograms?: boolean;
45
- /** Internal use: Tracks visited souls to prevent loops */
46
27
  visited?: Set<string>;
47
28
  }
48
29
 
49
- /**
50
- * Represents a Hologram object, typically containing an id and a soul path.
51
- */
52
30
  interface Hologram {
53
31
  id: string;
54
32
  soul: string;
55
- [key: string]: any; // Allow other properties, e.g., _federation
33
+ [key: string]: any;
56
34
  }
57
35
 
58
- /**
59
- * Federation info interface
60
- */
61
36
  interface FederationInfo {
62
- /** Identifier of the holon */
63
37
  id: string;
64
- /** Name of the holon */
65
38
  name: string;
66
- /** List of federated space IDs (spaces this holon federates with) */
67
39
  federation: string[];
68
- /** List of spaces to notify about changes */
40
+ federated: string[];
69
41
  notify: string[];
70
- /** Timestamp of last update */
71
42
  timestamp: number;
43
+ lensConfig: Record<string, any>;
44
+ partnerNames: Record<string, string>;
72
45
  }
73
46
 
74
- /**
75
- * Options for federated data retrieval
76
- */
77
47
  interface GetFederatedOptions {
78
- /** Whether to aggregate results by ID */
79
48
  aggregate?: boolean;
80
- /** Field to use as ID */
81
49
  idField?: string;
82
- /** Fields to sum during aggregation */
83
50
  sumFields?: string[];
84
- /** Array fields to concatenate during aggregation */
85
51
  concatArrays?: string[];
86
- /** Whether to remove duplicates in concatenated arrays */
87
52
  removeDuplicates?: boolean;
88
- /** Custom merge function for aggregation */
89
53
  mergeStrategy?: (items: any[]) => any;
90
- /** Whether to include local data */
91
54
  includeLocal?: boolean;
92
- /** Whether to include federated data */
93
55
  includeFederated?: boolean;
94
- /** Whether to resolve federation references */
95
56
  resolveReferences?: boolean;
96
- /** Maximum number of federated spaces to query */
97
57
  maxFederatedSpaces?: number;
98
- /** Timeout in milliseconds for federated queries */
99
58
  timeout?: number;
100
59
  }
101
60
 
102
- /**
103
- * Results from a propagation operation
104
- */
105
61
  interface PropagationResult {
106
- /** Number of successfully propagated items */
107
62
  success: number;
108
- /** Number of errors encountered */
109
63
  errors: number;
110
- /** Details about errors */
111
64
  errorDetails: Array<{ space: string, error: string }>;
112
- /** Whether any propagation occurred */
113
65
  propagated: boolean;
114
- /** Whether references were used */
115
66
  referencesUsed: boolean;
116
- /** Error message if applicable */
117
67
  error?: string;
118
- /** Information message if applicable */
119
68
  message?: string;
120
- /** Parent propagation results */
121
69
  parentPropagation?: {
122
- /** Number of successfully propagated items to parents */
123
70
  success: number;
124
- /** Number of errors encountered during parent propagation */
125
71
  errors: number;
126
- /** Number of parent propagations skipped */
127
72
  skipped: number;
128
- /** Messages from parent propagation */
129
73
  messages: string[];
130
74
  };
131
75
  }
132
76
 
133
- /**
134
- * Result from a put operation
135
- */
136
77
  interface PutResult {
137
- /** Indicates if the put operation was successful */
138
78
  success: boolean;
139
- /** Indicates if the data ultimately put at the path was a hologram */
140
79
  isHologramAtPath?: boolean;
141
- /** The final holon where data was put (after potential redirection) */
142
80
  pathHolon: string;
143
- /** The final lens where data was put (after potential redirection) */
144
81
  pathLens: string;
145
- /** The final key under which data was put (after potential redirection) */
146
82
  pathKey: string;
147
- /** Result of any automatic propagation, if it occurred */
148
83
  propagationResult?: PropagationResult | null;
149
- /** Error message if the put operation failed at some point */
150
84
  error?: string;
151
85
  }
152
86
 
87
+ interface CanWriteResult {
88
+ canWrite: boolean;
89
+ reason: string;
90
+ accessType: string;
91
+ }
92
+
93
+ interface HoloSphereConfig {
94
+ appName?: string;
95
+ appname?: string;
96
+ privateKey?: Uint8Array | string | null;
97
+ strict?: boolean;
98
+ backend?: string;
99
+ openaiKey?: string | null;
100
+ nostr?: {
101
+ peers?: string[];
102
+ relays?: string[];
103
+ persistence?: boolean;
104
+ };
105
+ }
106
+
153
107
  declare class HoloSphere {
154
- private appname;
155
- private strict;
156
- private validator;
157
- public gun;
158
- private sea;
159
- private openai?;
160
- private subscriptions;
161
-
162
- /**
163
- * Initializes a new instance of the HoloSphere class.
164
- * @param {string} appname - The name of the application.
165
- * @param {boolean} strict - Whether to enforce strict schema validation.
166
- * @param {string|null} openaikey - The OpenAI API key.
167
- * @param {object|null} gunInstance - The Gun instance to use.
168
- */
169
- constructor(appname: string, strict?: boolean, openaikey?: string | null, gunInstance?: any);
170
-
171
- /**
172
- * Gets the Gun instance.
173
- * @returns {any} - The Gun instance.
174
- */
175
- getGun(): any;
108
+ appname: string;
109
+ config: HoloSphereConfig;
110
+ client: { publicKey: string };
111
+ gun: any;
112
+ subscriptions: Record<string, any>;
113
+
114
+ constructor(config: HoloSphereConfig);
115
+ constructor(appname: string, strict?: boolean, openaikey?: string | null, gunOptions?: any);
176
116
 
177
- // ================================ SCHEMA FUNCTIONS ================================
117
+ ready(): Promise<HoloSphere>;
118
+ getGun(): any;
178
119
 
179
- /**
180
- * Sets the JSON schema for a specific lens.
181
- * @param {string} lens - The lens identifier.
182
- * @param {object} schema - The JSON schema to set.
183
- * @returns {Promise<boolean>} - Resolves when the schema is set.
184
- */
120
+ // Schema
185
121
  setSchema(lens: string, schema: object): Promise<boolean>;
122
+ getSchema(lens: string, options?: { useCache?: boolean; maxCacheAge?: number }): Promise<object | null>;
123
+ clearSchemaCache(lens?: string | null): boolean;
186
124
 
187
- /**
188
- * Retrieves the JSON schema for a specific lens.
189
- * @param {string} lens - The lens identifier.
190
- * @returns {Promise<object|null>} - The retrieved schema or null if not found.
191
- */
192
- getSchema(lens: string): Promise<object | null>;
193
-
194
- // ================================ CONTENT FUNCTIONS ================================
195
-
196
- /**
197
- * Stores content in the specified holon and lens.
198
- * @param {string} holon - The holon identifier.
199
- * @param {string} lens - The lens under which to store the content.
200
- * @param {object} data - The data to store.
201
- * @param {string} [password] - Optional password for private holon.
202
- * @param {PutOptions} [options] - Additional options
203
- * @returns {Promise<any>} - Returns result object if successful
204
- */
125
+ // Content - v2-compatible signatures
126
+ put(holon: string, lens: string, data: object, options?: PutOptions): Promise<PutResult>;
205
127
  put(holon: string, lens: string, data: object, password?: string | null, options?: PutOptions): Promise<PutResult>;
206
-
207
- /**
208
- * Retrieves content from the specified holon and lens.
209
- * @param {string} holon - The holon identifier.
210
- * @param {string} lens - The lens from which to retrieve content.
211
- * @param {string} key - The specific key to retrieve.
212
- * @param {string} [password] - Optional password for private holon.
213
- * @param {GetOptions} [options] - Additional options
214
- * @returns {Promise<any|null>} - The retrieved content or null if not found.
215
- */
128
+ get(holon: string, lens: string): Promise<any | null>;
216
129
  get(holon: string, lens: string, key: string, password?: string | null, options?: GetOptions): Promise<any | null>;
217
-
218
- /**
219
- * Retrieves a node directly using its soul path
220
- * @param {string} soul - The soul path of the node
221
- * @returns {Promise<any>} - The retrieved node or null if not found.
222
- */
223
- getNodeBySoul(soul: string): Promise<any>;
224
-
225
- /**
226
- * Propagates data to federated holons
227
- * @param {string} holon - The holon identifier
228
- * @param {string} lens - The lens identifier
229
- * @param {object} data - The data to propagate
230
- * @param {PropagationOptions} [options] - Propagation options
231
- * @returns {Promise<PropagationResult>} - Result with success count and errors
232
- */
233
- propagate(holon: string, lens: string, data: object, options?: PropagationOptions): Promise<PropagationResult>;
234
-
235
- /**
236
- * Retrieves all content from the specified holon and lens.
237
- * @param {string} holon - The holon identifier.
238
- * @param {string} lens - The lens from which to retrieve content.
239
- * @param {string} [password] - Optional password for private holon.
240
- * @returns {Promise<Array<any>>} - The retrieved content.
241
- */
242
130
  getAll(holon: string, lens: string, password?: string | null): Promise<Array<any>>;
243
-
244
- /**
245
- * Deletes a specific key from a given holon and lens.
246
- * @param {string} holon - The holon identifier.
247
- * @param {string} lens - The lens from which to delete the key.
248
- * @param {string} key - The specific key to delete.
249
- * @param {string} [password] - Optional password for private holon.
250
- * @returns {Promise<boolean>} - Returns true if successful
251
- */
131
+ parse(rawData: any): Promise<object | null>;
252
132
  delete(holon: string, lens: string, key: string, password?: string | null): Promise<boolean>;
253
-
254
- /**
255
- * Deletes all keys from a given holon and lens.
256
- * @param {string} holon - The holon identifier.
257
- * @param {string} lens - The lens from which to delete all keys.
258
- * @param {string} [password] - Optional password for private holon.
259
- * @returns {Promise<boolean>} - Returns true if successful
260
- */
261
133
  deleteAll(holon: string, lens: string, password?: string | null): Promise<boolean>;
262
134
 
263
- // ================================ NODE FUNCTIONS ================================
264
-
265
- /**
266
- * Stores a specific gun node in a given holon and lens.
267
- * @param {string} holon - The holon identifier.
268
- * @param {string} lens - The lens under which to store the node.
269
- * @param {object} data - The node to store.
270
- * @returns {Promise<boolean>} - Returns true if successful
271
- */
135
+ // Node
272
136
  putNode(holon: string, lens: string, data: object): Promise<boolean>;
273
-
274
- /**
275
- * Retrieves a specific gun node from the specified holon and lens.
276
- * @param {string} holon - The holon identifier.
277
- * @param {string} lens - The lens identifier.
278
- * @param {string} key - The specific key to retrieve.
279
- * @returns {Promise<any|null>} - The retrieved node or null if not found.
280
- */
281
137
  getNode(holon: string, lens: string, key: string): Promise<any | null>;
282
-
283
- /**
284
- * Gets a Gun reference to a node by its soul
285
- * @param {string} soul - The soul path
286
- * @returns {any} - A Gun reference to the node
287
- */
288
138
  getNodeRef(soul: string): any;
289
-
290
- /**
291
- * Deletes a specific gun node from a given holon and lens.
292
- * @param {string} holon - The holon identifier.
293
- * @param {string} lens - The lens identifier.
294
- * @param {string} key - The key of the node to delete.
295
- * @returns {Promise<boolean>} - Returns true if successful
296
- */
139
+ getNodeBySoul(soul: string): Promise<any>;
297
140
  deleteNode(holon: string, lens: string, key: string): Promise<boolean>;
298
141
 
299
- // ================================ HOLOGRAM FUNCTIONS ================================
300
-
301
- /**
302
- * Creates a soul hologram object for a data item.
303
- * @param {string} holon - The holon where the original data is stored.
304
- * @param {string} lens - The lens where the original data is stored.
305
- * @param {object} data - The data to create a hologram for. Must have an 'id' field.
306
- * @returns {Hologram} - A hologram object containing id and soul.
307
- */
308
- createHologram(holon: string, lens: string, data: { id: string, [key: string]: any }): Hologram;
309
-
310
- /**
311
- * Checks if an object is a hologram (has id and soul).
312
- * @param {any} data - The data to check.
313
- * @returns {boolean} - True if the object is considered a hologram.
314
- */
315
- isHologram(data: any): data is Hologram;
316
-
317
- /**
318
- * Resolves a hologram to its actual data by following its soul path.
319
- * @param {Hologram} hologram - The hologram object to resolve.
320
- * @param {ResolveHologramOptions} [options] - Options for resolution.
321
- * @returns {Promise<object|null>} - The resolved data, null if not found, or the original hologram in case of loops/errors.
322
- */
323
- resolveHologram(hologram: Hologram, options?: ResolveHologramOptions): Promise<object | null>;
324
-
325
- // ================================ GLOBAL FUNCTIONS ================================
326
-
327
- /**
328
- * Stores data in a global (non-holon-specific) table.
329
- * @param {string} tableName - The table name to store data in.
330
- * @param {object} data - The data to store. If it has an 'id' field, it will be used as the key.
331
- * @param {string} [password] - Optional password for private holon.
332
- * @returns {Promise<void>}
333
- */
142
+ // Global
334
143
  putGlobal(tableName: string, data: object, password?: string | null): Promise<void>;
335
-
336
- /**
337
- * Retrieves a specific key from a global table.
338
- * @param {string} tableName - The table name to retrieve from.
339
- * @param {string} key - The key to retrieve.
340
- * @param {string} [password] - Optional password for private holon.
341
- * @returns {Promise<any|null>} - The parsed data for the key or null if not found.
342
- */
144
+ writeGlobal(tableName: string, data: object): Promise<void>;
343
145
  getGlobal(tableName: string, key: string, password?: string | null): Promise<any | null>;
344
-
345
- /**
346
- * Retrieves all data from a global table.
347
- * @param {string} tableName - The table name to retrieve data from.
348
- * @param {string} [password] - Optional password for private holon.
349
- * @returns {Promise<Array<any>>} - The parsed data from the table as an array.
350
- */
351
146
  getAllGlobal(tableName: string, password?: string | null): Promise<Array<any>>;
352
-
353
- /**
354
- * Deletes a specific key from a global table.
355
- * @param {string} tableName - The table name to delete from.
356
- * @param {string} key - The key to delete.
357
- * @param {string} [password] - Optional password for private holon.
358
- * @returns {Promise<boolean>} - Returns true if successful
359
- */
360
147
  deleteGlobal(tableName: string, key: string, password?: string | null): Promise<boolean>;
361
-
362
- /**
363
- * Deletes an entire global table.
364
- * @param {string} tableName - The table name to delete.
365
- * @param {string} [password] - Optional password for private holon.
366
- * @returns {Promise<boolean>} - Returns true if successful
367
- */
368
148
  deleteAllGlobal(tableName: string, password?: string | null): Promise<boolean>;
149
+ subscribeGlobal(lens: string, key: string | null, callback: (data: any, key?: string) => void, options?: { realtimeOnly?: boolean }): Promise<{ unsubscribe: () => void }>;
150
+ subscribeGlobal(lens: string, callback: (data: any, key?: string) => void): Promise<{ unsubscribe: () => void }>;
369
151
 
370
- // ================================ COMPUTE FUNCTIONS ================================
371
-
372
- /**
373
- * Computes operations across multiple layers up the hierarchy
374
- * @param {string} holon - Starting holon identifier
375
- * @param {string} lens - The lens to compute
376
- * @param {object} options - Computation options
377
- * @param {number} [maxLevels=15] - Maximum levels to compute up
378
- * @param {string} [password] - Optional password for private holons
379
- * @returns {Promise<Array<any>>} - Computation results
380
- */
381
- computeHierarchy(holon: string, lens: string, options: object, maxLevels?: number, password?: string | null): Promise<Array<any>>;
152
+ // Hologram
153
+ createHologram(holon: string, lens: string, data: { id: string, [key: string]: any }): Hologram;
154
+ isHologram(data: any): data is Hologram;
155
+ parseSoulPath(soul: string): { appname: string, holon: string, lens: string, key: string } | null;
156
+ resolveHologram(hologram: Hologram, options?: ResolveHologramOptions): Promise<object | null>;
382
157
 
383
- /**
384
- * Computes operations on content within a holon and lens for one layer up.
385
- * @param {string} holon - The holon identifier.
386
- * @param {string} lens - The lens to compute.
387
- * @param {object|string} options - Computation options or operation name
388
- * @param {string} [password] - Optional password for private holons
389
- * @returns {Promise<any>} - Computation result
390
- */
391
- compute(holon: string, lens: string, options: object|string, password?: string | null): Promise<any>;
392
-
393
- /**
394
- * Upcasts content to parent holonagons recursively using federation and soul references.
395
- * @param {string} holon - The current holon identifier.
396
- * @param {string} lens - The lens under which to upcast.
397
- * @param {object} content - The content to upcast.
398
- * @param {number} [maxLevels=15] - Maximum levels to upcast.
399
- * @returns {Promise<object>} - The original content.
400
- */
158
+ // Compute
159
+ computeHierarchy(holon: string, lens: string, options: object, maxLevels?: number, password?: string | null): Promise<Array<any>>;
160
+ compute(holon: string, lens: string, options: object | string, password?: string | null): Promise<any>;
161
+ summarize(history: string): Promise<string>;
401
162
  upcast(holon: string, lens: string, content: object, maxLevels?: number): Promise<object>;
402
-
403
- /**
404
- * Updates the parent holon with a new report.
405
- * @param {string} id - The child holon identifier.
406
- * @param {string} report - The report to update.
407
- * @returns {Promise<object>} - The updated parent information.
408
- */
409
163
  updateParent(id: string, report: string): Promise<object>;
164
+ propagate(holon: string, lens: string, data: object, options?: PropagationOptions): Promise<PropagationResult>;
410
165
 
411
- // ================================ LOCATION FUNCTIONS ================================
412
-
413
- /**
414
- * Converts latitude and longitude to a holon identifier.
415
- * @param {number} lat - The latitude.
416
- * @param {number} lng - The longitude.
417
- * @param {number} resolution - The resolution level.
418
- * @returns {Promise<string>} - The resulting holon identifier.
419
- */
166
+ // Location
420
167
  getHolon(lat: number, lng: number, resolution: number): Promise<string>;
421
-
422
- /**
423
- * Retrieves all containing holonagons at all scales for given coordinates.
424
- * @param {number} lat - The latitude.
425
- * @param {number} lng - The longitude.
426
- * @returns {Array<string>} - List of holon identifiers.
427
- */
428
168
  getScalespace(lat: number, lng: number): string[];
429
-
430
- /**
431
- * Retrieves all containing holonagons at all scales for a given holon.
432
- * @param {string} holon - The holon identifier.
433
- * @returns {Array<string>} - List of holon identifiers.
434
- */
435
169
  getHolonScalespace(holon: string): string[];
436
170
 
437
- // ================================ SUBSCRIPTION FUNCTIONS ================================
438
-
439
- /**
440
- * Subscribes to changes in a specific holon and lens.
441
- * @param {string} holon - The holon identifier.
442
- * @param {string} lens - The lens to subscribe to.
443
- * @param {function} callback - The callback to execute on changes.
444
- * @returns {Promise<object>} - Subscription object with unsubscribe method
445
- */
171
+ // Subscription
446
172
  subscribe(holon: string, lens: string, callback: (data: any, key?: string) => void): Promise<{ unsubscribe: () => void }>;
447
173
 
448
- // ================================ FEDERATION FUNCTIONS ================================
449
-
450
- /**
451
- * Creates a federation relationship between two holons
452
- * @param {string} holonId1 - The first holon ID
453
- * @param {string} holonId2 - The second holon ID
454
- * @param {string} [password1] - Optional password for the first holon
455
- * @param {string} [password2] - Optional password for the second holon
456
- * @param {boolean} [bidirectional=true] - Whether to set up bidirectional notifications automatically
457
- * @param {object} [lensConfig] - Optional lens-specific configuration
458
- * @param {string[]} [lensConfig.federate] - List of lenses to federate (default: all)
459
- * @param {string[]} [lensConfig.notify] - List of lenses to notify (default: all)
460
- * @returns {Promise<boolean>} - True if federation was created successfully
461
- */
174
+ // Federation - v1 style
462
175
  federate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null, bidirectional?: boolean, lensConfig?: { federate?: string[], notify?: string[] }): Promise<boolean>;
176
+ unfederate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null): Promise<boolean>;
463
177
 
464
- /**
465
- * Subscribes to federation notifications for a holon
466
- * @param {string} holonId - The holon ID to subscribe to
467
- * @param {string} [password] - Optional password for the holon
468
- * @param {function} callback - The callback to execute on notifications
469
- * @param {object} [options] - Subscription options
470
- * @returns {Promise<object>} - Subscription object with unsubscribe() method
471
- */
472
- subscribeFederation(holonId: string, password: string | null, callback: (data: any, federatedSpace?: string, lens?: string) => void, options?: { lenses?: string[], throttle?: number }): Promise<{ unsubscribe: () => void, getSubscriptionCount: () => number }>;
178
+ // Federation - v2 style
179
+ federateHolon(sourceHolon: string, targetHolon: string, options?: { lensConfig?: any; partnerName?: string; skipPropagation?: boolean }): Promise<boolean>;
180
+ unfederateHolon(sourceHolon: string, targetHolon: string): Promise<boolean>;
473
181
 
474
- /**
475
- * Gets federation info for a holon
476
- * @param {string} holonId - The holon ID
477
- * @param {string} [password] - Optional password for the holon
478
- * @returns {Promise<FederationInfo|null>} - Federation info or null if not found
479
- */
182
+ subscribeFederation(holonId: string, password: string | null, callback: (data: any, federatedSpace?: string, lens?: string) => void, options?: { lenses?: string[], throttle?: number }): Promise<{ unsubscribe: () => void, getSubscriptionCount: () => number }>;
480
183
  getFederation(holonId: string, password?: string | null): Promise<FederationInfo | null>;
481
-
482
- /**
483
- * Retrieves the lens-specific configuration for a federation link between two holons.
484
- * @param {string} holonId - The ID of the source holon.
485
- * @param {string} targetHolonId - The ID of the target holon in the federation link.
486
- * @param {string} [password] - Optional password for the source holon.
487
- * @returns {Promise<{ federate: string[], notify: string[] } | null>} - An object with 'federate' and 'notify' arrays, or null if not found.
488
- */
489
184
  getFederatedConfig(holonId: string, targetHolonId: string, password?: string | null): Promise<{ federate: string[], notify: string[] } | null>;
490
-
491
- /**
492
- * Removes a federation relationship between holons
493
- * @param {string} holonId1 - The first holon ID
494
- * @param {string} holonId2 - The second holon ID
495
- * @param {string} [password1] - Optional password for the first holon
496
- * @param {string} [password2] - Optional password for the second holon
497
- * @returns {Promise<boolean>} - True if federation was removed successfully
498
- */
499
- unfederate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null): Promise<boolean>;
500
-
501
- /**
502
- * Removes a notification relationship between two spaces
503
- * @param {string} holonId1 - The space to modify (remove from its notify list)
504
- * @param {string} holonId2 - The space to be removed from notifications
505
- * @param {string} [password1] - Optional password for the first space
506
- * @returns {Promise<boolean>} - True if notification was removed successfully
507
- */
508
185
  removeNotify(holonId1: string, holonId2: string, password1?: string | null): Promise<boolean>;
509
-
510
- /**
511
- * Get and aggregate data from federated holons
512
- * @param {string} holon - The holon name
513
- * @param {string} lens - The lens name
514
- * @param {GetFederatedOptions} [options] - Options for retrieval and aggregation
515
- * @returns {Promise<Array<any>>} - Combined array of local and federated data
516
- */
517
186
  getFederated(holon: string, lens: string, options?: GetFederatedOptions): Promise<Array<any>>;
518
-
519
- /**
520
- * Tracks a federated message across different chats
521
- * @param {string} originalChatId - The ID of the original chat
522
- * @param {string} messageId - The ID of the original message
523
- * @param {string} federatedChatId - The ID of the federated chat
524
- * @param {string} federatedMessageId - The ID of the message in the federated chat
525
- * @param {string} [type] - The type of message (e.g., 'quest', 'announcement')
526
- * @returns {Promise<void>}
527
- */
528
187
  federateMessage(originalChatId: string, messageId: string, federatedChatId: string, federatedMessageId: string, type?: string): Promise<void>;
529
-
530
- /**
531
- * Gets all federated messages for a given original message
532
- * @param {string} originalChatId - The ID of the original chat
533
- * @param {string} messageId - The ID of the original message
534
- * @returns {Promise<object|null>} - The tracking information for the message
535
- */
536
188
  getFederatedMessages(originalChatId: string, messageId: string): Promise<object | null>;
537
-
538
- /**
539
- * Updates a federated message across all federated chats
540
- * @param {string} originalChatId - The ID of the original chat
541
- * @param {string} messageId - The ID of the original message
542
- * @param {Function} updateCallback - Function to update the message in each chat
543
- * @returns {Promise<void>}
544
- */
545
189
  updateFederatedMessages(originalChatId: string, messageId: string, updateCallback: (chatId: string, messageId: string) => Promise<void>): Promise<void>;
546
-
547
- /**
548
- * Resets the federation settings for a holon
549
- * @param {string} holonId - The holon ID
550
- * @param {string} [password] - Optional password for the holon
551
- * @returns {Promise<boolean>} - True if federation was reset successfully
552
- */
553
190
  resetFederation(holonId: string, password?: string | null): Promise<boolean>;
554
191
 
555
- // ================================ UTILITY FUNCTIONS ================================
192
+ // Authorization
193
+ canWrite(holonId: string, lensName: string, actingAs: string, options?: any): Promise<CanWriteResult>;
194
+ addAllowedAuthor(pubkey: string): void;
195
+ removeAllowedAuthor(pubkey: string): void;
196
+ listAllowedAuthors(): string[];
556
197
 
557
- /**
558
- * Generates a unique ID for data items
559
- * @returns {string} A unique ID
560
- */
198
+ // Utility
561
199
  generateId(): string;
562
-
563
- /**
564
- * Closes the HoloSphere instance and cleans up resources.
565
- * @returns {Promise<void>}
566
- */
567
200
  close(): Promise<void>;
568
-
569
- /**
570
- * Configures radisk storage options for GunDB.
571
- * @param {object} options - Radisk configuration options
572
- * @param {string} [options.file='./radata'] - Directory for radisk storage
573
- * @param {boolean} [options.radisk=true] - Whether to enable radisk storage
574
- * @param {number} [options.until] - Timestamp until which to keep data
575
- * @param {number} [options.retry] - Number of retries for failed operations
576
- * @param {number} [options.timeout] - Timeout for operations in milliseconds
577
- */
578
- configureRadisk(options?: {
579
- file?: string;
580
- radisk?: boolean;
581
- until?: number | null;
582
- retry?: number;
583
- timeout?: number;
584
- }): void;
585
-
586
- /**
587
- * Gets radisk storage statistics and information.
588
- * @returns {object} Radisk statistics including file path, enabled status, and storage info
589
- */
590
- getRadiskStats(): {
591
- enabled: boolean;
592
- filePath: string;
593
- retry: number;
594
- timeout: number;
595
- until: number | null;
596
- peers: any[];
597
- localStorage: boolean;
598
- } | { error: string };
201
+ getVersion(): string;
202
+ userName(holonId: string): string;
203
+ configureRadisk(options?: { file?: string; radisk?: boolean; until?: number | null; retry?: number; timeout?: number }): void;
204
+ getRadiskStats(): { enabled: boolean; filePath: string; retry: number; timeout: number; until: number | null; peers: any[]; localStorage: boolean } | { error: string };
599
205
  }
600
206
 
207
+ // Named exports
208
+ export declare const version: string;
209
+
210
+ export declare const nostrUtils: {
211
+ generatePrivateKey(): string;
212
+ getPublicKey(privateKeyHex: string): string;
213
+ getPublicKeyFromBytes(privateKeyBytes: Uint8Array): string;
214
+ parseNsecOrHex(input: string): string | null;
215
+ parseNpubOrHex(input: string): string | null;
216
+ hexToNpub(hex: string): string;
217
+ hexToNsec(hex: string): string;
218
+ npubToHex(npub: string): string;
219
+ nsecToHex(nsec: string): string;
220
+ hexToBytes(hex: string): Uint8Array;
221
+ bytesToHex(bytes: Uint8Array): string;
222
+ shortenPubKey(pubkey: string, len?: number): string;
223
+ shortenNpub(npub: string, len?: number): string;
224
+ generateNonce(): string;
225
+ };
226
+
227
+ export declare function buildLensPath(appName: string, holonId: string, lens: string): string;
228
+
229
+ export declare const subscriptions: {
230
+ createSubscription(client: HoloSphere, path: string, callback: (data: any, key?: string) => void, options?: { realtimeOnly?: boolean; resolveHolograms?: boolean; appname?: string }): { unsubscribe: () => void; stop: () => void };
231
+ };
232
+
233
+ export declare const registry: {
234
+ storeInboundCapability(client: HoloSphere, appName: string, holonId: string, capability: any): Promise<{ success: boolean; id?: string; error?: string }>;
235
+ getInboundCapabilities(client: HoloSphere, appName: string, holonId: string): Promise<any[]>;
236
+ removeInboundCapability(client: HoloSphere, appName: string, holonId: string, capabilityId: string): Promise<boolean>;
237
+ };
238
+
239
+ export declare const handshake: {
240
+ subscribeToFederationDMs(holosphere: HoloSphere, privateKey: any, publicKey: string, handlers: {
241
+ onRequest?: (request: any, senderPubKey: string) => void;
242
+ onResponse?: (response: any, senderPubKey: string) => void;
243
+ onUpdate?: (update: any, senderPubKey: string) => void;
244
+ onUpdateResponse?: (response: any, senderPubKey: string) => void;
245
+ }): () => void;
246
+ initiateFederationHandshake(holosphere: HoloSphere, privateKey: any, params: {
247
+ partnerPubKey: string;
248
+ holonId: string;
249
+ holonName: string;
250
+ lensConfig?: any;
251
+ message?: string;
252
+ }): Promise<{ success: boolean; requestId?: string }>;
253
+ acceptFederationRequest(holosphere: HoloSphere, privateKey: any, params: {
254
+ requesterPubKey: string;
255
+ holonId: string;
256
+ holonName: string;
257
+ lensConfig?: any;
258
+ requestId?: string;
259
+ }): Promise<{ success: boolean }>;
260
+ rejectFederationRequest(holosphere: HoloSphere, privateKey: any, params: {
261
+ requesterPubKey: string;
262
+ holonId: string;
263
+ reason?: string;
264
+ requestId?: string;
265
+ }): Promise<{ success: boolean }>;
266
+ processFederationResponse(holosphere: HoloSphere, response: any, senderPubKey: string, options?: {
267
+ holonId: string;
268
+ inboundLenses?: string[];
269
+ }): Promise<{ success: boolean; responderHolonId?: string; error?: string }>;
270
+ requestFederationUpdate(holosphere: HoloSphere, privateKey: any, params: {
271
+ partnerPubKey: string;
272
+ holonId: string;
273
+ holonName: string;
274
+ newLensConfig?: any;
275
+ message?: string;
276
+ }): Promise<{ success: boolean }>;
277
+ acceptFederationUpdate(holosphere: HoloSphere, privateKey: any, params: any): Promise<{ success: boolean }>;
278
+ rejectFederationUpdate(holosphere: HoloSphere, privateKey: any, params: any): Promise<{ success: boolean }>;
279
+ };
280
+
601
281
  export default HoloSphere;
282
+ export { HoloSphere };