@moltdm/client 1.3.2 → 1.4.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.
- package/dist/index.d.mts +44 -12
- package/dist/index.d.ts +44 -12
- package/dist/index.js +224 -122
- package/dist/index.mjs +221 -122
- package/dist/moltdm.browser.js +17 -0
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -113,13 +113,54 @@ interface PollResult {
|
|
|
113
113
|
requests: MessageRequest[];
|
|
114
114
|
lastPollTime: string;
|
|
115
115
|
}
|
|
116
|
+
interface Storage {
|
|
117
|
+
get(key: string): Promise<string | null>;
|
|
118
|
+
set(key: string, value: string): Promise<void>;
|
|
119
|
+
delete(key: string): Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* In-memory storage (for testing or ephemeral use)
|
|
123
|
+
*/
|
|
124
|
+
declare class MemoryStorage implements Storage {
|
|
125
|
+
private data;
|
|
126
|
+
get(key: string): Promise<string | null>;
|
|
127
|
+
set(key: string, value: string): Promise<void>;
|
|
128
|
+
delete(key: string): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Browser localStorage storage
|
|
132
|
+
*/
|
|
133
|
+
declare class BrowserStorage implements Storage {
|
|
134
|
+
private prefix;
|
|
135
|
+
constructor(prefix?: string);
|
|
136
|
+
get(key: string): Promise<string | null>;
|
|
137
|
+
set(key: string, value: string): Promise<void>;
|
|
138
|
+
delete(key: string): Promise<void>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Node.js file system storage
|
|
142
|
+
* Note: This class uses dynamic imports and only works in Node.js environments.
|
|
143
|
+
* For browser usage, use BrowserStorage or MemoryStorage instead.
|
|
144
|
+
*/
|
|
145
|
+
declare class FileStorage implements Storage {
|
|
146
|
+
private basePath;
|
|
147
|
+
private _fs;
|
|
148
|
+
private _path;
|
|
149
|
+
private _initialized;
|
|
150
|
+
constructor(basePath?: string);
|
|
151
|
+
private ensureModules;
|
|
152
|
+
get(key: string): Promise<string | null>;
|
|
153
|
+
set(key: string, value: string): Promise<void>;
|
|
154
|
+
delete(key: string): Promise<void>;
|
|
155
|
+
}
|
|
116
156
|
interface MoltDMClientOptions {
|
|
157
|
+
storage?: Storage;
|
|
117
158
|
storagePath?: string;
|
|
118
159
|
relayUrl?: string;
|
|
119
160
|
identity?: Identity;
|
|
120
161
|
}
|
|
121
162
|
declare class MoltDMClient {
|
|
122
|
-
private
|
|
163
|
+
private storage;
|
|
123
164
|
private relayUrl;
|
|
124
165
|
private identity;
|
|
125
166
|
private senderKeys;
|
|
@@ -129,6 +170,7 @@ declare class MoltDMClient {
|
|
|
129
170
|
get moltbotId(): string;
|
|
130
171
|
getIdentity(): Identity | null;
|
|
131
172
|
initialize(): Promise<void>;
|
|
173
|
+
private validateIdentity;
|
|
132
174
|
private createIdentity;
|
|
133
175
|
private loadSenderKeys;
|
|
134
176
|
private saveSenderKeys;
|
|
@@ -229,19 +271,9 @@ declare class MoltDMClient {
|
|
|
229
271
|
private encrypt;
|
|
230
272
|
decrypt(ciphertext: string, key: Uint8Array): Promise<string>;
|
|
231
273
|
private ensureInitialized;
|
|
232
|
-
/**
|
|
233
|
-
* Sign a message using Ed25519
|
|
234
|
-
*/
|
|
235
274
|
private signMessage;
|
|
236
|
-
/**
|
|
237
|
-
* Create the message to sign for a request
|
|
238
|
-
* Format: timestamp:method:path:bodyHash
|
|
239
|
-
*/
|
|
240
275
|
private createSignedMessage;
|
|
241
|
-
/**
|
|
242
|
-
* Make an authenticated fetch request with Ed25519 signature
|
|
243
|
-
*/
|
|
244
276
|
private fetch;
|
|
245
277
|
}
|
|
246
278
|
|
|
247
|
-
export { type Conversation, type DecryptedMessage, type Device, type Identity, type Invite, type InvitePreview, type MembershipEvent, type Message, type MessageRequest, MoltDMClient, type MoltDMClientOptions, type PairingRequest, type PollResult, type Reaction, type ReactionSummary, MoltDMClient as default };
|
|
279
|
+
export { BrowserStorage, type Conversation, type DecryptedMessage, type Device, FileStorage, type Identity, type Invite, type InvitePreview, type MembershipEvent, MemoryStorage, type Message, type MessageRequest, MoltDMClient, type MoltDMClientOptions, type PairingRequest, type PollResult, type Reaction, type ReactionSummary, type Storage, MoltDMClient as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -113,13 +113,54 @@ interface PollResult {
|
|
|
113
113
|
requests: MessageRequest[];
|
|
114
114
|
lastPollTime: string;
|
|
115
115
|
}
|
|
116
|
+
interface Storage {
|
|
117
|
+
get(key: string): Promise<string | null>;
|
|
118
|
+
set(key: string, value: string): Promise<void>;
|
|
119
|
+
delete(key: string): Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* In-memory storage (for testing or ephemeral use)
|
|
123
|
+
*/
|
|
124
|
+
declare class MemoryStorage implements Storage {
|
|
125
|
+
private data;
|
|
126
|
+
get(key: string): Promise<string | null>;
|
|
127
|
+
set(key: string, value: string): Promise<void>;
|
|
128
|
+
delete(key: string): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Browser localStorage storage
|
|
132
|
+
*/
|
|
133
|
+
declare class BrowserStorage implements Storage {
|
|
134
|
+
private prefix;
|
|
135
|
+
constructor(prefix?: string);
|
|
136
|
+
get(key: string): Promise<string | null>;
|
|
137
|
+
set(key: string, value: string): Promise<void>;
|
|
138
|
+
delete(key: string): Promise<void>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Node.js file system storage
|
|
142
|
+
* Note: This class uses dynamic imports and only works in Node.js environments.
|
|
143
|
+
* For browser usage, use BrowserStorage or MemoryStorage instead.
|
|
144
|
+
*/
|
|
145
|
+
declare class FileStorage implements Storage {
|
|
146
|
+
private basePath;
|
|
147
|
+
private _fs;
|
|
148
|
+
private _path;
|
|
149
|
+
private _initialized;
|
|
150
|
+
constructor(basePath?: string);
|
|
151
|
+
private ensureModules;
|
|
152
|
+
get(key: string): Promise<string | null>;
|
|
153
|
+
set(key: string, value: string): Promise<void>;
|
|
154
|
+
delete(key: string): Promise<void>;
|
|
155
|
+
}
|
|
116
156
|
interface MoltDMClientOptions {
|
|
157
|
+
storage?: Storage;
|
|
117
158
|
storagePath?: string;
|
|
118
159
|
relayUrl?: string;
|
|
119
160
|
identity?: Identity;
|
|
120
161
|
}
|
|
121
162
|
declare class MoltDMClient {
|
|
122
|
-
private
|
|
163
|
+
private storage;
|
|
123
164
|
private relayUrl;
|
|
124
165
|
private identity;
|
|
125
166
|
private senderKeys;
|
|
@@ -129,6 +170,7 @@ declare class MoltDMClient {
|
|
|
129
170
|
get moltbotId(): string;
|
|
130
171
|
getIdentity(): Identity | null;
|
|
131
172
|
initialize(): Promise<void>;
|
|
173
|
+
private validateIdentity;
|
|
132
174
|
private createIdentity;
|
|
133
175
|
private loadSenderKeys;
|
|
134
176
|
private saveSenderKeys;
|
|
@@ -229,19 +271,9 @@ declare class MoltDMClient {
|
|
|
229
271
|
private encrypt;
|
|
230
272
|
decrypt(ciphertext: string, key: Uint8Array): Promise<string>;
|
|
231
273
|
private ensureInitialized;
|
|
232
|
-
/**
|
|
233
|
-
* Sign a message using Ed25519
|
|
234
|
-
*/
|
|
235
274
|
private signMessage;
|
|
236
|
-
/**
|
|
237
|
-
* Create the message to sign for a request
|
|
238
|
-
* Format: timestamp:method:path:bodyHash
|
|
239
|
-
*/
|
|
240
275
|
private createSignedMessage;
|
|
241
|
-
/**
|
|
242
|
-
* Make an authenticated fetch request with Ed25519 signature
|
|
243
|
-
*/
|
|
244
276
|
private fetch;
|
|
245
277
|
}
|
|
246
278
|
|
|
247
|
-
export { type Conversation, type DecryptedMessage, type Device, type Identity, type Invite, type InvitePreview, type MembershipEvent, type Message, type MessageRequest, MoltDMClient, type MoltDMClientOptions, type PairingRequest, type PollResult, type Reaction, type ReactionSummary, MoltDMClient as default };
|
|
279
|
+
export { BrowserStorage, type Conversation, type DecryptedMessage, type Device, FileStorage, type Identity, type Invite, type InvitePreview, type MembershipEvent, MemoryStorage, type Message, type MessageRequest, MoltDMClient, type MoltDMClientOptions, type PairingRequest, type PollResult, type Reaction, type ReactionSummary, type Storage, MoltDMClient as default };
|