shogun-core 3.3.6 ā 3.3.8
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/README.md +76 -121
- package/dist/browser/shogun-core.js +164 -491
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/core.js +4 -5
- package/dist/examples/simple-api-test.js +90 -65
- package/dist/gundb/api.js +111 -467
- package/dist/gundb/db.js +44 -15
- package/dist/managers/AuthManager.js +4 -3
- package/dist/managers/CoreInitializer.js +1 -1
- package/dist/types/core.d.ts +2 -2
- package/dist/types/examples/simple-api-test.d.ts +6 -1
- package/dist/types/gundb/api.d.ts +77 -165
- package/dist/types/gundb/db.d.ts +15 -6
- package/dist/types/interfaces/events.d.ts +1 -1
- package/dist/types/interfaces/shogun.d.ts +7 -1
- package/dist/types/managers/AuthManager.d.ts +1 -1
- package/package.json +1 -8
- package/dist/examples/api-test.js +0 -273
- package/dist/types/events.js +0 -70
- package/dist/types/examples/api-test.d.ts +0 -12
- package/dist/types/shogun.js +0 -21
- package/dist/types/types/events.d.ts +0 -59
- package/dist/types/types/shogun.d.ts +0 -188
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Esempio completo che mostra le differenze tra i vari metodi dell'API ShogunCore
|
|
4
|
-
*
|
|
5
|
-
* Questo esempio dimostra:
|
|
6
|
-
* - get() vs getData() vs getNode() vs node() vs chain()
|
|
7
|
-
* - put() vs set() vs putUserData() vs setUserData()
|
|
8
|
-
* - remove() vs removeUserData()
|
|
9
|
-
* - Operazioni globali vs operazioni utente
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.demonstrateAPIDifferences = demonstrateAPIDifferences;
|
|
13
|
-
exports.showAPIDifferences = showAPIDifferences;
|
|
14
|
-
const api_1 = require("../gundb/api");
|
|
15
|
-
async function demonstrateAPIDifferences() {
|
|
16
|
-
console.log("š Iniziamo il test delle differenze API...\n");
|
|
17
|
-
// 1. Setup iniziale
|
|
18
|
-
const quickStart = new api_1.AutoQuickStart({
|
|
19
|
-
peers: ["https://peer.wallie.io/gun"],
|
|
20
|
-
appScope: "test-api",
|
|
21
|
-
});
|
|
22
|
-
await quickStart.init();
|
|
23
|
-
const api = quickStart.api;
|
|
24
|
-
console.log("ā
Setup completato\n");
|
|
25
|
-
// 2. Test operazioni GLOBALI (senza autenticazione)
|
|
26
|
-
console.log("š === TEST OPERAZIONI GLOBALI ===\n");
|
|
27
|
-
// Test get() - restituisce dati direttamente o null
|
|
28
|
-
console.log("š Test get():");
|
|
29
|
-
const globalData = await api.get("global/test");
|
|
30
|
-
console.log('get("global/test"):', globalData); // null se non esiste
|
|
31
|
-
// Test getNode() - restituisce nodo Gun per operazioni di chaining
|
|
32
|
-
console.log("\nš Test getNode():");
|
|
33
|
-
const globalNode = api.getNode("global/test");
|
|
34
|
-
console.log('getNode("global/test"):', typeof globalNode); // Gun node object
|
|
35
|
-
// Test node() - alias di getNode()
|
|
36
|
-
console.log("\nš Test node():");
|
|
37
|
-
const globalNode2 = api.node("global/test");
|
|
38
|
-
console.log('node("global/test"):', typeof globalNode2); // Gun node object
|
|
39
|
-
// Test chain() - wrapper con metodi di convenienza
|
|
40
|
-
console.log("\nāļø Test chain():");
|
|
41
|
-
const globalChain = api.chain("global/test");
|
|
42
|
-
console.log('chain("global/test"):', Object.keys(globalChain)); // ['get', 'put', 'set', 'once', 'then', 'map']
|
|
43
|
-
// Test put() vs set() - operazioni globali
|
|
44
|
-
console.log("\nš¾ Test put() vs set():");
|
|
45
|
-
const testData = { message: "Hello Global!", timestamp: Date.now() };
|
|
46
|
-
const putResult = await api.put("global/test", testData);
|
|
47
|
-
console.log("put() result:", putResult); // boolean
|
|
48
|
-
const setResult = await api.set("global/test2", {
|
|
49
|
-
...testData,
|
|
50
|
-
method: "set",
|
|
51
|
-
});
|
|
52
|
-
console.log("set() result:", setResult); // boolean
|
|
53
|
-
// Verifica che i dati siano stati salvati
|
|
54
|
-
const retrievedData1 = await api.get("global/test");
|
|
55
|
-
const retrievedData2 = await api.get("global/test2");
|
|
56
|
-
console.log("Retrieved put data:", retrievedData1);
|
|
57
|
-
console.log("Retrieved set data:", retrievedData2);
|
|
58
|
-
// Test remove() - operazione globale
|
|
59
|
-
console.log("\nšļø Test remove():");
|
|
60
|
-
const removeResult = await api.remove("global/test2");
|
|
61
|
-
console.log("remove() result:", removeResult); // boolean
|
|
62
|
-
const removedData = await api.get("global/test2");
|
|
63
|
-
console.log("Data after remove:", removedData); // null
|
|
64
|
-
// 3. Test autenticazione
|
|
65
|
-
console.log("\n\nš === TEST AUTENTICAZIONE ===\n");
|
|
66
|
-
const username = "testuser_" + Date.now();
|
|
67
|
-
const password = "testpass123";
|
|
68
|
-
// Test signup
|
|
69
|
-
console.log("š Test signup():");
|
|
70
|
-
const signupResult = await api.signup(username, password);
|
|
71
|
-
console.log("signup result:", signupResult);
|
|
72
|
-
if (signupResult) {
|
|
73
|
-
console.log("ā
Utente creato:", signupResult.username);
|
|
74
|
-
// Test login
|
|
75
|
-
console.log("\nš Test login():");
|
|
76
|
-
const loginResult = await api.login(username, password);
|
|
77
|
-
console.log("login result:", loginResult);
|
|
78
|
-
if (loginResult) {
|
|
79
|
-
console.log("ā
Login riuscito:", loginResult.username);
|
|
80
|
-
// 4. Test operazioni UTENTE (con autenticazione)
|
|
81
|
-
console.log("\n\nš¤ === TEST OPERAZIONI UTENTE ===\n");
|
|
82
|
-
// Test getUserData() - restituisce dati utente direttamente
|
|
83
|
-
console.log("š Test getUserData():");
|
|
84
|
-
const userData = await api.getUserData("profile");
|
|
85
|
-
console.log('getUserData("profile"):', userData); // null se non esiste
|
|
86
|
-
// Test putUserData() vs setUserData() - operazioni utente
|
|
87
|
-
console.log("\nš¾ Test putUserData() vs setUserData():");
|
|
88
|
-
const profileData = {
|
|
89
|
-
name: "Test User",
|
|
90
|
-
email: "test@example.com",
|
|
91
|
-
bio: "Test bio",
|
|
92
|
-
preferences: {
|
|
93
|
-
theme: "dark",
|
|
94
|
-
notifications: true,
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
const putUserResult = await api.putUserData("profile", profileData);
|
|
98
|
-
console.log("putUserData() result:", putUserResult); // boolean
|
|
99
|
-
const settingsData = {
|
|
100
|
-
language: "it",
|
|
101
|
-
timezone: "Europe/Rome",
|
|
102
|
-
privacy: "public",
|
|
103
|
-
};
|
|
104
|
-
const setUserResult = await api.setUserData("settings", settingsData);
|
|
105
|
-
console.log("setUserData() result:", setUserResult); // boolean
|
|
106
|
-
// Verifica che i dati utente siano stati salvati
|
|
107
|
-
const retrievedProfile = await api.getUserData("profile");
|
|
108
|
-
const retrievedSettings = await api.getUserData("settings");
|
|
109
|
-
console.log("Retrieved profile:", retrievedProfile);
|
|
110
|
-
console.log("Retrieved settings:", retrievedSettings);
|
|
111
|
-
// Test getUserNode() - nodo utente per operazioni avanzate
|
|
112
|
-
console.log("\nš Test getUserNode():");
|
|
113
|
-
try {
|
|
114
|
-
const userNode = api.getUserNode("profile");
|
|
115
|
-
console.log('getUserNode("profile"):', typeof userNode); // Gun node object
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
console.log("getUserNode error:", error.message);
|
|
119
|
-
}
|
|
120
|
-
// Test removeUserData() - rimozione dati utente
|
|
121
|
-
console.log("\nšļø Test removeUserData():");
|
|
122
|
-
const removeUserResult = await api.removeUserData("settings");
|
|
123
|
-
console.log("removeUserData() result:", removeUserResult); // boolean
|
|
124
|
-
const removedUserData = await api.getUserData("settings");
|
|
125
|
-
console.log("User data after remove:", removedUserData); // null
|
|
126
|
-
// 5. Test metodi di convenienza
|
|
127
|
-
console.log("\n\nš ļø === TEST METODI DI CONVENIENZA ===\n");
|
|
128
|
-
// Test updateProfile()
|
|
129
|
-
console.log("š¤ Test updateProfile():");
|
|
130
|
-
const profileUpdate = {
|
|
131
|
-
name: "Updated Test User",
|
|
132
|
-
bio: "Updated bio",
|
|
133
|
-
avatar: "https://example.com/avatar.jpg",
|
|
134
|
-
};
|
|
135
|
-
const profileResult = await api.updateProfile(profileUpdate);
|
|
136
|
-
console.log("updateProfile() result:", profileResult);
|
|
137
|
-
const updatedProfile = await api.getProfile();
|
|
138
|
-
console.log("Updated profile:", updatedProfile);
|
|
139
|
-
// Test saveSettings()
|
|
140
|
-
console.log("\nāļø Test saveSettings():");
|
|
141
|
-
const settings = {
|
|
142
|
-
theme: "light",
|
|
143
|
-
language: "en",
|
|
144
|
-
notifications: false,
|
|
145
|
-
};
|
|
146
|
-
const settingsResult = await api.saveSettings(settings);
|
|
147
|
-
console.log("saveSettings() result:", settingsResult);
|
|
148
|
-
const savedSettings = await api.getSettings();
|
|
149
|
-
console.log("Saved settings:", savedSettings);
|
|
150
|
-
// Test createCollection()
|
|
151
|
-
console.log("\nš Test createCollection():");
|
|
152
|
-
const todos = {
|
|
153
|
-
"1": { id: "1", text: "Learn ShogunCore", completed: false },
|
|
154
|
-
"2": { id: "2", text: "Build awesome app", completed: false },
|
|
155
|
-
"3": { id: "3", text: "Deploy to production", completed: true },
|
|
156
|
-
};
|
|
157
|
-
const collectionResult = await api.createCollection("todos", todos);
|
|
158
|
-
console.log("createCollection() result:", collectionResult);
|
|
159
|
-
const todosCollection = await api.getCollection("todos");
|
|
160
|
-
console.log("Todos collection:", todosCollection);
|
|
161
|
-
// Test addToCollection()
|
|
162
|
-
console.log("\nā Test addToCollection():");
|
|
163
|
-
const newTodo = { id: "4", text: "Test API methods", completed: false };
|
|
164
|
-
const addResult = await api.addToCollection("todos", "4", newTodo);
|
|
165
|
-
console.log("addToCollection() result:", addResult);
|
|
166
|
-
const updatedCollection = await api.getCollection("todos");
|
|
167
|
-
console.log("Updated collection:", updatedCollection);
|
|
168
|
-
// Test removeFromCollection()
|
|
169
|
-
console.log("\nā Test removeFromCollection():");
|
|
170
|
-
const removeFromCollectionResult = await api.removeFromCollection("todos", "3");
|
|
171
|
-
console.log("removeFromCollection() result:", removeFromCollectionResult);
|
|
172
|
-
const finalCollection = await api.getCollection("todos");
|
|
173
|
-
console.log("Final collection:", finalCollection);
|
|
174
|
-
// 6. Test utility methods
|
|
175
|
-
console.log("\n\nš§ === TEST METODI UTILITY ===\n");
|
|
176
|
-
// Test getCurrentUser()
|
|
177
|
-
console.log("š¤ Test getCurrentUser():");
|
|
178
|
-
const currentUser = api.getCurrentUser();
|
|
179
|
-
console.log("Current user:", currentUser);
|
|
180
|
-
// Test isLoggedIn()
|
|
181
|
-
console.log("\nš Test isLoggedIn():");
|
|
182
|
-
const isLoggedIn = api.isLoggedIn();
|
|
183
|
-
console.log("Is logged in:", isLoggedIn);
|
|
184
|
-
// Test userExists()
|
|
185
|
-
console.log("\nš Test userExists():");
|
|
186
|
-
const userExists = await api.userExists(username);
|
|
187
|
-
console.log(`User ${username} exists:`, userExists);
|
|
188
|
-
// Test getUser()
|
|
189
|
-
console.log("\nš„ Test getUser():");
|
|
190
|
-
const userInfo = await api.getUser(username);
|
|
191
|
-
console.log("User info:", userInfo);
|
|
192
|
-
// Test logout
|
|
193
|
-
console.log("\nšŖ Test logout():");
|
|
194
|
-
api.logout();
|
|
195
|
-
const isLoggedInAfter = api.isLoggedIn();
|
|
196
|
-
console.log("Is logged in after logout:", isLoggedInAfter);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
console.log("ā Login fallito");
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
console.log("ā Signup fallito");
|
|
204
|
-
}
|
|
205
|
-
// 7. Test array utilities
|
|
206
|
-
console.log("\n\nš === TEST ARRAY UTILITIES ===\n");
|
|
207
|
-
const testArray = [
|
|
208
|
-
{ id: "1", name: "Item 1", value: 100 },
|
|
209
|
-
{ id: "2", name: "Item 2", value: 200 },
|
|
210
|
-
{ id: "3", name: "Item 3", value: 300 },
|
|
211
|
-
];
|
|
212
|
-
console.log("Original array:", testArray);
|
|
213
|
-
// Test arrayToIndexedObject()
|
|
214
|
-
const indexedObject = api.arrayToIndexedObject(testArray);
|
|
215
|
-
console.log("Array to indexed object:", indexedObject);
|
|
216
|
-
// Test indexedObjectToArray()
|
|
217
|
-
const backToArray = api.indexedObjectToArray(indexedObject);
|
|
218
|
-
console.log("Indexed object back to array:", backToArray);
|
|
219
|
-
console.log("\nā
Test completato!");
|
|
220
|
-
}
|
|
221
|
-
// Funzione per mostrare le differenze principali
|
|
222
|
-
function showAPIDifferences() {
|
|
223
|
-
console.log(`
|
|
224
|
-
š === RIEPILOGO DIFFERENZE API ===
|
|
225
|
-
|
|
226
|
-
š METODI GET:
|
|
227
|
-
⢠get(path) ā Restituisce dati direttamente o null
|
|
228
|
-
⢠getNode(path) ā Restituisce nodo Gun per chaining (.map(), .on(), etc.)
|
|
229
|
-
⢠node(path) ā Alias di getNode()
|
|
230
|
-
⢠chain(path) ā Wrapper con metodi di convenienza (get, put, set, once, then, map)
|
|
231
|
-
⢠getUserData(path) ā Come get() ma per dati utente (richiede login)
|
|
232
|
-
|
|
233
|
-
š¾ METODI PUT/SET:
|
|
234
|
-
⢠put(path, data) ā Salva dati globali, restituisce boolean
|
|
235
|
-
⢠set(path, data) ā Come put() ma con semantica diversa
|
|
236
|
-
⢠putUserData(path, data) ā Salva dati utente, restituisce boolean
|
|
237
|
-
⢠setUserData(path, data) ā Come putUserData() ma con semantica diversa
|
|
238
|
-
|
|
239
|
-
šļø METODI REMOVE:
|
|
240
|
-
⢠remove(path) ā Rimuove dati globali, restituisce boolean
|
|
241
|
-
⢠removeUserData(path) ā Rimuove dati utente, restituisce boolean
|
|
242
|
-
|
|
243
|
-
š AUTENTICAZIONE:
|
|
244
|
-
⢠signup(username, password) ā Crea nuovo utente
|
|
245
|
-
⢠login(username, password) ā Autentica utente esistente
|
|
246
|
-
⢠logout() ā Disconnette utente
|
|
247
|
-
⢠isLoggedIn() ā Controlla se utente ĆØ autenticato
|
|
248
|
-
|
|
249
|
-
š¤ UTILITY UTENTE:
|
|
250
|
-
⢠getCurrentUser() ā Info utente corrente
|
|
251
|
-
⢠getUser(alias) ā Info utente per alias
|
|
252
|
-
⢠userExists(alias) ā Controlla se utente esiste
|
|
253
|
-
|
|
254
|
-
š ļø METODI DI CONVENIENZA:
|
|
255
|
-
⢠updateProfile(data) ā Aggiorna profilo utente
|
|
256
|
-
⢠getProfile() ā Ottiene profilo utente
|
|
257
|
-
⢠saveSettings(data) ā Salva impostazioni utente
|
|
258
|
-
⢠getSettings() ā Ottiene impostazioni utente
|
|
259
|
-
⢠createCollection(name, items) ā Crea collezione
|
|
260
|
-
⢠addToCollection(name, id, item) ā Aggiunge item a collezione
|
|
261
|
-
⢠getCollection(name) ā Ottiene collezione
|
|
262
|
-
⢠removeFromCollection(name, id) ā Rimuove item da collezione
|
|
263
|
-
|
|
264
|
-
š ARRAY UTILITIES:
|
|
265
|
-
⢠arrayToIndexedObject(arr) ā Converte array in oggetto indicizzato per GunDB
|
|
266
|
-
⢠indexedObjectToArray(obj) ā Converte oggetto indicizzato in array
|
|
267
|
-
`);
|
|
268
|
-
}
|
|
269
|
-
// Esegui il test
|
|
270
|
-
if (require.main === module) {
|
|
271
|
-
showAPIDifferences();
|
|
272
|
-
demonstrateAPIDifferences().catch(console.error);
|
|
273
|
-
}
|
package/dist/types/events.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Event types and interfaces for Shogun SDK
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ShogunEventEmitter = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Event emitter class for Shogun SDK
|
|
9
|
-
*/
|
|
10
|
-
class ShogunEventEmitter {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.listeners = new Map();
|
|
13
|
-
}
|
|
14
|
-
on(eventName, listener) {
|
|
15
|
-
if (!this.listeners.has(eventName)) {
|
|
16
|
-
this.listeners.set(eventName, []);
|
|
17
|
-
}
|
|
18
|
-
this.listeners.get(eventName).push(listener);
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
off(eventName, listener) {
|
|
22
|
-
const eventListeners = this.listeners.get(eventName);
|
|
23
|
-
if (eventListeners) {
|
|
24
|
-
const index = eventListeners.indexOf(listener);
|
|
25
|
-
if (index > -1) {
|
|
26
|
-
eventListeners.splice(index, 1);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
once(eventName, listener) {
|
|
32
|
-
const onceListener = (...args) => {
|
|
33
|
-
this.off(eventName, onceListener);
|
|
34
|
-
listener(...args);
|
|
35
|
-
};
|
|
36
|
-
return this.on(eventName, onceListener);
|
|
37
|
-
}
|
|
38
|
-
emit(eventName, data) {
|
|
39
|
-
const eventListeners = this.listeners.get(eventName);
|
|
40
|
-
if (!eventListeners || eventListeners.length === 0) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
eventListeners.forEach((listener) => {
|
|
44
|
-
try {
|
|
45
|
-
listener(data);
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
console.error(`Error in event listener for ${eventName}:`, error);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
removeAllListeners(eventName) {
|
|
54
|
-
if (eventName) {
|
|
55
|
-
this.listeners.delete(eventName);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
this.listeners.clear();
|
|
59
|
-
}
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
listenerCount(eventName) {
|
|
63
|
-
const eventListeners = this.listeners.get(eventName);
|
|
64
|
-
return eventListeners ? eventListeners.length : 0;
|
|
65
|
-
}
|
|
66
|
-
eventNames() {
|
|
67
|
-
return Array.from(this.listeners.keys());
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.ShogunEventEmitter = ShogunEventEmitter;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Esempio completo che mostra le differenze tra i vari metodi dell'API ShogunCore
|
|
3
|
-
*
|
|
4
|
-
* Questo esempio dimostra:
|
|
5
|
-
* - get() vs getData() vs getNode() vs node() vs chain()
|
|
6
|
-
* - put() vs set() vs putUserData() vs setUserData()
|
|
7
|
-
* - remove() vs removeUserData()
|
|
8
|
-
* - Operazioni globali vs operazioni utente
|
|
9
|
-
*/
|
|
10
|
-
declare function demonstrateAPIDifferences(): Promise<void>;
|
|
11
|
-
declare function showAPIDifferences(): void;
|
|
12
|
-
export { demonstrateAPIDifferences, showAPIDifferences };
|
package/dist/types/shogun.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Core types and interfaces for Shogun SDK
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CorePlugins = exports.PluginCategory = void 0;
|
|
7
|
-
var PluginCategory;
|
|
8
|
-
(function (PluginCategory) {
|
|
9
|
-
PluginCategory["Authentication"] = "authentication";
|
|
10
|
-
PluginCategory["Wallet"] = "wallet";
|
|
11
|
-
PluginCategory["Privacy"] = "privacy";
|
|
12
|
-
PluginCategory["Identity"] = "identity";
|
|
13
|
-
PluginCategory["Utility"] = "utility";
|
|
14
|
-
})(PluginCategory || (exports.PluginCategory = PluginCategory = {}));
|
|
15
|
-
var CorePlugins;
|
|
16
|
-
(function (CorePlugins) {
|
|
17
|
-
CorePlugins["WebAuthn"] = "webauthn";
|
|
18
|
-
CorePlugins["Web3"] = "web3";
|
|
19
|
-
CorePlugins["Nostr"] = "nostr";
|
|
20
|
-
CorePlugins["OAuth"] = "oauth";
|
|
21
|
-
})(CorePlugins || (exports.CorePlugins = CorePlugins = {}));
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event types and interfaces for Shogun SDK
|
|
3
|
-
*/
|
|
4
|
-
export interface AuthEventData {
|
|
5
|
-
userPub?: string;
|
|
6
|
-
username?: string;
|
|
7
|
-
method: "password" | "webauthn" | "web3" | "nostr" | "oauth" | "bitcoin" | "pair";
|
|
8
|
-
provider?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface WalletEventData {
|
|
11
|
-
address: string;
|
|
12
|
-
path?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface ErrorEventData {
|
|
15
|
-
action: string;
|
|
16
|
-
message: string;
|
|
17
|
-
type: string;
|
|
18
|
-
details?: any;
|
|
19
|
-
}
|
|
20
|
-
export interface GunDataEventData {
|
|
21
|
-
path: string;
|
|
22
|
-
data?: any;
|
|
23
|
-
success: boolean;
|
|
24
|
-
error?: string;
|
|
25
|
-
timestamp: number;
|
|
26
|
-
}
|
|
27
|
-
export interface GunPeerEventData {
|
|
28
|
-
peer: string;
|
|
29
|
-
action: "add" | "remove" | "connect" | "disconnect";
|
|
30
|
-
timestamp: number;
|
|
31
|
-
}
|
|
32
|
-
export interface PluginEventData {
|
|
33
|
-
name: string;
|
|
34
|
-
version?: string;
|
|
35
|
-
category?: string;
|
|
36
|
-
}
|
|
37
|
-
export interface DebugEventData {
|
|
38
|
-
action: string;
|
|
39
|
-
data?: any;
|
|
40
|
-
timestamp: number;
|
|
41
|
-
}
|
|
42
|
-
export interface UsernameChangedEventData {
|
|
43
|
-
oldUsername: string;
|
|
44
|
-
newUsername: string;
|
|
45
|
-
userPub: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Event emitter class for Shogun SDK
|
|
49
|
-
*/
|
|
50
|
-
export declare class ShogunEventEmitter {
|
|
51
|
-
private listeners;
|
|
52
|
-
on(eventName: string, listener: Function): this;
|
|
53
|
-
off(eventName: string, listener: Function): this;
|
|
54
|
-
once(eventName: string, listener: Function): this;
|
|
55
|
-
emit(eventName: string, data?: any): boolean;
|
|
56
|
-
removeAllListeners(eventName?: string): this;
|
|
57
|
-
listenerCount(eventName: string): number;
|
|
58
|
-
eventNames(): string[];
|
|
59
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core types and interfaces for Shogun SDK
|
|
3
|
-
*/
|
|
4
|
-
export declare enum PluginCategory {
|
|
5
|
-
Authentication = "authentication",
|
|
6
|
-
Wallet = "wallet",
|
|
7
|
-
Privacy = "privacy",
|
|
8
|
-
Identity = "identity",
|
|
9
|
-
Utility = "utility"
|
|
10
|
-
}
|
|
11
|
-
export declare enum CorePlugins {
|
|
12
|
-
WebAuthn = "webauthn",
|
|
13
|
-
Web3 = "web3",
|
|
14
|
-
Nostr = "nostr",
|
|
15
|
-
OAuth = "oauth"
|
|
16
|
-
}
|
|
17
|
-
export type AuthMethod = "password" | "webauthn" | "web3" | "nostr" | "oauth" | "bitcoin" | "pair";
|
|
18
|
-
export interface ISEAPair {
|
|
19
|
-
pub: string;
|
|
20
|
-
priv: string;
|
|
21
|
-
epub: string;
|
|
22
|
-
epriv: string;
|
|
23
|
-
}
|
|
24
|
-
export interface AuthResult {
|
|
25
|
-
success: boolean;
|
|
26
|
-
userPub?: string;
|
|
27
|
-
username?: string;
|
|
28
|
-
sessionToken?: string;
|
|
29
|
-
authMethod: AuthMethod;
|
|
30
|
-
sea?: ISEAPair;
|
|
31
|
-
error?: string;
|
|
32
|
-
provider?: string;
|
|
33
|
-
redirectUrl?: string;
|
|
34
|
-
pendingAuth?: boolean;
|
|
35
|
-
message?: string;
|
|
36
|
-
isNewUser?: boolean;
|
|
37
|
-
user?: {
|
|
38
|
-
userPub: string;
|
|
39
|
-
username: string;
|
|
40
|
-
email?: string;
|
|
41
|
-
name?: string;
|
|
42
|
-
picture?: string;
|
|
43
|
-
oauth?: {
|
|
44
|
-
provider: string;
|
|
45
|
-
id: string;
|
|
46
|
-
email: string;
|
|
47
|
-
name: string;
|
|
48
|
-
picture: string;
|
|
49
|
-
lastLogin: number;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export interface SignUpResult {
|
|
54
|
-
success: boolean;
|
|
55
|
-
userPub?: string;
|
|
56
|
-
username?: string;
|
|
57
|
-
pub?: string;
|
|
58
|
-
authMethod?: AuthMethod;
|
|
59
|
-
sessionToken?: string;
|
|
60
|
-
isNewUser?: boolean;
|
|
61
|
-
sea?: ISEAPair;
|
|
62
|
-
error?: string;
|
|
63
|
-
message?: string;
|
|
64
|
-
provider?: string;
|
|
65
|
-
redirectUrl?: string;
|
|
66
|
-
pendingAuth?: boolean;
|
|
67
|
-
user?: {
|
|
68
|
-
userPub: string;
|
|
69
|
-
username: string;
|
|
70
|
-
email?: string;
|
|
71
|
-
name?: string;
|
|
72
|
-
picture?: string;
|
|
73
|
-
oauth?: {
|
|
74
|
-
provider: string;
|
|
75
|
-
id: string;
|
|
76
|
-
email: string;
|
|
77
|
-
name: string;
|
|
78
|
-
picture: string;
|
|
79
|
-
lastLogin: number;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
export interface WebauthnConfig {
|
|
84
|
-
enabled: boolean;
|
|
85
|
-
rpName?: string;
|
|
86
|
-
rpId?: string;
|
|
87
|
-
}
|
|
88
|
-
export interface Web3Config {
|
|
89
|
-
enabled: boolean;
|
|
90
|
-
}
|
|
91
|
-
export interface NostrConfig {
|
|
92
|
-
enabled: boolean;
|
|
93
|
-
}
|
|
94
|
-
export interface OAuthProviderConfig {
|
|
95
|
-
clientId: string;
|
|
96
|
-
clientSecret?: string;
|
|
97
|
-
}
|
|
98
|
-
export interface OAuthConfig {
|
|
99
|
-
enabled: boolean;
|
|
100
|
-
usePKCE?: boolean;
|
|
101
|
-
allowUnsafeClientSecret?: boolean;
|
|
102
|
-
providers?: {
|
|
103
|
-
google?: OAuthProviderConfig;
|
|
104
|
-
github?: OAuthProviderConfig;
|
|
105
|
-
[key: string]: OAuthProviderConfig | undefined;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
export interface TimeoutsConfig {
|
|
109
|
-
login?: number;
|
|
110
|
-
signup?: number;
|
|
111
|
-
operation?: number;
|
|
112
|
-
}
|
|
113
|
-
export interface PluginsConfig {
|
|
114
|
-
autoRegister?: string[];
|
|
115
|
-
}
|
|
116
|
-
export interface ShogunSDKConfig {
|
|
117
|
-
gunInstance?: any;
|
|
118
|
-
authToken?: string;
|
|
119
|
-
scope?: string;
|
|
120
|
-
peers?: string[];
|
|
121
|
-
webauthn?: WebauthnConfig;
|
|
122
|
-
web3?: Web3Config;
|
|
123
|
-
nostr?: NostrConfig;
|
|
124
|
-
oauth?: OAuthConfig;
|
|
125
|
-
timeouts?: TimeoutsConfig;
|
|
126
|
-
plugins?: PluginsConfig;
|
|
127
|
-
appToken?: string;
|
|
128
|
-
gunOptions?: any;
|
|
129
|
-
disableAutoRecall?: boolean;
|
|
130
|
-
silent?: boolean;
|
|
131
|
-
}
|
|
132
|
-
export interface ShogunEvents {
|
|
133
|
-
error: (data: any) => void;
|
|
134
|
-
"auth:signup": (data: any) => void;
|
|
135
|
-
"auth:login": (data: any) => void;
|
|
136
|
-
"auth:logout": () => void;
|
|
137
|
-
"auth:username_changed": (data: any) => void;
|
|
138
|
-
"wallet:created": (data: any) => void;
|
|
139
|
-
"gun:put": (data: any) => void;
|
|
140
|
-
"gun:get": (data: any) => void;
|
|
141
|
-
"gun:set": (data: any) => void;
|
|
142
|
-
"gun:remove": (data: any) => void;
|
|
143
|
-
"gun:peer:add": (data: any) => void;
|
|
144
|
-
"gun:peer:remove": (data: any) => void;
|
|
145
|
-
"gun:peer:connect": (data: any) => void;
|
|
146
|
-
"gun:peer:disconnect": (data: any) => void;
|
|
147
|
-
"plugin:registered": (data: any) => void;
|
|
148
|
-
"plugin:unregistered": (data: any) => void;
|
|
149
|
-
debug: (data: any) => void;
|
|
150
|
-
}
|
|
151
|
-
export interface Wallets {
|
|
152
|
-
secp256k1Bitcoin?: {
|
|
153
|
-
privateKey: string;
|
|
154
|
-
publicKey: string;
|
|
155
|
-
address: string;
|
|
156
|
-
};
|
|
157
|
-
secp256k1Ethereum?: {
|
|
158
|
-
privateKey: string;
|
|
159
|
-
publicKey: string;
|
|
160
|
-
address: string;
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
export interface IShogunCore {
|
|
164
|
-
registerPlugin: (plugin: any) => void;
|
|
165
|
-
unregisterPlugin: (pluginName: string) => void;
|
|
166
|
-
getPlugin: (name: string) => any;
|
|
167
|
-
getPlugins: () => any[];
|
|
168
|
-
hasPlugin: (name: string) => boolean;
|
|
169
|
-
gun: any;
|
|
170
|
-
db: any;
|
|
171
|
-
rx: any;
|
|
172
|
-
storage: any;
|
|
173
|
-
config: any;
|
|
174
|
-
on: (eventName: string, listener: Function) => any;
|
|
175
|
-
off: (eventName: string, listener: Function) => any;
|
|
176
|
-
once: (eventName: string, listener: Function) => any;
|
|
177
|
-
removeAllListeners: (eventName?: string) => any;
|
|
178
|
-
emit: (eventName: string, data?: any) => boolean;
|
|
179
|
-
getRecentErrors: (count?: number) => any[];
|
|
180
|
-
login: (username: string, password: string, pair?: any) => Promise<AuthResult>;
|
|
181
|
-
signUp: (username: string, password?: string, pair?: any) => Promise<SignUpResult>;
|
|
182
|
-
getAuthenticationMethod: (type: AuthMethod) => any;
|
|
183
|
-
getCurrentUser: () => any;
|
|
184
|
-
changeUsername: (newUsername: string) => Promise<any>;
|
|
185
|
-
logout: () => void;
|
|
186
|
-
isLoggedIn: () => boolean;
|
|
187
|
-
}
|
|
188
|
-
export type ShogunCoreConfig = ShogunSDKConfig;
|