@veramo/message-handler 4.3.1-next.9 → 4.3.1-unstable.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.
@@ -1,5 +1,5 @@
1
1
  import { IAgentContext } from '@veramo/core';
2
- import { Message } from './message.js';
2
+ import { Message } from './message';
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,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
+ {"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,22 +1,39 @@
1
- import Debug from 'debug';
2
- const debug = Debug('veramo:message-handler');
3
- export const unsupportedMessageTypeError = new Error('Unsupported message type');
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');
4
19
  /**
5
20
  * An abstract class for creating {@link @veramo/message-handler#MessageHandler} plugins
6
21
  * @public
7
22
  */
8
- export class AbstractMessageHandler {
9
- nextMessageHandler;
23
+ class AbstractMessageHandler {
10
24
  setNext(messageHandler) {
11
25
  this.nextMessageHandler = messageHandler;
12
26
  return messageHandler;
13
27
  }
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);
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
+ });
20
36
  }
21
37
  }
38
+ exports.AbstractMessageHandler = AbstractMessageHandler;
22
39
  //# 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,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"}
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"}
package/build/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- export { MessageHandler } from './message-handler.js';
8
- export { AbstractMessageHandler } from './abstract-message-handler.js';
9
- export { Message } from './message.js';
7
+ export { MessageHandler } from './message-handler';
8
+ export { AbstractMessageHandler } from './abstract-message-handler';
9
+ export { Message } from './message';
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,sBAAsB,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
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"}
package/build/index.js CHANGED
@@ -1,10 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Message = exports.AbstractMessageHandler = exports.MessageHandler = void 0;
1
4
  /**
2
5
  * Provides a {@link @veramo/message-handler#MessageHandler | plugin} for the
3
6
  * {@link @veramo/core#Agent} that implements {@link @veramo/core#IMessageHandler} interface.
4
7
  *
5
8
  * @packageDocumentation
6
9
  */
7
- export { MessageHandler } from './message-handler.js';
8
- export { AbstractMessageHandler } from './abstract-message-handler.js';
9
- export { Message } from './message.js';
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; } });
10
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"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,5 +1,5 @@
1
1
  import { IDataStore, IAgentPlugin, IAgentContext, IMessageHandler, IHandleMessageArgs, IMessage } from '@veramo/core';
2
- import { AbstractMessageHandler } from './abstract-message-handler.js';
2
+ import { AbstractMessageHandler } from './abstract-message-handler';
3
3
  export declare const EventTypes: {
4
4
  validatedMessage: string;
5
5
  savedMessage: string;
@@ -25,364 +25,7 @@ export declare class MessageHandler implements IAgentPlugin {
25
25
  * @public
26
26
  */
27
27
  readonly methods: IMessageHandler;
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
- };
28
+ readonly schema: any;
386
29
  private messageHandler?;
387
30
  constructor(options: {
388
31
  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,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,YAA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AAE;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,12 +1,26 @@
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 = {
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 = {
7
21
  validatedMessage: 'validatedMessage',
8
22
  savedMessage: 'savedMessage',
9
- error: CoreEvents.error,
23
+ error: core_1.CoreEvents.error,
10
24
  };
11
25
  /**
12
26
  * A Veramo agent plugin that implements {@link @veramo/core#IMessageHandler | IMessageHandler} methods.
@@ -22,15 +36,9 @@ export const EventTypes = {
22
36
  *
23
37
  * @public
24
38
  */
25
- export class MessageHandler {
26
- /**
27
- * Plugin methods
28
- * @public
29
- */
30
- methods;
31
- schema = schema.IMessageHandler;
32
- messageHandler;
39
+ class MessageHandler {
33
40
  constructor(options) {
41
+ this.schema = core_1.schema.IMessageHandler;
34
42
  for (const messageHandler of options.messageHandlers) {
35
43
  if (!this.messageHandler) {
36
44
  this.messageHandler = messageHandler;
@@ -49,31 +57,34 @@ export class MessageHandler {
49
57
  };
50
58
  }
51
59
  /** {@inheritDoc @veramo/core#IMessageHandler.handleMessage} */
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);
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'));
63
66
  }
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);
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;
69
80
  }
70
- return message;
71
- }
72
- catch (error) {
73
- debug('Error', error);
74
- context.agent.emit(EventTypes.error, error);
75
- return Promise.reject(error);
76
- }
81
+ catch (error) {
82
+ debug('Error', error);
83
+ context.agent.emit(exports.EventTypes.error, error);
84
+ return Promise.reject(error);
85
+ }
86
+ });
77
87
  }
78
88
  }
89
+ exports.MessageHandler = MessageHandler;
79
90
  //# sourceMappingURL=message-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-handler.js","sourceRoot":"","sources":["../src/message-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,UAAU,GAEX,MAAM,cAAc,CAAA;AACrB,OAAO,MAAM,MAAM,uCAAuC,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAA;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,KAAK,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAA;AAE7C,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,gBAAgB,EAAE,kBAAkB;IACpC,YAAY,EAAE,cAAc;IAC5B,KAAK,EAAE,UAAU,CAAC,KAAK;CACxB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,cAAc;IACzB;;;OAGG;IACM,OAAO,CAAiB;IACxB,MAAM,GAAG,MAAM,CAAC,eAAe,CAAA;IAChC,cAAc,CAAyB;IAE/C,YAAY,OAAsD;QAChE,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,kBAAkB,KAAK,SAAS,EAAE;oBACnD,WAAW,GAAG,WAAW,CAAC,kBAAkB,CAAA;iBAC7C;gBACD,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;aACpC;SACF;QAED,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa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
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Message = void 0;
1
4
  /**
2
5
  * A class implementing {@link @veramo/core#IMessage | IMessage}.
3
6
  *
@@ -5,32 +8,15 @@
5
8
  *
6
9
  * @public
7
10
  */
8
- export class Message {
11
+ class Message {
9
12
  constructor(data) {
10
- if (data?.raw) {
13
+ if (data === null || data === void 0 ? void 0 : data.raw) {
11
14
  this.raw = data.raw;
12
15
  }
13
- if (data?.metaData) {
16
+ if (data === null || data === void 0 ? void 0 : data.metaData) {
14
17
  this.metaData = data.metaData;
15
18
  }
16
19
  }
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;
34
20
  addMetaData(meta) {
35
21
  if (this.metaData) {
36
22
  this.metaData.push(meta);
@@ -57,4 +43,5 @@ export class Message {
57
43
  return true;
58
44
  }
59
45
  }
46
+ exports.Message = Message;
60
47
  //# sourceMappingURL=message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message.js","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,OAAO,OAAO;IAClB,YAAY,IAA8C;QACxD,IAAI,IAAI,EAAE,GAAG,EAAE;YACb,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;SACpB;QACD,IAAI,IAAI,EAAE,QAAQ,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;SAC9B;IACH,CAAC;IAED,YAAY;IACZ,EAAE,CAAQ;IAEV,SAAS,CAAS;IAElB,SAAS,CAAS;IAElB,QAAQ,CAAS;IAEjB,YAAY;IACZ,IAAI,CAAQ;IAEZ,GAAG,CAAS;IAEZ,IAAI,CAAM;IAEV,OAAO,CA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Q,GAAG,IAAI,CAAC,QAAQ,CAAA;SAC9B;IACH,CAAC;IAgCD,WAAW,CAAC,IAAe;QACzB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACzB;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,CAAA;SACvB;IACH,CAAC;IAED,eAAe;QACb,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3D,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;SAC/C;aAAM;YACL,OAAO,IAAI,CAAA;SACZ;IACH,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,EAAE;YAC1C,OAAO,KAAK,CAAA;SACb;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,EAAE,EAAE;YACrD,OAAO,KAAK,CAAA;SACb;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAjED,0BAiEC"}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.33.8"
8
+ "packageVersion": "7.33.7"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@veramo/message-handler",
3
3
  "description": "Message Handler plugin for Veramo",
4
- "version": "4.3.1-next.9+02873401",
4
+ "version": "4.3.1-unstable.0+7e89dddf",
5
5
  "main": "build/index.js",
6
- "exports": "./build/index.js",
7
6
  "types": "build/index.d.ts",
8
7
  "scripts": {
9
8
  "build": "tsc",
10
9
  "extract-api": "node ../cli/bin/veramo.js dev extract-api"
11
10
  },
12
11
  "dependencies": {
13
- "@veramo/core": "^4.3.1-next.9+02873401",
12
+ "@veramo/core": "^4.3.1-unstable.0+7e89dddf",
14
13
  "debug": "^4.3.4"
15
14
  },
16
15
  "devDependencies": {
@@ -36,10 +35,5 @@
36
35
  ],
37
36
  "license": "Apache-2.0",
38
37
  "keywords": [],
39
- "type": "module",
40
- "moduleDirectories": [
41
- "node_modules",
42
- "src"
43
- ],
44
- "gitHead": "02873401508a8a7d8c999bc12dc1d107a4a5202f"
38
+ "gitHead": "7e89dddf1043fe91b7b84ad2b2b276fdef33884d"
45
39
  }
@@ -1,7 +1,6 @@
1
- import { createAgent, IAgentContext, IMessageHandler } from '@veramo/core'
1
+ import { createAgent, IAgentContext, IMessageHandler } from '../../../core/src'
2
2
  import { MessageHandler } from '..'
3
3
  import { AbstractMessageHandler, Message } from '../../build'
4
- import { jest } from '@jest/globals'
5
4
 
6
5
  jest.setTimeout(60000)
7
6
 
@@ -1,5 +1,5 @@
1
1
  import { IAgentContext } from '@veramo/core'
2
- import { Message } from './message.js'
2
+ import { Message } from './message'
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.js'
8
- export { AbstractMessageHandler } from './abstract-message-handler.js'
9
- export { Message } from './message.js'
7
+ export { MessageHandler } from './message-handler'
8
+ export { AbstractMessageHandler } from './abstract-message-handler'
9
+ export { Message } from './message'
@@ -4,12 +4,12 @@ import {
4
4
  IAgentContext,
5
5
  IMessageHandler,
6
6
  IHandleMessageArgs,
7
+ schema,
7
8
  CoreEvents,
8
9
  IMessage,
9
10
  } from '@veramo/core'
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'
11
+ import { Message } from './message'
12
+ import { AbstractMessageHandler } from './abstract-message-handler'
13
13
 
14
14
  import Debug from 'debug'
15
15