shogun-core 5.2.0 → 5.2.1
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/dist/browser/defaultVendors-node_modules_hpke_chacha20poly1305_esm_mod_js.shogun-core.js +1220 -0
- package/dist/browser/defaultVendors-node_modules_hpke_chacha20poly1305_esm_mod_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_hpke_hybridkem-x-wing_esm_mod_js.shogun-core.js +844 -0
- package/dist/browser/defaultVendors-node_modules_hpke_hybridkem-x-wing_esm_mod_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_mlkem_esm_mod_js.shogun-core.js +2335 -0
- package/dist/browser/defaultVendors-node_modules_mlkem_esm_mod_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_noble_ciphers_chacha_js.shogun-core.js +999 -0
- package/dist/browser/defaultVendors-node_modules_noble_ciphers_chacha_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js +1651 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_edwards_js-node_modules_noble_curves_es-a82056.shogun-core.js +825 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_edwards_js-node_modules_noble_curves_es-a82056.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed25519_js.shogun-core.js +508 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed25519_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js +747 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js +1608 -0
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_noble_post-quantum_ml-dsa_js.shogun-core.js +2117 -0
- package/dist/browser/defaultVendors-node_modules_noble_post-quantum_ml-dsa_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_openpgp_dist_openpgp_min_mjs.shogun-core.js +86 -0
- package/dist/browser/defaultVendors-node_modules_openpgp_dist_openpgp_min_mjs.shogun-core.js.map +1 -0
- package/dist/browser/node_modules_hpke_ml-kem_esm_mod_js.shogun-core.js +539 -0
- package/dist/browser/node_modules_hpke_ml-kem_esm_mod_js.shogun-core.js.map +1 -0
- package/dist/browser/shogun-core.js +160386 -0
- package/dist/browser/shogun-core.js.map +1 -0
- package/dist/config/simplified-config.js +236 -0
- package/dist/core.js +329 -0
- package/dist/crypto/asymmetric.js +99 -0
- package/dist/crypto/double-ratchet.js +370 -0
- package/dist/crypto/file-encryption.js +213 -0
- package/dist/crypto/hashing.js +87 -0
- package/dist/crypto/index.js +34 -0
- package/dist/crypto/mls-codec.js +202 -0
- package/dist/crypto/mls.js +550 -0
- package/dist/crypto/pgp.js +390 -0
- package/dist/crypto/random-generation.js +341 -0
- package/dist/crypto/sframe.js +350 -0
- package/dist/crypto/signal-protocol.js +376 -0
- package/dist/crypto/symmetric.js +91 -0
- package/dist/crypto/types.js +2 -0
- package/dist/crypto/utils.js +140 -0
- package/dist/examples/auth-test.js +253 -0
- package/dist/examples/crypto-identity-example.js +151 -0
- package/dist/examples/crypto-working-test.js +83 -0
- package/dist/examples/double-ratchet-test.js +155 -0
- package/dist/examples/mls-advanced-example.js +294 -0
- package/dist/examples/mls-sframe-test.js +304 -0
- package/dist/examples/pgp-example.js +200 -0
- package/dist/examples/quick-auth-test.js +61 -0
- package/dist/examples/random-generation-test.js +151 -0
- package/dist/examples/signal-protocol-test.js +38 -0
- package/dist/examples/simple-api-test.js +114 -0
- package/dist/examples/simple-crypto-identity-example.js +84 -0
- package/dist/examples/timeout-test.js +227 -0
- package/dist/examples/zkproof-credentials-example.js +212 -0
- package/dist/examples/zkproof-example.js +201 -0
- package/dist/gundb/api.js +435 -0
- package/dist/gundb/crypto.js +283 -0
- package/dist/gundb/db.js +1946 -0
- package/dist/gundb/derive.js +232 -0
- package/dist/gundb/errors.js +76 -0
- package/dist/gundb/index.js +22 -0
- package/dist/gundb/rxjs.js +447 -0
- package/dist/gundb/types.js +5 -0
- package/dist/index.js +58 -0
- package/dist/interfaces/common.js +2 -0
- package/dist/interfaces/events.js +40 -0
- package/dist/interfaces/plugin.js +2 -0
- package/dist/interfaces/shogun.js +37 -0
- package/dist/managers/AuthManager.js +226 -0
- package/dist/managers/CoreInitializer.js +228 -0
- package/dist/managers/CryptoIdentityManager.js +366 -0
- package/dist/managers/EventManager.js +70 -0
- package/dist/managers/PluginManager.js +299 -0
- package/dist/plugins/base.js +50 -0
- package/dist/plugins/index.js +32 -0
- package/dist/plugins/nostr/index.js +20 -0
- package/dist/plugins/nostr/nostrConnector.js +419 -0
- package/dist/plugins/nostr/nostrConnectorPlugin.js +453 -0
- package/dist/plugins/nostr/nostrSigner.js +319 -0
- package/dist/plugins/nostr/types.js +2 -0
- package/dist/plugins/smartwallet/index.js +18 -0
- package/dist/plugins/smartwallet/smartWalletPlugin.js +511 -0
- package/dist/plugins/smartwallet/types.js +2 -0
- package/dist/plugins/web3/index.js +20 -0
- package/dist/plugins/web3/types.js +2 -0
- package/dist/plugins/web3/web3Connector.js +533 -0
- package/dist/plugins/web3/web3ConnectorPlugin.js +455 -0
- package/dist/plugins/web3/web3Signer.js +314 -0
- package/dist/plugins/webauthn/index.js +19 -0
- package/dist/plugins/webauthn/types.js +14 -0
- package/dist/plugins/webauthn/webauthn.js +496 -0
- package/dist/plugins/webauthn/webauthnPlugin.js +489 -0
- package/dist/plugins/webauthn/webauthnSigner.js +310 -0
- package/dist/plugins/zkproof/index.js +53 -0
- package/dist/plugins/zkproof/types.js +2 -0
- package/dist/plugins/zkproof/zkCredentials.js +213 -0
- package/dist/plugins/zkproof/zkProofConnector.js +198 -0
- package/dist/plugins/zkproof/zkProofPlugin.js +272 -0
- package/dist/storage/storage.js +145 -0
- package/dist/types/config/simplified-config.d.ts +114 -0
- package/dist/types/core.d.ts +305 -0
- package/dist/types/crypto/asymmetric.d.ts +6 -0
- package/dist/types/crypto/double-ratchet.d.ts +22 -0
- package/dist/types/crypto/file-encryption.d.ts +19 -0
- package/dist/types/crypto/hashing.d.ts +9 -0
- package/dist/types/crypto/index.d.ts +13 -0
- package/dist/types/crypto/mls-codec.d.ts +39 -0
- package/dist/types/crypto/mls.d.ts +130 -0
- package/dist/types/crypto/pgp.d.ts +95 -0
- package/dist/types/crypto/random-generation.d.ts +35 -0
- package/dist/types/crypto/sframe.d.ts +102 -0
- package/dist/types/crypto/signal-protocol.d.ts +26 -0
- package/dist/types/crypto/symmetric.d.ts +9 -0
- package/dist/types/crypto/types.d.ts +144 -0
- package/dist/types/crypto/utils.d.ts +22 -0
- package/dist/types/examples/auth-test.d.ts +8 -0
- package/dist/types/examples/crypto-identity-example.d.ts +5 -0
- package/dist/types/examples/crypto-working-test.d.ts +1 -0
- package/dist/types/examples/double-ratchet-test.d.ts +1 -0
- package/dist/types/examples/mls-advanced-example.d.ts +53 -0
- package/dist/types/examples/mls-sframe-test.d.ts +1 -0
- package/dist/types/examples/pgp-example.d.ts +75 -0
- package/dist/types/examples/quick-auth-test.d.ts +8 -0
- package/dist/types/examples/random-generation-test.d.ts +1 -0
- package/dist/types/examples/signal-protocol-test.d.ts +1 -0
- package/dist/types/examples/simple-api-test.d.ts +10 -0
- package/dist/types/examples/simple-crypto-identity-example.d.ts +6 -0
- package/dist/types/examples/timeout-test.d.ts +8 -0
- package/dist/types/examples/zkproof-credentials-example.d.ts +12 -0
- package/dist/types/examples/zkproof-example.d.ts +11 -0
- package/dist/types/gundb/api.d.ts +185 -0
- package/dist/types/gundb/crypto.d.ts +95 -0
- package/dist/types/gundb/db.d.ts +397 -0
- package/dist/types/gundb/derive.d.ts +21 -0
- package/dist/types/gundb/errors.d.ts +42 -0
- package/dist/types/gundb/index.d.ts +3 -0
- package/dist/types/gundb/rxjs.d.ts +110 -0
- package/dist/types/gundb/types.d.ts +255 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/interfaces/common.d.ts +85 -0
- package/dist/types/interfaces/events.d.ts +131 -0
- package/dist/types/interfaces/plugin.d.ts +162 -0
- package/dist/types/interfaces/shogun.d.ts +208 -0
- package/dist/types/managers/AuthManager.d.ts +72 -0
- package/dist/types/managers/CoreInitializer.d.ts +40 -0
- package/dist/types/managers/CryptoIdentityManager.d.ts +102 -0
- package/dist/types/managers/EventManager.d.ts +49 -0
- package/dist/types/managers/PluginManager.d.ts +145 -0
- package/dist/types/plugins/base.d.ts +35 -0
- package/dist/types/plugins/index.d.ts +18 -0
- package/dist/types/plugins/nostr/index.d.ts +4 -0
- package/dist/types/plugins/nostr/nostrConnector.d.ts +119 -0
- package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +163 -0
- package/dist/types/plugins/nostr/nostrSigner.d.ts +105 -0
- package/dist/types/plugins/nostr/types.d.ts +122 -0
- package/dist/types/plugins/smartwallet/index.d.ts +2 -0
- package/dist/types/plugins/smartwallet/smartWalletPlugin.d.ts +67 -0
- package/dist/types/plugins/smartwallet/types.d.ts +80 -0
- package/dist/types/plugins/web3/index.d.ts +4 -0
- package/dist/types/plugins/web3/types.d.ts +107 -0
- package/dist/types/plugins/web3/web3Connector.d.ts +129 -0
- package/dist/types/plugins/web3/web3ConnectorPlugin.d.ts +160 -0
- package/dist/types/plugins/web3/web3Signer.d.ts +114 -0
- package/dist/types/plugins/webauthn/index.d.ts +3 -0
- package/dist/types/plugins/webauthn/types.d.ts +183 -0
- package/dist/types/plugins/webauthn/webauthn.d.ts +129 -0
- package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +179 -0
- package/dist/types/plugins/webauthn/webauthnSigner.d.ts +91 -0
- package/dist/types/plugins/zkproof/index.d.ts +48 -0
- package/dist/types/plugins/zkproof/types.d.ts +123 -0
- package/dist/types/plugins/zkproof/zkCredentials.d.ts +112 -0
- package/dist/types/plugins/zkproof/zkProofConnector.d.ts +46 -0
- package/dist/types/plugins/zkproof/zkProofPlugin.d.ts +76 -0
- package/dist/types/storage/storage.d.ts +51 -0
- package/dist/types/utils/errorHandler.d.ts +119 -0
- package/dist/types/utils/eventEmitter.d.ts +39 -0
- package/dist/types/utils/seedPhrase.d.ts +50 -0
- package/dist/types/utils/validation.d.ts +27 -0
- package/dist/utils/errorHandler.js +246 -0
- package/dist/utils/eventEmitter.js +79 -0
- package/dist/utils/seedPhrase.js +97 -0
- package/dist/utils/validation.js +81 -0
- package/package.json +10 -1
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { IGunInstance, IGunUserInstance } from "gun";
|
|
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: IGunInstance<any>);
|
|
15
|
+
/**
|
|
16
|
+
* Get the current user
|
|
17
|
+
* @returns The current user
|
|
18
|
+
*/
|
|
19
|
+
getUser(): IGunUserInstance<any>;
|
|
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
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for GunDB to replace 'any' usage
|
|
3
|
+
*/
|
|
4
|
+
export type GunType = (config?: any) => IGunInstance<any>;
|
|
5
|
+
export type SEAType = any;
|
|
6
|
+
export type GunUser = IGunUserInstance<any>;
|
|
7
|
+
export type UserInfo = {
|
|
8
|
+
pub: string;
|
|
9
|
+
epub?: string;
|
|
10
|
+
alias?: string;
|
|
11
|
+
user?: GunUser;
|
|
12
|
+
timestamp?: number;
|
|
13
|
+
};
|
|
14
|
+
export type AuthCallback = (user: GunUser) => void;
|
|
15
|
+
export type AuthResult = {
|
|
16
|
+
success: boolean;
|
|
17
|
+
userPub?: string;
|
|
18
|
+
error?: string;
|
|
19
|
+
ack?: any;
|
|
20
|
+
sea?: {
|
|
21
|
+
pub: string;
|
|
22
|
+
priv: string;
|
|
23
|
+
epub: string;
|
|
24
|
+
epriv: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type GunData = any;
|
|
28
|
+
export type GunNode = any;
|
|
29
|
+
export type GunCallback = any;
|
|
30
|
+
export type GunDataCallback = any;
|
|
31
|
+
export type GunMapCallback = any;
|
|
32
|
+
export interface UsernameLookupResult {
|
|
33
|
+
pub?: string;
|
|
34
|
+
userPub?: string;
|
|
35
|
+
username?: string;
|
|
36
|
+
source: string;
|
|
37
|
+
immutable: boolean;
|
|
38
|
+
hash?: string;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}
|
|
41
|
+
export interface UserMetadata {
|
|
42
|
+
username: string;
|
|
43
|
+
pub: string;
|
|
44
|
+
createdAt: number;
|
|
45
|
+
lastLogin: number;
|
|
46
|
+
}
|
|
47
|
+
export interface MappingData {
|
|
48
|
+
username: string;
|
|
49
|
+
userPub: string;
|
|
50
|
+
createdAt: number;
|
|
51
|
+
}
|
|
52
|
+
export interface SecurityData {
|
|
53
|
+
questions: string;
|
|
54
|
+
hint: string;
|
|
55
|
+
}
|
|
56
|
+
export interface FrozenData {
|
|
57
|
+
data: any;
|
|
58
|
+
timestamp: number;
|
|
59
|
+
description: string;
|
|
60
|
+
metadata: Record<string, any>;
|
|
61
|
+
}
|
|
62
|
+
export interface FrozenSpaceOptions {
|
|
63
|
+
namespace?: string;
|
|
64
|
+
path?: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
metadata?: Record<string, any>;
|
|
67
|
+
}
|
|
68
|
+
export interface ConnectivityTestResult {
|
|
69
|
+
peers: {
|
|
70
|
+
[peer: string]: {
|
|
71
|
+
connected: boolean;
|
|
72
|
+
status: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
gunInstance: boolean;
|
|
76
|
+
userInstance: boolean;
|
|
77
|
+
canWrite: boolean;
|
|
78
|
+
canRead: boolean;
|
|
79
|
+
testWriteResult?: any;
|
|
80
|
+
testReadResult?: any;
|
|
81
|
+
}
|
|
82
|
+
export interface LoginResult {
|
|
83
|
+
success: boolean;
|
|
84
|
+
userPub?: string;
|
|
85
|
+
username?: string;
|
|
86
|
+
error?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface SignupResult {
|
|
89
|
+
success: boolean;
|
|
90
|
+
userPub?: string;
|
|
91
|
+
username?: string;
|
|
92
|
+
message?: string;
|
|
93
|
+
error?: string;
|
|
94
|
+
sea?: {
|
|
95
|
+
pub: string;
|
|
96
|
+
priv: string;
|
|
97
|
+
epub: string;
|
|
98
|
+
epriv: string;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export interface PostAuthResult {
|
|
102
|
+
success: boolean;
|
|
103
|
+
userPub?: string;
|
|
104
|
+
username?: string;
|
|
105
|
+
error?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface PasswordHintResult {
|
|
108
|
+
success: boolean;
|
|
109
|
+
hint?: string;
|
|
110
|
+
error?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface P256Keys {
|
|
113
|
+
pub: string;
|
|
114
|
+
priv: string;
|
|
115
|
+
epub: string;
|
|
116
|
+
epriv: string;
|
|
117
|
+
}
|
|
118
|
+
export interface Secp256k1Keys {
|
|
119
|
+
pub: string;
|
|
120
|
+
priv: string;
|
|
121
|
+
address: string;
|
|
122
|
+
}
|
|
123
|
+
export interface DeriveResult {
|
|
124
|
+
p256?: P256Keys;
|
|
125
|
+
secp256k1Bitcoin?: Secp256k1Keys;
|
|
126
|
+
secp256k1Ethereum?: Secp256k1Keys;
|
|
127
|
+
}
|
|
128
|
+
export interface FrozenSpaceResult {
|
|
129
|
+
hash: string;
|
|
130
|
+
fullPath: string;
|
|
131
|
+
data: FrozenData;
|
|
132
|
+
}
|
|
133
|
+
export interface VerificationResult {
|
|
134
|
+
verified: boolean;
|
|
135
|
+
frozenData?: FrozenData;
|
|
136
|
+
error?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface SessionRestorationResult {
|
|
139
|
+
success: boolean;
|
|
140
|
+
userPub?: string;
|
|
141
|
+
error?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface UserExistenceResult {
|
|
144
|
+
exists: boolean;
|
|
145
|
+
userPub?: string;
|
|
146
|
+
error?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface UserCreationResult {
|
|
149
|
+
success: boolean;
|
|
150
|
+
pub?: string;
|
|
151
|
+
error?: string;
|
|
152
|
+
}
|
|
153
|
+
export type EventData = any;
|
|
154
|
+
export type EventListener = (data: EventData) => void;
|
|
155
|
+
export interface GunOperationResult {
|
|
156
|
+
success: boolean;
|
|
157
|
+
error?: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Improved type definitions to reduce 'any' usage while maintaining GunDB compatibility
|
|
161
|
+
*/
|
|
162
|
+
import type { IGunUserInstance, IGunInstance, ISEAPair } from "gun/types";
|
|
163
|
+
export interface GunAckCallback {
|
|
164
|
+
(ack: {
|
|
165
|
+
err?: string;
|
|
166
|
+
ok?: number;
|
|
167
|
+
pub?: string;
|
|
168
|
+
}): void;
|
|
169
|
+
}
|
|
170
|
+
export interface TypedGunOperationResult<T = unknown> {
|
|
171
|
+
success: boolean;
|
|
172
|
+
data?: T;
|
|
173
|
+
error?: string;
|
|
174
|
+
ack?: {
|
|
175
|
+
err?: string;
|
|
176
|
+
ok?: number;
|
|
177
|
+
pub?: string;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
export interface TypedAuthCallback {
|
|
181
|
+
(user: IGunUserInstance<any>): void;
|
|
182
|
+
}
|
|
183
|
+
export interface TypedAuthResult {
|
|
184
|
+
success: boolean;
|
|
185
|
+
userPub?: string;
|
|
186
|
+
username?: string;
|
|
187
|
+
error?: string;
|
|
188
|
+
ack?: {
|
|
189
|
+
err?: string;
|
|
190
|
+
ok?: number;
|
|
191
|
+
pub?: string;
|
|
192
|
+
sea?: ISEAPair;
|
|
193
|
+
};
|
|
194
|
+
sea?: ISEAPair;
|
|
195
|
+
}
|
|
196
|
+
export interface TypedGunConfig {
|
|
197
|
+
peers?: string[];
|
|
198
|
+
localStorage?: boolean;
|
|
199
|
+
radisk?: boolean;
|
|
200
|
+
file?: string;
|
|
201
|
+
uuid?: () => string;
|
|
202
|
+
[key: string]: unknown;
|
|
203
|
+
}
|
|
204
|
+
export interface TypedEventData {
|
|
205
|
+
type: string;
|
|
206
|
+
data: unknown;
|
|
207
|
+
timestamp: number;
|
|
208
|
+
source?: string;
|
|
209
|
+
}
|
|
210
|
+
export type GunPath = string | string[];
|
|
211
|
+
export interface PathOperation<T = unknown> {
|
|
212
|
+
path: GunPath;
|
|
213
|
+
data?: T;
|
|
214
|
+
callback?: GunAckCallback;
|
|
215
|
+
}
|
|
216
|
+
export interface TypedRxJSObservable<T = unknown> {
|
|
217
|
+
subscribe: (observer: {
|
|
218
|
+
next: (value: T) => void;
|
|
219
|
+
error?: (error: Error) => void;
|
|
220
|
+
complete?: () => void;
|
|
221
|
+
}) => {
|
|
222
|
+
unsubscribe: () => void;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
export interface TypedPluginConfig {
|
|
226
|
+
name: string;
|
|
227
|
+
version: string;
|
|
228
|
+
enabled: boolean;
|
|
229
|
+
config?: Record<string, unknown>;
|
|
230
|
+
}
|
|
231
|
+
export interface TypedStorageData {
|
|
232
|
+
key: string;
|
|
233
|
+
value: unknown;
|
|
234
|
+
timestamp: number;
|
|
235
|
+
ttl?: number;
|
|
236
|
+
}
|
|
237
|
+
export interface TypedGunError extends Error {
|
|
238
|
+
code?: string;
|
|
239
|
+
type: "GUN_ERROR" | "AUTH_ERROR" | "NETWORK_ERROR" | "VALIDATION_ERROR";
|
|
240
|
+
context?: Record<string, unknown>;
|
|
241
|
+
}
|
|
242
|
+
export type GunOperation = "get" | "put" | "set" | "remove" | "once" | "on" | "off";
|
|
243
|
+
export type GunAuthMethod = "password" | "pair" | "webauthn" | "web3" | "nostr" | "zkproof";
|
|
244
|
+
export interface TypedGunWrapper<T = Record<string, unknown>> {
|
|
245
|
+
gun: IGunInstance<any>;
|
|
246
|
+
user: IGunUserInstance | null;
|
|
247
|
+
get(path: GunPath): Promise<T>;
|
|
248
|
+
put(path: GunPath, data: T): Promise<TypedGunOperationResult<T>>;
|
|
249
|
+
set(path: GunPath, data: T): Promise<TypedGunOperationResult<T>>;
|
|
250
|
+
remove(path: GunPath): Promise<TypedGunOperationResult>;
|
|
251
|
+
getUserData(path: string): Promise<T>;
|
|
252
|
+
putUserData(path: string, data: T): Promise<void>;
|
|
253
|
+
login(username: string, password: string): Promise<TypedAuthResult>;
|
|
254
|
+
signUp(username: string, password: string): Promise<TypedAuthResult>;
|
|
255
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ShogunCore } from "./core";
|
|
2
|
+
import { IGunUserInstance, IGunInstance, GunDataEventData, GunPeerEventData, DeriveOptions } from "./gundb/db";
|
|
3
|
+
import { RxJS, crypto, derive, GunErrors, DataBase } from "./gundb/db";
|
|
4
|
+
import { SimpleGunAPI, QuickStart, quickStart, createSimpleAPI, TypedGunOperationResult, TypedAuthResult, AutoQuickStart, autoQuickStart } from "./gundb";
|
|
5
|
+
import { SEA } from "./gundb/db";
|
|
6
|
+
import Gun from "./gundb/db";
|
|
7
|
+
export * from "./utils/errorHandler";
|
|
8
|
+
export * from "./plugins";
|
|
9
|
+
export * from "./interfaces/shogun";
|
|
10
|
+
export * from "./config/simplified-config";
|
|
11
|
+
export type * from "./interfaces/plugin";
|
|
12
|
+
export type { IGunUserInstance, IGunInstance, GunDataEventData, GunPeerEventData, DeriveOptions, TypedGunOperationResult, TypedAuthResult, };
|
|
13
|
+
export { Gun, ShogunCore, SEA, RxJS, crypto, derive, GunErrors, DataBase, SimpleGunAPI, QuickStart, quickStart, createSimpleAPI, AutoQuickStart, autoQuickStart, };
|
|
14
|
+
export { generateSeedPhrase, validateSeedPhrase, mnemonicToSeed, seedToPassword, deriveCredentialsFromMnemonic, formatSeedPhrase, normalizeSeedPhrase, } from "./utils/seedPhrase";
|
|
15
|
+
export * from "./crypto";
|
|
16
|
+
export { CryptoIdentityManager } from "./managers/CryptoIdentityManager";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base event interface
|
|
3
|
+
*/
|
|
4
|
+
export interface BaseEvent {
|
|
5
|
+
type: string;
|
|
6
|
+
data: Record<string, unknown>;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Base configuration interface
|
|
11
|
+
*/
|
|
12
|
+
export interface BaseConfig {
|
|
13
|
+
timeout?: number;
|
|
14
|
+
maxRetries?: number;
|
|
15
|
+
retryDelay?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Base cache entry interface
|
|
19
|
+
*/
|
|
20
|
+
export interface BaseCacheEntry<T = unknown> {
|
|
21
|
+
timestamp: number;
|
|
22
|
+
data?: T;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Base operation result
|
|
26
|
+
*/
|
|
27
|
+
export interface BaseResult {
|
|
28
|
+
success: boolean;
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Base authentication result
|
|
33
|
+
*/
|
|
34
|
+
export interface BaseAuthResult extends BaseResult {
|
|
35
|
+
username?: string;
|
|
36
|
+
password?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Common log levels
|
|
40
|
+
*/
|
|
41
|
+
export type LogLevel = "info" | "error" | "debug" | "warn";
|
|
42
|
+
/**
|
|
43
|
+
* Base log message
|
|
44
|
+
*/
|
|
45
|
+
export interface BaseLogMessage {
|
|
46
|
+
timestamp: string;
|
|
47
|
+
level: LogLevel;
|
|
48
|
+
message: string;
|
|
49
|
+
data?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Base device info
|
|
53
|
+
*/
|
|
54
|
+
export interface BaseDeviceInfo {
|
|
55
|
+
deviceId: string;
|
|
56
|
+
timestamp: number;
|
|
57
|
+
name: string;
|
|
58
|
+
platform: string;
|
|
59
|
+
lastUsed?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Base backup options
|
|
63
|
+
*/
|
|
64
|
+
export interface BaseBackupOptions {
|
|
65
|
+
encryptionPassword?: string;
|
|
66
|
+
includeHistory?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Base import options
|
|
70
|
+
*/
|
|
71
|
+
export interface BaseImportOptions {
|
|
72
|
+
decryptionPassword?: string;
|
|
73
|
+
validateData?: boolean;
|
|
74
|
+
overwriteExisting?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Basic error information
|
|
78
|
+
*/
|
|
79
|
+
export interface ErrorInfo {
|
|
80
|
+
message: string;
|
|
81
|
+
code?: string;
|
|
82
|
+
name?: string;
|
|
83
|
+
stack?: string;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { EventEmitter } from "../utils/eventEmitter";
|
|
2
|
+
/**
|
|
3
|
+
* Interface representing authentication event data
|
|
4
|
+
* @interface AuthEventData
|
|
5
|
+
* @property {string} [userPub] - The user's public key (optional)
|
|
6
|
+
* @property {string} [username] - Optional username
|
|
7
|
+
* @property {"password" | "webauthn" | "web3" | "nostr" | "zkproof" | "pair" } method - Authentication method used
|
|
8
|
+
* @property {string} [provider] - Optional provider name
|
|
9
|
+
*/
|
|
10
|
+
export interface AuthEventData {
|
|
11
|
+
userPub?: string;
|
|
12
|
+
username?: string;
|
|
13
|
+
method: "password" | "webauthn" | "web3" | "nostr" | "zkproof" | "pair";
|
|
14
|
+
provider?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Interface representing wallet event data
|
|
18
|
+
* @interface WalletEventData
|
|
19
|
+
* @property {string} address - The wallet address
|
|
20
|
+
* @property {string} [path] - Optional derivation path
|
|
21
|
+
*/
|
|
22
|
+
export interface WalletEventData {
|
|
23
|
+
address: string;
|
|
24
|
+
path?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Interface representing error event data
|
|
28
|
+
* @interface ErrorEventData
|
|
29
|
+
* @property {string} action - Error action/code
|
|
30
|
+
* @property {string} message - Error message
|
|
31
|
+
* @property {string} type - Error type
|
|
32
|
+
* @property {unknown} [details] - Optional additional error details
|
|
33
|
+
*/
|
|
34
|
+
export interface ErrorEventData {
|
|
35
|
+
action: string;
|
|
36
|
+
message: string;
|
|
37
|
+
type: string;
|
|
38
|
+
details?: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Interface representing Gun data operation event data
|
|
42
|
+
* @interface GunDataEventData
|
|
43
|
+
* @property {string} path - The path where the operation occurred
|
|
44
|
+
* @property {any} [data] - The data involved in the operation
|
|
45
|
+
* @property {boolean} success - Whether the operation was successful
|
|
46
|
+
* @property {string} [error] - Error message if operation failed
|
|
47
|
+
* @property {number} timestamp - Timestamp of the operation
|
|
48
|
+
*/
|
|
49
|
+
export interface GunDataEventData {
|
|
50
|
+
path: string;
|
|
51
|
+
data?: any;
|
|
52
|
+
success: boolean;
|
|
53
|
+
error?: string;
|
|
54
|
+
timestamp: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Interface representing Gun peer event data
|
|
58
|
+
* @interface GunPeerEventData
|
|
59
|
+
* @property {string} peer - The peer URL
|
|
60
|
+
* @property {string} action - The action performed (add, remove, connect, disconnect)
|
|
61
|
+
* @property {number} timestamp - Timestamp of the event
|
|
62
|
+
*/
|
|
63
|
+
export interface GunPeerEventData {
|
|
64
|
+
peer: string;
|
|
65
|
+
action: "add" | "remove" | "connect" | "disconnect";
|
|
66
|
+
timestamp: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Type defining all available Shogun event listeners
|
|
70
|
+
*/
|
|
71
|
+
export type ShogunEventMap = {
|
|
72
|
+
"auth:login": AuthEventData;
|
|
73
|
+
"auth:logout": void;
|
|
74
|
+
"auth:signup": AuthEventData;
|
|
75
|
+
"auth:username_changed": {
|
|
76
|
+
oldUsername?: string;
|
|
77
|
+
newUsername?: string;
|
|
78
|
+
userPub?: string;
|
|
79
|
+
};
|
|
80
|
+
"wallet:created": WalletEventData;
|
|
81
|
+
"gun:put": GunDataEventData;
|
|
82
|
+
"gun:get": GunDataEventData;
|
|
83
|
+
"gun:set": GunDataEventData;
|
|
84
|
+
"gun:remove": GunDataEventData;
|
|
85
|
+
"gun:peer:add": GunPeerEventData;
|
|
86
|
+
"gun:peer:remove": GunPeerEventData;
|
|
87
|
+
"gun:peer:connect": GunPeerEventData;
|
|
88
|
+
"gun:peer:disconnect": GunPeerEventData;
|
|
89
|
+
"plugin:registered": {
|
|
90
|
+
name: string;
|
|
91
|
+
version?: string;
|
|
92
|
+
category?: string;
|
|
93
|
+
};
|
|
94
|
+
"plugin:unregistered": {
|
|
95
|
+
name: string;
|
|
96
|
+
};
|
|
97
|
+
debug: {
|
|
98
|
+
action: string;
|
|
99
|
+
[key: string]: any;
|
|
100
|
+
};
|
|
101
|
+
error: ErrorEventData;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Extended EventEmitter class with typed events for Shogun
|
|
105
|
+
* @class ShogunEventEmitter
|
|
106
|
+
* @extends EventEmitter
|
|
107
|
+
*/
|
|
108
|
+
export declare class ShogunEventEmitter extends EventEmitter<ShogunEventMap> {
|
|
109
|
+
/**
|
|
110
|
+
* Emit a typed Shogun event
|
|
111
|
+
* @template K - Event key type
|
|
112
|
+
* @param {K} event - Event name
|
|
113
|
+
* @param {ShogunEventMap[K]} data - Event data
|
|
114
|
+
* @returns {boolean} - Returns true if the event had listeners, false otherwise
|
|
115
|
+
*/
|
|
116
|
+
emit<K extends keyof ShogunEventMap>(event: K, data?: ShogunEventMap[K] extends void ? never : ShogunEventMap[K]): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Register a listener for a typed Shogun event
|
|
119
|
+
* @template K - Event key type
|
|
120
|
+
* @param {K} event - Event name
|
|
121
|
+
* @param {(data: ShogunEventMap[K]) => void} listener - Event listener function
|
|
122
|
+
*/
|
|
123
|
+
on<K extends keyof ShogunEventMap>(event: K, listener: ShogunEventMap[K] extends void ? () => void : (data: ShogunEventMap[K]) => void): void;
|
|
124
|
+
/**
|
|
125
|
+
* Remove a listener for a typed Shogun event
|
|
126
|
+
* @template K - Event key type
|
|
127
|
+
* @param {K} event - Event name
|
|
128
|
+
* @param {(data: ShogunEventMap[K]) => void} listener - Event listener function to remove
|
|
129
|
+
*/
|
|
130
|
+
off<K extends keyof ShogunEventMap>(event: K, listener: ShogunEventMap[K] extends void ? () => void : (data: ShogunEventMap[K]) => void): void;
|
|
131
|
+
}
|