@massalabs/gossip-sdk 0.0.2-dev.20260128094509 → 0.0.2-dev.20260128160824

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 (148) hide show
  1. package/dist/api/messageProtocol/index.d.ts +19 -0
  2. package/dist/api/messageProtocol/index.js +26 -0
  3. package/dist/api/messageProtocol/mock.d.ts +12 -0
  4. package/{src/api/messageProtocol/mock.ts → dist/api/messageProtocol/mock.js} +2 -3
  5. package/dist/api/messageProtocol/rest.d.ts +22 -0
  6. package/dist/api/messageProtocol/rest.js +161 -0
  7. package/dist/api/messageProtocol/types.d.ts +61 -0
  8. package/dist/api/messageProtocol/types.js +6 -0
  9. package/dist/assets/generated/wasm/README.md +281 -0
  10. package/dist/assets/generated/wasm/gossip_wasm.d.ts +638 -0
  11. package/dist/assets/generated/wasm/gossip_wasm.js +1557 -0
  12. package/dist/assets/generated/wasm/gossip_wasm_bg.wasm +0 -0
  13. package/dist/assets/generated/wasm/gossip_wasm_bg.wasm.d.ts +164 -0
  14. package/dist/assets/generated/wasm/package.json +15 -0
  15. package/dist/assets/generated/wasm-node/README.md +281 -0
  16. package/dist/assets/generated/wasm-node/gossip_wasm.d.ts +443 -0
  17. package/dist/assets/generated/wasm-node/gossip_wasm.js +1488 -0
  18. package/dist/assets/generated/wasm-node/gossip_wasm_bg.wasm +0 -0
  19. package/dist/assets/generated/wasm-node/gossip_wasm_bg.wasm.d.ts +164 -0
  20. package/dist/assets/generated/wasm-node/package.json +11 -0
  21. package/dist/config/protocol.d.ts +36 -0
  22. package/dist/config/protocol.js +77 -0
  23. package/dist/config/sdk.d.ts +82 -0
  24. package/dist/config/sdk.js +55 -0
  25. package/{src/contacts.ts → dist/contacts.d.ts} +11 -95
  26. package/dist/contacts.js +166 -0
  27. package/dist/core/SdkEventEmitter.d.ts +36 -0
  28. package/dist/core/SdkEventEmitter.js +59 -0
  29. package/dist/core/SdkPolling.d.ts +35 -0
  30. package/dist/core/SdkPolling.js +100 -0
  31. package/{src/core/index.ts → dist/core/index.d.ts} +0 -2
  32. package/dist/core/index.js +5 -0
  33. package/dist/crypto/bip39.d.ts +34 -0
  34. package/dist/crypto/bip39.js +62 -0
  35. package/dist/crypto/encryption.d.ts +37 -0
  36. package/dist/crypto/encryption.js +46 -0
  37. package/dist/db.d.ts +190 -0
  38. package/dist/db.js +311 -0
  39. package/dist/gossipSdk.d.ts +274 -0
  40. package/dist/gossipSdk.js +690 -0
  41. package/dist/index.d.ts +59 -0
  42. package/dist/index.js +61 -0
  43. package/dist/services/announcement.d.ts +43 -0
  44. package/dist/services/announcement.js +491 -0
  45. package/dist/services/auth.d.ts +37 -0
  46. package/dist/services/auth.js +76 -0
  47. package/dist/services/discussion.d.ts +63 -0
  48. package/dist/services/discussion.js +297 -0
  49. package/dist/services/message.d.ts +74 -0
  50. package/dist/services/message.js +826 -0
  51. package/dist/services/refresh.d.ts +41 -0
  52. package/dist/services/refresh.js +205 -0
  53. package/{src/sw.ts → dist/sw.d.ts} +1 -8
  54. package/dist/sw.js +10 -0
  55. package/dist/types/events.d.ts +80 -0
  56. package/dist/types/events.js +7 -0
  57. package/dist/types.d.ts +32 -0
  58. package/dist/types.js +7 -0
  59. package/dist/utils/base64.d.ts +10 -0
  60. package/dist/utils/base64.js +30 -0
  61. package/dist/utils/contacts.d.ts +42 -0
  62. package/dist/utils/contacts.js +113 -0
  63. package/dist/utils/discussions.d.ts +24 -0
  64. package/dist/utils/discussions.js +38 -0
  65. package/dist/utils/logs.d.ts +19 -0
  66. package/dist/utils/logs.js +89 -0
  67. package/dist/utils/messageSerialization.d.ts +64 -0
  68. package/dist/utils/messageSerialization.js +184 -0
  69. package/dist/utils/queue.d.ts +50 -0
  70. package/dist/utils/queue.js +110 -0
  71. package/dist/utils/type.d.ts +10 -0
  72. package/dist/utils/type.js +4 -0
  73. package/dist/utils/userId.d.ts +40 -0
  74. package/dist/utils/userId.js +90 -0
  75. package/dist/utils/validation.d.ts +50 -0
  76. package/dist/utils/validation.js +112 -0
  77. package/dist/utils.d.ts +30 -0
  78. package/{src/utils.ts → dist/utils.js} +9 -19
  79. package/dist/wasm/encryption.d.ts +56 -0
  80. package/{src/wasm/encryption.ts → dist/wasm/encryption.js} +22 -51
  81. package/dist/wasm/index.d.ts +10 -0
  82. package/{src/wasm/index.ts → dist/wasm/index.js} +1 -8
  83. package/dist/wasm/loader.d.ts +22 -0
  84. package/dist/wasm/loader.js +78 -0
  85. package/dist/wasm/session.d.ts +85 -0
  86. package/dist/wasm/session.js +226 -0
  87. package/dist/wasm/userKeys.d.ts +17 -0
  88. package/{src/wasm/userKeys.ts → dist/wasm/userKeys.js} +6 -13
  89. package/package.json +15 -2
  90. package/src/api/messageProtocol/index.ts +0 -53
  91. package/src/api/messageProtocol/rest.ts +0 -209
  92. package/src/api/messageProtocol/types.ts +0 -70
  93. package/src/config/protocol.ts +0 -97
  94. package/src/config/sdk.ts +0 -131
  95. package/src/core/SdkEventEmitter.ts +0 -91
  96. package/src/core/SdkPolling.ts +0 -134
  97. package/src/crypto/bip39.ts +0 -84
  98. package/src/crypto/encryption.ts +0 -77
  99. package/src/db.ts +0 -465
  100. package/src/gossipSdk.ts +0 -994
  101. package/src/index.ts +0 -211
  102. package/src/services/announcement.ts +0 -653
  103. package/src/services/auth.ts +0 -95
  104. package/src/services/discussion.ts +0 -380
  105. package/src/services/message.ts +0 -1055
  106. package/src/services/refresh.ts +0 -234
  107. package/src/types/events.ts +0 -108
  108. package/src/types.ts +0 -70
  109. package/src/utils/base64.ts +0 -39
  110. package/src/utils/contacts.ts +0 -161
  111. package/src/utils/discussions.ts +0 -55
  112. package/src/utils/logs.ts +0 -86
  113. package/src/utils/messageSerialization.ts +0 -257
  114. package/src/utils/queue.ts +0 -106
  115. package/src/utils/type.ts +0 -7
  116. package/src/utils/userId.ts +0 -114
  117. package/src/utils/validation.ts +0 -144
  118. package/src/wasm/loader.ts +0 -123
  119. package/src/wasm/session.ts +0 -276
  120. package/test/config/protocol.spec.ts +0 -31
  121. package/test/config/sdk.spec.ts +0 -163
  122. package/test/db/helpers.spec.ts +0 -142
  123. package/test/db/operations.spec.ts +0 -128
  124. package/test/db/states.spec.ts +0 -535
  125. package/test/integration/discussion-flow.spec.ts +0 -422
  126. package/test/integration/messaging-flow.spec.ts +0 -708
  127. package/test/integration/sdk-lifecycle.spec.ts +0 -325
  128. package/test/mocks/index.ts +0 -9
  129. package/test/mocks/mockMessageProtocol.ts +0 -100
  130. package/test/services/auth.spec.ts +0 -311
  131. package/test/services/discussion.spec.ts +0 -279
  132. package/test/services/message-deduplication.spec.ts +0 -299
  133. package/test/services/message-startup.spec.ts +0 -331
  134. package/test/services/message.spec.ts +0 -817
  135. package/test/services/refresh.spec.ts +0 -199
  136. package/test/services/session-status.spec.ts +0 -349
  137. package/test/session/wasm.spec.ts +0 -227
  138. package/test/setup.ts +0 -52
  139. package/test/utils/contacts.spec.ts +0 -156
  140. package/test/utils/discussions.spec.ts +0 -66
  141. package/test/utils/queue.spec.ts +0 -52
  142. package/test/utils/serialization.spec.ts +0 -120
  143. package/test/utils/userId.spec.ts +0 -120
  144. package/test/utils/validation.spec.ts +0 -223
  145. package/test/utils.ts +0 -212
  146. package/tsconfig.json +0 -26
  147. package/tsconfig.tsbuildinfo +0 -1
  148. package/vitest.config.ts +0 -28
package/src/index.ts DELETED
@@ -1,211 +0,0 @@
1
- /**
2
- * Gossip SDK
3
- *
4
- * Main entry point for the Gossip SDK.
5
- * Provides a platform-agnostic interface for automation, chatbot,
6
- * and integration use cases with the Gossip messenger.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { gossipSdk } from 'gossip-sdk';
11
- *
12
- * // Initialize once at app startup
13
- * await gossipSdk.init({
14
- * db,
15
- * protocolBaseUrl: 'https://api.example.com',
16
- * });
17
- *
18
- * // Open session (login)
19
- * await gossipSdk.openSession({ mnemonic: '...' });
20
- *
21
- * // Use clean API
22
- * await gossipSdk.messages.send(contactId, 'Hello!');
23
- * await gossipSdk.discussions.start(contact);
24
- *
25
- * // Events
26
- * gossipSdk.on('message', (msg) => { ... });
27
- *
28
- * // Logout
29
- * await gossipSdk.closeSession();
30
- * ```
31
- *
32
- * @packageDocumentation
33
- */
34
-
35
- // SDK version - matches package.json
36
- export const SDK_VERSION = '0.0.1';
37
-
38
- // ─────────────────────────────────────────────────────────────────────────────
39
- // SDK Singleton - Primary API
40
- // ─────────────────────────────────────────────────────────────────────────────
41
- export { gossipSdk, GossipSdkImpl } from './gossipSdk';
42
- export type {
43
- GossipSdkInitOptions,
44
- OpenSessionOptions,
45
- SdkEventType,
46
- SdkEventHandlers,
47
- } from './gossipSdk';
48
-
49
- // SDK Events
50
- export type { GossipSdkEvents } from './types/events';
51
-
52
- // Services - class-based with dependency injection
53
- export { AuthService } from './services/auth';
54
- export type { PublicKeyResult } from './services/auth';
55
- export {
56
- getPublicKeyErrorMessage,
57
- PUBLIC_KEY_NOT_FOUND_ERROR,
58
- PUBLIC_KEY_NOT_FOUND_MESSAGE,
59
- FAILED_TO_FETCH_ERROR,
60
- FAILED_TO_FETCH_MESSAGE,
61
- FAILED_TO_RETRIEVE_CONTACT_PUBLIC_KEY_ERROR,
62
- } from './services/auth';
63
-
64
- export {
65
- AnnouncementService,
66
- EstablishSessionError,
67
- } from './services/announcement';
68
- export type { AnnouncementReceptionResult } from './services/announcement';
69
-
70
- export { MessageService } from './services/message';
71
- export type { MessageResult, SendMessageResult } from './services/message';
72
-
73
- export { DiscussionService } from './services/discussion';
74
-
75
- export { RefreshService } from './services/refresh';
76
-
77
- // Contact Management (utility functions)
78
- export {
79
- getContacts,
80
- getContact,
81
- addContact,
82
- updateContactName,
83
- deleteContact,
84
- } from './contacts';
85
- export type {
86
- UpdateContactNameResult,
87
- DeleteContactResult,
88
- } from './utils/contacts';
89
-
90
- // Discussion utilities
91
- export { updateDiscussionName } from './utils/discussions';
92
- export type { UpdateDiscussionNameResult } from './utils/discussions';
93
-
94
- // Types - re-export all types from the types module
95
- export * from './types';
96
-
97
- // Message Protocol - for direct use by host apps
98
- export {
99
- createMessageProtocol,
100
- restMessageProtocol,
101
- RestMessageProtocol,
102
- MessageProtocol,
103
- } from './api/messageProtocol';
104
- export type {
105
- IMessageProtocol,
106
- EncryptedMessage,
107
- MessageProtocolResponse,
108
- BulletinItem,
109
- } from './api/messageProtocol';
110
-
111
- // Config - for runtime configuration
112
- export {
113
- setProtocolBaseUrl,
114
- resetProtocolBaseUrl,
115
- MessageProtocolType,
116
- protocolConfig,
117
- } from './config/protocol';
118
- export type { ProtocolConfig } from './config/protocol';
119
-
120
- // SDK Config - for SDK initialization options
121
- export { defaultSdkConfig, mergeConfig } from './config/sdk';
122
- export type {
123
- SdkConfig,
124
- PollingConfig,
125
- MessagesConfig,
126
- AnnouncementsConfig,
127
- DeepPartial,
128
- } from './config/sdk';
129
-
130
- // Database - for direct access by host apps
131
- export { setDb, getDb, db, GossipDatabase } from './db';
132
-
133
- // WASM utilities - for session management
134
- export { SessionModule, sessionStatusToString } from './wasm/session';
135
- export {
136
- initializeWasm,
137
- ensureWasmInitialized,
138
- startWasmInitialization,
139
- } from './wasm/loader';
140
- export {
141
- EncryptionKey,
142
- Nonce,
143
- generateEncryptionKey,
144
- generateEncryptionKeyFromSeed,
145
- encryptionKeyFromBytes,
146
- generateNonce,
147
- nonceFromBytes,
148
- encryptAead,
149
- decryptAead,
150
- } from './wasm/encryption';
151
- export { generateUserKeys } from './wasm/userKeys';
152
-
153
- // Utility functions - for direct use
154
- export {
155
- encodeUserId,
156
- decodeUserId,
157
- isValidUserId,
158
- formatUserId,
159
- generate as generateUserId,
160
- } from './utils/userId';
161
- export {
162
- validateUsernameFormat,
163
- validatePassword,
164
- validateUserIdFormat,
165
- validateUsernameAvailability,
166
- validateUsernameFormatAndAvailability,
167
- } from './utils/validation';
168
- export type { ValidationResult } from './utils/validation';
169
- export {
170
- encodeToBase64,
171
- decodeFromBase64,
172
- encodeToBase64Url,
173
- decodeFromBase64Url,
174
- } from './utils/base64';
175
- export type { Result } from './utils/type';
176
-
177
- // Message serialization utilities
178
- export {
179
- MESSAGE_TYPE_KEEP_ALIVE,
180
- serializeKeepAliveMessage,
181
- serializeRegularMessage,
182
- serializeReplyMessage,
183
- serializeForwardMessage,
184
- deserializeMessage,
185
- } from './utils/messageSerialization';
186
- export type { DeserializedMessage } from './utils/messageSerialization';
187
-
188
- // Crypto utilities
189
- export {
190
- generateMnemonic,
191
- validateMnemonic,
192
- mnemonicToSeed,
193
- accountFromMnemonic,
194
- PRIVATE_KEY_VERSION,
195
- } from './crypto/bip39';
196
- export { encrypt, decrypt, deriveKey } from './crypto/encryption';
197
-
198
- // WASM types and functions re-exported for convenience
199
- export {
200
- UserPublicKeys,
201
- UserSecretKeys,
202
- SessionStatus,
203
- SessionConfig,
204
- SessionManagerWrapper,
205
- SendMessageOutput,
206
- ReceiveMessageOutput,
207
- AnnouncementResult,
208
- generate_user_keys,
209
- } from './assets/generated/wasm/gossip_wasm';
210
-
211
- export { UserKeys } from './wasm/userKeys';