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,264 +0,0 @@
|
|
|
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
|
-
alias?: string;
|
|
10
|
-
timestamp?: number;
|
|
11
|
-
user?: GunUser;
|
|
12
|
-
};
|
|
13
|
-
export type AuthCallback = (user: GunUser) => void;
|
|
14
|
-
export type AuthResult = {
|
|
15
|
-
success: boolean;
|
|
16
|
-
userPub?: string;
|
|
17
|
-
error?: string;
|
|
18
|
-
ack?: any;
|
|
19
|
-
sea?: {
|
|
20
|
-
pub: string;
|
|
21
|
-
priv: string;
|
|
22
|
-
epub: string;
|
|
23
|
-
epriv: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export type GunData = any;
|
|
27
|
-
export type GunNode = any;
|
|
28
|
-
export type GunCallback = any;
|
|
29
|
-
export type GunDataCallback = any;
|
|
30
|
-
export type GunMapCallback = any;
|
|
31
|
-
export interface UsernameLookupResult {
|
|
32
|
-
pub?: string;
|
|
33
|
-
userPub?: string;
|
|
34
|
-
username?: string;
|
|
35
|
-
source: string;
|
|
36
|
-
immutable: boolean;
|
|
37
|
-
hash?: string;
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
}
|
|
40
|
-
export interface UserMetadata {
|
|
41
|
-
username: string;
|
|
42
|
-
pub: string;
|
|
43
|
-
createdAt: number;
|
|
44
|
-
lastLogin: number;
|
|
45
|
-
}
|
|
46
|
-
export interface MappingData {
|
|
47
|
-
username: string;
|
|
48
|
-
userPub: string;
|
|
49
|
-
createdAt: number;
|
|
50
|
-
}
|
|
51
|
-
export interface SecurityData {
|
|
52
|
-
questions: string;
|
|
53
|
-
hint: string;
|
|
54
|
-
}
|
|
55
|
-
export interface FrozenData {
|
|
56
|
-
data: any;
|
|
57
|
-
timestamp: number;
|
|
58
|
-
description: string;
|
|
59
|
-
metadata: Record<string, any>;
|
|
60
|
-
}
|
|
61
|
-
export interface FrozenSpaceOptions {
|
|
62
|
-
namespace?: string;
|
|
63
|
-
path?: string;
|
|
64
|
-
description?: string;
|
|
65
|
-
metadata?: Record<string, any>;
|
|
66
|
-
}
|
|
67
|
-
export interface ConnectivityTestResult {
|
|
68
|
-
peers: {
|
|
69
|
-
[peer: string]: {
|
|
70
|
-
connected: boolean;
|
|
71
|
-
status: string;
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
gunInstance: boolean;
|
|
75
|
-
userInstance: boolean;
|
|
76
|
-
canWrite: boolean;
|
|
77
|
-
canRead: boolean;
|
|
78
|
-
testWriteResult?: any;
|
|
79
|
-
testReadResult?: any;
|
|
80
|
-
}
|
|
81
|
-
export interface LoginResult {
|
|
82
|
-
success: boolean;
|
|
83
|
-
userPub?: string;
|
|
84
|
-
username?: string;
|
|
85
|
-
error?: string;
|
|
86
|
-
}
|
|
87
|
-
export interface SignupResult {
|
|
88
|
-
success: boolean;
|
|
89
|
-
userPub?: string;
|
|
90
|
-
username?: string;
|
|
91
|
-
message?: string;
|
|
92
|
-
error?: string;
|
|
93
|
-
sea?: {
|
|
94
|
-
pub: string;
|
|
95
|
-
priv: string;
|
|
96
|
-
epub: string;
|
|
97
|
-
epriv: string;
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
export interface PostAuthResult {
|
|
101
|
-
success: boolean;
|
|
102
|
-
userPub?: string;
|
|
103
|
-
username?: string;
|
|
104
|
-
error?: string;
|
|
105
|
-
}
|
|
106
|
-
export interface PasswordHintResult {
|
|
107
|
-
success: boolean;
|
|
108
|
-
hint?: string;
|
|
109
|
-
error?: string;
|
|
110
|
-
}
|
|
111
|
-
export interface P256Keys {
|
|
112
|
-
pub: string;
|
|
113
|
-
priv: string;
|
|
114
|
-
epub: string;
|
|
115
|
-
epriv: string;
|
|
116
|
-
}
|
|
117
|
-
export interface Secp256k1Keys {
|
|
118
|
-
pub: string;
|
|
119
|
-
priv: string;
|
|
120
|
-
address: string;
|
|
121
|
-
}
|
|
122
|
-
export interface DeriveResult {
|
|
123
|
-
p256?: P256Keys;
|
|
124
|
-
secp256k1Bitcoin?: Secp256k1Keys;
|
|
125
|
-
secp256k1Ethereum?: Secp256k1Keys;
|
|
126
|
-
}
|
|
127
|
-
export interface FrozenSpaceResult {
|
|
128
|
-
hash: string;
|
|
129
|
-
fullPath: string;
|
|
130
|
-
data: FrozenData;
|
|
131
|
-
}
|
|
132
|
-
export interface VerificationResult {
|
|
133
|
-
verified: boolean;
|
|
134
|
-
frozenData?: FrozenData;
|
|
135
|
-
error?: string;
|
|
136
|
-
}
|
|
137
|
-
export interface SessionRestorationResult {
|
|
138
|
-
success: boolean;
|
|
139
|
-
userPub?: string;
|
|
140
|
-
error?: string;
|
|
141
|
-
}
|
|
142
|
-
export interface UserExistenceResult {
|
|
143
|
-
exists: boolean;
|
|
144
|
-
userPub?: string;
|
|
145
|
-
error?: string;
|
|
146
|
-
}
|
|
147
|
-
export interface UserCreationResult {
|
|
148
|
-
success: boolean;
|
|
149
|
-
pub?: string;
|
|
150
|
-
error?: string;
|
|
151
|
-
}
|
|
152
|
-
export type EventData = any;
|
|
153
|
-
export type EventListener = (data: EventData) => void;
|
|
154
|
-
export interface GunOperationResult {
|
|
155
|
-
success: boolean;
|
|
156
|
-
error?: string;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Improved type definitions to reduce 'any' usage while maintaining GunDB compatibility
|
|
160
|
-
*/
|
|
161
|
-
import type { IGunUserInstance, IGunInstance, IGunChain, ISEAPair } from "gun/types";
|
|
162
|
-
export type GunInstance = IGunInstance<any>;
|
|
163
|
-
export type GunUserInstance = IGunUserInstance<any>;
|
|
164
|
-
export type GunChain = IGunChain<any, IGunInstance<any>, IGunInstance<any>, string>;
|
|
165
|
-
export interface GunAckCallback {
|
|
166
|
-
(ack: {
|
|
167
|
-
err?: string;
|
|
168
|
-
ok?: number;
|
|
169
|
-
pub?: string;
|
|
170
|
-
}): void;
|
|
171
|
-
}
|
|
172
|
-
export interface TypedGunOperationResult<T = unknown> {
|
|
173
|
-
success: boolean;
|
|
174
|
-
data?: T;
|
|
175
|
-
error?: string;
|
|
176
|
-
ack?: {
|
|
177
|
-
err?: string;
|
|
178
|
-
ok?: number;
|
|
179
|
-
pub?: string;
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
export interface TypedUserInfo {
|
|
183
|
-
pub: string;
|
|
184
|
-
alias?: string;
|
|
185
|
-
timestamp?: number;
|
|
186
|
-
user?: GunUserInstance;
|
|
187
|
-
metadata?: Record<string, unknown>;
|
|
188
|
-
}
|
|
189
|
-
export interface TypedAuthCallback {
|
|
190
|
-
(user: GunUserInstance): void;
|
|
191
|
-
}
|
|
192
|
-
export interface TypedAuthResult {
|
|
193
|
-
success: boolean;
|
|
194
|
-
userPub?: string;
|
|
195
|
-
username?: string;
|
|
196
|
-
error?: string;
|
|
197
|
-
ack?: {
|
|
198
|
-
err?: string;
|
|
199
|
-
ok?: number;
|
|
200
|
-
pub?: string;
|
|
201
|
-
sea?: ISEAPair;
|
|
202
|
-
};
|
|
203
|
-
sea?: ISEAPair;
|
|
204
|
-
}
|
|
205
|
-
export interface TypedGunConfig {
|
|
206
|
-
peers?: string[];
|
|
207
|
-
localStorage?: boolean;
|
|
208
|
-
radisk?: boolean;
|
|
209
|
-
file?: string;
|
|
210
|
-
uuid?: () => string;
|
|
211
|
-
[key: string]: unknown;
|
|
212
|
-
}
|
|
213
|
-
export interface TypedEventData {
|
|
214
|
-
type: string;
|
|
215
|
-
data: unknown;
|
|
216
|
-
timestamp: number;
|
|
217
|
-
source?: string;
|
|
218
|
-
}
|
|
219
|
-
export type GunPath = string | string[];
|
|
220
|
-
export interface PathOperation<T = unknown> {
|
|
221
|
-
path: GunPath;
|
|
222
|
-
data?: T;
|
|
223
|
-
callback?: GunAckCallback;
|
|
224
|
-
}
|
|
225
|
-
export interface TypedRxJSObservable<T = unknown> {
|
|
226
|
-
subscribe: (observer: {
|
|
227
|
-
next: (value: T) => void;
|
|
228
|
-
error?: (error: Error) => void;
|
|
229
|
-
complete?: () => void;
|
|
230
|
-
}) => {
|
|
231
|
-
unsubscribe: () => void;
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
export interface TypedPluginConfig {
|
|
235
|
-
name: string;
|
|
236
|
-
version: string;
|
|
237
|
-
enabled: boolean;
|
|
238
|
-
config?: Record<string, unknown>;
|
|
239
|
-
}
|
|
240
|
-
export interface TypedStorageData {
|
|
241
|
-
key: string;
|
|
242
|
-
value: unknown;
|
|
243
|
-
timestamp: number;
|
|
244
|
-
ttl?: number;
|
|
245
|
-
}
|
|
246
|
-
export interface TypedGunError extends Error {
|
|
247
|
-
code?: string;
|
|
248
|
-
type: "GUN_ERROR" | "AUTH_ERROR" | "NETWORK_ERROR" | "VALIDATION_ERROR";
|
|
249
|
-
context?: Record<string, unknown>;
|
|
250
|
-
}
|
|
251
|
-
export type GunOperation = "get" | "put" | "set" | "remove" | "once" | "on" | "off";
|
|
252
|
-
export type GunAuthMethod = "password" | "pair" | "webauthn" | "web3" | "nostr";
|
|
253
|
-
export interface TypedGunWrapper<T = Record<string, unknown>> {
|
|
254
|
-
gun: GunInstance;
|
|
255
|
-
user: GunUserInstance | null;
|
|
256
|
-
get(path: GunPath): Promise<T>;
|
|
257
|
-
put(path: GunPath, data: T): Promise<TypedGunOperationResult<T>>;
|
|
258
|
-
set(path: GunPath, data: T): Promise<TypedGunOperationResult<T>>;
|
|
259
|
-
remove(path: GunPath): Promise<TypedGunOperationResult>;
|
|
260
|
-
getUserData(path: string): Promise<T>;
|
|
261
|
-
putUserData(path: string, data: T): Promise<void>;
|
|
262
|
-
login(username: string, password: string): Promise<TypedAuthResult>;
|
|
263
|
-
signUp(username: string, password: string): Promise<TypedAuthResult>;
|
|
264
|
-
}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ShogunCore } from "./core";
|
|
2
|
-
import { IGunUserInstance, IGunInstance, GunDataEventData, GunPeerEventData, DeriveOptions } from "./gundb/db";
|
|
3
|
-
import { SEA, RxJS, crypto, derive, GunErrors, DataBase } from "./gundb/db";
|
|
4
|
-
import { SimpleGunAPI, QuickStart, quickStart, createSimpleAPI, GunInstance, GunUserInstance, TypedGunOperationResult, TypedAuthResult } from "./gundb";
|
|
5
|
-
import Gun from "./gundb/db";
|
|
6
|
-
export * from "./utils/errorHandler";
|
|
7
|
-
export * from "./plugins";
|
|
8
|
-
export * from "./interfaces/shogun";
|
|
9
|
-
export type * from "./interfaces/plugin";
|
|
10
|
-
export * from "./config/simplified-config";
|
|
11
|
-
export type { IGunUserInstance, IGunInstance, GunDataEventData, GunPeerEventData, DeriveOptions, GunInstance, GunUserInstance, TypedGunOperationResult, TypedAuthResult, };
|
|
12
|
-
export { SEA, RxJS, crypto, derive, GunErrors, DataBase, SimpleGunAPI, QuickStart, quickStart, createSimpleAPI, };
|
|
13
|
-
export { Gun };
|
|
14
|
-
export { ShogunCore };
|
|
@@ -1,85 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
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" | "oauth" | "bitcoin" } method - Authentication method used
|
|
8
|
-
* @property {string} [provider] - Optional provider name (for OAuth)
|
|
9
|
-
*/
|
|
10
|
-
export interface AuthEventData {
|
|
11
|
-
userPub?: string;
|
|
12
|
-
username?: string;
|
|
13
|
-
method: "password" | "webauthn" | "web3" | "nostr" | "oauth" | "bitcoin";
|
|
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
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { ShogunCore } from "../core";
|
|
2
|
-
import { PluginCategory } from "./shogun";
|
|
3
|
-
/**
|
|
4
|
-
* Interfaccia di base per tutti i plugin di ShogunCore
|
|
5
|
-
*/
|
|
6
|
-
export interface ShogunPlugin {
|
|
7
|
-
/** Nome univoco del plugin */
|
|
8
|
-
name: string;
|
|
9
|
-
/** Versione del plugin */
|
|
10
|
-
version: string;
|
|
11
|
-
/** Descrizione opzionale del plugin */
|
|
12
|
-
description?: string;
|
|
13
|
-
/** Categoria del plugin (opzionale) */
|
|
14
|
-
_category?: PluginCategory;
|
|
15
|
-
/**
|
|
16
|
-
* Metodo opzionale per inizializzare il plugin
|
|
17
|
-
* @param core Istanza di ShogunCore
|
|
18
|
-
*/
|
|
19
|
-
initialize(core: ShogunCore): void;
|
|
20
|
-
/**
|
|
21
|
-
* Metodo opzionale per distruggere il plugin e liberare risorse
|
|
22
|
-
*/
|
|
23
|
-
destroy?(): void;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Interfaccia per la gestione dei plugin in ShogunCore
|
|
27
|
-
*/
|
|
28
|
-
export interface PluginManager {
|
|
29
|
-
/**
|
|
30
|
-
* Registra un nuovo plugin
|
|
31
|
-
* @param plugin Il plugin da registrare
|
|
32
|
-
*/
|
|
33
|
-
register(plugin: ShogunPlugin): void;
|
|
34
|
-
/**
|
|
35
|
-
* Cancella la registrazione di un plugin
|
|
36
|
-
* @param pluginName Nome del plugin da cancellare
|
|
37
|
-
*/
|
|
38
|
-
unregister(pluginName: string): void;
|
|
39
|
-
/**
|
|
40
|
-
* Recupera un plugin registrato per nome
|
|
41
|
-
* @param name Nome del plugin
|
|
42
|
-
* @returns Il plugin richiesto o undefined se non trovato
|
|
43
|
-
* @template T Tipo del plugin o dell'interfaccia pubblica del plugin
|
|
44
|
-
*/
|
|
45
|
-
getPlugin<T = ShogunPlugin>(name: string): T | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Verifica se un plugin è registrato
|
|
48
|
-
* @param name Nome del plugin da verificare
|
|
49
|
-
* @returns true se il plugin è registrato, false altrimenti
|
|
50
|
-
*/
|
|
51
|
-
hasPlugin(name: string): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Ottiene tutti i plugin di una determinata categoria
|
|
54
|
-
* @param category Categoria di plugin da filtrare
|
|
55
|
-
* @returns Array di plugin della categoria specificata
|
|
56
|
-
*/
|
|
57
|
-
getPluginsByCategory(category: PluginCategory): ShogunPlugin[];
|
|
58
|
-
/**
|
|
59
|
-
* Ottiene informazioni su tutti i plugin registrati
|
|
60
|
-
* @returns Array di oggetti con informazioni sui plugin
|
|
61
|
-
*/
|
|
62
|
-
getPluginsInfo(): Array<{
|
|
63
|
-
name: string;
|
|
64
|
-
version: string;
|
|
65
|
-
category?: PluginCategory;
|
|
66
|
-
description?: string;
|
|
67
|
-
}>;
|
|
68
|
-
/**
|
|
69
|
-
* Ottiene il numero totale di plugin registrati
|
|
70
|
-
* @returns Numero di plugin registrati
|
|
71
|
-
*/
|
|
72
|
-
getPluginCount(): number;
|
|
73
|
-
/**
|
|
74
|
-
* Verifica se tutti i plugin sono inizializzati correttamente
|
|
75
|
-
* @returns Oggetto con stato di inizializzazione per ogni plugin
|
|
76
|
-
*/
|
|
77
|
-
getPluginsInitializationStatus(): Record<string, {
|
|
78
|
-
initialized: boolean;
|
|
79
|
-
error?: string;
|
|
80
|
-
}>;
|
|
81
|
-
/**
|
|
82
|
-
* Valida l'integrità del sistema di plugin
|
|
83
|
-
* @returns Oggetto con risultati della validazione
|
|
84
|
-
*/
|
|
85
|
-
validatePluginSystem(): {
|
|
86
|
-
totalPlugins: number;
|
|
87
|
-
initializedPlugins: number;
|
|
88
|
-
failedPlugins: string[];
|
|
89
|
-
warnings: string[];
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Tenta di reinizializzare i plugin falliti
|
|
93
|
-
* @returns Oggetto con risultati della reinizializzazione
|
|
94
|
-
*/
|
|
95
|
-
reinitializeFailedPlugins(): {
|
|
96
|
-
success: string[];
|
|
97
|
-
failed: Array<{
|
|
98
|
-
name: string;
|
|
99
|
-
error: string;
|
|
100
|
-
}>;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Verifica la compatibilità dei plugin con la versione corrente di ShogunCore
|
|
104
|
-
* @returns Oggetto con informazioni sulla compatibilità
|
|
105
|
-
*/
|
|
106
|
-
checkPluginCompatibility(): {
|
|
107
|
-
compatible: Array<{
|
|
108
|
-
name: string;
|
|
109
|
-
version: string;
|
|
110
|
-
}>;
|
|
111
|
-
incompatible: Array<{
|
|
112
|
-
name: string;
|
|
113
|
-
version: string;
|
|
114
|
-
reason: string;
|
|
115
|
-
}>;
|
|
116
|
-
unknown: Array<{
|
|
117
|
-
name: string;
|
|
118
|
-
version: string;
|
|
119
|
-
}>;
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Ottiene informazioni complete di debug sul sistema di plugin
|
|
123
|
-
* @returns Informazioni complete di debug del sistema di plugin
|
|
124
|
-
*/
|
|
125
|
-
getPluginSystemDebugInfo(): {
|
|
126
|
-
shogunCoreVersion: string;
|
|
127
|
-
totalPlugins: number;
|
|
128
|
-
plugins: Array<{
|
|
129
|
-
name: string;
|
|
130
|
-
version: string;
|
|
131
|
-
category?: PluginCategory;
|
|
132
|
-
description?: string;
|
|
133
|
-
initialized: boolean;
|
|
134
|
-
error?: string;
|
|
135
|
-
}>;
|
|
136
|
-
initializationStatus: Record<string, {
|
|
137
|
-
initialized: boolean;
|
|
138
|
-
error?: string;
|
|
139
|
-
}>;
|
|
140
|
-
validation: {
|
|
141
|
-
totalPlugins: number;
|
|
142
|
-
initializedPlugins: number;
|
|
143
|
-
failedPlugins: string[];
|
|
144
|
-
warnings: string[];
|
|
145
|
-
};
|
|
146
|
-
compatibility: {
|
|
147
|
-
compatible: Array<{
|
|
148
|
-
name: string;
|
|
149
|
-
version: string;
|
|
150
|
-
}>;
|
|
151
|
-
incompatible: Array<{
|
|
152
|
-
name: string;
|
|
153
|
-
version: string;
|
|
154
|
-
reason: string;
|
|
155
|
-
}>;
|
|
156
|
-
unknown: Array<{
|
|
157
|
-
name: string;
|
|
158
|
-
version: string;
|
|
159
|
-
}>;
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
}
|