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.
- package/package.json +1 -1
- package/dist/browser/shogun-core.js +0 -92128
- package/dist/browser/shogun-core.js.map +0 -1
- package/dist/config/simplified-config.js +0 -230
- package/dist/core.js +0 -338
- package/dist/gundb/crypto.js +0 -268
- package/dist/gundb/db.js +0 -1833
- package/dist/gundb/derive.js +0 -229
- package/dist/gundb/errors.js +0 -66
- package/dist/gundb/index.js +0 -6
- package/dist/gundb/restricted-put.js +0 -81
- package/dist/gundb/rxjs.js +0 -445
- package/dist/gundb/simple-api.js +0 -438
- package/dist/gundb/types.js +0 -4
- package/dist/index.js +0 -16
- package/dist/interfaces/common.js +0 -1
- package/dist/interfaces/events.js +0 -36
- package/dist/interfaces/plugin.js +0 -1
- package/dist/interfaces/shogun.js +0 -34
- package/dist/managers/AuthManager.js +0 -225
- package/dist/managers/CoreInitializer.js +0 -234
- package/dist/managers/EventManager.js +0 -67
- package/dist/managers/PluginManager.js +0 -296
- package/dist/migration-test.js +0 -91
- package/dist/plugins/base.js +0 -47
- package/dist/plugins/index.js +0 -15
- package/dist/plugins/nostr/index.js +0 -4
- package/dist/plugins/nostr/nostrConnector.js +0 -413
- package/dist/plugins/nostr/nostrConnectorPlugin.js +0 -446
- package/dist/plugins/nostr/nostrSigner.js +0 -313
- package/dist/plugins/nostr/types.js +0 -1
- package/dist/plugins/oauth/index.js +0 -3
- package/dist/plugins/oauth/oauthConnector.js +0 -753
- package/dist/plugins/oauth/oauthPlugin.js +0 -396
- package/dist/plugins/oauth/types.js +0 -1
- package/dist/plugins/web3/index.js +0 -4
- package/dist/plugins/web3/types.js +0 -1
- package/dist/plugins/web3/web3Connector.js +0 -528
- package/dist/plugins/web3/web3ConnectorPlugin.js +0 -448
- package/dist/plugins/web3/web3Signer.js +0 -308
- package/dist/plugins/webauthn/index.js +0 -3
- package/dist/plugins/webauthn/types.js +0 -11
- package/dist/plugins/webauthn/webauthn.js +0 -478
- package/dist/plugins/webauthn/webauthnPlugin.js +0 -398
- package/dist/plugins/webauthn/webauthnSigner.js +0 -304
- package/dist/storage/storage.js +0 -147
- package/dist/types/config/simplified-config.d.ts +0 -114
- package/dist/types/core.d.ts +0 -305
- package/dist/types/gundb/crypto.d.ts +0 -95
- package/dist/types/gundb/db.d.ts +0 -404
- package/dist/types/gundb/derive.d.ts +0 -21
- package/dist/types/gundb/errors.d.ts +0 -42
- package/dist/types/gundb/index.d.ts +0 -3
- package/dist/types/gundb/restricted-put.d.ts +0 -15
- package/dist/types/gundb/rxjs.d.ts +0 -110
- package/dist/types/gundb/simple-api.d.ts +0 -90
- package/dist/types/gundb/types.d.ts +0 -264
- package/dist/types/index.d.ts +0 -14
- package/dist/types/interfaces/common.d.ts +0 -85
- package/dist/types/interfaces/events.d.ts +0 -131
- package/dist/types/interfaces/plugin.d.ts +0 -162
- package/dist/types/interfaces/shogun.d.ts +0 -215
- package/dist/types/managers/AuthManager.d.ts +0 -72
- package/dist/types/managers/CoreInitializer.d.ts +0 -40
- package/dist/types/managers/EventManager.d.ts +0 -49
- package/dist/types/managers/PluginManager.d.ts +0 -145
- package/dist/types/migration-test.d.ts +0 -16
- package/dist/types/plugins/base.d.ts +0 -35
- package/dist/types/plugins/index.d.ts +0 -14
- package/dist/types/plugins/nostr/index.d.ts +0 -4
- package/dist/types/plugins/nostr/nostrConnector.d.ts +0 -119
- package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +0 -163
- package/dist/types/plugins/nostr/nostrSigner.d.ts +0 -105
- package/dist/types/plugins/nostr/types.d.ts +0 -122
- package/dist/types/plugins/oauth/index.d.ts +0 -3
- package/dist/types/plugins/oauth/oauthConnector.d.ts +0 -110
- package/dist/types/plugins/oauth/oauthPlugin.d.ts +0 -91
- package/dist/types/plugins/oauth/types.d.ts +0 -114
- package/dist/types/plugins/web3/index.d.ts +0 -4
- package/dist/types/plugins/web3/types.d.ts +0 -107
- package/dist/types/plugins/web3/web3Connector.d.ts +0 -129
- package/dist/types/plugins/web3/web3ConnectorPlugin.d.ts +0 -160
- package/dist/types/plugins/web3/web3Signer.d.ts +0 -114
- package/dist/types/plugins/webauthn/index.d.ts +0 -3
- package/dist/types/plugins/webauthn/types.d.ts +0 -162
- package/dist/types/plugins/webauthn/webauthn.d.ts +0 -129
- package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +0 -158
- package/dist/types/plugins/webauthn/webauthnSigner.d.ts +0 -91
- package/dist/types/storage/storage.d.ts +0 -50
- package/dist/types/utils/errorHandler.d.ts +0 -119
- package/dist/types/utils/eventEmitter.d.ts +0 -39
- package/dist/types/utils/validation.d.ts +0 -27
- package/dist/utils/errorHandler.js +0 -241
- package/dist/utils/eventEmitter.js +0 -76
- package/dist/utils/validation.js +0 -72
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { GunInstance, GunUserInstance } from "../gundb/types";
|
|
2
|
-
import { ISEAPair } from "gun";
|
|
3
|
-
import { ethers } from "ethers";
|
|
4
|
-
import { ShogunError } from "../utils/errorHandler";
|
|
5
|
-
import { DataBase } from "../gundb/db";
|
|
6
|
-
import { RxJS } from "../gundb/rxjs";
|
|
7
|
-
import { ShogunPlugin, PluginManager } from "./plugin";
|
|
8
|
-
import { ShogunStorage } from "../storage/storage";
|
|
9
|
-
import { ShogunEventMap } from "./events";
|
|
10
|
-
/**
|
|
11
|
-
* Standard plugin categories in ShogunCore
|
|
12
|
-
*/
|
|
13
|
-
export declare enum PluginCategory {
|
|
14
|
-
/** Authentication plugins (WebAuthn, MetaMask, Bitcoin) */
|
|
15
|
-
Authentication = "authentication",
|
|
16
|
-
/** Wallet management plugins */
|
|
17
|
-
Wallet = "wallet",
|
|
18
|
-
/** Privacy and anonymity plugins */
|
|
19
|
-
Privacy = "privacy",
|
|
20
|
-
/** Decentralized identity plugins */
|
|
21
|
-
Identity = "identity",
|
|
22
|
-
/** Other utility plugins */
|
|
23
|
-
Utility = "utility",
|
|
24
|
-
/** Messages plugins */
|
|
25
|
-
Messages = "messages",
|
|
26
|
-
/** Messaging plugins */
|
|
27
|
-
Other = "other"
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Standard names for built-in plugins
|
|
31
|
-
*/
|
|
32
|
-
export declare enum CorePlugins {
|
|
33
|
-
/** WebAuthn plugin */
|
|
34
|
-
WebAuthn = "webauthn",
|
|
35
|
-
/** Ethereum plugin */
|
|
36
|
-
Web3 = "web3",
|
|
37
|
-
/** Bitcoin wallet plugin */
|
|
38
|
-
Nostr = "nostr",
|
|
39
|
-
/** OAuth plugin */
|
|
40
|
-
OAuth = "oauth"
|
|
41
|
-
}
|
|
42
|
-
export type AuthMethod = "password" | "webauthn" | "web3" | "nostr" | "oauth" | "pair";
|
|
43
|
-
export interface AuthResult {
|
|
44
|
-
success: boolean;
|
|
45
|
-
error?: string;
|
|
46
|
-
userPub?: string;
|
|
47
|
-
username?: string;
|
|
48
|
-
sessionToken?: string;
|
|
49
|
-
authMethod?: AuthMethod;
|
|
50
|
-
sea?: {
|
|
51
|
-
pub: string;
|
|
52
|
-
priv: string;
|
|
53
|
-
epub: string;
|
|
54
|
-
epriv: string;
|
|
55
|
-
};
|
|
56
|
-
redirectUrl?: string;
|
|
57
|
-
pendingAuth?: boolean;
|
|
58
|
-
message?: string;
|
|
59
|
-
provider?: string;
|
|
60
|
-
isNewUser?: boolean;
|
|
61
|
-
user?: {
|
|
62
|
-
userPub?: string;
|
|
63
|
-
username?: string;
|
|
64
|
-
email?: string;
|
|
65
|
-
name?: string;
|
|
66
|
-
picture?: string;
|
|
67
|
-
oauth?: {
|
|
68
|
-
provider: string;
|
|
69
|
-
id: string;
|
|
70
|
-
email?: string;
|
|
71
|
-
name?: string;
|
|
72
|
-
picture?: string;
|
|
73
|
-
lastLogin: number;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Sign up result interface
|
|
79
|
-
*/
|
|
80
|
-
export interface SignUpResult {
|
|
81
|
-
success: boolean;
|
|
82
|
-
userPub?: string;
|
|
83
|
-
username?: string;
|
|
84
|
-
pub?: string;
|
|
85
|
-
error?: string;
|
|
86
|
-
message?: string;
|
|
87
|
-
wallet?: any;
|
|
88
|
-
isNewUser?: boolean;
|
|
89
|
-
authMethod?: AuthMethod;
|
|
90
|
-
sessionToken?: string;
|
|
91
|
-
sea?: {
|
|
92
|
-
pub: string;
|
|
93
|
-
priv: string;
|
|
94
|
-
epub: string;
|
|
95
|
-
epriv: string;
|
|
96
|
-
};
|
|
97
|
-
redirectUrl?: string;
|
|
98
|
-
pendingAuth?: boolean;
|
|
99
|
-
provider?: string;
|
|
100
|
-
user?: {
|
|
101
|
-
userPub?: string;
|
|
102
|
-
username?: string;
|
|
103
|
-
email?: string;
|
|
104
|
-
name?: string;
|
|
105
|
-
picture?: string;
|
|
106
|
-
oauth?: {
|
|
107
|
-
provider: string;
|
|
108
|
-
id: string;
|
|
109
|
-
email?: string;
|
|
110
|
-
name?: string;
|
|
111
|
-
picture?: string;
|
|
112
|
-
lastLogin: number;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
export interface IShogunCore extends PluginManager {
|
|
117
|
-
gun: GunInstance;
|
|
118
|
-
_gun: GunInstance;
|
|
119
|
-
user: GunUserInstance | null;
|
|
120
|
-
_user: GunUserInstance | null;
|
|
121
|
-
db: DataBase;
|
|
122
|
-
rx: RxJS;
|
|
123
|
-
storage: ShogunStorage;
|
|
124
|
-
config: ShogunCoreConfig;
|
|
125
|
-
provider?: ethers.Provider;
|
|
126
|
-
signer?: ethers.Signer;
|
|
127
|
-
wallets?: Wallets;
|
|
128
|
-
pluginManager: any;
|
|
129
|
-
on<K extends keyof ShogunEventMap>(eventName: K, listener: ShogunEventMap[K] extends void ? () => void : (data: ShogunEventMap[K]) => void): this;
|
|
130
|
-
off<K extends keyof ShogunEventMap>(eventName: K, listener: ShogunEventMap[K] extends void ? () => void : (data: ShogunEventMap[K]) => void): this;
|
|
131
|
-
once<K extends keyof ShogunEventMap>(eventName: K, listener: ShogunEventMap[K] extends void ? () => void : (data: ShogunEventMap[K]) => void): this;
|
|
132
|
-
removeAllListeners(eventName?: string | symbol): this;
|
|
133
|
-
emit<K extends keyof ShogunEventMap>(eventName: K, data?: ShogunEventMap[K] extends void ? never : ShogunEventMap[K]): boolean;
|
|
134
|
-
getRecentErrors(count?: number): ShogunError[];
|
|
135
|
-
login(username: string, password: string, pair?: ISEAPair | null): Promise<AuthResult>;
|
|
136
|
-
loginWithPair(pair: ISEAPair): Promise<AuthResult>;
|
|
137
|
-
signUp(username: string, password?: string, pair?: ISEAPair | null): Promise<SignUpResult>;
|
|
138
|
-
getAuthenticationMethod(type: AuthMethod): any;
|
|
139
|
-
setAuthMethod(method: AuthMethod): void;
|
|
140
|
-
getAuthMethod(): AuthMethod | undefined;
|
|
141
|
-
getCurrentUser(): {
|
|
142
|
-
pub: string;
|
|
143
|
-
user?: any;
|
|
144
|
-
} | null;
|
|
145
|
-
getIsLoggedIn(): boolean;
|
|
146
|
-
logout(): void;
|
|
147
|
-
isLoggedIn(): boolean;
|
|
148
|
-
saveCredentials(credentials: any): Promise<void>;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* WebAuthn configuration
|
|
152
|
-
*/
|
|
153
|
-
export interface WebauthnConfig {
|
|
154
|
-
/** Enable WebAuthn */
|
|
155
|
-
enabled?: boolean;
|
|
156
|
-
/** Relying party name */
|
|
157
|
-
rpName?: string;
|
|
158
|
-
/** Relying party ID */
|
|
159
|
-
rpId?: string;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Shogun SDK configuration
|
|
163
|
-
*/
|
|
164
|
-
export interface ShogunCoreConfig {
|
|
165
|
-
gunInstance?: GunInstance;
|
|
166
|
-
gunOptions?: any;
|
|
167
|
-
webauthn?: WebauthnConfig;
|
|
168
|
-
web3?: {
|
|
169
|
-
enabled?: boolean;
|
|
170
|
-
};
|
|
171
|
-
nostr?: {
|
|
172
|
-
enabled?: boolean;
|
|
173
|
-
};
|
|
174
|
-
oauth?: {
|
|
175
|
-
enabled?: boolean;
|
|
176
|
-
usePKCE?: boolean;
|
|
177
|
-
allowUnsafeClientSecret?: boolean;
|
|
178
|
-
providers?: Record<string, any>;
|
|
179
|
-
};
|
|
180
|
-
timeouts?: {
|
|
181
|
-
login?: number;
|
|
182
|
-
signup?: number;
|
|
183
|
-
operation?: number;
|
|
184
|
-
};
|
|
185
|
-
plugins?: {
|
|
186
|
-
autoRegister?: ShogunPlugin[];
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
export interface ShogunEvents {
|
|
190
|
-
error: (data: {
|
|
191
|
-
action: string;
|
|
192
|
-
message: string;
|
|
193
|
-
}) => void;
|
|
194
|
-
"auth:signup": (data: {
|
|
195
|
-
username: string;
|
|
196
|
-
userPub: string;
|
|
197
|
-
}) => void;
|
|
198
|
-
"auth:login": (data: {
|
|
199
|
-
username: string;
|
|
200
|
-
userPub: string;
|
|
201
|
-
}) => void;
|
|
202
|
-
"auth:logout": (data: Record<string, never>) => void;
|
|
203
|
-
}
|
|
204
|
-
export interface Wallets {
|
|
205
|
-
secp256k1Bitcoin: {
|
|
206
|
-
privateKey: string;
|
|
207
|
-
publicKey: string;
|
|
208
|
-
address: string;
|
|
209
|
-
};
|
|
210
|
-
secp256k1Ethereum: {
|
|
211
|
-
privateKey: string;
|
|
212
|
-
publicKey: string;
|
|
213
|
-
address: string;
|
|
214
|
-
};
|
|
215
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { IShogunCore, AuthResult, SignUpResult, AuthMethod } from "../interfaces/shogun";
|
|
2
|
-
import { ISEAPair } from "gun";
|
|
3
|
-
/**
|
|
4
|
-
* Manages authentication operations for ShogunCore
|
|
5
|
-
*/
|
|
6
|
-
export declare class AuthManager {
|
|
7
|
-
private core;
|
|
8
|
-
private currentAuthMethod?;
|
|
9
|
-
constructor(core: IShogunCore);
|
|
10
|
-
/**
|
|
11
|
-
* Check if user is logged in
|
|
12
|
-
* @returns {boolean} True if user is logged in, false otherwise
|
|
13
|
-
* @description Verifies authentication status by checking GunInstance login state
|
|
14
|
-
* and presence of authentication credentials in storage
|
|
15
|
-
*/
|
|
16
|
-
isLoggedIn(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Perform user logout
|
|
19
|
-
* @description Logs out the current user from GunInstance and emits logout event.
|
|
20
|
-
* If user is not authenticated, the logout operation is ignored.
|
|
21
|
-
*/
|
|
22
|
-
logout(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Authenticate user with username and password
|
|
25
|
-
* @param username - Username
|
|
26
|
-
* @param password - User password
|
|
27
|
-
* @returns {Promise<AuthResult>} Promise with authentication result
|
|
28
|
-
* @description Attempts to log in user with provided credentials.
|
|
29
|
-
* Emits login event on success.
|
|
30
|
-
*/
|
|
31
|
-
login(username: string, password: string, pair?: ISEAPair | null): Promise<AuthResult>;
|
|
32
|
-
/**
|
|
33
|
-
* Login with GunDB pair directly
|
|
34
|
-
* @param pair - GunDB SEA pair for authentication
|
|
35
|
-
* @returns {Promise<AuthResult>} Promise with authentication result
|
|
36
|
-
* @description Authenticates user using a GunDB pair directly.
|
|
37
|
-
* Emits login event on success.
|
|
38
|
-
*/
|
|
39
|
-
loginWithPair(pair: ISEAPair): Promise<AuthResult>;
|
|
40
|
-
/**
|
|
41
|
-
* Register a new user with provided credentials
|
|
42
|
-
* @param username - Username
|
|
43
|
-
* @param password - Password
|
|
44
|
-
* @param email - Email (optional)
|
|
45
|
-
* @param pair - Pair of keys
|
|
46
|
-
* @returns {Promise<SignUpResult>} Registration result
|
|
47
|
-
* @description Creates a new user account with the provided credentials.
|
|
48
|
-
* Validates password requirements and emits signup event on success.
|
|
49
|
-
*/
|
|
50
|
-
signUp(username: string, password?: string, pair?: ISEAPair | null): Promise<SignUpResult>;
|
|
51
|
-
/**
|
|
52
|
-
* Set the current authentication method
|
|
53
|
-
* This is used by plugins to indicate which authentication method was used
|
|
54
|
-
* @param method The authentication method used
|
|
55
|
-
*/
|
|
56
|
-
setAuthMethod(method: AuthMethod): void;
|
|
57
|
-
/**
|
|
58
|
-
* Get the current authentication method
|
|
59
|
-
* @returns The current authentication method or undefined if not set
|
|
60
|
-
*/
|
|
61
|
-
getAuthMethod(): AuthMethod | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Get an authentication method plugin by type
|
|
64
|
-
* @param type The type of authentication method
|
|
65
|
-
* @returns The authentication plugin or undefined if not available
|
|
66
|
-
* This is a more modern approach to accessing authentication methods
|
|
67
|
-
*/
|
|
68
|
-
getAuthenticationMethod(type: AuthMethod): import("..").ShogunPlugin | {
|
|
69
|
-
login: (username: string, password: string) => Promise<AuthResult>;
|
|
70
|
-
signUp: (username: string, password: string, confirm?: string) => Promise<SignUpResult>;
|
|
71
|
-
} | undefined;
|
|
72
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IShogunCore, ShogunCoreConfig } from "../interfaces/shogun";
|
|
2
|
-
/**
|
|
3
|
-
* Handles initialization of ShogunCore components
|
|
4
|
-
*/
|
|
5
|
-
export declare class CoreInitializer {
|
|
6
|
-
private core;
|
|
7
|
-
constructor(core: IShogunCore);
|
|
8
|
-
/**
|
|
9
|
-
* Initialize the Shogun SDK
|
|
10
|
-
* @param config - SDK Configuration object
|
|
11
|
-
* @description Creates a new instance of ShogunCore with the provided configuration.
|
|
12
|
-
* Initializes all required components including storage, event emitter, GunInstance connection,
|
|
13
|
-
* and plugin system.
|
|
14
|
-
*/
|
|
15
|
-
initialize(config: ShogunCoreConfig): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Initialize Gun instance
|
|
18
|
-
*/
|
|
19
|
-
private initializeGun;
|
|
20
|
-
/**
|
|
21
|
-
* Initialize Gun user
|
|
22
|
-
*/
|
|
23
|
-
private initializeGunUser;
|
|
24
|
-
/**
|
|
25
|
-
* Setup Gun event forwarding
|
|
26
|
-
*/
|
|
27
|
-
private setupGunEventForwarding;
|
|
28
|
-
/**
|
|
29
|
-
* Setup wallet derivation
|
|
30
|
-
*/
|
|
31
|
-
private setupWalletDerivation;
|
|
32
|
-
/**
|
|
33
|
-
* Register built-in plugins based on configuration
|
|
34
|
-
*/
|
|
35
|
-
private registerBuiltinPlugins;
|
|
36
|
-
/**
|
|
37
|
-
* Initialize async components
|
|
38
|
-
*/
|
|
39
|
-
private initializeAsync;
|
|
40
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ShogunEventEmitter, ShogunEventMap } from "../interfaces/events";
|
|
2
|
-
/**
|
|
3
|
-
* Manages event operations for ShogunCore
|
|
4
|
-
*/
|
|
5
|
-
export declare class EventManager {
|
|
6
|
-
private eventEmitter;
|
|
7
|
-
constructor();
|
|
8
|
-
/**
|
|
9
|
-
* Emits an event through the core's event emitter.
|
|
10
|
-
* Plugins should use this method to emit events instead of accessing the private eventEmitter directly.
|
|
11
|
-
* @param eventName The name of the event to emit.
|
|
12
|
-
* @param data The data to pass with the event.
|
|
13
|
-
* @returns {boolean} Indicates if the event had listeners.
|
|
14
|
-
*/
|
|
15
|
-
emit<K extends keyof ShogunEventMap>(eventName: K, data?: ShogunEventMap[K] extends void ? never : ShogunEventMap[K]): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Add an event listener
|
|
18
|
-
* @param eventName The name of the event to listen for
|
|
19
|
-
* @param listener The callback function to execute when the event is emitted
|
|
20
|
-
* @returns {this} Returns this instance for method chaining
|
|
21
|
-
*/
|
|
22
|
-
on<K extends keyof ShogunEventMap>(eventName: K, listener: ShogunEventMap[K] extends void ? () => void : (data: ShogunEventMap[K]) => void): this;
|
|
23
|
-
/**
|
|
24
|
-
* Add a one-time event listener
|
|
25
|
-
* @param eventName The name of the event to listen for
|
|
26
|
-
* @param listener The callback function to execute when the event is emitted
|
|
27
|
-
* @returns {this} Returns this instance for method chaining
|
|
28
|
-
*/
|
|
29
|
-
once<K extends keyof ShogunEventMap>(eventName: K, listener: ShogunEventMap[K] extends void ? () => void : (data: ShogunEventMap[K]) => void): this;
|
|
30
|
-
/**
|
|
31
|
-
* Remove an event listener
|
|
32
|
-
* @param eventName The name of the event to stop listening for
|
|
33
|
-
* @param listener The callback function to remove
|
|
34
|
-
* @returns {this} Returns this instance for method chaining
|
|
35
|
-
*/
|
|
36
|
-
off<K extends keyof ShogunEventMap>(eventName: K, listener: ShogunEventMap[K] extends void ? () => void : (data: ShogunEventMap[K]) => void): this;
|
|
37
|
-
/**
|
|
38
|
-
* Remove all listeners for a specific event or all events
|
|
39
|
-
* @param eventName Optional. The name of the event to remove listeners for.
|
|
40
|
-
* If not provided, all listeners for all events are removed.
|
|
41
|
-
* @returns {this} Returns this instance for method chaining
|
|
42
|
-
*/
|
|
43
|
-
removeAllListeners(eventName?: string | symbol): this;
|
|
44
|
-
/**
|
|
45
|
-
* Get the underlying event emitter instance
|
|
46
|
-
* @returns The ShogunEventEmitter instance
|
|
47
|
-
*/
|
|
48
|
-
getEventEmitter(): ShogunEventEmitter;
|
|
49
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { ShogunPlugin } from "../interfaces/plugin";
|
|
2
|
-
import { PluginCategory } from "../interfaces/shogun";
|
|
3
|
-
import { IShogunCore } from "../interfaces/shogun";
|
|
4
|
-
/**
|
|
5
|
-
* Manages plugin registration, validation, and lifecycle
|
|
6
|
-
*/
|
|
7
|
-
export declare class PluginManager {
|
|
8
|
-
private plugins;
|
|
9
|
-
private core;
|
|
10
|
-
constructor(core: IShogunCore);
|
|
11
|
-
/**
|
|
12
|
-
* Register a plugin with the Shogun SDK
|
|
13
|
-
* @param plugin Plugin instance to register
|
|
14
|
-
* @throws Error if a plugin with the same name is already registered
|
|
15
|
-
*/
|
|
16
|
-
register(plugin: ShogunPlugin): void;
|
|
17
|
-
/**
|
|
18
|
-
* Unregister a plugin from the Shogun SDK
|
|
19
|
-
* @param name Name of the plugin to unregister
|
|
20
|
-
*/
|
|
21
|
-
unregister(name: string): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Retrieve a registered plugin by name
|
|
24
|
-
* @param name Name of the plugin
|
|
25
|
-
* @returns The requested plugin or undefined if not found
|
|
26
|
-
* @template T Type of the plugin or its public interface
|
|
27
|
-
*/
|
|
28
|
-
getPlugin<T = ShogunPlugin>(name: string): T | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Get information about all registered plugins
|
|
31
|
-
* @returns Array of plugin information objects
|
|
32
|
-
*/
|
|
33
|
-
getPluginsInfo(): Array<{
|
|
34
|
-
name: string;
|
|
35
|
-
version: string;
|
|
36
|
-
category?: PluginCategory;
|
|
37
|
-
description?: string;
|
|
38
|
-
}>;
|
|
39
|
-
/**
|
|
40
|
-
* Get the total number of registered plugins
|
|
41
|
-
* @returns Number of registered plugins
|
|
42
|
-
*/
|
|
43
|
-
getPluginCount(): number;
|
|
44
|
-
/**
|
|
45
|
-
* Check if all plugins are properly initialized
|
|
46
|
-
* @returns Object with initialization status for each plugin
|
|
47
|
-
*/
|
|
48
|
-
getPluginsInitializationStatus(): Record<string, {
|
|
49
|
-
initialized: boolean;
|
|
50
|
-
error?: string;
|
|
51
|
-
}>;
|
|
52
|
-
/**
|
|
53
|
-
* Validate plugin system integrity
|
|
54
|
-
* @returns Object with validation results
|
|
55
|
-
*/
|
|
56
|
-
validatePluginSystem(): {
|
|
57
|
-
totalPlugins: number;
|
|
58
|
-
initializedPlugins: number;
|
|
59
|
-
failedPlugins: string[];
|
|
60
|
-
warnings: string[];
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Attempt to reinitialize failed plugins
|
|
64
|
-
* @returns Object with reinitialization results
|
|
65
|
-
*/
|
|
66
|
-
reinitializeFailedPlugins(): {
|
|
67
|
-
success: string[];
|
|
68
|
-
failed: Array<{
|
|
69
|
-
name: string;
|
|
70
|
-
error: string;
|
|
71
|
-
}>;
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Check plugin compatibility with current ShogunCore version
|
|
75
|
-
* @returns Object with compatibility information
|
|
76
|
-
*/
|
|
77
|
-
checkPluginCompatibility(): {
|
|
78
|
-
compatible: Array<{
|
|
79
|
-
name: string;
|
|
80
|
-
version: string;
|
|
81
|
-
}>;
|
|
82
|
-
incompatible: Array<{
|
|
83
|
-
name: string;
|
|
84
|
-
version: string;
|
|
85
|
-
reason: string;
|
|
86
|
-
}>;
|
|
87
|
-
unknown: Array<{
|
|
88
|
-
name: string;
|
|
89
|
-
version: string;
|
|
90
|
-
}>;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Get comprehensive debug information about the plugin system
|
|
94
|
-
* @returns Complete plugin system debug information
|
|
95
|
-
*/
|
|
96
|
-
getPluginSystemDebugInfo(): {
|
|
97
|
-
shogunCoreVersion: string;
|
|
98
|
-
totalPlugins: number;
|
|
99
|
-
plugins: Array<{
|
|
100
|
-
name: string;
|
|
101
|
-
version: string;
|
|
102
|
-
category?: PluginCategory;
|
|
103
|
-
description?: string;
|
|
104
|
-
initialized: boolean;
|
|
105
|
-
error?: string;
|
|
106
|
-
}>;
|
|
107
|
-
initializationStatus: Record<string, {
|
|
108
|
-
initialized: boolean;
|
|
109
|
-
error?: string;
|
|
110
|
-
}>;
|
|
111
|
-
validation: {
|
|
112
|
-
totalPlugins: number;
|
|
113
|
-
initializedPlugins: number;
|
|
114
|
-
failedPlugins: string[];
|
|
115
|
-
warnings: string[];
|
|
116
|
-
};
|
|
117
|
-
compatibility: {
|
|
118
|
-
compatible: Array<{
|
|
119
|
-
name: string;
|
|
120
|
-
version: string;
|
|
121
|
-
}>;
|
|
122
|
-
incompatible: Array<{
|
|
123
|
-
name: string;
|
|
124
|
-
version: string;
|
|
125
|
-
reason: string;
|
|
126
|
-
}>;
|
|
127
|
-
unknown: Array<{
|
|
128
|
-
name: string;
|
|
129
|
-
version: string;
|
|
130
|
-
}>;
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Check if a plugin is registered
|
|
135
|
-
* @param name Name of the plugin to check
|
|
136
|
-
* @returns true if the plugin is registered, false otherwise
|
|
137
|
-
*/
|
|
138
|
-
hasPlugin(name: string): boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Get all plugins of a specific category
|
|
141
|
-
* @param category Category of plugins to filter
|
|
142
|
-
* @returns Array of plugins in the specified category
|
|
143
|
-
*/
|
|
144
|
-
getPluginsByCategory(category: PluginCategory): ShogunPlugin[];
|
|
145
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Migration test file to verify that the refactored ShogunCore
|
|
3
|
-
* maintains the same public API as the original implementation
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Test function to verify API compatibility
|
|
7
|
-
*/
|
|
8
|
-
export declare function testApiCompatibility(): void;
|
|
9
|
-
/**
|
|
10
|
-
* Test that the refactored implementation maintains the same static properties
|
|
11
|
-
*/
|
|
12
|
-
export declare function testStaticProperties(): void;
|
|
13
|
-
/**
|
|
14
|
-
* Run all compatibility tests
|
|
15
|
-
*/
|
|
16
|
-
export declare function runCompatibilityTests(): void;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ShogunCore } from "../core";
|
|
2
|
-
import { ShogunPlugin } from "../interfaces/plugin";
|
|
3
|
-
import { PluginCategory } from "../interfaces/shogun";
|
|
4
|
-
import { EventEmitter } from "../utils/eventEmitter";
|
|
5
|
-
/**
|
|
6
|
-
* Classe base per tutti i plugin di ShogunCore
|
|
7
|
-
* Fornisce funzionalità comuni e implementazione base dell'interfaccia ShogunPlugin
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class BasePlugin extends EventEmitter implements ShogunPlugin {
|
|
10
|
-
/** Nome univoco del plugin - deve essere implementato dalle sottoclassi */
|
|
11
|
-
abstract name: string;
|
|
12
|
-
/** Versione del plugin - deve essere implementata dalle sottoclassi */
|
|
13
|
-
abstract version: string;
|
|
14
|
-
/** Descrizione opzionale del plugin */
|
|
15
|
-
description?: string;
|
|
16
|
-
/** Categoria del plugin */
|
|
17
|
-
_category?: PluginCategory;
|
|
18
|
-
/** Riferimento all'istanza di ShogunCore */
|
|
19
|
-
protected core: ShogunCore | null;
|
|
20
|
-
/**
|
|
21
|
-
* Inizializza il plugin con un'istanza di ShogunCore
|
|
22
|
-
* @param core Istanza di ShogunCore
|
|
23
|
-
*/
|
|
24
|
-
initialize(core: ShogunCore): void;
|
|
25
|
-
/**
|
|
26
|
-
* Distrugge il plugin e libera le risorse
|
|
27
|
-
*/
|
|
28
|
-
destroy(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Verifica che il plugin sia stato inizializzato prima di usare il core
|
|
31
|
-
* @throws Error se il plugin non è stato inizializzato
|
|
32
|
-
* @returns L'istanza di ShogunCore non null
|
|
33
|
-
*/
|
|
34
|
-
protected assertInitialized(): ShogunCore;
|
|
35
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { BasePlugin } from "./base";
|
|
2
|
-
export type { ShogunPlugin, PluginManager } from "../interfaces/plugin";
|
|
3
|
-
export { Webauthn } from "./webauthn/webauthn";
|
|
4
|
-
export { WebauthnPlugin } from "./webauthn/webauthnPlugin";
|
|
5
|
-
export type { WebauthnPluginInterface } from "./webauthn/types";
|
|
6
|
-
export { Web3Connector } from "./web3/web3Connector";
|
|
7
|
-
export { Web3ConnectorPlugin } from "./web3/web3ConnectorPlugin";
|
|
8
|
-
export type { Web3ConnectorPluginInterface } from "./web3/types";
|
|
9
|
-
export { NostrConnector } from "./nostr/nostrConnector";
|
|
10
|
-
export { NostrConnectorPlugin } from "./nostr/nostrConnectorPlugin";
|
|
11
|
-
export type { NostrConnectorPluginInterface, NostrConnectorCredentials, NostrConnectorKeyPair, NostrConnectorConfig, AlbyProvider, NostrProvider, } from "./nostr/types";
|
|
12
|
-
export { OAuthConnector } from "./oauth/oauthConnector";
|
|
13
|
-
export { OAuthPlugin } from "./oauth/oauthPlugin";
|
|
14
|
-
export * from "./oauth/types";
|