@veramo/message-handler 4.2.1-next.6 → 4.2.1-unstable.9

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.
@@ -1,5 +1,5 @@
1
1
  import { IAgentContext } from '@veramo/core';
2
- import { Message } from './message';
2
+ import { Message } from './message.js';
3
3
  export declare const unsupportedMessageTypeError: Error;
4
4
  /**
5
5
  * An abstract class for creating {@link @veramo/message-handler#MessageHandler} plugins
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-message-handler.d.ts","sourceRoot":"","sources":["../src/abstract-message-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,eAAO,MAAM,2BAA2B,OAAwC,CAAA;AAEhF;;;GAGG;AACH,8BAAsB,sBAAsB;IACnC,kBAAkB,CAAC,EAAE,sBAAsB,CAAA;IAE3C,OAAO,CAAC,cAAc,EAAE,sBAAsB,GAAG,sBAAsB;IAKjE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAOpF"}
1
+ {"version":3,"file":"abstract-message-handler.d.ts","sourceRoot":"","sources":["../src/abstract-message-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAItC,eAAO,MAAM,2BAA2B,OAAwC,CAAA;AAEhF;;;GAGG;AACH,8BAAsB,sBAAsB;IACnC,kBAAkB,CAAC,EAAE,sBAAsB,CAAA;IAE3C,OAAO,CAAC,cAAc,EAAE,sBAAsB,GAAG,sBAAsB;IAKjE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAOpF"}
@@ -1,39 +1,22 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.AbstractMessageHandler = exports.unsupportedMessageTypeError = void 0;
16
- const debug_1 = __importDefault(require("debug"));
17
- const debug = (0, debug_1.default)('veramo:message-handler');
18
- exports.unsupportedMessageTypeError = new Error('Unsupported message type');
1
+ import Debug from 'debug';
2
+ const debug = Debug('veramo:message-handler');
3
+ export const unsupportedMessageTypeError = new Error('Unsupported message type');
19
4
  /**
20
5
  * An abstract class for creating {@link @veramo/message-handler#MessageHandler} plugins
21
6
  * @public
22
7
  */
23
- class AbstractMessageHandler {
8
+ export class AbstractMessageHandler {
9
+ nextMessageHandler;
24
10
  setNext(messageHandler) {
25
11
  this.nextMessageHandler = messageHandler;
26
12
  return messageHandler;
27
13
  }
28
- handle(message, context) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- if (this.nextMessageHandler) {
31
- return this.nextMessageHandler.handle(message, context);
32
- }
33
- debug("can't handle message: ", message);
34
- return Promise.reject(exports.unsupportedMessageTypeError);
35
- });
14
+ async handle(message, context) {
15
+ if (this.nextMessageHandler) {
16
+ return this.nextMessageHandler.handle(message, context);
17
+ }
18
+ debug("can't handle message: ", message);
19
+ return Promise.reject(unsupportedMessageTypeError);
36
20
  }
37
21
  }
38
- exports.AbstractMessageHandler = AbstractMessageHandler;
39
22
  //# sourceMappingURL=abstract-message-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-message-handler.js","sourceRoot":"","sources":["../src/abstract-message-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,kDAAyB;AAEzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,wBAAwB,CAAC,CAAA;AAChC,QAAA,2BAA2B,GAAG,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;AAEhF;;;GAGG;AACH,MAAsB,sBAAsB;IAGnC,OAAO,CAAC,cAAsC;QACnD,IAAI,CAAC,kBAAkB,GAAG,cAAc,CAAA;QACxC,OAAO,cAAc,CAAA;IACvB,CAAC;IAEY,MAAM,CAAC,OAAgB,EAAE,OAA0B;;YAC9D,IAAI,IAAI,CAAC,kBAAkB,EAAE;gBAC3B,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;aACxD;YACD,KAAK,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAA;YACxC,OAAO,OAAO,CAAC,MAAM,CAAC,mCAA2B,CAAC,CAAA;QACpD,CAAC;KAAA;CACF;AAfD,wDAeC"}
1
+ {"version":3,"file":"abstract-message-handler.js","sourceRoot":"","sources":["../src/abstract-message-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,KAAK,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAA;AAC7C,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;AAEhF;;;GAGG;AACH,MAAM,OAAgB,sBAAsB;IACnC,kBAAkB,CAAyB;IAE3C,OAAO,CAAC,cAAsC;QACnD,IAAI,CAAC,kBAAkB,GAAG,cAAc,CAAA;QACxC,OAAO,cAAc,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,OAA0B;QAC9D,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC3B,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;SACxD;QACD,KAAK,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAA;QACxC,OAAO,OAAO,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAA;IACpD,CAAC;CACF"}
package/build/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- export { MessageHandler } from './message-handler';
8
- export { AbstractMessageHandler } from './abstract-message-handler';
9
- export { Message } from './message';
7
+ export { MessageHandler } from './message-handler.js';
8
+ export { AbstractMessageHandler } from './abstract-message-handler.js';
9
+ export { Message } from './message.js';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
package/build/index.js CHANGED
@@ -1,16 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Message = exports.AbstractMessageHandler = exports.MessageHandler = void 0;
4
1
  /**
5
2
  * Provides a {@link @veramo/message-handler#MessageHandler | plugin} for the
6
3
  * {@link @veramo/core#Agent} that implements {@link @veramo/core#IMessageHandler} interface.
7
4
  *
8
5
  * @packageDocumentation
9
6
  */
10
- var message_handler_1 = require("./message-handler");
11
- Object.defineProperty(exports, "MessageHandler", { enumerable: true, get: function () { return message_handler_1.MessageHandler; } });
12
- var abstract_message_handler_1 = require("./abstract-message-handler");
13
- Object.defineProperty(exports, "AbstractMessageHandler", { enumerable: true, get: function () { return abstract_message_handler_1.AbstractMessageHandler; } });
14
- var message_1 = require("./message");
15
- Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return message_1.Message; } });
7
+ export { MessageHandler } from './message-handler.js';
8
+ export { AbstractMessageHandler } from './abstract-message-handler.js';
9
+ export { Message } from './message.js';
16
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,qDAAkD;AAAzC,iHAAA,cAAc,OAAA;AACvB,uEAAmE;AAA1D,kIAAA,sBAAsB,OAAA;AAC/B,qCAAmC;AAA1B,kGAAA,OAAO,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { IDataStore, IAgentPlugin, IAgentContext, IMessageHandler, IHandleMessageArgs, IMessage } from '@veramo/core';
2
- import { AbstractMessageHandler } from './abstract-message-handler';
2
+ import { AbstractMessageHandler } from './abstract-message-handler.js';
3
3
  export declare const EventTypes: {
4
4
  validatedMessage: string;
5
5
  savedMessage: string;
@@ -25,7 +25,364 @@ export declare class MessageHandler implements IAgentPlugin {
25
25
  * @public
26
26
  */
27
27
  readonly methods: IMessageHandler;
28
- readonly schema: any;
28
+ readonly schema: {
29
+ components: {
30
+ schemas: {
31
+ IHandleMessageArgs: {
32
+ type: string;
33
+ properties: {
34
+ raw: {
35
+ type: string;
36
+ description: string;
37
+ };
38
+ metaData: {
39
+ type: string;
40
+ items: {
41
+ $ref: string;
42
+ };
43
+ description: string;
44
+ };
45
+ save: {
46
+ type: string;
47
+ description: string;
48
+ deprecated: string;
49
+ };
50
+ };
51
+ required: string[];
52
+ description: string;
53
+ };
54
+ IMetaData: {
55
+ type: string;
56
+ properties: {
57
+ type: {
58
+ type: string;
59
+ description: string;
60
+ };
61
+ value: {
62
+ type: string;
63
+ description: string;
64
+ };
65
+ };
66
+ required: string[];
67
+ description: string;
68
+ };
69
+ IMessage: {
70
+ type: string;
71
+ properties: {
72
+ id: {
73
+ type: string;
74
+ description: string;
75
+ };
76
+ type: {
77
+ type: string;
78
+ description: string;
79
+ };
80
+ createdAt: {
81
+ type: string;
82
+ description: string;
83
+ };
84
+ expiresAt: {
85
+ type: string;
86
+ description: string;
87
+ };
88
+ threadId: {
89
+ type: string;
90
+ description: string;
91
+ };
92
+ raw: {
93
+ type: string;
94
+ description: string;
95
+ };
96
+ data: {
97
+ anyOf: {
98
+ type: string;
99
+ }[];
100
+ description: string;
101
+ };
102
+ replyTo: {
103
+ type: string;
104
+ items: {
105
+ type: string;
106
+ };
107
+ description: string;
108
+ };
109
+ replyUrl: {
110
+ type: string;
111
+ description: string;
112
+ };
113
+ from: {
114
+ type: string;
115
+ description: string;
116
+ };
117
+ to: {
118
+ type: string;
119
+ description: string;
120
+ };
121
+ metaData: {
122
+ anyOf: ({
123
+ type: string;
124
+ items: {
125
+ $ref: string;
126
+ };
127
+ } | {
128
+ type: string;
129
+ items?: undefined;
130
+ })[];
131
+ description: string;
132
+ };
133
+ credentials: {
134
+ type: string;
135
+ items: {
136
+ $ref: string;
137
+ };
138
+ description: string;
139
+ };
140
+ presentations: {
141
+ type: string;
142
+ items: {
143
+ $ref: string;
144
+ };
145
+ description: string;
146
+ };
147
+ attachments: {
148
+ type: string;
149
+ items: {
150
+ $ref: string;
151
+ };
152
+ description: string;
153
+ };
154
+ };
155
+ required: string[];
156
+ description: string;
157
+ };
158
+ VerifiableCredential: {
159
+ type: string;
160
+ properties: {
161
+ proof: {
162
+ $ref: string;
163
+ };
164
+ issuer: {
165
+ $ref: string;
166
+ };
167
+ credentialSubject: {
168
+ $ref: string;
169
+ };
170
+ type: {
171
+ anyOf: ({
172
+ type: string;
173
+ items: {
174
+ type: string;
175
+ };
176
+ } | {
177
+ type: string;
178
+ items?: undefined;
179
+ })[];
180
+ };
181
+ "@context": {
182
+ anyOf: ({
183
+ type: string;
184
+ items: {
185
+ type: string;
186
+ };
187
+ } | {
188
+ type: string;
189
+ items?: undefined;
190
+ })[];
191
+ };
192
+ issuanceDate: {
193
+ type: string;
194
+ };
195
+ expirationDate: {
196
+ type: string;
197
+ };
198
+ credentialStatus: {
199
+ $ref: string;
200
+ };
201
+ id: {
202
+ type: string;
203
+ };
204
+ };
205
+ required: string[];
206
+ description: string;
207
+ };
208
+ ProofType: {
209
+ type: string;
210
+ properties: {
211
+ type: {
212
+ type: string;
213
+ };
214
+ };
215
+ description: string;
216
+ };
217
+ IssuerType: {
218
+ anyOf: ({
219
+ type: string;
220
+ properties: {
221
+ id: {
222
+ type: string;
223
+ };
224
+ };
225
+ required: string[];
226
+ } | {
227
+ type: string;
228
+ properties?: undefined;
229
+ required?: undefined;
230
+ })[];
231
+ description: string;
232
+ };
233
+ CredentialSubject: {
234
+ type: string;
235
+ properties: {
236
+ id: {
237
+ type: string;
238
+ };
239
+ };
240
+ description: string;
241
+ };
242
+ CredentialStatusReference: {
243
+ type: string;
244
+ properties: {
245
+ id: {
246
+ type: string;
247
+ };
248
+ type: {
249
+ type: string;
250
+ };
251
+ };
252
+ required: string[];
253
+ description: string;
254
+ };
255
+ VerifiablePresentation: {
256
+ type: string;
257
+ properties: {
258
+ proof: {
259
+ $ref: string;
260
+ };
261
+ holder: {
262
+ type: string;
263
+ };
264
+ verifiableCredential: {
265
+ type: string;
266
+ items: {
267
+ $ref: string;
268
+ };
269
+ };
270
+ type: {
271
+ anyOf: ({
272
+ type: string;
273
+ items: {
274
+ type: string;
275
+ };
276
+ } | {
277
+ type: string;
278
+ items?: undefined;
279
+ })[];
280
+ };
281
+ "@context": {
282
+ anyOf: ({
283
+ type: string;
284
+ items: {
285
+ type: string;
286
+ };
287
+ } | {
288
+ type: string;
289
+ items?: undefined;
290
+ })[];
291
+ };
292
+ verifier: {
293
+ type: string;
294
+ items: {
295
+ type: string;
296
+ };
297
+ };
298
+ issuanceDate: {
299
+ type: string;
300
+ };
301
+ expirationDate: {
302
+ type: string;
303
+ };
304
+ id: {
305
+ type: string;
306
+ };
307
+ };
308
+ required: string[];
309
+ description: string;
310
+ };
311
+ W3CVerifiableCredential: {
312
+ anyOf: {
313
+ $ref: string;
314
+ }[];
315
+ description: string;
316
+ };
317
+ CompactJWT: {
318
+ type: string;
319
+ description: string;
320
+ };
321
+ IMessageAttachment: {
322
+ type: string;
323
+ properties: {
324
+ id: {
325
+ type: string;
326
+ };
327
+ description: {
328
+ type: string;
329
+ };
330
+ filename: {
331
+ type: string;
332
+ };
333
+ media_type: {
334
+ type: string;
335
+ };
336
+ format: {
337
+ type: string;
338
+ };
339
+ lastmod_time: {
340
+ type: string;
341
+ };
342
+ byte_count: {
343
+ type: string;
344
+ };
345
+ data: {
346
+ $ref: string;
347
+ };
348
+ };
349
+ required: string[];
350
+ description: string;
351
+ };
352
+ IMessageAttachmentData: {
353
+ type: string;
354
+ properties: {
355
+ jws: {};
356
+ hash: {
357
+ type: string;
358
+ };
359
+ links: {
360
+ type: string;
361
+ items: {
362
+ type: string;
363
+ };
364
+ };
365
+ base64: {
366
+ type: string;
367
+ };
368
+ json: {};
369
+ };
370
+ description: string;
371
+ };
372
+ };
373
+ methods: {
374
+ handleMessage: {
375
+ description: string;
376
+ arguments: {
377
+ $ref: string;
378
+ };
379
+ returnType: {
380
+ $ref: string;
381
+ };
382
+ };
383
+ };
384
+ };
385
+ };
29
386
  private messageHandler?;
30
387
  constructor(options: {
31
388
  messageHandlers: AbstractMessageHandler[];
@@ -1 +1 @@
1
- {"version":3,"file":"message-handler.d.ts","sourceRoot":"","sources":["../src/message-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,kBAAkB,EAGlB,QAAQ,EACT,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAMnE,eAAO,MAAM,UAAU;;;;CAItB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAe,YAAW,YAAY;IACjD;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;IACjC,QAAQ,CAAC,MAAM,MAAyB;IACxC,OAAO,CAAC,cAAc,CAAC,CAAwB;gBAEnC,OAAO,EAAE;QAAE,eAAe,EAAE,sBAAsB,EAAE,CAAA;KAAE;IAmBlE,+DAA+D;IAClD,aAAa,CACxB,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,GACjC,OAAO,CAAC,QAAQ,CAAC;CA2BrB"}
1
+ {"version":3,"file":"message-handler.d.ts","sourceRoot":"","sources":["../src/message-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,kBAAkB,EAElB,QAAQ,EACT,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAMtE,eAAO,MAAM,UAAU;;;;CAItB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAe,YAAW,YAAY;IACjD;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;IACjC,QAAQ,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAyB;IACxC,OAAO,CAAC,cAAc,CAAC,CAAwB;gBAEnC,OAAO,EAAE;QAAE,eAAe,EAAE,sBAAsB,EAAE,CAAA;KAAE;IAmBlE,+DAA+D;IAClD,aAAa,CACxB,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,GACjC,OAAO,CAAC,QAAQ,CAAC;CA2BrB"}
@@ -1,26 +1,12 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.MessageHandler = exports.EventTypes = void 0;
16
- const core_1 = require("@veramo/core");
17
- const message_1 = require("./message");
18
- const debug_1 = __importDefault(require("debug"));
19
- const debug = (0, debug_1.default)('veramo:message-handler');
20
- exports.EventTypes = {
1
+ import { CoreEvents, } from '@veramo/core';
2
+ import schema from '@veramo/core/build/plugin.schema.json' assert { type: 'json' };
3
+ import { Message } from './message.js';
4
+ import Debug from 'debug';
5
+ const debug = Debug('veramo:message-handler');
6
+ export const EventTypes = {
21
7
  validatedMessage: 'validatedMessage',
22
8
  savedMessage: 'savedMessage',
23
- error: core_1.CoreEvents.error,
9
+ error: CoreEvents.error,
24
10
  };
25
11
  /**
26
12
  * A Veramo agent plugin that implements {@link @veramo/core#IMessageHandler | IMessageHandler} methods.
@@ -36,9 +22,15 @@ exports.EventTypes = {
36
22
  *
37
23
  * @public
38
24
  */
39
- class MessageHandler {
25
+ export class MessageHandler {
26
+ /**
27
+ * Plugin methods
28
+ * @public
29
+ */
30
+ methods;
31
+ schema = schema.IMessageHandler;
32
+ messageHandler;
40
33
  constructor(options) {
41
- this.schema = core_1.schema.IMessageHandler;
42
34
  for (const messageHandler of options.messageHandlers) {
43
35
  if (!this.messageHandler) {
44
36
  this.messageHandler = messageHandler;
@@ -57,34 +49,31 @@ class MessageHandler {
57
49
  };
58
50
  }
59
51
  /** {@inheritDoc @veramo/core#IMessageHandler.handleMessage} */
60
- handleMessage(args, context) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const { raw, metaData, save } = args;
63
- debug('%o', { raw, metaData, save });
64
- if (!this.messageHandler) {
65
- return Promise.reject(new Error('Message handler not provided'));
66
- }
67
- try {
68
- const message = yield this.messageHandler.handle(new message_1.Message({ raw, metaData }), context);
69
- if (message.isValid()) {
70
- debug('Emitting event', exports.EventTypes.validatedMessage);
71
- context.agent.emit(exports.EventTypes.validatedMessage, message);
72
- }
73
- debug('Validated message %o', message);
74
- if (save) {
75
- yield context.agent.dataStoreSaveMessage({ message });
76
- debug('Emitting event', exports.EventTypes.savedMessage);
77
- context.agent.emit(exports.EventTypes.savedMessage, message);
78
- }
79
- return message;
52
+ async handleMessage(args, context) {
53
+ const { raw, metaData, save } = args;
54
+ debug('%o', { raw, metaData, save });
55
+ if (!this.messageHandler) {
56
+ return Promise.reject(new Error('Message handler not provided'));
57
+ }
58
+ try {
59
+ const message = await this.messageHandler.handle(new Message({ raw, metaData }), context);
60
+ if (message.isValid()) {
61
+ debug('Emitting event', EventTypes.validatedMessage);
62
+ context.agent.emit(EventTypes.validatedMessage, message);
80
63
  }
81
- catch (error) {
82
- debug('Error', error);
83
- context.agent.emit(exports.EventTypes.error, error);
84
- return Promise.reject(error);
64
+ debug('Validated message %o', message);
65
+ if (save) {
66
+ await context.agent.dataStoreSaveMessage({ message });
67
+ debug('Emitting event', EventTypes.savedMessage);
68
+ context.agent.emit(EventTypes.savedMessage, message);
85
69
  }
86
- });
70
+ return message;
71
+ }
72
+ catch (error) {
73
+ debug('Error', error);
74
+ context.agent.emit(EventTypes.error, error);
75
+ return Promise.reject(error);
76
+ }
87
77
  }
88
78
  }
89
- exports.MessageHandler = MessageHandler;
90
79
  //# sourceMappingURL=message-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-handler.js","sourceRoot":"","sources":["../src/message-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCASqB;AACrB,uCAAmC;AAGnC,kDAAyB;AAEzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,wBAAwB,CAAC,CAAA;AAEhC,QAAA,UAAU,GAAG;IACxB,gBAAgB,EAAE,kBAAkB;IACpC,YAAY,EAAE,cAAc;IAC5B,KAAK,EAAE,iBAAU,CAAC,KAAK;CACxB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,cAAc;IASzB,YAAY,OAAsD;QAHzD,WAAM,GAAG,aAAM,CAAC,eAAe,CAAA;QAItC,KAAK,MAAM,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE;YACpD,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;gBACxB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;aACrC;iBAAM;gBACL,IAAI,WAAW,GAAG,IAAI,CAAC,cAAc,CAAA;gBACrC,OAAO,WAAW,CAAC,kBAAk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,YAAY,CAAC,CAAA;gBAChD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;aACrD;YACD,OAAO,OAAO,CAAA;SACf;QAAC,OAAO,KAAK,EAAE;YACd,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;YACrB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;YAC3C,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;SAC7B;IACH,CAAC;CACF"}
package/build/message.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Message = void 0;
4
1
  /**
5
2
  * A class implementing {@link @veramo/core#IMessage | IMessage}.
6
3
  *
@@ -8,15 +5,32 @@ exports.Message = void 0;
8
5
  *
9
6
  * @public
10
7
  */
11
- class Message {
8
+ export class Message {
12
9
  constructor(data) {
13
- if (data === null || data === void 0 ? void 0 : data.raw) {
10
+ if (data?.raw) {
14
11
  this.raw = data.raw;
15
12
  }
16
- if (data === null || data === void 0 ? void 0 : data.metaData) {
13
+ if (data?.metaData) {
17
14
  this.metaData = data.metaData;
18
15
  }
19
16
  }
17
+ //@ts-ignore
18
+ id;
19
+ createdAt;
20
+ expiresAt;
21
+ threadId;
22
+ //@ts-ignore
23
+ type;
24
+ raw;
25
+ data;
26
+ replyTo;
27
+ replyUrl;
28
+ from;
29
+ to;
30
+ metaData;
31
+ presentations;
32
+ credentials;
33
+ attachments;
20
34
  addMetaData(meta) {
21
35
  if (this.metaData) {
22
36
  this.metaData.push(meta);
@@ -43,5 +57,4 @@ class Message {
43
57
  return true;
44
58
  }
45
59
  }
46
- exports.Message = Message;
47
60
  //# sourceMappingURL=message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message.js","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":";;;AAQA;;;;;;GAMG;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A;IACb,CAAC;CACF"}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.33.6"
8
+ "packageVersion": "7.33.8"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@veramo/message-handler",
3
3
  "description": "Message Handler plugin for Veramo",
4
- "version": "4.2.1-next.6+f2258b61",
4
+ "version": "4.2.1-unstable.9+ba3e5435",
5
5
  "main": "build/index.js",
6
+ "exports": "./build/index.js",
6
7
  "types": "build/index.d.ts",
7
8
  "scripts": {
8
9
  "build": "tsc",
9
- "extract-api": "yarn veramo dev extract-api"
10
+ "extract-api": "node ../cli/bin/veramo.js dev extract-api"
10
11
  },
11
12
  "dependencies": {
12
- "@veramo/core": "^4.2.1-next.6+f2258b61"
13
+ "@veramo/core": "^4.2.1-unstable.9+ba3e5435",
14
+ "debug": "^4.3.4"
13
15
  },
14
16
  "devDependencies": {
17
+ "@types/debug": "4.1.7",
15
18
  "typescript": "4.9.4"
16
19
  },
17
20
  "files": [
@@ -33,5 +36,10 @@
33
36
  ],
34
37
  "license": "Apache-2.0",
35
38
  "keywords": [],
36
- "gitHead": "f2258b61612a3380aa27cb6a82534334b75e5960"
39
+ "type": "module",
40
+ "moduleDirectories": [
41
+ "node_modules",
42
+ "src"
43
+ ],
44
+ "gitHead": "ba3e5435dc7a09599f6c9af311b40d92162e810a"
37
45
  }
@@ -1,6 +1,7 @@
1
1
  import { createAgent, IAgentContext, IMessageHandler } from '@veramo/core'
2
2
  import { MessageHandler } from '..'
3
3
  import { AbstractMessageHandler, Message } from '../../build'
4
+ import { jest } from '@jest/globals'
4
5
 
5
6
  jest.setTimeout(60000)
6
7
 
@@ -1,5 +1,5 @@
1
1
  import { IAgentContext } from '@veramo/core'
2
- import { Message } from './message'
2
+ import { Message } from './message.js'
3
3
  import Debug from 'debug'
4
4
 
5
5
  const debug = Debug('veramo:message-handler')
package/src/index.ts CHANGED
@@ -4,6 +4,6 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- export { MessageHandler } from './message-handler'
8
- export { AbstractMessageHandler } from './abstract-message-handler'
9
- export { Message } from './message'
7
+ export { MessageHandler } from './message-handler.js'
8
+ export { AbstractMessageHandler } from './abstract-message-handler.js'
9
+ export { Message } from './message.js'
@@ -4,12 +4,12 @@ import {
4
4
  IAgentContext,
5
5
  IMessageHandler,
6
6
  IHandleMessageArgs,
7
- schema,
8
7
  CoreEvents,
9
8
  IMessage,
10
9
  } from '@veramo/core'
11
- import { Message } from './message'
12
- import { AbstractMessageHandler } from './abstract-message-handler'
10
+ import schema from '@veramo/core/build/plugin.schema.json' assert { type: 'json' }
11
+ import { Message } from './message.js'
12
+ import { AbstractMessageHandler } from './abstract-message-handler.js'
13
13
 
14
14
  import Debug from 'debug'
15
15