@massalabs/gossip-sdk 0.0.2-dev.20260128111120 → 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.
- package/dist/assets/generated/wasm/gossip_wasm.d.ts +299 -159
- package/dist/assets/generated/wasm/gossip_wasm.js +1323 -1165
- package/dist/assets/generated/wasm/gossip_wasm_bg.wasm +0 -0
- package/dist/assets/generated/wasm/gossip_wasm_bg.wasm.d.ts +140 -44
- package/dist/assets/generated/wasm/package.json +1 -1
- package/dist/assets/generated/wasm-node/README.md +281 -0
- package/dist/assets/generated/wasm-node/gossip_wasm.d.ts +443 -0
- package/dist/assets/generated/wasm-node/gossip_wasm.js +1488 -0
- package/dist/assets/generated/wasm-node/gossip_wasm_bg.wasm +0 -0
- package/dist/assets/generated/wasm-node/gossip_wasm_bg.wasm.d.ts +164 -0
- package/dist/assets/generated/wasm-node/package.json +11 -0
- package/dist/contacts.d.ts +1 -1
- package/dist/gossipSdk.d.ts +1 -1
- package/dist/index.d.ts +9 -23
- package/dist/index.js +19 -35
- package/dist/services/announcement.d.ts +1 -1
- package/dist/services/announcement.js +1 -1
- package/dist/services/auth.d.ts +1 -1
- package/dist/services/auth.js +1 -1
- package/dist/services/discussion.js +1 -1
- package/dist/services/message.js +1 -1
- package/dist/services/refresh.js +1 -1
- package/dist/wasm/encryption.d.ts +1 -1
- package/dist/wasm/encryption.js +1 -1
- package/dist/wasm/loader.d.ts +4 -3
- package/dist/wasm/loader.js +13 -38
- package/dist/wasm/session.d.ts +1 -1
- package/dist/wasm/session.js +1 -1
- package/dist/wasm/userKeys.d.ts +1 -1
- package/dist/wasm/userKeys.js +1 -1
- package/package.json +11 -2
|
Binary file
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_announcementresult_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_encryptionkey_free: (a: number, b: number) => void;
|
|
6
|
+
export const __wbg_nonce_free: (a: number, b: number) => void;
|
|
7
|
+
export const __wbg_receivemessageoutput_free: (a: number, b: number) => void;
|
|
8
|
+
export const __wbg_sendmessageoutput_free: (a: number, b: number) => void;
|
|
9
|
+
export const __wbg_sessionconfig_free: (a: number, b: number) => void;
|
|
10
|
+
export const __wbg_sessionmanagerwrapper_free: (a: number, b: number) => void;
|
|
11
|
+
export const __wbg_userkeys_free: (a: number, b: number) => void;
|
|
12
|
+
export const __wbg_userpublickeys_free: (a: number, b: number) => void;
|
|
13
|
+
export const __wbg_usersecretkeys_free: (a: number, b: number) => void;
|
|
14
|
+
export const aead_decrypt: (
|
|
15
|
+
a: number,
|
|
16
|
+
b: number,
|
|
17
|
+
c: number,
|
|
18
|
+
d: number,
|
|
19
|
+
e: number,
|
|
20
|
+
f: number
|
|
21
|
+
) => [number, number];
|
|
22
|
+
export const aead_encrypt: (
|
|
23
|
+
a: number,
|
|
24
|
+
b: number,
|
|
25
|
+
c: number,
|
|
26
|
+
d: number,
|
|
27
|
+
e: number,
|
|
28
|
+
f: number
|
|
29
|
+
) => [number, number];
|
|
30
|
+
export const announcementresult_announcer_public_keys: (a: number) => number;
|
|
31
|
+
export const announcementresult_timestamp: (a: number) => number;
|
|
32
|
+
export const announcementresult_user_data: (a: number) => [number, number];
|
|
33
|
+
export const encryptionkey_from_bytes: (
|
|
34
|
+
a: number,
|
|
35
|
+
b: number
|
|
36
|
+
) => [number, number, number];
|
|
37
|
+
export const encryptionkey_from_seed: (
|
|
38
|
+
a: number,
|
|
39
|
+
b: number,
|
|
40
|
+
c: number,
|
|
41
|
+
d: number
|
|
42
|
+
) => [number, number, number];
|
|
43
|
+
export const encryptionkey_generate: () => number;
|
|
44
|
+
export const encryptionkey_to_bytes: (a: number) => [number, number];
|
|
45
|
+
export const generate_user_keys: (
|
|
46
|
+
a: number,
|
|
47
|
+
b: number
|
|
48
|
+
) => [number, number, number];
|
|
49
|
+
export const nonce_from_bytes: (
|
|
50
|
+
a: number,
|
|
51
|
+
b: number
|
|
52
|
+
) => [number, number, number];
|
|
53
|
+
export const nonce_generate: () => number;
|
|
54
|
+
export const nonce_to_bytes: (a: number) => [number, number];
|
|
55
|
+
export const receivemessageoutput_acknowledged_seekers: (a: number) => any;
|
|
56
|
+
export const receivemessageoutput_message: (a: number) => [number, number];
|
|
57
|
+
export const receivemessageoutput_timestamp: (a: number) => number;
|
|
58
|
+
export const receivemessageoutput_user_id: (a: number) => [number, number];
|
|
59
|
+
export const sendmessageoutput_data: (a: number) => [number, number];
|
|
60
|
+
export const sendmessageoutput_seeker: (a: number) => [number, number];
|
|
61
|
+
export const sessionconfig_new: (
|
|
62
|
+
a: number,
|
|
63
|
+
b: number,
|
|
64
|
+
c: number,
|
|
65
|
+
d: number,
|
|
66
|
+
e: number,
|
|
67
|
+
f: number,
|
|
68
|
+
g: bigint
|
|
69
|
+
) => number;
|
|
70
|
+
export const sessionconfig_new_default: () => number;
|
|
71
|
+
export const sessionmanagerwrapper_establish_outgoing_session: (
|
|
72
|
+
a: number,
|
|
73
|
+
b: number,
|
|
74
|
+
c: number,
|
|
75
|
+
d: number,
|
|
76
|
+
e: number,
|
|
77
|
+
f: number
|
|
78
|
+
) => [number, number];
|
|
79
|
+
export const sessionmanagerwrapper_feed_incoming_announcement: (
|
|
80
|
+
a: number,
|
|
81
|
+
b: number,
|
|
82
|
+
c: number,
|
|
83
|
+
d: number,
|
|
84
|
+
e: number
|
|
85
|
+
) => number;
|
|
86
|
+
export const sessionmanagerwrapper_feed_incoming_message_board_read: (
|
|
87
|
+
a: number,
|
|
88
|
+
b: number,
|
|
89
|
+
c: number,
|
|
90
|
+
d: number,
|
|
91
|
+
e: number,
|
|
92
|
+
f: number
|
|
93
|
+
) => number;
|
|
94
|
+
export const sessionmanagerwrapper_from_encrypted_blob: (
|
|
95
|
+
a: number,
|
|
96
|
+
b: number,
|
|
97
|
+
c: number
|
|
98
|
+
) => [number, number, number];
|
|
99
|
+
export const sessionmanagerwrapper_get_message_board_read_keys: (
|
|
100
|
+
a: number
|
|
101
|
+
) => any;
|
|
102
|
+
export const sessionmanagerwrapper_new: (a: number) => number;
|
|
103
|
+
export const sessionmanagerwrapper_peer_discard: (
|
|
104
|
+
a: number,
|
|
105
|
+
b: number,
|
|
106
|
+
c: number
|
|
107
|
+
) => [number, number];
|
|
108
|
+
export const sessionmanagerwrapper_peer_list: (a: number) => any;
|
|
109
|
+
export const sessionmanagerwrapper_peer_session_status: (
|
|
110
|
+
a: number,
|
|
111
|
+
b: number,
|
|
112
|
+
c: number
|
|
113
|
+
) => [number, number, number];
|
|
114
|
+
export const sessionmanagerwrapper_refresh: (a: number) => any;
|
|
115
|
+
export const sessionmanagerwrapper_send_message: (
|
|
116
|
+
a: number,
|
|
117
|
+
b: number,
|
|
118
|
+
c: number,
|
|
119
|
+
d: number,
|
|
120
|
+
e: number
|
|
121
|
+
) => [number, number, number];
|
|
122
|
+
export const sessionmanagerwrapper_to_encrypted_blob: (
|
|
123
|
+
a: number,
|
|
124
|
+
b: number
|
|
125
|
+
) => [number, number, number, number];
|
|
126
|
+
export const userkeys_public_keys: (a: number) => [number, number, number];
|
|
127
|
+
export const userkeys_secret_keys: (a: number) => [number, number, number];
|
|
128
|
+
export const userpublickeys_derive_id: (a: number) => [number, number];
|
|
129
|
+
export const userpublickeys_dsa_verification_key: (
|
|
130
|
+
a: number
|
|
131
|
+
) => [number, number];
|
|
132
|
+
export const userpublickeys_from_bytes: (
|
|
133
|
+
a: number,
|
|
134
|
+
b: number
|
|
135
|
+
) => [number, number, number];
|
|
136
|
+
export const userpublickeys_kem_public_key: (a: number) => [number, number];
|
|
137
|
+
export const userpublickeys_massa_public_key: (a: number) => [number, number];
|
|
138
|
+
export const userpublickeys_to_bytes: (
|
|
139
|
+
a: number
|
|
140
|
+
) => [number, number, number, number];
|
|
141
|
+
export const usersecretkeys_dsa_signing_key: (a: number) => [number, number];
|
|
142
|
+
export const usersecretkeys_from_bytes: (
|
|
143
|
+
a: number,
|
|
144
|
+
b: number
|
|
145
|
+
) => [number, number, number];
|
|
146
|
+
export const usersecretkeys_kem_secret_key: (a: number) => [number, number];
|
|
147
|
+
export const usersecretkeys_massa_secret_key: (a: number) => [number, number];
|
|
148
|
+
export const usersecretkeys_to_bytes: (
|
|
149
|
+
a: number
|
|
150
|
+
) => [number, number, number, number];
|
|
151
|
+
export const start: () => void;
|
|
152
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
153
|
+
export const __externref_table_alloc: () => number;
|
|
154
|
+
export const __wbindgen_export_2: WebAssembly.Table;
|
|
155
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
156
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
157
|
+
export const __wbindgen_realloc: (
|
|
158
|
+
a: number,
|
|
159
|
+
b: number,
|
|
160
|
+
c: number,
|
|
161
|
+
d: number
|
|
162
|
+
) => number;
|
|
163
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
164
|
+
export const __wbindgen_start: () => void;
|
package/dist/contacts.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { type Contact, type GossipDatabase } from './db';
|
|
21
21
|
import type { UpdateContactNameResult, DeleteContactResult } from './utils/contacts';
|
|
22
|
-
import type { UserPublicKeys } from '
|
|
22
|
+
import type { UserPublicKeys } from '#wasm';
|
|
23
23
|
import type { SessionModule } from './wasm/session';
|
|
24
24
|
export type { UpdateContactNameResult, DeleteContactResult };
|
|
25
25
|
/**
|
package/dist/gossipSdk.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ import { type MessageResult, type SendMessageResult } from './services/message';
|
|
|
46
46
|
import { AuthService } from './services/auth';
|
|
47
47
|
import type { DeleteContactResult, UpdateContactNameResult } from './utils/contacts';
|
|
48
48
|
import { type ValidationResult } from './utils/validation';
|
|
49
|
-
import type { UserPublicKeys } from '
|
|
49
|
+
import type { UserPublicKeys } from '#wasm';
|
|
50
50
|
import { type SdkEventType, type SdkEventHandlers } from './core/SdkEventEmitter';
|
|
51
51
|
export type { SdkEventType, SdkEventHandlers };
|
|
52
52
|
export interface GossipSdkInitOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,36 +2,23 @@
|
|
|
2
2
|
* Gossip SDK
|
|
3
3
|
*
|
|
4
4
|
* Main entry point for the Gossip SDK.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Works in both browser and Node.js environments.
|
|
6
|
+
*
|
|
7
|
+
* WASM is loaded via the #wasm subpath import which resolves conditionally:
|
|
8
|
+
* - Browser: web target (uses import.meta.url)
|
|
9
|
+
* - Node: nodejs target (uses fs, no import.meta.url)
|
|
7
10
|
*
|
|
8
11
|
* @example
|
|
9
12
|
* ```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
|
-
* });
|
|
13
|
+
* import { gossipSdk } from '@massalabs/gossip-sdk';
|
|
17
14
|
*
|
|
18
|
-
*
|
|
15
|
+
* await gossipSdk.init({ db, protocolBaseUrl: 'https://api.example.com' });
|
|
19
16
|
* await gossipSdk.openSession({ mnemonic: '...' });
|
|
20
|
-
*
|
|
21
|
-
* // Use clean API
|
|
22
17
|
* 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
18
|
* ```
|
|
31
19
|
*
|
|
32
20
|
* @packageDocumentation
|
|
33
21
|
*/
|
|
34
|
-
export declare const SDK_VERSION = "0.0.1";
|
|
35
22
|
export { gossipSdk, GossipSdkImpl } from './gossipSdk';
|
|
36
23
|
export type { GossipSdkInitOptions, OpenSessionOptions, SdkEventType, SdkEventHandlers, } from './gossipSdk';
|
|
37
24
|
export type { GossipSdkEvents } from './types/events';
|
|
@@ -59,7 +46,7 @@ export { setDb, getDb, db, GossipDatabase } from './db';
|
|
|
59
46
|
export { SessionModule, sessionStatusToString } from './wasm/session';
|
|
60
47
|
export { initializeWasm, ensureWasmInitialized, startWasmInitialization, } from './wasm/loader';
|
|
61
48
|
export { EncryptionKey, Nonce, generateEncryptionKey, generateEncryptionKeyFromSeed, encryptionKeyFromBytes, generateNonce, nonceFromBytes, encryptAead, decryptAead, } from './wasm/encryption';
|
|
62
|
-
export { generateUserKeys } from './wasm/userKeys';
|
|
49
|
+
export { generateUserKeys, UserKeys } from './wasm/userKeys';
|
|
63
50
|
export { encodeUserId, decodeUserId, isValidUserId, formatUserId, generate as generateUserId, } from './utils/userId';
|
|
64
51
|
export { validateUsernameFormat, validatePassword, validateUserIdFormat, validateUsernameAvailability, validateUsernameFormatAndAvailability, } from './utils/validation';
|
|
65
52
|
export type { ValidationResult } from './utils/validation';
|
|
@@ -69,5 +56,4 @@ export { MESSAGE_TYPE_KEEP_ALIVE, serializeKeepAliveMessage, serializeRegularMes
|
|
|
69
56
|
export type { DeserializedMessage } from './utils/messageSerialization';
|
|
70
57
|
export { generateMnemonic, validateMnemonic, mnemonicToSeed, accountFromMnemonic, PRIVATE_KEY_VERSION, } from './crypto/bip39';
|
|
71
58
|
export { encrypt, decrypt, deriveKey } from './crypto/encryption';
|
|
72
|
-
export { UserPublicKeys, UserSecretKeys, SessionStatus, SessionConfig, SessionManagerWrapper, SendMessageOutput, ReceiveMessageOutput, AnnouncementResult, generate_user_keys, } from '
|
|
73
|
-
export { UserKeys } from './wasm/userKeys';
|
|
59
|
+
export { UserPublicKeys, UserSecretKeys, SessionStatus, SessionConfig, SessionManagerWrapper, SendMessageOutput, ReceiveMessageOutput, AnnouncementResult, generate_user_keys, } from '#wasm';
|
package/dist/index.js
CHANGED
|
@@ -2,76 +2,60 @@
|
|
|
2
2
|
* Gossip SDK
|
|
3
3
|
*
|
|
4
4
|
* Main entry point for the Gossip SDK.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Works in both browser and Node.js environments.
|
|
6
|
+
*
|
|
7
|
+
* WASM is loaded via the #wasm subpath import which resolves conditionally:
|
|
8
|
+
* - Browser: web target (uses import.meta.url)
|
|
9
|
+
* - Node: nodejs target (uses fs, no import.meta.url)
|
|
7
10
|
*
|
|
8
11
|
* @example
|
|
9
12
|
* ```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
|
-
* });
|
|
13
|
+
* import { gossipSdk } from '@massalabs/gossip-sdk';
|
|
17
14
|
*
|
|
18
|
-
*
|
|
15
|
+
* await gossipSdk.init({ db, protocolBaseUrl: 'https://api.example.com' });
|
|
19
16
|
* await gossipSdk.openSession({ mnemonic: '...' });
|
|
20
|
-
*
|
|
21
|
-
* // Use clean API
|
|
22
17
|
* 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
18
|
* ```
|
|
31
19
|
*
|
|
32
20
|
* @packageDocumentation
|
|
33
21
|
*/
|
|
34
|
-
// SDK version - matches package.json
|
|
35
|
-
export const SDK_VERSION = '0.0.1';
|
|
36
22
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
37
23
|
// SDK Singleton - Primary API
|
|
38
24
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
39
25
|
export { gossipSdk, GossipSdkImpl } from './gossipSdk';
|
|
40
|
-
// Services
|
|
26
|
+
// Services
|
|
41
27
|
export { AuthService } from './services/auth';
|
|
42
28
|
export { getPublicKeyErrorMessage, PUBLIC_KEY_NOT_FOUND_ERROR, PUBLIC_KEY_NOT_FOUND_MESSAGE, FAILED_TO_FETCH_ERROR, FAILED_TO_FETCH_MESSAGE, FAILED_TO_RETRIEVE_CONTACT_PUBLIC_KEY_ERROR, } from './services/auth';
|
|
43
29
|
export { AnnouncementService, EstablishSessionError, } from './services/announcement';
|
|
44
30
|
export { MessageService } from './services/message';
|
|
45
31
|
export { DiscussionService } from './services/discussion';
|
|
46
32
|
export { RefreshService } from './services/refresh';
|
|
47
|
-
// Contact Management
|
|
33
|
+
// Contact Management
|
|
48
34
|
export { getContacts, getContact, addContact, updateContactName, deleteContact, } from './contacts';
|
|
49
35
|
// Discussion utilities
|
|
50
36
|
export { updateDiscussionName } from './utils/discussions';
|
|
51
|
-
// Types
|
|
37
|
+
// Types
|
|
52
38
|
export * from './types';
|
|
53
|
-
// Message Protocol
|
|
39
|
+
// Message Protocol
|
|
54
40
|
export { createMessageProtocol, restMessageProtocol, RestMessageProtocol, MessageProtocol, } from './api/messageProtocol';
|
|
55
|
-
// Config
|
|
41
|
+
// Config
|
|
56
42
|
export { setProtocolBaseUrl, resetProtocolBaseUrl, MessageProtocolType, protocolConfig, } from './config/protocol';
|
|
57
|
-
// SDK Config - for SDK initialization options
|
|
58
43
|
export { defaultSdkConfig, mergeConfig } from './config/sdk';
|
|
59
|
-
// Database
|
|
44
|
+
// Database
|
|
60
45
|
export { setDb, getDb, db, GossipDatabase } from './db';
|
|
61
|
-
// WASM utilities
|
|
46
|
+
// WASM utilities
|
|
62
47
|
export { SessionModule, sessionStatusToString } from './wasm/session';
|
|
63
48
|
export { initializeWasm, ensureWasmInitialized, startWasmInitialization, } from './wasm/loader';
|
|
64
49
|
export { EncryptionKey, Nonce, generateEncryptionKey, generateEncryptionKeyFromSeed, encryptionKeyFromBytes, generateNonce, nonceFromBytes, encryptAead, decryptAead, } from './wasm/encryption';
|
|
65
|
-
export { generateUserKeys } from './wasm/userKeys';
|
|
66
|
-
// Utility functions
|
|
50
|
+
export { generateUserKeys, UserKeys } from './wasm/userKeys';
|
|
51
|
+
// Utility functions
|
|
67
52
|
export { encodeUserId, decodeUserId, isValidUserId, formatUserId, generate as generateUserId, } from './utils/userId';
|
|
68
53
|
export { validateUsernameFormat, validatePassword, validateUserIdFormat, validateUsernameAvailability, validateUsernameFormatAndAvailability, } from './utils/validation';
|
|
69
54
|
export { encodeToBase64, decodeFromBase64, encodeToBase64Url, decodeFromBase64Url, } from './utils/base64';
|
|
70
|
-
// Message serialization
|
|
55
|
+
// Message serialization
|
|
71
56
|
export { MESSAGE_TYPE_KEEP_ALIVE, serializeKeepAliveMessage, serializeRegularMessage, serializeReplyMessage, serializeForwardMessage, deserializeMessage, } from './utils/messageSerialization';
|
|
72
57
|
// Crypto utilities
|
|
73
58
|
export { generateMnemonic, validateMnemonic, mnemonicToSeed, accountFromMnemonic, PRIVATE_KEY_VERSION, } from './crypto/bip39';
|
|
74
59
|
export { encrypt, decrypt, deriveKey } from './crypto/encryption';
|
|
75
|
-
// WASM types
|
|
76
|
-
export { UserPublicKeys, UserSecretKeys, SessionStatus, SessionConfig, SessionManagerWrapper, SendMessageOutput, ReceiveMessageOutput, AnnouncementResult, generate_user_keys, } from '
|
|
77
|
-
export { UserKeys } from './wasm/userKeys';
|
|
60
|
+
// WASM types re-exported for convenience
|
|
61
|
+
export { UserPublicKeys, UserSecretKeys, SessionStatus, SessionConfig, SessionManagerWrapper, SendMessageOutput, ReceiveMessageOutput, AnnouncementResult, generate_user_keys, } from '#wasm';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { type Discussion, type GossipDatabase } from '../db';
|
|
7
7
|
import { IMessageProtocol } from '../api/messageProtocol';
|
|
8
|
-
import { UserPublicKeys } from '
|
|
8
|
+
import { UserPublicKeys } from '#wasm';
|
|
9
9
|
import { SessionModule } from '../wasm/session';
|
|
10
10
|
import { GossipSdkEvents } from '../types/events';
|
|
11
11
|
import { SdkConfig } from '../config/sdk';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { DiscussionStatus, DiscussionDirection, } from '../db';
|
|
7
7
|
import { decodeUserId, encodeUserId } from '../utils/userId';
|
|
8
|
-
import { SessionStatus
|
|
8
|
+
import { SessionStatus } from '#wasm';
|
|
9
9
|
import { sessionStatusToString } from '../wasm/session';
|
|
10
10
|
import { Logger } from '../utils/logs';
|
|
11
11
|
import { defaultSdkConfig } from '../config/sdk';
|
package/dist/services/auth.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Handles storing and retrieving public keys by userId hash via the auth API.
|
|
5
5
|
*/
|
|
6
|
-
import { UserPublicKeys } from '
|
|
6
|
+
import { UserPublicKeys } from '#wasm';
|
|
7
7
|
import { IMessageProtocol } from '../api/messageProtocol/types';
|
|
8
8
|
import { type GossipDatabase } from '../db';
|
|
9
9
|
export type PublicKeyResult = {
|
package/dist/services/auth.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Handles storing and retrieving public keys by userId hash via the auth API.
|
|
5
5
|
*/
|
|
6
|
-
import { UserPublicKeys } from '
|
|
6
|
+
import { UserPublicKeys } from '#wasm';
|
|
7
7
|
import { decodeUserId } from '../utils/userId';
|
|
8
8
|
import { encodeToBase64, decodeFromBase64 } from '../utils/base64';
|
|
9
9
|
export class AuthService {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Class-based service for initializing, accepting, and managing discussions.
|
|
5
5
|
*/
|
|
6
6
|
import { DiscussionStatus, MessageDirection, MessageStatus, DiscussionDirection, } from '../db';
|
|
7
|
-
import { UserPublicKeys, SessionStatus
|
|
7
|
+
import { UserPublicKeys, SessionStatus } from '#wasm';
|
|
8
8
|
import { EstablishSessionError } from './announcement';
|
|
9
9
|
import { sessionStatusToString } from '../wasm/session';
|
|
10
10
|
import { decodeUserId } from '../utils/userId';
|
package/dist/services/message.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { DiscussionStatus, MessageDirection, MessageStatus, MessageType, } from '../db';
|
|
8
8
|
import { decodeUserId, encodeUserId } from '../utils/userId';
|
|
9
|
-
import { SessionStatus
|
|
9
|
+
import { SessionStatus } from '#wasm';
|
|
10
10
|
import { serializeRegularMessage, serializeReplyMessage, serializeForwardMessage, serializeKeepAliveMessage, deserializeMessage, } from '../utils/messageSerialization';
|
|
11
11
|
import { encodeToBase64 } from '../utils/base64';
|
|
12
12
|
import { sessionStatusToString } from '../wasm/session';
|
package/dist/services/refresh.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { MessageDirection, MessageStatus, MessageType, } from '../db';
|
|
8
8
|
import { sessionStatusToString } from '../wasm/session';
|
|
9
|
-
import { SessionStatus } from '
|
|
9
|
+
import { SessionStatus } from '#wasm';
|
|
10
10
|
import { decodeUserId, encodeUserId } from '../utils/userId';
|
|
11
11
|
import { Logger } from '../utils/logs';
|
|
12
12
|
const logger = new Logger('RefreshService');
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* and AEAD (Authenticated Encryption with Additional Data) operations,
|
|
6
6
|
* ensuring proper initialization before calling any WASM functions.
|
|
7
7
|
*/
|
|
8
|
-
import { EncryptionKey, Nonce } from '
|
|
8
|
+
import { EncryptionKey, Nonce } from '#wasm';
|
|
9
9
|
export { EncryptionKey, Nonce };
|
|
10
10
|
/**
|
|
11
11
|
* Generate a new random encryption key (64 bytes)
|
package/dist/wasm/encryption.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* ensuring proper initialization before calling any WASM functions.
|
|
7
7
|
*/
|
|
8
8
|
import { ensureWasmInitialized } from './loader';
|
|
9
|
-
import { EncryptionKey, Nonce, aead_encrypt as _aead_encrypt, aead_decrypt as _aead_decrypt, } from '
|
|
9
|
+
import { EncryptionKey, Nonce, aead_encrypt as _aead_encrypt, aead_decrypt as _aead_decrypt, } from '#wasm';
|
|
10
10
|
// Re-export classes
|
|
11
11
|
export { EncryptionKey, Nonce };
|
|
12
12
|
/**
|
package/dist/wasm/loader.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WASM Module Loader and Initialization Service
|
|
3
3
|
*
|
|
4
|
-
* This file handles
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* This file handles WASM initialization. The actual wasm module is resolved
|
|
5
|
+
* via the #wasm import which conditionally loads the correct target:
|
|
6
|
+
* - Browser: web target (has init function, uses import.meta.url + fetch)
|
|
7
|
+
* - Node: nodejs target (auto-initializes, no init function needed)
|
|
7
8
|
*/
|
|
8
9
|
/**
|
|
9
10
|
* Initialize WASM modules if not already initialized
|
package/dist/wasm/loader.js
CHANGED
|
@@ -1,38 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WASM Module Loader and Initialization Service
|
|
3
3
|
*
|
|
4
|
-
* This file handles
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* This file handles WASM initialization. The actual wasm module is resolved
|
|
5
|
+
* via the #wasm import which conditionally loads the correct target:
|
|
6
|
+
* - Browser: web target (has init function, uses import.meta.url + fetch)
|
|
7
|
+
* - Node: nodejs target (auto-initializes, no init function needed)
|
|
7
8
|
*/
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function isNodeEnvironment() {
|
|
13
|
-
return (typeof process !== 'undefined' &&
|
|
14
|
-
process.versions != null &&
|
|
15
|
-
process.versions.node != null);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Load WASM module for Node.js environment using fs.readFileSync
|
|
19
|
-
*/
|
|
20
|
-
async function loadWasmForNode() {
|
|
21
|
-
// Dynamic import to avoid bundling Node.js modules in browser builds
|
|
22
|
-
const fs = await import('node:fs');
|
|
23
|
-
const path = await import('node:path');
|
|
24
|
-
const { fileURLToPath } = await import('node:url');
|
|
25
|
-
// Get the directory of the current module
|
|
26
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
27
|
-
const __dirname = path.dirname(__filename);
|
|
28
|
-
// Resolve path to WASM file - WASM is in the SDK's generated folder
|
|
29
|
-
const wasmPath = path.resolve(__dirname, '../assets/generated/wasm/gossip_wasm_bg.wasm');
|
|
30
|
-
// Read WASM file as binary
|
|
31
|
-
const wasmBuffer = fs.readFileSync(wasmPath);
|
|
32
|
-
// Instantiate WASM module
|
|
33
|
-
const wasmModule = await WebAssembly.compile(wasmBuffer);
|
|
34
|
-
return wasmModule;
|
|
35
|
-
}
|
|
9
|
+
import * as wasmModule from '#wasm';
|
|
10
|
+
// The web target has a default export (init function), nodejs target doesn't
|
|
11
|
+
const init = wasmModule
|
|
12
|
+
.default;
|
|
36
13
|
/**
|
|
37
14
|
* WASM Initialization State
|
|
38
15
|
*/
|
|
@@ -58,15 +35,13 @@ export async function initializeWasm() {
|
|
|
58
35
|
initError = null;
|
|
59
36
|
initializationPromise = (async () => {
|
|
60
37
|
try {
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
// In browser/jsdom, use default init (which uses fetch)
|
|
38
|
+
// The #wasm import resolves to the correct target based on environment:
|
|
39
|
+
// - Browser (web target): has init() function that needs to be called
|
|
40
|
+
// - Node (nodejs target): auto-initializes on import, no init needed
|
|
41
|
+
if (typeof init === 'function') {
|
|
68
42
|
await init();
|
|
69
43
|
}
|
|
44
|
+
// For nodejs target, wasm is already initialized on import
|
|
70
45
|
isInitialized = true;
|
|
71
46
|
isInitializing = false;
|
|
72
47
|
}
|
package/dist/wasm/session.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This file contains the real WASM implementation of the SessionModule
|
|
5
5
|
* using SessionManagerWrapper and related WASM classes.
|
|
6
6
|
*/
|
|
7
|
-
import { UserPublicKeys, UserSecretKeys, ReceiveMessageOutput, SendMessageOutput, SessionStatus, EncryptionKey, SessionConfig, AnnouncementResult, UserKeys } from '
|
|
7
|
+
import { UserPublicKeys, UserSecretKeys, ReceiveMessageOutput, SendMessageOutput, SessionStatus, EncryptionKey, SessionConfig, AnnouncementResult, UserKeys } from '#wasm';
|
|
8
8
|
import { UserProfile } from '../db';
|
|
9
9
|
export declare class SessionModule {
|
|
10
10
|
private sessionManager;
|
package/dist/wasm/session.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This file contains the real WASM implementation of the SessionModule
|
|
5
5
|
* using SessionManagerWrapper and related WASM classes.
|
|
6
6
|
*/
|
|
7
|
-
import { SessionManagerWrapper, SessionStatus, SessionConfig, } from '
|
|
7
|
+
import { SessionManagerWrapper, SessionStatus, SessionConfig, } from '#wasm';
|
|
8
8
|
import { encodeUserId } from '../utils/userId';
|
|
9
9
|
export class SessionModule {
|
|
10
10
|
constructor(userKeys, onPersist, config) {
|
package/dist/wasm/userKeys.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This file provides proxy functions for user key generation,
|
|
5
5
|
* ensuring proper initialization before calling any WASM functions.
|
|
6
6
|
*/
|
|
7
|
-
import { UserKeys } from '
|
|
7
|
+
import { UserKeys } from '#wasm';
|
|
8
8
|
export { UserKeys };
|
|
9
9
|
/**
|
|
10
10
|
* Generate user keys from a passphrase using password-based key derivation
|
package/dist/wasm/userKeys.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ensuring proper initialization before calling any WASM functions.
|
|
6
6
|
*/
|
|
7
7
|
import { ensureWasmInitialized } from './loader';
|
|
8
|
-
import { generate_user_keys as _generate_user_keys, UserKeys
|
|
8
|
+
import { generate_user_keys as _generate_user_keys, UserKeys } from '#wasm';
|
|
9
9
|
// Re-export classes
|
|
10
10
|
export { UserKeys };
|
|
11
11
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massalabs/gossip-sdk",
|
|
3
|
-
"version": "0.0.2-dev.
|
|
3
|
+
"version": "0.0.2-dev.20260128160824",
|
|
4
4
|
"description": "Gossip SDK for automation, chatbot, and integration use cases",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
"dist",
|
|
10
10
|
"README.md"
|
|
11
11
|
],
|
|
12
|
+
"imports": {
|
|
13
|
+
"#wasm": {
|
|
14
|
+
"browser": "./dist/assets/generated/wasm/gossip_wasm.js",
|
|
15
|
+
"default": "./dist/assets/generated/wasm-node/gossip_wasm.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
12
18
|
"exports": {
|
|
13
19
|
".": {
|
|
14
20
|
"types": "./dist/index.d.ts",
|
|
@@ -20,7 +26,9 @@
|
|
|
20
26
|
}
|
|
21
27
|
},
|
|
22
28
|
"scripts": {
|
|
23
|
-
"
|
|
29
|
+
"prebuild": "rimraf dist",
|
|
30
|
+
"build": "tsc && npm run copy:wasm",
|
|
31
|
+
"copy:wasm": "mkdir -p dist/assets/generated/wasm dist/assets/generated/wasm-node && cp -R src/assets/generated/wasm/* dist/assets/generated/wasm/ && cp -R src/assets/generated/wasm-node/* dist/assets/generated/wasm-node/",
|
|
24
32
|
"test": "vitest",
|
|
25
33
|
"test:run": "vitest run",
|
|
26
34
|
"test:coverage": "vitest run --coverage"
|
|
@@ -35,6 +43,7 @@
|
|
|
35
43
|
"license": "MIT",
|
|
36
44
|
"devDependencies": {
|
|
37
45
|
"fake-indexeddb": "^6.2.5",
|
|
46
|
+
"rimraf": "^6.1.2",
|
|
38
47
|
"typescript": "^5.9.3",
|
|
39
48
|
"vitest": "^4.0.17"
|
|
40
49
|
},
|