@bandeira-tech/b3nd-web 0.2.0
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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/apps/mod.d.ts +79 -0
- package/dist/apps/mod.js +7 -0
- package/dist/chunk-2D2RT2DW.js +277 -0
- package/dist/chunk-C2ZIFM22.js +272 -0
- package/dist/chunk-G6JDROB4.js +327 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-PMBS2GFA.js +223 -0
- package/dist/chunk-QHDBFVLU.js +87 -0
- package/dist/chunk-XH4OLKBV.js +295 -0
- package/dist/clients/http/mod.d.ts +33 -0
- package/dist/clients/http/mod.js +7 -0
- package/dist/clients/local-storage/mod.d.ts +60 -0
- package/dist/clients/local-storage/mod.js +7 -0
- package/dist/clients/websocket/mod.d.ts +62 -0
- package/dist/clients/websocket/mod.js +7 -0
- package/dist/encrypt/mod.d.ts +1 -0
- package/dist/encrypt/mod.js +31 -0
- package/dist/mod-DHjjiF1o.d.ts +111 -0
- package/dist/src/mod.web.d.ts +7 -0
- package/dist/src/mod.web.js +27 -0
- package/dist/types-Bw0Boe0n.d.ts +219 -0
- package/dist/wallet/mod.d.ts +278 -0
- package/dist/wallet/mod.js +7 -0
- package/package.json +84 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
// clients/local-storage/mod.ts
|
|
2
|
+
var LocalStorageClient = class {
|
|
3
|
+
config;
|
|
4
|
+
schema;
|
|
5
|
+
storage;
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.config = {
|
|
8
|
+
keyPrefix: config.keyPrefix || "b3nd:",
|
|
9
|
+
serializer: {
|
|
10
|
+
serialize: (data) => JSON.stringify(data),
|
|
11
|
+
deserialize: (data) => JSON.parse(data),
|
|
12
|
+
...config.serializer
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
this.schema = config.schema || {};
|
|
16
|
+
this.storage = config.storage || (typeof localStorage !== "undefined" ? localStorage : null);
|
|
17
|
+
if (!this.storage) {
|
|
18
|
+
throw new Error("localStorage is not available in this environment");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the localStorage key for a URI
|
|
23
|
+
*/
|
|
24
|
+
getKey(uri) {
|
|
25
|
+
return `${this.config.keyPrefix}${uri}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validate write operation against schema
|
|
29
|
+
*/
|
|
30
|
+
async validateWrite(uri, value) {
|
|
31
|
+
const programKey = this.findMatchingProgram(uri);
|
|
32
|
+
if (programKey && this.schema[programKey]) {
|
|
33
|
+
const validator = this.schema[programKey];
|
|
34
|
+
return await validator({ uri, value, read: this.read.bind(this) });
|
|
35
|
+
}
|
|
36
|
+
return { valid: true };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Find matching program key for URI
|
|
40
|
+
*/
|
|
41
|
+
findMatchingProgram(uri) {
|
|
42
|
+
for (const programKey of Object.keys(this.schema)) {
|
|
43
|
+
if (uri.startsWith(programKey)) {
|
|
44
|
+
return programKey;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Serialize data using configured serializer
|
|
51
|
+
*/
|
|
52
|
+
serialize(data) {
|
|
53
|
+
return this.config.serializer.serialize(data);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Deserialize data using configured serializer
|
|
57
|
+
*/
|
|
58
|
+
deserialize(data) {
|
|
59
|
+
return this.config.serializer.deserialize(data);
|
|
60
|
+
}
|
|
61
|
+
async write(uri, value) {
|
|
62
|
+
try {
|
|
63
|
+
const validation = await this.validateWrite(uri, value);
|
|
64
|
+
if (!validation.valid) {
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
error: validation.error || "Validation failed"
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const key = this.getKey(uri);
|
|
71
|
+
const record = {
|
|
72
|
+
ts: Date.now(),
|
|
73
|
+
data: value
|
|
74
|
+
};
|
|
75
|
+
const serialized = this.serialize(record);
|
|
76
|
+
this.storage.setItem(key, serialized);
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
record
|
|
80
|
+
};
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return {
|
|
83
|
+
success: false,
|
|
84
|
+
error: error instanceof Error ? error.message : String(error)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async read(uri) {
|
|
89
|
+
try {
|
|
90
|
+
const key = this.getKey(uri);
|
|
91
|
+
const serialized = this.storage.getItem(key);
|
|
92
|
+
if (serialized === null) {
|
|
93
|
+
return {
|
|
94
|
+
success: false,
|
|
95
|
+
error: "Not found"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const record = this.deserialize(serialized);
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
record
|
|
102
|
+
};
|
|
103
|
+
} catch (error) {
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
error: error instanceof Error ? error.message : String(error)
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async list(uri, options) {
|
|
111
|
+
try {
|
|
112
|
+
const { page = 1, limit = 50, pattern, sortBy = "name", sortOrder = "asc" } = options || {};
|
|
113
|
+
const items = [];
|
|
114
|
+
const prefix = this.getKey(uri);
|
|
115
|
+
for (let i = 0; i < this.storage.length; i++) {
|
|
116
|
+
const key = this.storage.key(i);
|
|
117
|
+
if (key && key.startsWith(prefix)) {
|
|
118
|
+
const uri2 = key.substring(this.config.keyPrefix.length);
|
|
119
|
+
if (pattern && !uri2.includes(pattern)) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const isDirectory = this.hasChildren(uri2);
|
|
123
|
+
items.push({
|
|
124
|
+
uri: uri2,
|
|
125
|
+
type: isDirectory ? "directory" : "file"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
items.sort((a, b) => {
|
|
130
|
+
let comparison = 0;
|
|
131
|
+
if (sortBy === "name") {
|
|
132
|
+
comparison = a.uri.localeCompare(b.uri);
|
|
133
|
+
} else if (sortBy === "timestamp") {
|
|
134
|
+
const aData = this.getStoredData(a.uri);
|
|
135
|
+
const bData = this.getStoredData(b.uri);
|
|
136
|
+
const aTs = (aData == null ? void 0 : aData.ts) || 0;
|
|
137
|
+
const bTs = (bData == null ? void 0 : bData.ts) || 0;
|
|
138
|
+
comparison = aTs - bTs;
|
|
139
|
+
}
|
|
140
|
+
return sortOrder === "asc" ? comparison : -comparison;
|
|
141
|
+
});
|
|
142
|
+
const startIndex = (page - 1) * limit;
|
|
143
|
+
const endIndex = startIndex + limit;
|
|
144
|
+
const paginatedItems = items.slice(startIndex, endIndex);
|
|
145
|
+
return {
|
|
146
|
+
success: true,
|
|
147
|
+
data: paginatedItems,
|
|
148
|
+
pagination: {
|
|
149
|
+
page,
|
|
150
|
+
limit,
|
|
151
|
+
total: items.length
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
} catch (error) {
|
|
155
|
+
return {
|
|
156
|
+
success: false,
|
|
157
|
+
error: error instanceof Error ? error.message : String(error)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Check if a URI has children (is a directory)
|
|
163
|
+
*/
|
|
164
|
+
hasChildren(uri) {
|
|
165
|
+
const prefix = this.getKey(uri) + "/";
|
|
166
|
+
for (let i = 0; i < this.storage.length; i++) {
|
|
167
|
+
const key = this.storage.key(i);
|
|
168
|
+
if (key && key.startsWith(prefix)) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get stored data for a URI (for timestamp sorting)
|
|
176
|
+
*/
|
|
177
|
+
getStoredData(uri) {
|
|
178
|
+
try {
|
|
179
|
+
const key = this.getKey(uri);
|
|
180
|
+
const serialized = this.storage.getItem(key);
|
|
181
|
+
if (serialized) {
|
|
182
|
+
return this.deserialize(serialized);
|
|
183
|
+
}
|
|
184
|
+
} catch {
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
async delete(uri) {
|
|
189
|
+
try {
|
|
190
|
+
const key = this.getKey(uri);
|
|
191
|
+
const exists = this.storage.getItem(key) !== null;
|
|
192
|
+
if (!exists) {
|
|
193
|
+
return {
|
|
194
|
+
success: false,
|
|
195
|
+
error: "Not found"
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
this.storage.removeItem(key);
|
|
199
|
+
return {
|
|
200
|
+
success: true
|
|
201
|
+
};
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return {
|
|
204
|
+
success: false,
|
|
205
|
+
error: error instanceof Error ? error.message : String(error)
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async health() {
|
|
210
|
+
try {
|
|
211
|
+
const testKey = `${this.config.keyPrefix}health-check`;
|
|
212
|
+
this.storage.setItem(testKey, "test");
|
|
213
|
+
this.storage.removeItem(testKey);
|
|
214
|
+
const stats = this.getStorageStats();
|
|
215
|
+
return {
|
|
216
|
+
status: "healthy",
|
|
217
|
+
message: "LocalStorage client is operational",
|
|
218
|
+
details: stats
|
|
219
|
+
};
|
|
220
|
+
} catch (error) {
|
|
221
|
+
return {
|
|
222
|
+
status: "unhealthy",
|
|
223
|
+
message: error instanceof Error ? error.message : String(error)
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Get localStorage usage statistics
|
|
229
|
+
*/
|
|
230
|
+
getStorageStats() {
|
|
231
|
+
try {
|
|
232
|
+
let totalKeys = 0;
|
|
233
|
+
let b3ndKeys = 0;
|
|
234
|
+
let totalSize = 0;
|
|
235
|
+
for (let i = 0; i < this.storage.length; i++) {
|
|
236
|
+
const key = this.storage.key(i);
|
|
237
|
+
if (key) {
|
|
238
|
+
totalKeys++;
|
|
239
|
+
const value = this.storage.getItem(key) || "";
|
|
240
|
+
totalSize += key.length + value.length;
|
|
241
|
+
if (key.startsWith(this.config.keyPrefix)) {
|
|
242
|
+
b3ndKeys++;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
totalKeys,
|
|
248
|
+
b3ndKeys,
|
|
249
|
+
totalSize,
|
|
250
|
+
keyPrefix: this.config.keyPrefix,
|
|
251
|
+
estimatedRemainingSpace: this.estimateRemainingSpace()
|
|
252
|
+
};
|
|
253
|
+
} catch {
|
|
254
|
+
return {};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Estimate remaining localStorage space (rough approximation)
|
|
259
|
+
*/
|
|
260
|
+
estimateRemainingSpace() {
|
|
261
|
+
try {
|
|
262
|
+
const typicalLimit = 5 * 1024 * 1024;
|
|
263
|
+
let currentSize = 0;
|
|
264
|
+
for (let i = 0; i < this.storage.length; i++) {
|
|
265
|
+
const key = this.storage.key(i);
|
|
266
|
+
if (key) {
|
|
267
|
+
const value = this.storage.getItem(key) || "";
|
|
268
|
+
currentSize += key.length + value.length;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return Math.max(0, typicalLimit - currentSize);
|
|
272
|
+
} catch {
|
|
273
|
+
return 0;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
async getSchema() {
|
|
277
|
+
return Object.keys(this.schema);
|
|
278
|
+
}
|
|
279
|
+
async cleanup() {
|
|
280
|
+
const keysToRemove = [];
|
|
281
|
+
for (let i = 0; i < this.storage.length; i++) {
|
|
282
|
+
const key = this.storage.key(i);
|
|
283
|
+
if (key && key.startsWith(this.config.keyPrefix)) {
|
|
284
|
+
keysToRemove.push(key);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
for (const key of keysToRemove) {
|
|
288
|
+
this.storage.removeItem(key);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export {
|
|
294
|
+
LocalStorageClient
|
|
295
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { N as NodeProtocolInterface, a as HttpClientConfig, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, D as DeleteResult, H as HealthStatus } from '../../types-Bw0Boe0n.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HttpClient - HTTP implementation of NodeProtocolInterface
|
|
5
|
+
*
|
|
6
|
+
* Connects to B3nd HTTP API servers and forwards operations.
|
|
7
|
+
* No schema validation - validation happens server-side.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare class HttpClient implements NodeProtocolInterface {
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private headers;
|
|
13
|
+
private timeout;
|
|
14
|
+
constructor(config: HttpClientConfig);
|
|
15
|
+
/**
|
|
16
|
+
* Make an HTTP request with timeout
|
|
17
|
+
*/
|
|
18
|
+
private request;
|
|
19
|
+
/**
|
|
20
|
+
* Parse URI into components
|
|
21
|
+
* Example: "users://alice/profile" -> { protocol: "users", domain: "alice", path: "/profile" }
|
|
22
|
+
*/
|
|
23
|
+
private parseUri;
|
|
24
|
+
write<T = unknown>(uri: string, value: T): Promise<WriteResult<T>>;
|
|
25
|
+
read<T = unknown>(uri: string): Promise<ReadResult<T>>;
|
|
26
|
+
list(uri: string, options?: ListOptions): Promise<ListResult>;
|
|
27
|
+
delete(uri: string): Promise<DeleteResult>;
|
|
28
|
+
health(): Promise<HealthStatus>;
|
|
29
|
+
getSchema(): Promise<string[]>;
|
|
30
|
+
cleanup(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { HttpClient };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { N as NodeProtocolInterface, d as LocalStorageClientConfig, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, D as DeleteResult, H as HealthStatus } from '../../types-Bw0Boe0n.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* LocalStorageClient - Browser localStorage implementation of NodeProtocolInterface
|
|
5
|
+
*
|
|
6
|
+
* Provides persistent storage in browser environments using localStorage.
|
|
7
|
+
* Supports schema validation and custom serialization.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare class LocalStorageClient implements NodeProtocolInterface {
|
|
11
|
+
private config;
|
|
12
|
+
private schema;
|
|
13
|
+
private storage;
|
|
14
|
+
constructor(config: LocalStorageClientConfig);
|
|
15
|
+
/**
|
|
16
|
+
* Get the localStorage key for a URI
|
|
17
|
+
*/
|
|
18
|
+
private getKey;
|
|
19
|
+
/**
|
|
20
|
+
* Validate write operation against schema
|
|
21
|
+
*/
|
|
22
|
+
private validateWrite;
|
|
23
|
+
/**
|
|
24
|
+
* Find matching program key for URI
|
|
25
|
+
*/
|
|
26
|
+
private findMatchingProgram;
|
|
27
|
+
/**
|
|
28
|
+
* Serialize data using configured serializer
|
|
29
|
+
*/
|
|
30
|
+
private serialize;
|
|
31
|
+
/**
|
|
32
|
+
* Deserialize data using configured serializer
|
|
33
|
+
*/
|
|
34
|
+
private deserialize;
|
|
35
|
+
write<T = unknown>(uri: string, value: T): Promise<WriteResult<T>>;
|
|
36
|
+
read<T = unknown>(uri: string): Promise<ReadResult<T>>;
|
|
37
|
+
list(uri: string, options?: ListOptions): Promise<ListResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Check if a URI has children (is a directory)
|
|
40
|
+
*/
|
|
41
|
+
private hasChildren;
|
|
42
|
+
/**
|
|
43
|
+
* Get stored data for a URI (for timestamp sorting)
|
|
44
|
+
*/
|
|
45
|
+
private getStoredData;
|
|
46
|
+
delete(uri: string): Promise<DeleteResult>;
|
|
47
|
+
health(): Promise<HealthStatus>;
|
|
48
|
+
/**
|
|
49
|
+
* Get localStorage usage statistics
|
|
50
|
+
*/
|
|
51
|
+
private getStorageStats;
|
|
52
|
+
/**
|
|
53
|
+
* Estimate remaining localStorage space (rough approximation)
|
|
54
|
+
*/
|
|
55
|
+
private estimateRemainingSpace;
|
|
56
|
+
getSchema(): Promise<string[]>;
|
|
57
|
+
cleanup(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { LocalStorageClient };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { N as NodeProtocolInterface, W as WebSocketClientConfig, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, D as DeleteResult, H as HealthStatus } from '../../types-Bw0Boe0n.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WebSocketClient - WebSocket implementation of NodeProtocolInterface
|
|
5
|
+
*
|
|
6
|
+
* Connects to B3nd WebSocket servers and forwards operations.
|
|
7
|
+
* Handles reconnection and connection pooling.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare class WebSocketClient implements NodeProtocolInterface {
|
|
11
|
+
private config;
|
|
12
|
+
private ws;
|
|
13
|
+
private connected;
|
|
14
|
+
private reconnectAttempts;
|
|
15
|
+
private reconnectTimer;
|
|
16
|
+
private pendingRequests;
|
|
17
|
+
private messageHandler;
|
|
18
|
+
private closeHandler;
|
|
19
|
+
private errorHandler;
|
|
20
|
+
constructor(config: WebSocketClientConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Ensure WebSocket connection is established
|
|
23
|
+
*/
|
|
24
|
+
private ensureConnected;
|
|
25
|
+
/**
|
|
26
|
+
* Establish WebSocket connection
|
|
27
|
+
*/
|
|
28
|
+
private connect;
|
|
29
|
+
/**
|
|
30
|
+
* Handle WebSocket messages
|
|
31
|
+
*/
|
|
32
|
+
private handleMessage;
|
|
33
|
+
/**
|
|
34
|
+
* Handle WebSocket close
|
|
35
|
+
*/
|
|
36
|
+
private handleClose;
|
|
37
|
+
/**
|
|
38
|
+
* Handle WebSocket errors
|
|
39
|
+
*/
|
|
40
|
+
private handleError;
|
|
41
|
+
/**
|
|
42
|
+
* Schedule reconnection attempt
|
|
43
|
+
*/
|
|
44
|
+
private scheduleReconnect;
|
|
45
|
+
/**
|
|
46
|
+
* Cleanup pending requests with error
|
|
47
|
+
*/
|
|
48
|
+
private cleanupPendingRequests;
|
|
49
|
+
/**
|
|
50
|
+
* Send request and wait for response
|
|
51
|
+
*/
|
|
52
|
+
private sendRequest;
|
|
53
|
+
write<T = unknown>(uri: string, value: T): Promise<WriteResult<T>>;
|
|
54
|
+
read<T = unknown>(uri: string): Promise<ReadResult<T>>;
|
|
55
|
+
list(uri: string, options?: ListOptions): Promise<ListResult>;
|
|
56
|
+
delete(uri: string): Promise<DeleteResult>;
|
|
57
|
+
health(): Promise<HealthStatus>;
|
|
58
|
+
getSchema(): Promise<string[]>;
|
|
59
|
+
cleanup(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { WebSocketClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { A as AuthenticatedMessage, a as EncryptedPayload, E as EncryptionKeyPair, K as KeyPair, S as SignedEncryptedMessage, h as createAuthenticatedMessage, i as createSignedEncryptedMessage, d as decrypt, f as decryptWithHex, e as encrypt, b as generateEncryptionKeyPair, k as generateNonce, l as generateRandomData, g as generateSigningKeyPair, s as sign, c as signWithHex, v as verify, j as verifyAndDecrypt } from '../mod-DHjjiF1o.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAuthenticatedMessage,
|
|
3
|
+
createSignedEncryptedMessage,
|
|
4
|
+
decrypt,
|
|
5
|
+
decryptWithHex,
|
|
6
|
+
encrypt,
|
|
7
|
+
generateEncryptionKeyPair,
|
|
8
|
+
generateNonce,
|
|
9
|
+
generateRandomData,
|
|
10
|
+
generateSigningKeyPair,
|
|
11
|
+
sign,
|
|
12
|
+
signWithHex,
|
|
13
|
+
verify,
|
|
14
|
+
verifyAndDecrypt
|
|
15
|
+
} from "../chunk-G6JDROB4.js";
|
|
16
|
+
import "../chunk-MLKGABMK.js";
|
|
17
|
+
export {
|
|
18
|
+
createAuthenticatedMessage,
|
|
19
|
+
createSignedEncryptedMessage,
|
|
20
|
+
decrypt,
|
|
21
|
+
decryptWithHex,
|
|
22
|
+
encrypt,
|
|
23
|
+
generateEncryptionKeyPair,
|
|
24
|
+
generateNonce,
|
|
25
|
+
generateRandomData,
|
|
26
|
+
generateSigningKeyPair,
|
|
27
|
+
sign,
|
|
28
|
+
signWithHex,
|
|
29
|
+
verify,
|
|
30
|
+
verifyAndDecrypt
|
|
31
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
interface KeyPair {
|
|
2
|
+
publicKey: CryptoKey;
|
|
3
|
+
privateKey: CryptoKey;
|
|
4
|
+
publicKeyHex: string;
|
|
5
|
+
privateKeyHex: string;
|
|
6
|
+
}
|
|
7
|
+
interface EncryptionKeyPair {
|
|
8
|
+
publicKey: CryptoKey;
|
|
9
|
+
privateKey: CryptoKey;
|
|
10
|
+
publicKeyHex: string;
|
|
11
|
+
}
|
|
12
|
+
interface EncryptedPayload {
|
|
13
|
+
data: string;
|
|
14
|
+
nonce: string;
|
|
15
|
+
ephemeralPublicKey?: string;
|
|
16
|
+
}
|
|
17
|
+
interface AuthenticatedMessage<T = unknown> {
|
|
18
|
+
auth: Array<{
|
|
19
|
+
pubkey: string;
|
|
20
|
+
signature: string;
|
|
21
|
+
}>;
|
|
22
|
+
payload: T;
|
|
23
|
+
}
|
|
24
|
+
interface SignedEncryptedMessage {
|
|
25
|
+
auth: Array<{
|
|
26
|
+
pubkey: string;
|
|
27
|
+
signature: string;
|
|
28
|
+
}>;
|
|
29
|
+
payload: EncryptedPayload;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generate an Ed25519 keypair for signing
|
|
33
|
+
*/
|
|
34
|
+
declare function generateSigningKeyPair(): Promise<KeyPair>;
|
|
35
|
+
/**
|
|
36
|
+
* Generate an X25519 keypair for encryption (ECDH)
|
|
37
|
+
*/
|
|
38
|
+
declare function generateEncryptionKeyPair(): Promise<EncryptionKeyPair>;
|
|
39
|
+
/**
|
|
40
|
+
* Sign a payload with an Ed25519 private key
|
|
41
|
+
*/
|
|
42
|
+
declare function sign<T>(privateKey: CryptoKey, payload: T): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Sign a payload with an Ed25519 private key from hex
|
|
45
|
+
*/
|
|
46
|
+
declare function signWithHex<T>(privateKeyHex: string, payload: T): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Verify a signature using Ed25519 public key
|
|
49
|
+
*/
|
|
50
|
+
declare function verify<T>(publicKeyHex: string, signatureHex: string, payload: T): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Encrypt data using X25519 ECDH + AES-GCM
|
|
53
|
+
* Uses ephemeral keypair for forward secrecy
|
|
54
|
+
*/
|
|
55
|
+
declare function encrypt(data: unknown, recipientPublicKeyHex: string): Promise<EncryptedPayload>;
|
|
56
|
+
/**
|
|
57
|
+
* Decrypt data using X25519 ECDH + AES-GCM
|
|
58
|
+
*/
|
|
59
|
+
declare function decrypt(encryptedPayload: EncryptedPayload, recipientPrivateKey: CryptoKey): Promise<unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* Decrypt data using private key from hex
|
|
62
|
+
*/
|
|
63
|
+
declare function decryptWithHex(encryptedPayload: EncryptedPayload, recipientPrivateKeyHex: string): Promise<unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* Create an authenticated message (signed but not encrypted)
|
|
66
|
+
*/
|
|
67
|
+
declare function createAuthenticatedMessage<T>(payload: T, signers: Array<{
|
|
68
|
+
privateKey: CryptoKey;
|
|
69
|
+
publicKeyHex: string;
|
|
70
|
+
}>): Promise<AuthenticatedMessage<T>>;
|
|
71
|
+
/**
|
|
72
|
+
* Create a signed and encrypted message
|
|
73
|
+
*/
|
|
74
|
+
declare function createSignedEncryptedMessage(data: unknown, signers: Array<{
|
|
75
|
+
privateKey: CryptoKey;
|
|
76
|
+
publicKeyHex: string;
|
|
77
|
+
}>, recipientPublicKeyHex: string): Promise<SignedEncryptedMessage>;
|
|
78
|
+
/**
|
|
79
|
+
* Verify and decrypt a signed encrypted message
|
|
80
|
+
*/
|
|
81
|
+
declare function verifyAndDecrypt(message: SignedEncryptedMessage, recipientPrivateKey: CryptoKey): Promise<{
|
|
82
|
+
data: unknown;
|
|
83
|
+
verified: boolean;
|
|
84
|
+
signers: string[];
|
|
85
|
+
}>;
|
|
86
|
+
declare function generateNonce(length?: number): Uint8Array;
|
|
87
|
+
declare function generateRandomData(size: number): Uint8Array;
|
|
88
|
+
|
|
89
|
+
type mod_AuthenticatedMessage<T = unknown> = AuthenticatedMessage<T>;
|
|
90
|
+
type mod_EncryptedPayload = EncryptedPayload;
|
|
91
|
+
type mod_EncryptionKeyPair = EncryptionKeyPair;
|
|
92
|
+
type mod_KeyPair = KeyPair;
|
|
93
|
+
type mod_SignedEncryptedMessage = SignedEncryptedMessage;
|
|
94
|
+
declare const mod_createAuthenticatedMessage: typeof createAuthenticatedMessage;
|
|
95
|
+
declare const mod_createSignedEncryptedMessage: typeof createSignedEncryptedMessage;
|
|
96
|
+
declare const mod_decrypt: typeof decrypt;
|
|
97
|
+
declare const mod_decryptWithHex: typeof decryptWithHex;
|
|
98
|
+
declare const mod_encrypt: typeof encrypt;
|
|
99
|
+
declare const mod_generateEncryptionKeyPair: typeof generateEncryptionKeyPair;
|
|
100
|
+
declare const mod_generateNonce: typeof generateNonce;
|
|
101
|
+
declare const mod_generateRandomData: typeof generateRandomData;
|
|
102
|
+
declare const mod_generateSigningKeyPair: typeof generateSigningKeyPair;
|
|
103
|
+
declare const mod_sign: typeof sign;
|
|
104
|
+
declare const mod_signWithHex: typeof signWithHex;
|
|
105
|
+
declare const mod_verify: typeof verify;
|
|
106
|
+
declare const mod_verifyAndDecrypt: typeof verifyAndDecrypt;
|
|
107
|
+
declare namespace mod {
|
|
108
|
+
export { type mod_AuthenticatedMessage as AuthenticatedMessage, type mod_EncryptedPayload as EncryptedPayload, type mod_EncryptionKeyPair as EncryptionKeyPair, type mod_KeyPair as KeyPair, type mod_SignedEncryptedMessage as SignedEncryptedMessage, mod_createAuthenticatedMessage as createAuthenticatedMessage, mod_createSignedEncryptedMessage as createSignedEncryptedMessage, mod_decrypt as decrypt, mod_decryptWithHex as decryptWithHex, mod_encrypt as encrypt, mod_generateEncryptionKeyPair as generateEncryptionKeyPair, mod_generateNonce as generateNonce, mod_generateRandomData as generateRandomData, mod_generateSigningKeyPair as generateSigningKeyPair, mod_sign as sign, mod_signWithHex as signWithHex, mod_verify as verify, mod_verifyAndDecrypt as verifyAndDecrypt };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { type AuthenticatedMessage as A, type EncryptionKeyPair as E, type KeyPair as K, type SignedEncryptedMessage as S, type EncryptedPayload as a, generateEncryptionKeyPair as b, signWithHex as c, decrypt as d, encrypt as e, decryptWithHex as f, generateSigningKeyPair as g, createAuthenticatedMessage as h, createSignedEncryptedMessage as i, verifyAndDecrypt as j, generateNonce as k, generateRandomData as l, mod as m, sign as s, verify as v };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { C as ClientError, D as DeleteResult, H as HealthStatus, a as HttpClientConfig, L as ListItem, b as ListOptions, c as ListResult, d as LocalStorageClientConfig, N as NodeProtocolInterface, P as PersistenceRecord, R as ReadResult, S as Schema, V as ValidationFn, W as WebSocketClientConfig, e as WebSocketRequest, f as WebSocketResponse, g as WriteResult } from '../types-Bw0Boe0n.js';
|
|
2
|
+
export { HttpClient } from '../clients/http/mod.js';
|
|
3
|
+
export { WebSocketClient } from '../clients/websocket/mod.js';
|
|
4
|
+
export { LocalStorageClient } from '../clients/local-storage/mod.js';
|
|
5
|
+
export { WalletClient } from '../wallet/mod.js';
|
|
6
|
+
export { AppsClient } from '../apps/mod.js';
|
|
7
|
+
export { m as encrypt } from '../mod-DHjjiF1o.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppsClient
|
|
3
|
+
} from "../chunk-QHDBFVLU.js";
|
|
4
|
+
import {
|
|
5
|
+
mod_exports
|
|
6
|
+
} from "../chunk-G6JDROB4.js";
|
|
7
|
+
import {
|
|
8
|
+
WalletClient
|
|
9
|
+
} from "../chunk-2D2RT2DW.js";
|
|
10
|
+
import {
|
|
11
|
+
HttpClient
|
|
12
|
+
} from "../chunk-PMBS2GFA.js";
|
|
13
|
+
import {
|
|
14
|
+
LocalStorageClient
|
|
15
|
+
} from "../chunk-XH4OLKBV.js";
|
|
16
|
+
import {
|
|
17
|
+
WebSocketClient
|
|
18
|
+
} from "../chunk-C2ZIFM22.js";
|
|
19
|
+
import "../chunk-MLKGABMK.js";
|
|
20
|
+
export {
|
|
21
|
+
AppsClient,
|
|
22
|
+
HttpClient,
|
|
23
|
+
LocalStorageClient,
|
|
24
|
+
WalletClient,
|
|
25
|
+
WebSocketClient,
|
|
26
|
+
mod_exports as encrypt
|
|
27
|
+
};
|