shogun-core 3.0.3 → 3.0.4

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.
Files changed (95) hide show
  1. package/package.json +1 -1
  2. package/dist/browser/shogun-core.js +0 -92128
  3. package/dist/browser/shogun-core.js.map +0 -1
  4. package/dist/config/simplified-config.js +0 -230
  5. package/dist/core.js +0 -338
  6. package/dist/gundb/crypto.js +0 -268
  7. package/dist/gundb/db.js +0 -1833
  8. package/dist/gundb/derive.js +0 -229
  9. package/dist/gundb/errors.js +0 -66
  10. package/dist/gundb/index.js +0 -6
  11. package/dist/gundb/restricted-put.js +0 -81
  12. package/dist/gundb/rxjs.js +0 -445
  13. package/dist/gundb/simple-api.js +0 -438
  14. package/dist/gundb/types.js +0 -4
  15. package/dist/index.js +0 -16
  16. package/dist/interfaces/common.js +0 -1
  17. package/dist/interfaces/events.js +0 -36
  18. package/dist/interfaces/plugin.js +0 -1
  19. package/dist/interfaces/shogun.js +0 -34
  20. package/dist/managers/AuthManager.js +0 -225
  21. package/dist/managers/CoreInitializer.js +0 -234
  22. package/dist/managers/EventManager.js +0 -67
  23. package/dist/managers/PluginManager.js +0 -296
  24. package/dist/migration-test.js +0 -91
  25. package/dist/plugins/base.js +0 -47
  26. package/dist/plugins/index.js +0 -15
  27. package/dist/plugins/nostr/index.js +0 -4
  28. package/dist/plugins/nostr/nostrConnector.js +0 -413
  29. package/dist/plugins/nostr/nostrConnectorPlugin.js +0 -446
  30. package/dist/plugins/nostr/nostrSigner.js +0 -313
  31. package/dist/plugins/nostr/types.js +0 -1
  32. package/dist/plugins/oauth/index.js +0 -3
  33. package/dist/plugins/oauth/oauthConnector.js +0 -753
  34. package/dist/plugins/oauth/oauthPlugin.js +0 -396
  35. package/dist/plugins/oauth/types.js +0 -1
  36. package/dist/plugins/web3/index.js +0 -4
  37. package/dist/plugins/web3/types.js +0 -1
  38. package/dist/plugins/web3/web3Connector.js +0 -528
  39. package/dist/plugins/web3/web3ConnectorPlugin.js +0 -448
  40. package/dist/plugins/web3/web3Signer.js +0 -308
  41. package/dist/plugins/webauthn/index.js +0 -3
  42. package/dist/plugins/webauthn/types.js +0 -11
  43. package/dist/plugins/webauthn/webauthn.js +0 -478
  44. package/dist/plugins/webauthn/webauthnPlugin.js +0 -398
  45. package/dist/plugins/webauthn/webauthnSigner.js +0 -304
  46. package/dist/storage/storage.js +0 -147
  47. package/dist/types/config/simplified-config.d.ts +0 -114
  48. package/dist/types/core.d.ts +0 -305
  49. package/dist/types/gundb/crypto.d.ts +0 -95
  50. package/dist/types/gundb/db.d.ts +0 -404
  51. package/dist/types/gundb/derive.d.ts +0 -21
  52. package/dist/types/gundb/errors.d.ts +0 -42
  53. package/dist/types/gundb/index.d.ts +0 -3
  54. package/dist/types/gundb/restricted-put.d.ts +0 -15
  55. package/dist/types/gundb/rxjs.d.ts +0 -110
  56. package/dist/types/gundb/simple-api.d.ts +0 -90
  57. package/dist/types/gundb/types.d.ts +0 -264
  58. package/dist/types/index.d.ts +0 -14
  59. package/dist/types/interfaces/common.d.ts +0 -85
  60. package/dist/types/interfaces/events.d.ts +0 -131
  61. package/dist/types/interfaces/plugin.d.ts +0 -162
  62. package/dist/types/interfaces/shogun.d.ts +0 -215
  63. package/dist/types/managers/AuthManager.d.ts +0 -72
  64. package/dist/types/managers/CoreInitializer.d.ts +0 -40
  65. package/dist/types/managers/EventManager.d.ts +0 -49
  66. package/dist/types/managers/PluginManager.d.ts +0 -145
  67. package/dist/types/migration-test.d.ts +0 -16
  68. package/dist/types/plugins/base.d.ts +0 -35
  69. package/dist/types/plugins/index.d.ts +0 -14
  70. package/dist/types/plugins/nostr/index.d.ts +0 -4
  71. package/dist/types/plugins/nostr/nostrConnector.d.ts +0 -119
  72. package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +0 -163
  73. package/dist/types/plugins/nostr/nostrSigner.d.ts +0 -105
  74. package/dist/types/plugins/nostr/types.d.ts +0 -122
  75. package/dist/types/plugins/oauth/index.d.ts +0 -3
  76. package/dist/types/plugins/oauth/oauthConnector.d.ts +0 -110
  77. package/dist/types/plugins/oauth/oauthPlugin.d.ts +0 -91
  78. package/dist/types/plugins/oauth/types.d.ts +0 -114
  79. package/dist/types/plugins/web3/index.d.ts +0 -4
  80. package/dist/types/plugins/web3/types.d.ts +0 -107
  81. package/dist/types/plugins/web3/web3Connector.d.ts +0 -129
  82. package/dist/types/plugins/web3/web3ConnectorPlugin.d.ts +0 -160
  83. package/dist/types/plugins/web3/web3Signer.d.ts +0 -114
  84. package/dist/types/plugins/webauthn/index.d.ts +0 -3
  85. package/dist/types/plugins/webauthn/types.d.ts +0 -162
  86. package/dist/types/plugins/webauthn/webauthn.d.ts +0 -129
  87. package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +0 -158
  88. package/dist/types/plugins/webauthn/webauthnSigner.d.ts +0 -91
  89. package/dist/types/storage/storage.d.ts +0 -50
  90. package/dist/types/utils/errorHandler.d.ts +0 -119
  91. package/dist/types/utils/eventEmitter.d.ts +0 -39
  92. package/dist/types/utils/validation.d.ts +0 -27
  93. package/dist/utils/errorHandler.js +0 -241
  94. package/dist/utils/eventEmitter.js +0 -76
  95. package/dist/utils/validation.js +0 -72
@@ -1,404 +0,0 @@
1
- /**
2
- * GunDB class with enhanced features:
3
- * - Dynamic peer linking
4
- * - Support for remove/unset operations
5
- * - Direct authentication through Gun.user()
6
- */
7
- import type { GunUser, UserInfo, AuthCallback, GunData, EventData, EventListener, GunOperationResult } from "./types";
8
- import type { GunInstance, GunUserInstance, GunChain } from "./types";
9
- import type { AuthResult, SignUpResult } from "../interfaces/shogun";
10
- import Gun from "gun/gun";
11
- import SEA from "gun/sea";
12
- import "gun/lib/then";
13
- import "gun/lib/radix";
14
- import "gun/lib/radisk";
15
- import "gun/lib/store";
16
- import "gun/lib/rindexed";
17
- import "gun/lib/webrtc";
18
- import "gun/lib/wire";
19
- import "gun/lib/axe";
20
- import { restrictedPut } from "./restricted-put";
21
- import derive, { DeriveOptions } from "./derive";
22
- import type { ISEAPair } from "gun/types";
23
- import { GunDataEventData, GunPeerEventData } from "../interfaces/events";
24
- import { RxJS } from "./rxjs";
25
- import * as GunErrors from "./errors";
26
- import * as crypto from "./crypto";
27
- declare class DataBase {
28
- gun: GunInstance;
29
- user: GunUserInstance | null;
30
- crypto: typeof crypto;
31
- sea: typeof SEA;
32
- node: GunChain;
33
- private readonly onAuthCallbacks;
34
- private readonly eventEmitter;
35
- private _rxjs?;
36
- constructor(gun: GunInstance, appScope?: string);
37
- /**
38
- * Initialize the GunInstance asynchronously
39
- * This method should be called after construction to perform async operations
40
- */
41
- initialize(appScope?: string): Promise<void>;
42
- private subscribeToAuthEvents;
43
- private notifyAuthListeners;
44
- /**
45
- * Adds a new peer to the network
46
- * @param peer URL of the peer to add
47
- */
48
- addPeer(peer: string): void;
49
- /**
50
- * Removes a peer from the network
51
- * @param peer URL of the peer to remove
52
- */
53
- removePeer(peer: string): void;
54
- /**
55
- * Gets the list of currently connected peers
56
- * @returns Array of peer URLs
57
- */
58
- getCurrentPeers(): string[];
59
- /**
60
- * Gets the list of all configured peers (connected and disconnected)
61
- * @returns Array of peer URLs
62
- */
63
- getAllConfiguredPeers(): string[];
64
- /**
65
- * Gets detailed information about all peers
66
- * @returns Object with peer information
67
- */
68
- getPeerInfo(): {
69
- [peer: string]: {
70
- connected: boolean;
71
- status: string;
72
- };
73
- };
74
- /**
75
- * Reconnects to a specific peer
76
- * @param peer URL of the peer to reconnect
77
- */
78
- reconnectToPeer(peer: string): void;
79
- /**
80
- * Clears all peers and optionally adds new ones
81
- * @param newPeers Optional array of new peers to add
82
- */
83
- resetPeers(newPeers?: string[]): void;
84
- /**
85
- * Registers an authentication callback
86
- * @param callback Function to call on auth events
87
- * @returns Function to unsubscribe the callback
88
- */
89
- onAuth(callback: AuthCallback): () => void;
90
- /**
91
- * Helper method to navigate to a nested path by splitting and chaining .get() calls
92
- * @param node Starting Gun node
93
- * @param path Path string (e.g., "test/data/marco")
94
- * @returns Gun node at the specified path
95
- */
96
- private navigateToPath;
97
- /**
98
- * Gets the Gun instance
99
- * @returns Gun instance
100
- */
101
- getGun(): GunInstance;
102
- /**
103
- * Gets the current user
104
- * @returns Current user object or null
105
- */
106
- getCurrentUser(): UserInfo | null;
107
- /**
108
- * Gets the current user instance
109
- * @returns User instance
110
- */
111
- getUser(): GunUser;
112
- /**
113
- * Gets a node at the specified path
114
- * @param path Path to the node
115
- * @returns Gun node
116
- */
117
- get(path: string): any;
118
- /**
119
- * Gets data at the specified path (one-time read)
120
- * @param path Path to get the data from
121
- * @returns Promise resolving to the data
122
- */
123
- getData(path: string): Promise<GunData>;
124
- /**
125
- * Puts data at the specified path
126
- * @param path Path to store data
127
- * @param data Data to store
128
- * @returns Promise resolving to operation result
129
- */
130
- put(path: string, data: GunData): Promise<GunOperationResult>;
131
- /**
132
- * Sets data at the specified path
133
- * @param path Path to store data
134
- * @param data Data to store
135
- * @returns Promise resolving to operation result
136
- */
137
- set(path: string, data: GunData): Promise<GunOperationResult>;
138
- /**
139
- * Removes data at the specified path
140
- * @param path Path to remove
141
- * @returns Promise resolving to operation result
142
- */
143
- remove(path: string): Promise<GunOperationResult>;
144
- /**
145
- * Checks if a user is currently logged in
146
- * @returns True if logged in
147
- */
148
- isLoggedIn(): boolean;
149
- /**
150
- * Attempts to restore user session from local storage
151
- * @returns Promise resolving to session restoration result
152
- */
153
- restoreSession(): {
154
- success: boolean;
155
- userPub?: string;
156
- error?: string;
157
- };
158
- logout(): void;
159
- /**
160
- * Accesses the RxJS module for reactive programming
161
- * @returns GunRxJS instance
162
- */
163
- rx(): RxJS;
164
- /**
165
- * Validates password strength according to security requirements
166
- */
167
- private validatePasswordStrength;
168
- /**
169
- * Validates signup credentials with enhanced security
170
- */
171
- private validateSignupCredentials;
172
- /**
173
- * Creates a new user in Gun
174
- */
175
- private createNewUser;
176
- /**
177
- * Authenticates user after creation
178
- */
179
- private authenticateNewUser;
180
- /**
181
- * Signs up a new user using direct Gun authentication
182
- * @param username Username
183
- * @param password Password
184
- * @param pair Optional SEA pair for Web3 login
185
- * @returns Promise resolving to signup result
186
- */
187
- signUp(username: string, password: string, pair?: ISEAPair | null): Promise<SignUpResult>;
188
- /**
189
- * Creates a new user in Gun with pair-based authentication (for Web3/plugins)
190
- */
191
- private createNewUserWithPair;
192
- private runPostAuthOnAuthResult;
193
- /**
194
- * Sets up comprehensive user tracking system for agile user lookup
195
- * Creates multiple indexes for efficient user discovery
196
- */
197
- private setupComprehensiveUserTracking;
198
- /**
199
- * Creates alias index following GunDB pattern: ~@alias -> userPub
200
- */
201
- private createAliasIndex;
202
- /**
203
- * Creates username mapping: usernames/alias -> userPub
204
- */
205
- private createUsernameMapping;
206
- /**
207
- * Creates user registry: users/userPub -> user data
208
- */
209
- private createUserRegistry;
210
- /**
211
- * Creates reverse lookup: userPub -> alias
212
- */
213
- private createReverseLookup;
214
- /**
215
- * Creates epub index: epubKeys/epub -> userPub
216
- */
217
- private createEpubIndex;
218
- /**
219
- * Creates user metadata in user's own node
220
- */
221
- private createUserMetadata;
222
- /**
223
- * Gets user information by alias using the comprehensive tracking system
224
- * @param alias Username/alias to lookup
225
- * @returns Promise resolving to user information or null if not found
226
- */
227
- getUserByAlias(alias: string): Promise<{
228
- userPub: string;
229
- epub: string | null;
230
- username: string;
231
- registeredAt: number;
232
- lastSeen: number;
233
- } | null>;
234
- /**
235
- * Gets user information by public key
236
- * @param userPub User's public key
237
- * @returns Promise resolving to user information or null if not found
238
- */
239
- getUserDataByPub(userPub: string): Promise<{
240
- userPub: string;
241
- epub: string | null;
242
- username: string;
243
- registeredAt: number;
244
- lastSeen: number;
245
- } | null>;
246
- /**
247
- * Gets user public key by encryption public key (epub)
248
- * @param epub User's encryption public key
249
- * @returns Promise resolving to user public key or null if not found
250
- */
251
- getUserPubByEpub(epub: string): Promise<string | null>;
252
- /**
253
- * Gets user alias by public key
254
- * @param userPub User's public key
255
- * @returns Promise resolving to user alias or null if not found
256
- */
257
- getUserAliasByPub(userPub: string): Promise<string | null>;
258
- /**
259
- * Gets all registered users (for admin purposes)
260
- * @returns Promise resolving to array of user information
261
- */
262
- getAllRegisteredUsers(): Promise<Array<{
263
- userPub: string;
264
- epub: string | null;
265
- username: string;
266
- registeredAt: number;
267
- lastSeen: number;
268
- }>>;
269
- /**
270
- * Updates user's last seen timestamp
271
- * @param userPub User's public key
272
- */
273
- updateUserLastSeen(userPub: string): Promise<void>;
274
- /**
275
- * Performs authentication with Gun
276
- */
277
- private performAuthentication;
278
- /**
279
- * Builds login result object
280
- */
281
- private buildLoginResult;
282
- login(username: string, password: string, pair?: ISEAPair | null): Promise<AuthResult>;
283
- /**
284
- * Encrypts session data before storage
285
- */
286
- private encryptSessionData;
287
- /**
288
- * Decrypts session data from storage
289
- */
290
- private decryptSessionData;
291
- private saveCredentials;
292
- /**
293
- * Sets up security questions and password hint
294
- * @param username Username
295
- * @param password Current password
296
- * @param hint Password hint
297
- * @param securityQuestions Array of security questions
298
- * @param securityAnswers Array of answers to security questions
299
- * @returns Promise resolving with the operation result
300
- */
301
- setPasswordHintWithSecurity(username: string, password: string, hint: string, securityQuestions: string[], securityAnswers: string[]): Promise<{
302
- success: boolean;
303
- error?: string;
304
- }>;
305
- /**
306
- * Recovers password hint using security question answers
307
- * @param username Username
308
- * @param securityAnswers Array of answers to security questions
309
- * @returns Promise resolving with the password hint
310
- */
311
- forgotPassword(username: string, securityAnswers: string[]): Promise<{
312
- success: boolean;
313
- hint?: string;
314
- error?: string;
315
- }>;
316
- /**
317
- * Saves user data at the specified path
318
- * @param path Path to save the data (supports nested paths like "test/data/marco")
319
- * @param data Data to save
320
- * @returns Promise that resolves when the data is saved
321
- */
322
- putUserData(path: string, data: any): Promise<void>;
323
- /**
324
- * Gets user data from the specified path
325
- * @param path Path to get the data from (supports nested paths like "test/data/marco")
326
- * @returns Promise that resolves with the data
327
- */
328
- getUserData(path: string): Promise<any>;
329
- static Errors: typeof GunErrors;
330
- /**
331
- * Adds an event listener
332
- * @param event Event name
333
- * @param listener Event listener function
334
- */
335
- on(event: string | symbol, listener: EventListener): void;
336
- /**
337
- * Removes an event listener
338
- * @param event Event name
339
- * @param listener Event listener function
340
- */
341
- off(event: string | symbol, listener: EventListener): void;
342
- /**
343
- * Adds a one-time event listener
344
- * @param event Event name
345
- * @param listener Event listener function
346
- */
347
- once(event: string | symbol, listener: EventListener): void;
348
- /**
349
- * Emits an event
350
- * @param event Event name
351
- * @param data Event data
352
- */
353
- emit(event: string | symbol, data?: EventData): boolean;
354
- /**
355
- * Recall user session
356
- */
357
- recall(): void;
358
- /**
359
- * Leave user session
360
- */
361
- leave(): void;
362
- /**
363
- * Set user data
364
- */
365
- setUserData(data: any): void;
366
- /**
367
- * Set password hint
368
- */
369
- setPasswordHint(hint: string): void;
370
- /**
371
- * Get password hint
372
- */
373
- getPasswordHint(): string | null;
374
- /**
375
- * Save session to storage
376
- */
377
- saveSession(session: any): void;
378
- /**
379
- * Load session from storage
380
- */
381
- loadSession(): any;
382
- /**
383
- * Clear session
384
- */
385
- clearSession(): void;
386
- /**
387
- * Get app scope
388
- */
389
- getAppScope(): string;
390
- /**
391
- * Get user public key
392
- */
393
- getUserPub(): string | null;
394
- /**
395
- * Check if user is authenticated
396
- */
397
- isAuthenticated(): boolean;
398
- }
399
- declare const createGun: (config: any) => import("gun").IGunInstance<any>;
400
- export { Gun, DataBase, SEA, RxJS, crypto, GunErrors, derive, restrictedPut, createGun, };
401
- export default Gun;
402
- export type { IGunUserInstance, IGunInstance, IGunChain } from "gun/types";
403
- export type { GunDataEventData, GunPeerEventData };
404
- export type { DeriveOptions };
@@ -1,21 +0,0 @@
1
- export interface DeriveOptions {
2
- includeSecp256k1Bitcoin?: boolean;
3
- includeSecp256k1Ethereum?: boolean;
4
- includeP256?: boolean;
5
- }
6
- export default function (pwd: any, extra: any, options?: DeriveOptions): Promise<{
7
- pub: string;
8
- priv: string;
9
- epub: string;
10
- epriv: string;
11
- secp256k1Bitcoin: {
12
- privateKey: string;
13
- publicKey: string;
14
- address: string;
15
- };
16
- secp256k1Ethereum: {
17
- privateKey: string;
18
- publicKey: string;
19
- address: string;
20
- };
21
- }>;
@@ -1,42 +0,0 @@
1
- /**
2
- * Error classes for Gun and Auth
3
- */
4
- /**
5
- * Base error for Gun
6
- */
7
- export declare class GunError extends Error {
8
- constructor(message: string);
9
- }
10
- /**
11
- * Generic authentication error
12
- */
13
- export declare class AuthError extends GunError {
14
- constructor(message: string);
15
- }
16
- /**
17
- * Invalid credentials error
18
- */
19
- export declare class InvalidCredentials extends AuthError {
20
- constructor(message?: string);
21
- }
22
- /**
23
- * User already exists error
24
- */
25
- export declare class UserExists extends AuthError {
26
- constructor(message?: string);
27
- }
28
- /**
29
- * Timeout error
30
- */
31
- export declare class TimeoutError extends GunError {
32
- constructor(message?: string);
33
- }
34
- /**
35
- * Multiple authentication error
36
- */
37
- export declare class MultipleAuthError extends AuthError {
38
- constructor(message?: string);
39
- }
40
- /** Base error related to the network. */
41
- export declare class NetworkError extends GunError {
42
- }
@@ -1,3 +0,0 @@
1
- export * from "./db";
2
- export * from "./types";
3
- export * from "./simple-api";
@@ -1,15 +0,0 @@
1
- /**
2
- * Initialize the Gun headers module with Gun instance and optional token
3
- * @param Gun - Gun instance
4
- * @param token - Optional authentication token
5
- */
6
- export declare const restrictedPut: (Gun: any, token?: string) => void;
7
- /**
8
- * Set the authentication token for Gun requests
9
- * @param newToken - Token to set
10
- */
11
- export declare const setToken: (newToken: string) => string;
12
- /**
13
- * Get the current authentication token
14
- */
15
- export declare const getToken: () => string | undefined;
@@ -1,110 +0,0 @@
1
- import { Observable } from "rxjs";
2
- import { GunInstance, GunUserInstance } from "./types";
3
- /**
4
- * RxJS Integration for GunDB
5
- * Provides reactive programming capabilities for GunDB data
6
- */
7
- export declare class RxJS {
8
- private readonly gun;
9
- private readonly user;
10
- /**
11
- * Initialize GunRxJS with a GunDB instance
12
- * @param gun - GunDB instance
13
- */
14
- constructor(gun: GunInstance);
15
- /**
16
- * Get the current user
17
- * @returns The current user
18
- */
19
- getUser(): GunUserInstance;
20
- /**
21
- * Get the current user's public key
22
- * @returns The current user's public key
23
- */
24
- getUserPub(): string | undefined;
25
- /**
26
- * Observe a Gun node for changes
27
- * @param path - Path to observe (can be a string or a Gun chain)
28
- * @returns Observable that emits whenever the node changes
29
- */
30
- observe<T>(path: string | any): Observable<T>;
31
- /**
32
- * Match data based on Gun's '.map()' and convert to Observable
33
- * @param path - Path to the collection
34
- * @param matchFn - Optional function to filter results
35
- * @returns Observable array of matched items
36
- */
37
- match<T>(path: string | any, matchFn?: (data: any) => boolean): Observable<T[]>;
38
- /**
39
- * Put data and return an Observable
40
- * @param path - Path where to put the data
41
- * @param data - Data to put
42
- * @returns Observable that completes when the put is acknowledged
43
- */
44
- put<T>(path: string | any, data?: T): Observable<T>;
45
- /**
46
- * Backward-compatible overload that accepts optional callback like tests expect
47
- */
48
- putCompat<T extends Partial<any> & Record<string, any>>(data: T, callback?: (ack: any) => void): Observable<T>;
49
- /**
50
- * Set data on a node and return an Observable
51
- * @param path - Path to the collection
52
- * @param data - Data to set
53
- * @returns Observable that completes when the set is acknowledged
54
- */
55
- set<T>(path: string | any, data?: T): Observable<T>;
56
- setCompat<T>(data: T, callback?: (ack: any) => void): Observable<T>;
57
- /**
58
- * Get data once and return as Observable
59
- * @param path - Path to get data from
60
- * @returns Observable that emits the data once
61
- */
62
- once<T>(path?: string | any): Observable<T>;
63
- /**
64
- * Compute derived values from gun data
65
- * @param sources - Array of paths or observables to compute from
66
- * @param computeFn - Function that computes a new value from the sources
67
- * @returns Observable of computed values
68
- */
69
- compute<T, R>(sources: Array<string | Observable<any>>, computeFn: (...values: T[]) => R): Observable<R>;
70
- /**
71
- * User put data and return an Observable (for authenticated users)
72
- * @param path - Path where to put the data
73
- * @param data - Data to put
74
- * @returns Observable that completes when the put is acknowledged
75
- */
76
- userPut<T extends Partial<any> & Record<string, any>>(dataOrPath: string | T, maybeData?: T, callback?: (ack: any) => void): Observable<T>;
77
- /**
78
- * User set data and return an Observable (for authenticated users)
79
- * @param dataOrPath - Data to set or path where to set the data
80
- * @param maybeData - Data to set (if first parameter is path)
81
- * @param callback - Optional callback function
82
- * @returns Observable that completes when the set is acknowledged
83
- */
84
- userSet<T extends Partial<any> & Record<string, any>>(dataOrPath: string | T, maybeData?: T, callback?: (ack: any) => void): Observable<T>;
85
- /**
86
- * User once data and return an Observable (for authenticated users)
87
- * @param path - Optional path to get data from
88
- * @param callback - Optional callback function
89
- * @returns Observable that emits the data once
90
- */
91
- userOnce<T>(path?: string, callback?: (ack: any) => void): Observable<T>;
92
- /**
93
- * Get user data
94
- * @param path - Path to get data from
95
- * @returns Observable that emits the data once
96
- */
97
- userGet<T>(path: string): Observable<T>;
98
- /**
99
- * Observe user data
100
- * @param path - Path to observe in user space
101
- * @returns Observable that emits whenever the user data changes
102
- */
103
- observeUser<T>(path?: string): Observable<T>;
104
- /**
105
- * Remove Gun metadata from an object
106
- * @param obj - Object to clean
107
- * @returns Cleaned object without Gun metadata
108
- */
109
- private removeGunMeta;
110
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * Simplified API layer to reduce complexity for common use cases
3
- * Provides quick-start methods that wrap the full DataBase functionality
4
- */
5
- import { DataBase } from "./db";
6
- /**
7
- * Simple API wrapper that provides common operations with minimal complexity
8
- */
9
- export declare class SimpleGunAPI {
10
- private db;
11
- constructor(db: DataBase);
12
- /**
13
- * Quick data operations - simplified interface
14
- */
15
- get<T = unknown>(path: string): Promise<T | null>;
16
- put<T = unknown>(path: string, data: T): Promise<boolean>;
17
- set<T = unknown>(path: string, data: T): Promise<boolean>;
18
- remove(path: string): Promise<boolean>;
19
- /**
20
- * Quick authentication - simplified interface
21
- */
22
- login(username: string, password: string): Promise<{
23
- userPub: string;
24
- username: string;
25
- } | null>;
26
- signup(username: string, password: string): Promise<{
27
- userPub: string;
28
- username: string;
29
- } | null>;
30
- logout(): void;
31
- isLoggedIn(): boolean;
32
- /**
33
- * Quick user data operations - simplified interface
34
- */
35
- getUserData<T = unknown>(path: string): Promise<T | null>;
36
- putUserData<T = unknown>(path: string, data: T): Promise<boolean>;
37
- setUserData<T = unknown>(path: string, data: T): Promise<boolean>;
38
- removeUserData(path: string): Promise<boolean>;
39
- /**
40
- * Quick utility methods
41
- */
42
- getCurrentUser(): {
43
- pub: string;
44
- username?: string;
45
- } | null;
46
- userExists(alias: string): Promise<boolean>;
47
- getUser(alias: string): Promise<{
48
- userPub: string;
49
- username: string;
50
- } | null>;
51
- /**
52
- * Advanced user space operations
53
- */
54
- getAllUserData(): Promise<Record<string, unknown> | null>;
55
- updateProfile(profileData: {
56
- name?: string;
57
- email?: string;
58
- bio?: string;
59
- avatar?: string;
60
- [key: string]: unknown;
61
- }): Promise<boolean>;
62
- getProfile(): Promise<Record<string, unknown> | null>;
63
- saveSettings(settings: Record<string, unknown>): Promise<boolean>;
64
- getSettings(): Promise<Record<string, unknown> | null>;
65
- savePreferences(preferences: Record<string, unknown>): Promise<boolean>;
66
- getPreferences(): Promise<Record<string, unknown> | null>;
67
- createCollection<T = unknown>(collectionName: string, items: Record<string, T>): Promise<boolean>;
68
- addToCollection<T = unknown>(collectionName: string, itemId: string, item: T): Promise<boolean>;
69
- getCollection(collectionName: string): Promise<Record<string, unknown> | null>;
70
- removeFromCollection(collectionName: string, itemId: string): Promise<boolean>;
71
- }
72
- /**
73
- * Factory function to create a simple API instance
74
- */
75
- export declare function createSimpleAPI(db: DataBase): SimpleGunAPI;
76
- /**
77
- * Quick start helper - creates a simple API with minimal configuration
78
- */
79
- export declare class QuickStart {
80
- private db;
81
- private simpleAPI;
82
- constructor(gunInstance: any, appScope?: string);
83
- init(): Promise<void>;
84
- get api(): SimpleGunAPI;
85
- get database(): DataBase;
86
- }
87
- /**
88
- * Global helper for quick setup
89
- */
90
- export declare function quickStart(gunInstance: any, appScope?: string): QuickStart;