gun-eth 2.0.1 → 3.0.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.
Files changed (64) hide show
  1. package/README.md +320 -141
  2. package/dist/gun-eth.bundle.js +6809 -0
  3. package/dist/gun-eth.cjs +2468 -0
  4. package/dist/types/browser.d.ts +6 -0
  5. package/dist/types/config/local.d.ts +7 -0
  6. package/dist/types/constants/abis.d.ts +37 -0
  7. package/dist/types/constants/index.d.ts +1 -0
  8. package/dist/types/core/gun-eth.d.ts +419 -0
  9. package/dist/types/features/bubbles/client/bubble-client.d.ts +184 -0
  10. package/dist/types/features/bubbles/providers/base-bubble-provider.d.ts +303 -0
  11. package/dist/types/features/bubbles/providers/gun-bubble-provider.d.ts +173 -0
  12. package/dist/types/features/bubbles/providers/hybrid-bubble-provider.d.ts +124 -0
  13. package/dist/types/features/proof/ProofChain.d.ts +225 -0
  14. package/dist/types/features/stealth/StealthChain.d.ts +200 -0
  15. package/dist/types/index.d.ts +61 -0
  16. package/dist/types/utils/common.d.ts +11 -0
  17. package/dist/types/utils/encryption.d.ts +32 -0
  18. package/package.json +110 -26
  19. package/dist/gun-eth-protocol.cjs.js +0 -11528
  20. package/dist/gun-eth-protocol.esm.js +0 -11503
  21. package/dist/gun-eth-protocol.js +0 -18
  22. package/dist/gun-eth-protocol.react.js +0 -11503
  23. package/dist/gun-eth-protocol.umd.js +0 -18
  24. package/jsdoc.json +0 -7
  25. package/rollup.config.js +0 -80
  26. package/src/index.js +0 -181
  27. package/src/lib/authentication/index.js +0 -13
  28. package/src/lib/authentication/isAuthenticated.js +0 -20
  29. package/src/lib/authentication/login.js +0 -25
  30. package/src/lib/authentication/register.js +0 -58
  31. package/src/lib/blockchain/abis/SHINE.json +0 -262
  32. package/src/lib/blockchain/contracts/SHINE.sol +0 -52
  33. package/src/lib/blockchain/ethereum.js +0 -74
  34. package/src/lib/blockchain/shine.js +0 -204
  35. package/src/lib/certificates/friendsCertificates.js +0 -92
  36. package/src/lib/certificates/index.js +0 -44
  37. package/src/lib/certificates/messagingCertificates.js +0 -94
  38. package/src/lib/friends/acceptFriendRequest.js +0 -69
  39. package/src/lib/friends/addFriendRequest.js +0 -49
  40. package/src/lib/friends/friendRequests.js +0 -51
  41. package/src/lib/friends/friendsList.js +0 -57
  42. package/src/lib/friends/index.js +0 -36
  43. package/src/lib/friends/rejectFriendRequest.js +0 -31
  44. package/src/lib/messaging/chatsList.js +0 -42
  45. package/src/lib/messaging/createChat.js +0 -132
  46. package/src/lib/messaging/index.js +0 -36
  47. package/src/lib/messaging/messageList.js +0 -106
  48. package/src/lib/messaging/sendMessage.js +0 -132
  49. package/src/lib/messaging/sendVoiceMessage.js +0 -119
  50. package/src/lib/notes/createNote.js +0 -41
  51. package/src/lib/notes/deleteNote.js +0 -12
  52. package/src/lib/notes/getNote.js +0 -25
  53. package/src/lib/notes/getUserNote.js +0 -59
  54. package/src/lib/notes/index.js +0 -8
  55. package/src/lib/notes/updateNotes.js +0 -35
  56. package/src/lib/post/createPost.js +0 -17
  57. package/src/lib/post/decryptPost.js +0 -14
  58. package/src/lib/post/deletePost.js +0 -13
  59. package/src/lib/post/encryptPost,js +0 -16
  60. package/src/lib/post/getPost.js +0 -36
  61. package/src/lib/post/index.js +0 -9
  62. package/src/lib/post/updatePost.js +0 -16
  63. package/src/state/gun.js +0 -33
  64. package/types/types.d.ts +0 -244
@@ -1,41 +0,0 @@
1
- /**
2
- * Creates a new note.
3
- * @param {string} title - The title of the note.
4
- * @param {string} author - The author of the note.
5
- * @param {string} content - The content of the note.
6
- * @param {boolean} isPublic - Whether the note is public or private.
7
- * @param {string} [verification=''] - Verification data for public notes.
8
- * @returns {Promise<string>} A promise that resolves to the note's hash.
9
- */
10
- const createNote = async (title, author, content, isPublic, verification = '') => {
11
- if (!isPublic && !user.is) {
12
- console.log("L'utente deve essere autenticato per creare note private");
13
- throw new Error("L'utente deve essere autenticato per creare note private");
14
- }
15
-
16
- const noteData = {
17
- title: DOMPurify.sanitize(title),
18
- author: DOMPurify.sanitize(author),
19
- content: DOMPurify.sanitize(content),
20
- verification: isPublic ? DOMPurify.sanitize(verification) : '',
21
- lastUpdated: new Date().toISOString(),
22
- isPublic: isPublic
23
- };
24
-
25
- const noteString = JSON.stringify(noteData);
26
- const hash = await SEA.work(noteString, null, null, { name: "SHA-256" });
27
-
28
- if (isPublic) {
29
- await gun.get("gun-eth").get("public-notes").get(hash).put(noteString);
30
- } else {
31
- if (!user.is) {
32
- throw new Error("L'utente deve essere autenticato per creare note private");
33
- }
34
- await user.get("gun-eth").get("private-notes").get(hash).put(noteData);
35
- }
36
-
37
- return hash;
38
- };
39
-
40
- export default createNote;
41
-
@@ -1,12 +0,0 @@
1
- /**
2
- * Deletes a note by its hash.
3
- * @param {string} hash - The hash of the note to delete.
4
- * @returns {Promise<void>}
5
- */
6
- export const deleteNote = async (hash, isPublic) => {
7
- if (isPublic) {
8
- await gun.get("gun-eth").get("public-notes").get(hash).put(null);
9
- } else {
10
- await user.get("gun-eth").get("private-notes").get(hash).put(null);
11
- }
12
- };
@@ -1,25 +0,0 @@
1
- /**
2
- * Retrieves a note by its hash.
3
- * @param {string} hash - The hash of the note to retrieve.
4
- * @returns {Promise<Object|null>} A promise that resolves to the note object or null if not found.
5
- */
6
- const getNote = async (hash) => {
7
- const publicNote = await gun.get("gun-eth").get("public-notes").get(hash).then();
8
- if (publicNote) {
9
- return JSON.parse(publicNote);
10
- }
11
-
12
- if (!user.is) {
13
- throw new Error("L'utente deve essere autenticato per accedere alle note private");
14
- }
15
-
16
- const privateNote = await user.get("gun-eth").get("private-notes").get(hash).then();
17
- if (privateNote) {
18
- const decryptedData = await SEA.decrypt(privateNote, user._.sea);
19
- return JSON.parse(decryptedData);
20
- }
21
-
22
- return null;
23
- };
24
-
25
- export default getNote;
@@ -1,59 +0,0 @@
1
-
2
- /**
3
- * Retrieves all notes for the current user.
4
- * @returns {Promise<Array>} A promise that resolves to an array of user's notes.
5
- */
6
- const getUserNotes = () => {
7
- return new Promise((resolve) => {
8
- const notes = [];
9
-
10
- const loadPublicNotes = () => {
11
- return new Promise((resolvePublic) => {
12
- gun.get("gun-eth").get("public-notes").map().once((data, id) => {
13
- if (data && id !== '_') {
14
- try {
15
- notes.push({ id, ...JSON.parse(data), isPublic: true });
16
- } catch (error) {
17
- console.error("Errore durante il parsing della nota pubblica:", error);
18
- notes.push({ id, error: "Errore durante il parsing della nota", isPublic: true });
19
- }
20
- }
21
- });
22
- setTimeout(resolvePublic, 500);
23
- });
24
- };
25
-
26
- const loadPrivateNotes = () => {
27
- return new Promise((resolvePrivate) => {
28
- if (user.is) {
29
- user.get("gun-eth").get("private-notes").map().once(async (data, id) => {
30
- if (data && id !== '_') {
31
- try {
32
- const decryptedData = await SEA.decrypt(data, user._.sea);
33
- console.log("decryptedData:", decryptedData);
34
- if (typeof decryptedData === 'string' ) {
35
- notes.push({ id, ...JSON.parse(decryptedData), isPublic: false });
36
- } else if (typeof decryptedData === 'object' && decryptedData !== null) {
37
- notes.push({ id, ...decryptedData, isPublic: false });
38
- } else {
39
- console.error("Dati decriptati non validi:", decryptedData);
40
- notes.push({ id, error: "Dati decriptati non validi", isPublic: false });
41
- }
42
- } catch (error) {
43
- console.error("Errore durante la decrittazione della nota privata:", error);
44
- notes.push({ id, error: "Errore durante la decrittazione della nota", isPublic: false });
45
- }
46
- }
47
- });
48
- }
49
- setTimeout(resolvePrivate, 500);
50
- });
51
- };
52
-
53
- Promise.all([loadPublicNotes(), loadPrivateNotes()]).then(() => {
54
- resolve(notes);
55
- });
56
- });
57
- };
58
-
59
- export default getUserNotes;
@@ -1,8 +0,0 @@
1
- import createNote from "./createNote";
2
- import deleteNote from "./deleteNote";
3
- import getNote from "./getNote";
4
- import updateNote from "./updateNote";
5
- import getUserNotes from "./getUserNote";
6
-
7
- export { createNote, deleteNote, getNote, updateNote, getUserNotes };
8
-
@@ -1,35 +0,0 @@
1
- /**
2
- * Updates an existing note.
3
- * @param {string} hash - The hash of the note to update.
4
- * @param {string} title - The updated title of the note.
5
- * @param {string} author - The updated author of the note.
6
- * @param {string} content - The updated content of the note.
7
- * @param {boolean} isPublic - Whether the note is public or private.
8
- * @param {string} [verification=''] - Updated verification data for public notes.
9
- * @returns {Promise<void>}
10
- */
11
- const updateNote = async (hash, title, author, content, isPublic, verification = '') => {
12
- const noteData = {
13
- title: DOMPurify.sanitize(title),
14
- author: DOMPurify.sanitize(author),
15
- content: DOMPurify.sanitize(content),
16
- verification: isPublic ? DOMPurify.sanitize(verification) : '',
17
- lastUpdated: new Date().toISOString(),
18
- isPublic: isPublic
19
- };
20
-
21
- const noteString = JSON.stringify(noteData);
22
-
23
- if (isPublic) {
24
- await gun.get("gun-eth").get("public-notes").get(hash).put(noteString);
25
- } else {
26
- if (!user.is) {
27
- throw new Error("L'utente deve essere autenticato per aggiornare note private");
28
- }
29
- const encryptedData = await SEA.encrypt(noteString, user._.sea);
30
- await user.get("gun-eth").get("private-notes").get(hash).put(encryptedData);
31
- }
32
- };
33
-
34
-
35
- export default updateNote;
@@ -1,17 +0,0 @@
1
- import { gun } from "../../state/gun";
2
- /**
3
- * Creates a new encrypted post.
4
- * @param {Object} post - The post object to create.
5
- * @param {string} token - The encryption token.
6
- * @returns {Promise<string>} A promise that resolves to the new post's key.
7
- */
8
- const createPost = async (post, token) => {
9
- const dbPosts = gun.get('gun-eth').get('posts');
10
-
11
- const encrypted = await encryptPost(post, token);
12
- const key = Date.now().toString();
13
- await dbPosts.get(key).put(encrypted);
14
- return key;
15
- };
16
-
17
- export default createPost;
@@ -1,14 +0,0 @@
1
- import SEA from "gun/sea";
2
-
3
- /**
4
- * Decrypts a post's text content.
5
- * @param {Object} post - The encrypted post object to decrypt.
6
- * @param {string} token - The decryption token.
7
- * @returns {Promise<Object>} A promise that resolves to the decrypted post object.
8
- */
9
- const decryptPost = async (post, token) => {
10
- const text = await SEA.decrypt(post.text, token);
11
- return { ...post, text };
12
- };
13
-
14
- export default decryptPost;
@@ -1,13 +0,0 @@
1
- import { gun } from "../../state/gun";
2
-
3
- /**
4
- * Deletes a post by its key.
5
- * @param {string} key - The key of the post to delete.
6
- * @returns {Promise<void>}
7
- */
8
- const deletePost = async (key) => {
9
- const dbPosts = gun.get('gun-eth').get('posts');
10
- await dbPosts.get(key).put(null);
11
- };
12
-
13
- export default deletePost;
@@ -1,16 +0,0 @@
1
- import SEA from "gun/sea";
2
-
3
- /**
4
- * Encrypts a post's text content.
5
- * @param {Object} post - The post object to encrypt.
6
- * @param {string} token - The encryption token.
7
- * @returns {Promise<Object>} A promise that resolves to the encrypted post object.
8
- */
9
- const encryptPost = async (post, token) => {
10
- const text = await SEA.encrypt(post.text, token);
11
- return { ...post, text };
12
- };
13
-
14
-
15
- export default encryptPost;
16
-
@@ -1,36 +0,0 @@
1
- import { gun } from "../../state/gun";
2
- import decryptPost from "./decryptPost";
3
-
4
- /**
5
- * Retrieves and decrypts a post by its key.
6
- * @param {string} key - The key of the post to retrieve.
7
- * @param {string} token - The decryption token.
8
- * @returns {Promise<Object|null>} A promise that resolves to the decrypted post object or null if not found.
9
- */
10
- export const getPost = async (key, token) => {
11
- const dbPosts = gun.get('gun-eth').get('posts');
12
-
13
- const post = await dbPosts.get(key).then();
14
- if (post) {
15
- return await decryptPost(post, token);
16
- }
17
- return null;
18
- };
19
-
20
- /**
21
- * Retrieves and decrypts all posts.
22
- * @param {string} token - The decryption token.
23
- * @returns {Promise<Array>} A promise that resolves to an array of decrypted post objects.
24
- */
25
- exportconst getAllPosts = async (token) => {
26
- return new Promise((resolve) => {
27
- const posts = [];
28
- dbPosts.map().once(async (data, key) => {
29
- if (data) {
30
- const decrypted = await decryptPost(data, token);
31
- posts.push({ ...decrypted, id: key });
32
- }
33
- resolve(posts);
34
- });
35
- });
36
- };
@@ -1,9 +0,0 @@
1
- import createPost from "./createPost";
2
- import deletePost from "./deletePost";
3
- import getPost from "./getPost";
4
- import updatePost from "./updatePost";
5
- import decryptPost from "./decryptPost";
6
- import encryptPost from "./encryptPost";
7
- import getAllPosts from "./getPost";
8
-
9
- export { createPost, deletePost, getPost, updatePost, decryptPost, encryptPost, getAllPosts };
@@ -1,16 +0,0 @@
1
- import { gun } from "../../state/gun";
2
- import encryptPost from "./encryptPost";
3
-
4
- /**
5
- * Updates an existing post with new encrypted content.
6
- * @param {string} key - The key of the post to update.
7
- * @param {Object} post - The updated post object.
8
- * @param {string} token - The encryption token.
9
- * @returns {Promise<void>}
10
- */
11
- const updatePost = async (key, post, token) => {
12
- const encrypted = await encryptPost(post, token);
13
- await dbPosts.get(key).put(encrypted);
14
- };
15
-
16
- export default updatePost;
package/src/state/gun.js DELETED
@@ -1,33 +0,0 @@
1
- /**
2
- * Modulo per l'inizializzazione e la configurazione di Gun.js
3
- * @module gun
4
- */
5
-
6
- // Importa il modulo principale di Gun
7
- import Gun from "gun/gun";
8
- // Importa i moduli aggiuntivi di Gun
9
- import "gun/sea"; // Per la crittografia
10
- import "gun/lib/radix"; // Per l'ottimizzazione delle prestazioni
11
- import "gun/lib/radisk"; // Per la persistenza dei dati
12
- import "gun/lib/store"; // Per il salvataggio dei dati
13
- import "gun/lib/rindexed"; // Per l'indicizzazione dei dati
14
-
15
- /**
16
- * Inizializza un'istanza di Gun con configurazioni specifiche
17
- * @type {Gun}
18
- */
19
- let gun = new Gun({
20
- peers: ["https://gun-relay.scobrudot.dev/gun"], // Server peer per la sincronizzazione dei dati
21
- axe: false, // Disabilita il protocollo AXE
22
- localStorage: false, // Disabilita l'uso di localStorage
23
- radisk: true, // Abilita Radisk per la persistenza dei dati
24
- });
25
-
26
- /**
27
- * Inizializza un utente Gun e richiama la sessione da sessionStorage
28
- * @type {GunUser}
29
- */
30
- let user = gun.user().recall({ sessionStorage: true });
31
-
32
- // Esporta le istanze gun e user per l'uso in altri moduli
33
- export { gun, user };
package/types/types.d.ts DELETED
@@ -1,244 +0,0 @@
1
- /**
2
- * This contains a subscribable function that will return a boolean of whether or not the user is authenticated or not.
3
- */
4
- declare var isAuthenticated: any;
5
-
6
- /**
7
- * This function will check and see whether the user is authenticated or not.
8
- */
9
- declare function checkAuth(): void;
10
-
11
- /**
12
- * This function will authenticate a user who has registered.
13
- * @param credentials - The users authentication credentials that they used when registering.
14
- * @param callback - The callback function returns error messages or a success message.
15
- */
16
- declare function loginUser(credentials: {
17
- username: any;
18
- password: any;
19
- }, callback: (...params: any[]) => any): void;
20
-
21
- /**
22
- * This function will check to see if the email is already in use.
23
- * @returns Promise<boolean>
24
- */
25
- declare function checkUsernameInUse(username: string): any;
26
-
27
- /**
28
- * This function will create a user.
29
- * @param credentials - The users authentication credentials that they want to use when logging in.
30
- * @param callback - The callback function returns error messages or a success message.
31
- */
32
- declare function registerUser(credentials: {
33
- username: any;
34
- password: any;
35
- }, callback: (...params: any[]) => any): void;
36
-
37
- /**
38
- * Genera un certificato per le richieste di amicizia.
39
- * @param callback - Funzione di callback chiamata al completamento dell'operazione.
40
- */
41
- declare function generateFriendRequestsCertificate(callback: (...params: any[]) => any): Promise<void>;
42
-
43
- /**
44
- * Genera un certificato per aggiungere un amico.
45
- * @param publicKey - Chiave pubblica dell'amico da aggiungere.
46
- * @param callback - Funzione di callback chiamata al completamento dell'operazione.
47
- */
48
- declare function generateAddFriendCertificate(publicKey: string, callback: (...params: any[]) => any): Promise<void>;
49
-
50
- /**
51
- * Modulo per la gestione dei certificati nell'applicazione.
52
- */
53
- declare module "certificates" { }
54
-
55
- /**
56
- * Crea un certificato per le chat con un utente specifico.
57
- * @param publicKey - La chiave pubblica dell'utente per cui creare il certificato.
58
- * @param [callback] - Funzione di callback opzionale chiamata al completamento dell'operazione.
59
- */
60
- declare function createChatsCertificate(publicKey: string, callback?: (...params: any[]) => any): Promise<void>;
61
-
62
- /**
63
- * Crea un certificato per i messaggi con un utente specifico.
64
- * @param publicKey - La chiave pubblica dell'utente per cui creare il certificato.
65
- * @param [callback] - Funzione di callback opzionale chiamata al completamento dell'operazione.
66
- */
67
- declare function createMessagesCertificate(publicKey: string, callback?: (...params: any[]) => any): Promise<void>;
68
-
69
- /**
70
- * Accetta una richiesta di amicizia.
71
- * @param params - Parametri della funzione.
72
- * @param params.key - Chiave della richiesta di amicizia.
73
- * @param params.publicKey - Chiave pubblica dell'utente che ha inviato la richiesta.
74
- * @param [callback] - Funzione di callback opzionale.
75
- */
76
- declare function acceptFriendRequest(params: {
77
- key: string;
78
- publicKey: string;
79
- }, callback?: (...params: any[]) => any): void;
80
-
81
- /**
82
- * Invia una richiesta di amicizia a un utente specifico.
83
- * @param publicKey - La chiave pubblica dell'utente a cui inviare la richiesta di amicizia.
84
- * @param [callback] - Funzione di callback opzionale chiamata al completamento dell'operazione.
85
- */
86
- declare function addFriendRequest(publicKey: string, callback?: (...params: any[]) => any): Promise<void>;
87
-
88
- /**
89
- * Questo Observable emette oggetti contenenti informazioni sulle richieste di amicizia.
90
- Ogni oggetto emesso può avere le seguenti proprietà:
91
- - key: La chiave della richiesta di amicizia
92
- - pub: La chiave pubblica dell'utente che ha inviato la richiesta
93
- - alias: L'alias dell'utente che ha inviato la richiesta
94
- - displayName: Il nome visualizzato dell'utente (se disponibile)
95
- - about: Informazioni aggiuntive sull'utente (se disponibili)
96
-
97
- Se non ci sono richieste di amicizia, l'Observable emetterà `undefined`.
98
- */
99
- declare var friendRequests: Observable;
100
-
101
- /**
102
- * Modulo per la gestione della lista degli amici.
103
- */
104
- declare module "friendsList" {
105
- /**
106
- * Questo Observable emette oggetti contenenti informazioni sugli amici dell'utente.
107
- Ogni oggetto emesso può avere le seguenti proprietà:
108
- - key: La chiave dell'amico
109
- - pub: La chiave pubblica dell'amico
110
- - alias: L'alias dell'amico
111
- - displayName: Il nome visualizzato dell'amico (se disponibile)
112
- - about: Informazioni aggiuntive sull'amico (se disponibili)
113
-
114
- Se non ci sono amici nella lista, l'Observable emetterà `undefined`.
115
- */
116
- var friendsList: Observable;
117
- }
118
-
119
- /**
120
- * Modulo per la gestione delle amicizie
121
- */
122
- declare module "friends" {
123
- /**
124
- * Aggiunge una richiesta di amicizia
125
- */
126
- var addFriendRequest: any;
127
- /**
128
- * Accetta una richiesta di amicizia
129
- */
130
- var acceptFriendRequest: any;
131
- /**
132
- * Rifiuta una richiesta di amicizia
133
- */
134
- var rejectFriendRequest: any;
135
- /**
136
- * Ottiene l'elenco delle richieste di amicizia
137
- */
138
- var friendRequests: any;
139
- /**
140
- * Ottiene l'elenco degli amici
141
- */
142
- var friendsList: any;
143
- }
144
-
145
- /**
146
- * Rifiuta una richiesta di amicizia.
147
- * @param key - La chiave della richiesta di amicizia da rifiutare.
148
- * @param [callback] - Funzione di callback opzionale chiamata al completamento dell'operazione.
149
- */
150
- declare function rejectFriendRequest(key: string, callback?: (...params: any[]) => any): void;
151
-
152
- /**
153
- * Questo Observable si sottoscrive ai cambiamenti nella lista delle chat dell'utente
154
- e emette un nuovo oggetto per ogni chat aggiornata. Ogni oggetto chat contiene:
155
- - roomId: l'identificatore univoco della stanza di chat
156
- - pub: la chiave pubblica associata alla chat
157
- - latestMessage: l'ultimo messaggio nella chat
158
- * @example
159
- * chatsList.subscribe(chat => {
160
- console.log('Chat aggiornata:', chat);
161
- });
162
- */
163
- declare var chatsList: Observable;
164
-
165
- /**
166
- * Modulo per la creazione di una nuova chat.
167
- */
168
- declare module "createChat" {
169
- /**
170
- * Questa funzione crea una nuova chat tra l'utente corrente e un altro utente specificato dalla sua chiave pubblica.
171
- Verifica prima se la chat esiste già, poi controlla i certificati necessari e infine crea la chat per entrambi gli utenti.
172
- * @example
173
- * createChat("chiavePubblicaUtente", (result) => {
174
- if (result.success) {
175
- console.log("Chat creata:", result.chat);
176
- } else {
177
- console.error("Errore:", result.errMessage);
178
- }
179
- });
180
- * @param publicKey - La chiave pubblica dell'utente con cui creare la chat.
181
- * @param [callback] - Funzione di callback opzionale chiamata al completamento dell'operazione.
182
- */
183
- function createChat(publicKey: string, callback?: (...params: any[]) => any): Promise<void>;
184
- }
185
-
186
- /**
187
- * Modulo per la gestione dei messaggi e delle chat
188
- */
189
- declare module "messaging" {
190
- /**
191
- * Crea una nuova chat
192
- */
193
- var createChat: any;
194
- /**
195
- * Ottiene la lista delle chat
196
- */
197
- var chatsList: any;
198
- /**
199
- * Ottiene la lista dei messaggi di una chat
200
- */
201
- var messageList: any;
202
- /**
203
- * Invia un messaggio di testo
204
- */
205
- var sendMessage: any;
206
- /**
207
- * Invia un messaggio vocale
208
- */
209
- var sendVoiceMessage: any;
210
- }
211
-
212
- /**
213
- * Questa funzione crea un Observable che si sottoscrive ai messaggi di una specifica chat.
214
- Decripta i messaggi utilizzando la chiave pubblica dell'altro utente e emette sia un array iniziale
215
- di messaggi che singoli messaggi man mano che vengono ricevuti.
216
- * @example
217
- * const messages$ = messageList('room123', 'publicKey123');
218
- messages$.subscribe(({ initial, individual }) => {
219
- if (initial) {
220
- console.log('Messaggi iniziali:', initial);
221
- } else if (individual) {
222
- console.log('Nuovo messaggio:', individual);
223
- }
224
- });
225
- * @param roomId - L'identificatore univoco della stanza di chat.
226
- * @param pub - La chiave pubblica dell'altro utente nella chat.
227
- * @returns Un Observable che emette oggetti contenenti messaggi iniziali e individuali.
228
- */
229
- declare function messageList(roomId: string, pub: string): Observable;
230
-
231
- /**
232
- * Modulo per l'inizializzazione e la configurazione di Gun.js
233
- */
234
- declare module "gun" {
235
- /**
236
- * Inizializza un'istanza di Gun con configurazioni specifiche
237
- */
238
- var gun: Gun;
239
- /**
240
- * Inizializza un utente Gun e richiama la sessione da sessionStorage
241
- */
242
- var user: GunUser;
243
- }
244
-