@decentrl/event-store 0.0.20 → 0.5.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/event-store.d.ts.map +1 -1
- package/dist/event-store.js +0 -6
- package/dist/event-store.test.js +2 -9
- package/dist/types.d.ts +0 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/event-store.test.ts +4 -11
- package/src/event-store.ts +0 -8
- package/src/types.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-store.d.ts","sourceRoot":"","sources":["../src/event-store.ts"],"names":[],"mappings":"AAsBA,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,MAAM,SAAS,CAAC;AAQjB,qBAAa,kBAAkB;IAClB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,gBAAgB;IAE5C;;OAEG;IACG,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBvE;;OAEG;IACG,WAAW,CAAC,CAAC,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IA2E7E;;OAEG;IACG,oBAAoB,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC;IAiD7C;;;OAGG;IACG,8BAA8B,CAAC,CAAC,EACrC,SAAS,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,GACnE,OAAO,CAAC,CAAC,EAAE,CAAC;IAgBf;;OAEG;IACG,eAAe,CACpB,MAAM,EAAE,KAAK,CAAC;QAAE,OAAO,EAA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OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,GACnE,OAAO,CAAC,CAAC,EAAE,CAAC;IAgBf;;OAEG;IACG,eAAe,CACpB,MAAM,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,GACzD,OAAO,CAAC,IAAI,CAAC;IAoBhB;;;OAGG;IACG,sBAAsB,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE;QAC5C,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG;QAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAkE/D;;OAEG;IACG,kBAAkB,CACvB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,oBAAoB,GAC3B,OAAO,CAAC;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IAsCrC;;OAEG;IACG,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B7D;;OAEG;WACU,iBAAiB,CAC7B,OAAO,EAAE,kBAAkB,GACzB,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAqD9C;;OAEG;YACW,kBAAkB;IAgFhC;;OAEG;YACW,eAAe;IAkD7B;;OAEG;YACW,YAAY;IA2C1B;;OAEG;YACW,kBAAkB;IAyChC;;OAEG;YACW,wBAAwB;CAmBtC"}
|
package/dist/event-store.js
CHANGED
|
@@ -196,7 +196,6 @@ export class DecentrlEventStore {
|
|
|
196
196
|
const { identity } = this.config;
|
|
197
197
|
const timestamp = Math.floor(Date.now() / 1000);
|
|
198
198
|
const signedData = {
|
|
199
|
-
channel_id: options.channelId,
|
|
200
199
|
event,
|
|
201
200
|
tags: options.tags,
|
|
202
201
|
timestamp,
|
|
@@ -204,7 +203,6 @@ export class DecentrlEventStore {
|
|
|
204
203
|
const eventSignature = signJsonObject(signedData, identity.keys.signing.privateKey);
|
|
205
204
|
const command = generateOneWayPublicMediatorCommand(identity.did, `${identity.did}#signing`, identity.mediatorDid, {
|
|
206
205
|
type: 'PUBLISH_PUBLIC_EVENT',
|
|
207
|
-
channel_id: options.channelId,
|
|
208
206
|
event,
|
|
209
207
|
tags: options.tags,
|
|
210
208
|
timestamp,
|
|
@@ -235,9 +233,6 @@ export class DecentrlEventStore {
|
|
|
235
233
|
*/
|
|
236
234
|
static async fetchPublicEvents(options) {
|
|
237
235
|
const params = new URLSearchParams();
|
|
238
|
-
if (options.channelId) {
|
|
239
|
-
params.set('channel_id', options.channelId);
|
|
240
|
-
}
|
|
241
236
|
if (options.tags?.length) {
|
|
242
237
|
params.set('tags', options.tags.join(','));
|
|
243
238
|
}
|
|
@@ -258,7 +253,6 @@ export class DecentrlEventStore {
|
|
|
258
253
|
return {
|
|
259
254
|
data: response.data.events.map((e) => ({
|
|
260
255
|
id: e.id,
|
|
261
|
-
channelId: e.channel_id,
|
|
262
256
|
event: e.event,
|
|
263
257
|
tags: e.tags,
|
|
264
258
|
timestamp: e.timestamp,
|
package/dist/event-store.test.js
CHANGED
|
@@ -24,7 +24,6 @@ vi.mock('axios', () => {
|
|
|
24
24
|
events: [
|
|
25
25
|
{
|
|
26
26
|
id: 'pub-evt-1',
|
|
27
|
-
channel_id: 'blog',
|
|
28
27
|
event: '{"type":"blog.post","data":{"title":"Hello"}}',
|
|
29
28
|
tags: ['blog'],
|
|
30
29
|
timestamp: 1710000000,
|
|
@@ -303,7 +302,6 @@ describe('DecentrlEventStore', () => {
|
|
|
303
302
|
communicationContracts: () => [],
|
|
304
303
|
});
|
|
305
304
|
const result = await eventStore.publishPublicEvent('{"type":"test","data":{}}', {
|
|
306
|
-
channelId: 'blog',
|
|
307
305
|
tags: ['blog', 'test'],
|
|
308
306
|
});
|
|
309
307
|
expect(result.publicEventId).toBe('pub-123');
|
|
@@ -317,7 +315,7 @@ describe('DecentrlEventStore', () => {
|
|
|
317
315
|
identity: mockIdentity,
|
|
318
316
|
communicationContracts: () => [],
|
|
319
317
|
});
|
|
320
|
-
await eventStore.publishPublicEvent('test', {
|
|
318
|
+
await eventStore.publishPublicEvent('test', { tags: [] });
|
|
321
319
|
const signedData = vi.mocked(signJsonObject).mock.calls[0][0];
|
|
322
320
|
// Timestamp should be in seconds (roughly current time / 1000)
|
|
323
321
|
expect(signedData.timestamp).toBeLessThan(Date.now());
|
|
@@ -331,7 +329,7 @@ describe('DecentrlEventStore', () => {
|
|
|
331
329
|
identity: mockIdentity,
|
|
332
330
|
communicationContracts: () => [],
|
|
333
331
|
});
|
|
334
|
-
await expect(eventStore.publishPublicEvent('test', {
|
|
332
|
+
await expect(eventStore.publishPublicEvent('test', { tags: [] })).rejects.toThrow('Failed to publish public event');
|
|
335
333
|
});
|
|
336
334
|
});
|
|
337
335
|
describe('deletePublicEvent', () => {
|
|
@@ -362,11 +360,9 @@ describe('DecentrlEventStore', () => {
|
|
|
362
360
|
const result = await DecentrlEventStore.fetchPublicEvents({
|
|
363
361
|
mediatorEndpoint: 'http://mediator',
|
|
364
362
|
publisherDid: 'did:decentrl:bob',
|
|
365
|
-
channelId: 'blog',
|
|
366
363
|
});
|
|
367
364
|
expect(result.data).toHaveLength(1);
|
|
368
365
|
expect(result.data[0].id).toBe('pub-evt-1');
|
|
369
|
-
expect(result.data[0].channelId).toBe('blog');
|
|
370
366
|
expect(result.data[0].timestamp).toBe(1710000000);
|
|
371
367
|
expect(result.pagination.total).toBe(1);
|
|
372
368
|
});
|
|
@@ -375,14 +371,12 @@ describe('DecentrlEventStore', () => {
|
|
|
375
371
|
await DecentrlEventStore.fetchPublicEvents({
|
|
376
372
|
mediatorEndpoint: 'http://mediator',
|
|
377
373
|
publisherDid: 'did:decentrl:bob',
|
|
378
|
-
channelId: 'blog',
|
|
379
374
|
tags: ['tag1', 'tag2'],
|
|
380
375
|
afterTimestamp: 1710000000,
|
|
381
376
|
pagination: { page: 2, pageSize: 10 },
|
|
382
377
|
});
|
|
383
378
|
const url = vi.mocked(axios.get).mock.calls[0][0];
|
|
384
379
|
expect(url).toContain('/public/did:decentrl:bob');
|
|
385
|
-
expect(url).toContain('channel_id=blog');
|
|
386
380
|
expect(url).toContain('tags=tag1%2Ctag2');
|
|
387
381
|
expect(url).toContain('after=1710000000');
|
|
388
382
|
expect(url).toContain('page=2');
|
|
@@ -394,7 +388,6 @@ describe('DecentrlEventStore', () => {
|
|
|
394
388
|
publisherDid: 'did:decentrl:bob',
|
|
395
389
|
});
|
|
396
390
|
// Verify camelCase mapping
|
|
397
|
-
expect(result.data[0].channelId).toBe('blog');
|
|
398
391
|
expect(result.data[0].eventSignature).toBe('sig-1');
|
|
399
392
|
expect(result.pagination.pageSize).toBe(20);
|
|
400
393
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -46,13 +46,11 @@ export interface PaginatedResult<T> {
|
|
|
46
46
|
pagination: PaginationMeta;
|
|
47
47
|
}
|
|
48
48
|
export interface PublicPublishOptions {
|
|
49
|
-
channelId: string;
|
|
50
49
|
tags: string[];
|
|
51
50
|
}
|
|
52
51
|
export interface PublicQueryOptions {
|
|
53
52
|
mediatorEndpoint: string;
|
|
54
53
|
publisherDid: string;
|
|
55
|
-
channelId?: string;
|
|
56
54
|
tags?: string[];
|
|
57
55
|
/** Unix timestamp in seconds */
|
|
58
56
|
afterTimestamp?: number;
|
|
@@ -65,7 +63,6 @@ export interface PublicQueryOptions {
|
|
|
65
63
|
}
|
|
66
64
|
export interface PublicEventResult {
|
|
67
65
|
id: string;
|
|
68
|
-
channelId: string;
|
|
69
66
|
event: string;
|
|
70
67
|
tags: string[];
|
|
71
68
|
timestamp: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D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EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,EAAE,cAAc,CAAC;CAC3B;AAID,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,EAAE,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gCAAgC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AAED,MAAM,WAAW,iBAAiB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,eAAgB,SAAQ,KAAK;IAGjC,IAAI,EAAE,MAAM;IACZ,OAAO,CAAC,EAAE,OAAO;gBAFxB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,YAAA;CAKzB"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentrl/event-store",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Event-driven storage and communication library for decentrl",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"axios": "^1.6.0",
|
|
9
|
-
"@decentrl/
|
|
10
|
-
"@decentrl/
|
|
9
|
+
"@decentrl/crypto": "0.5.1",
|
|
10
|
+
"@decentrl/identity": "0.5.1"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"typescript": "^5.0.0",
|
package/src/event-store.test.ts
CHANGED
|
@@ -34,7 +34,6 @@ vi.mock('axios', () => {
|
|
|
34
34
|
events: [
|
|
35
35
|
{
|
|
36
36
|
id: 'pub-evt-1',
|
|
37
|
-
channel_id: 'blog',
|
|
38
37
|
event: '{"type":"blog.post","data":{"title":"Hello"}}',
|
|
39
38
|
tags: ['blog'],
|
|
40
39
|
timestamp: 1710000000,
|
|
@@ -382,7 +381,6 @@ describe('DecentrlEventStore', () => {
|
|
|
382
381
|
});
|
|
383
382
|
|
|
384
383
|
const result = await eventStore.publishPublicEvent('{"type":"test","data":{}}', {
|
|
385
|
-
channelId: 'blog',
|
|
386
384
|
tags: ['blog', 'test'],
|
|
387
385
|
});
|
|
388
386
|
|
|
@@ -404,7 +402,7 @@ describe('DecentrlEventStore', () => {
|
|
|
404
402
|
communicationContracts: () => [],
|
|
405
403
|
});
|
|
406
404
|
|
|
407
|
-
await eventStore.publishPublicEvent('test', {
|
|
405
|
+
await eventStore.publishPublicEvent('test', { tags: [] });
|
|
408
406
|
|
|
409
407
|
const signedData = vi.mocked(signJsonObject).mock.calls[0][0] as Record<string, unknown>;
|
|
410
408
|
// Timestamp should be in seconds (roughly current time / 1000)
|
|
@@ -422,9 +420,9 @@ describe('DecentrlEventStore', () => {
|
|
|
422
420
|
communicationContracts: () => [],
|
|
423
421
|
});
|
|
424
422
|
|
|
425
|
-
await expect(
|
|
426
|
-
|
|
427
|
-
)
|
|
423
|
+
await expect(eventStore.publishPublicEvent('test', { tags: [] })).rejects.toThrow(
|
|
424
|
+
'Failed to publish public event',
|
|
425
|
+
);
|
|
428
426
|
});
|
|
429
427
|
});
|
|
430
428
|
|
|
@@ -464,12 +462,10 @@ describe('DecentrlEventStore', () => {
|
|
|
464
462
|
const result = await DecentrlEventStore.fetchPublicEvents({
|
|
465
463
|
mediatorEndpoint: 'http://mediator',
|
|
466
464
|
publisherDid: 'did:decentrl:bob',
|
|
467
|
-
channelId: 'blog',
|
|
468
465
|
});
|
|
469
466
|
|
|
470
467
|
expect(result.data).toHaveLength(1);
|
|
471
468
|
expect(result.data[0].id).toBe('pub-evt-1');
|
|
472
|
-
expect(result.data[0].channelId).toBe('blog');
|
|
473
469
|
expect(result.data[0].timestamp).toBe(1710000000);
|
|
474
470
|
expect(result.pagination.total).toBe(1);
|
|
475
471
|
});
|
|
@@ -480,7 +476,6 @@ describe('DecentrlEventStore', () => {
|
|
|
480
476
|
await DecentrlEventStore.fetchPublicEvents({
|
|
481
477
|
mediatorEndpoint: 'http://mediator',
|
|
482
478
|
publisherDid: 'did:decentrl:bob',
|
|
483
|
-
channelId: 'blog',
|
|
484
479
|
tags: ['tag1', 'tag2'],
|
|
485
480
|
afterTimestamp: 1710000000,
|
|
486
481
|
pagination: { page: 2, pageSize: 10 },
|
|
@@ -488,7 +483,6 @@ describe('DecentrlEventStore', () => {
|
|
|
488
483
|
|
|
489
484
|
const url = vi.mocked(axios.get).mock.calls[0][0] as string;
|
|
490
485
|
expect(url).toContain('/public/did:decentrl:bob');
|
|
491
|
-
expect(url).toContain('channel_id=blog');
|
|
492
486
|
expect(url).toContain('tags=tag1%2Ctag2');
|
|
493
487
|
expect(url).toContain('after=1710000000');
|
|
494
488
|
expect(url).toContain('page=2');
|
|
@@ -502,7 +496,6 @@ describe('DecentrlEventStore', () => {
|
|
|
502
496
|
});
|
|
503
497
|
|
|
504
498
|
// Verify camelCase mapping
|
|
505
|
-
expect(result.data[0].channelId).toBe('blog');
|
|
506
499
|
expect(result.data[0].eventSignature).toBe('sig-1');
|
|
507
500
|
expect(result.pagination.pageSize).toBe(20);
|
|
508
501
|
});
|
package/src/event-store.ts
CHANGED
|
@@ -324,7 +324,6 @@ export class DecentrlEventStore {
|
|
|
324
324
|
const timestamp = Math.floor(Date.now() / 1000);
|
|
325
325
|
|
|
326
326
|
const signedData = {
|
|
327
|
-
channel_id: options.channelId,
|
|
328
327
|
event,
|
|
329
328
|
tags: options.tags,
|
|
330
329
|
timestamp,
|
|
@@ -338,7 +337,6 @@ export class DecentrlEventStore {
|
|
|
338
337
|
identity.mediatorDid,
|
|
339
338
|
{
|
|
340
339
|
type: 'PUBLISH_PUBLIC_EVENT',
|
|
341
|
-
channel_id: options.channelId,
|
|
342
340
|
event,
|
|
343
341
|
tags: options.tags,
|
|
344
342
|
timestamp,
|
|
@@ -398,10 +396,6 @@ export class DecentrlEventStore {
|
|
|
398
396
|
): Promise<PaginatedResult<PublicEventResult>> {
|
|
399
397
|
const params = new URLSearchParams();
|
|
400
398
|
|
|
401
|
-
if (options.channelId) {
|
|
402
|
-
params.set('channel_id', options.channelId);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
399
|
if (options.tags?.length) {
|
|
406
400
|
params.set('tags', options.tags.join(','));
|
|
407
401
|
}
|
|
@@ -424,7 +418,6 @@ export class DecentrlEventStore {
|
|
|
424
418
|
interface PublicEventsResponse {
|
|
425
419
|
events: Array<{
|
|
426
420
|
id: string;
|
|
427
|
-
channel_id: string;
|
|
428
421
|
event: string;
|
|
429
422
|
tags: string[];
|
|
430
423
|
timestamp: number;
|
|
@@ -440,7 +433,6 @@ export class DecentrlEventStore {
|
|
|
440
433
|
return {
|
|
441
434
|
data: response.data.events.map((e) => ({
|
|
442
435
|
id: e.id,
|
|
443
|
-
channelId: e.channel_id,
|
|
444
436
|
event: e.event,
|
|
445
437
|
tags: e.tags,
|
|
446
438
|
timestamp: e.timestamp,
|
package/src/types.ts
CHANGED
|
@@ -52,14 +52,12 @@ export interface PaginatedResult<T> {
|
|
|
52
52
|
// --- Public Events ---
|
|
53
53
|
|
|
54
54
|
export interface PublicPublishOptions {
|
|
55
|
-
channelId: string;
|
|
56
55
|
tags: string[];
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
export interface PublicQueryOptions {
|
|
60
59
|
mediatorEndpoint: string;
|
|
61
60
|
publisherDid: string;
|
|
62
|
-
channelId?: string;
|
|
63
61
|
tags?: string[];
|
|
64
62
|
/** Unix timestamp in seconds */
|
|
65
63
|
afterTimestamp?: number;
|
|
@@ -70,7 +68,6 @@ export interface PublicQueryOptions {
|
|
|
70
68
|
|
|
71
69
|
export interface PublicEventResult {
|
|
72
70
|
id: string;
|
|
73
|
-
channelId: string;
|
|
74
71
|
event: string;
|
|
75
72
|
tags: string[];
|
|
76
73
|
timestamp: number;
|