@verana-labs/vs-agent-nestjs-client 1.6.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 +201 -0
- package/README.md +222 -0
- package/build/app.module.d.ts +5 -0
- package/build/app.module.js +61 -0
- package/build/app.module.js.map +1 -0
- package/build/connections/connection.controller.d.ts +10 -0
- package/build/connections/connection.controller.js +65 -0
- package/build/connections/connection.controller.js.map +1 -0
- package/build/connections/connection.entity.d.ts +10 -0
- package/build/connections/connection.entity.js +49 -0
- package/build/connections/connection.entity.js.map +1 -0
- package/build/connections/connection.module.d.ts +5 -0
- package/build/connections/connection.module.js +44 -0
- package/build/connections/connection.module.js.map +1 -0
- package/build/connections/connection.repository.d.ts +27 -0
- package/build/connections/connection.repository.js +87 -0
- package/build/connections/connection.repository.js.map +1 -0
- package/build/connections/connection.service.d.ts +23 -0
- package/build/connections/connection.service.js +86 -0
- package/build/connections/connection.service.js.map +1 -0
- package/build/connections/index.d.ts +5 -0
- package/build/connections/index.js +22 -0
- package/build/connections/index.js.map +1 -0
- package/build/credentials/credential.entity.d.ts +13 -0
- package/build/credentials/credential.entity.js +59 -0
- package/build/credentials/credential.entity.js.map +1 -0
- package/build/credentials/credential.module.d.ts +5 -0
- package/build/credentials/credential.module.js +34 -0
- package/build/credentials/credential.module.js.map +1 -0
- package/build/credentials/credential.service.d.ts +100 -0
- package/build/credentials/credential.service.js +290 -0
- package/build/credentials/credential.service.js.map +1 -0
- package/build/credentials/index.d.ts +4 -0
- package/build/credentials/index.js +21 -0
- package/build/credentials/index.js.map +1 -0
- package/build/credentials/revocation-registry.entity.d.ts +9 -0
- package/build/credentials/revocation-registry.entity.js +48 -0
- package/build/credentials/revocation-registry.entity.js.map +1 -0
- package/build/index.d.ts +9 -0
- package/build/index.js +26 -0
- package/build/index.js.map +1 -0
- package/build/interfaces.d.ts +32 -0
- package/build/interfaces.js +3 -0
- package/build/interfaces.js.map +1 -0
- package/build/jms/index.d.ts +2 -0
- package/build/jms/index.js +19 -0
- package/build/jms/index.js.map +1 -0
- package/build/jms/stats-producer.service.d.ts +41 -0
- package/build/jms/stats-producer.service.js +145 -0
- package/build/jms/stats-producer.service.js.map +1 -0
- package/build/jms/stats.module.d.ts +5 -0
- package/build/jms/stats.module.js +34 -0
- package/build/jms/stats.module.js.map +1 -0
- package/build/messages/index.d.ts +3 -0
- package/build/messages/index.js +20 -0
- package/build/messages/index.js.map +1 -0
- package/build/messages/message.controller.d.ts +13 -0
- package/build/messages/message.controller.js +95 -0
- package/build/messages/message.controller.js.map +1 -0
- package/build/messages/message.module.d.ts +5 -0
- package/build/messages/message.module.js +41 -0
- package/build/messages/message.module.js.map +1 -0
- package/build/messages/message.service.d.ts +19 -0
- package/build/messages/message.service.js +103 -0
- package/build/messages/message.service.js.map +1 -0
- package/build/types.d.ts +65 -0
- package/build/types.js +11 -0
- package/build/types.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var StatProducerService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.StatProducerService = void 0;
|
|
17
|
+
// stats.service.ts
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
20
|
+
const rhea_1 = require("rhea");
|
|
21
|
+
let StatProducerService = StatProducerService_1 = class StatProducerService {
|
|
22
|
+
/**
|
|
23
|
+
* Initializes the StatProducerService with default settings optimized for a local development environment.
|
|
24
|
+
* By default, it connects to a JMS broker running on `localhost` with predefined credentials.
|
|
25
|
+
*
|
|
26
|
+
* If custom options are provided through `GLOBAL_MODULE_OPTIONS`, they will override the defaults.
|
|
27
|
+
*
|
|
28
|
+
* @param options - Configuration options for the JMS connection.
|
|
29
|
+
*/
|
|
30
|
+
constructor(options) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
32
|
+
this.options = options;
|
|
33
|
+
this.logger = new common_1.Logger(StatProducerService_1.name);
|
|
34
|
+
this.connection = null;
|
|
35
|
+
this.sender = null;
|
|
36
|
+
this.container = (0, rhea_1.create_container)();
|
|
37
|
+
this.config = {
|
|
38
|
+
host: ((_a = options.statOptions) === null || _a === void 0 ? void 0 : _a.host) || 'localhost',
|
|
39
|
+
port: ((_b = options.statOptions) === null || _b === void 0 ? void 0 : _b.port) || 61616,
|
|
40
|
+
queue: ((_c = options.statOptions) === null || _c === void 0 ? void 0 : _c.queue) || 'stats-queue',
|
|
41
|
+
username: ((_d = options.statOptions) === null || _d === void 0 ? void 0 : _d.username) || 'quarkus',
|
|
42
|
+
password: ((_e = options.statOptions) === null || _e === void 0 ? void 0 : _e.password) || 'quarkus',
|
|
43
|
+
reconnectLimit: ((_f = options.statOptions) === null || _f === void 0 ? void 0 : _f.reconnectLimit) || 10,
|
|
44
|
+
threads: ((_g = options.statOptions) === null || _g === void 0 ? void 0 : _g.threads) || 1,
|
|
45
|
+
delay: ((_h = options.statOptions) === null || _h === void 0 ? void 0 : _h.delay) || 1000,
|
|
46
|
+
};
|
|
47
|
+
this.logger.log('StatProducerService instantiated');
|
|
48
|
+
}
|
|
49
|
+
async onModuleInit() {
|
|
50
|
+
this.logger.log(`Initializing StatProducer with queue: ${this.config.queue}`);
|
|
51
|
+
await this.connect();
|
|
52
|
+
}
|
|
53
|
+
async onModuleDestroy() {
|
|
54
|
+
await this.disconnect();
|
|
55
|
+
}
|
|
56
|
+
async connect() {
|
|
57
|
+
try {
|
|
58
|
+
this.connection = this.container.connect({
|
|
59
|
+
host: this.config.host,
|
|
60
|
+
port: this.config.port,
|
|
61
|
+
username: this.config.username,
|
|
62
|
+
password: this.config.password,
|
|
63
|
+
reconnect: true,
|
|
64
|
+
reconnect_limit: this.config.reconnectLimit,
|
|
65
|
+
});
|
|
66
|
+
this.sender = this.connection.open_sender(this.config.queue);
|
|
67
|
+
this.sender.on('accepted', () => {
|
|
68
|
+
this.logger.debug('Message accepted');
|
|
69
|
+
});
|
|
70
|
+
this.sender.on('rejected', context => {
|
|
71
|
+
this.logger.error(`Message rejected: ${context.error}`);
|
|
72
|
+
});
|
|
73
|
+
this.logger.log('Successfully connected to ActiveMQ');
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
this.logger.error(`Failed to connect: ${error.message}`);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async disconnect() {
|
|
81
|
+
try {
|
|
82
|
+
if (this.sender) {
|
|
83
|
+
await this.sender.close();
|
|
84
|
+
}
|
|
85
|
+
if (this.connection) {
|
|
86
|
+
await this.connection.close();
|
|
87
|
+
}
|
|
88
|
+
this.logger.log('Successfully disconnected from ActiveMQ');
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.logger.error(`Error disconnecting: ${error.message}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Sends a message of type `JMSTextMessage` as defined by the IBM MQ documentation:
|
|
96
|
+
* https://www.ibm.com/docs/en/ibm-mq/9.4?topic=messaging-jmstextmessage.
|
|
97
|
+
*
|
|
98
|
+
* The method spools statistical events to a messaging system. If the sender
|
|
99
|
+
* is not initialized, it attempts to reconnect. Each message contains the event
|
|
100
|
+
* details serialized as a JSON string and is sent to the configured messaging queue.
|
|
101
|
+
*
|
|
102
|
+
* @param statClass - A string or array of strings representing the class of the statistic(s).
|
|
103
|
+
* @param entityId - A unique identifier for the entity associated with the statistics.
|
|
104
|
+
* @param statEnums - An array of statistical enums to send.
|
|
105
|
+
* @param ts - The timestamp for the event (defaults to the current date and time).
|
|
106
|
+
* @param increment - The increment value for the statistic (defaults to 1).
|
|
107
|
+
* @throws If the sender cannot be initialized or if sending a message fails.
|
|
108
|
+
*/
|
|
109
|
+
async spool(statClass, entityId, statEnums, ts = new Date(), increment = 1) {
|
|
110
|
+
// Check if the sender is initialized; if not, attempt to reconnect
|
|
111
|
+
if (!this.sender) {
|
|
112
|
+
this.logger.error('Sender is not initialized. Attempting to reconnect...');
|
|
113
|
+
await this.connect();
|
|
114
|
+
if (!this.sender) {
|
|
115
|
+
throw new Error('Failed to initialize sender after reconnection attempt');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const statClasses = Array.isArray(statClass) ? statClass : [statClass];
|
|
119
|
+
// Iterate over each stat class and send a message for it
|
|
120
|
+
for (const currentStatClass of statClasses) {
|
|
121
|
+
const event = new vs_agent_model_1.StatEvent(entityId, statEnums, increment, ts, currentStatClass);
|
|
122
|
+
try {
|
|
123
|
+
const msg = {
|
|
124
|
+
body: JSON.stringify(event),
|
|
125
|
+
};
|
|
126
|
+
this.sender.send(msg);
|
|
127
|
+
this.logger.debug(`Sending message: ${msg.body}`);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
this.logger.error(`Failed to send message: ${error.message}`);
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async spoolSingle(statClass, entityId, statEnum, ts = new Date(), increment = 1) {
|
|
136
|
+
await this.spool(statClass, entityId, [statEnum], ts, increment);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
exports.StatProducerService = StatProducerService;
|
|
140
|
+
exports.StatProducerService = StatProducerService = StatProducerService_1 = __decorate([
|
|
141
|
+
(0, common_1.Injectable)(),
|
|
142
|
+
__param(0, (0, common_1.Inject)('GLOBAL_MODULE_OPTIONS')),
|
|
143
|
+
__metadata("design:paramtypes", [Object])
|
|
144
|
+
], StatProducerService);
|
|
145
|
+
//# sourceMappingURL=stats-producer.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats-producer.service.js","sourceRoot":"","sources":["../../src/jms/stats-producer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,2CAA0F;AAC1F,gEAAiE;AACjE,+BAAsE;AAK/D,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAiB9B;;;;;;;OAOG;IACH,YAA6C,OAAiC;;QAAzB,YAAO,GAAP,OAAO,CAAkB;QAxB7D,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAA;QACtD,eAAU,GAAsB,IAAI,CAAA;QACpC,WAAM,GAAkB,IAAI,CAAA;QAuBlC,IAAI,CAAC,SAAS,GAAG,IAAA,uBAAgB,GAAE,CAAA;QACnC,IAAI,CAAC,MAAM,GAAG;YACZ,IAAI,EAAE,CAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,KAAI,WAAW;YAC9C,IAAI,EAAE,CAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,KAAI,KAAK;YACxC,KAAK,EAAE,CAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,KAAK,KAAI,aAAa;YAClD,QAAQ,EAAE,CAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,QAAQ,KAAI,SAAS;YACpD,QAAQ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A,IAAA,eAAM,EAAC,uBAAuB,CAAC,CAAA;;GAzBjC,mBAAmB,CAuJ/B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var StatEventModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.StatEventModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const stats_producer_service_1 = require("./stats-producer.service");
|
|
13
|
+
let StatEventModule = StatEventModule_1 = class StatEventModule {
|
|
14
|
+
static forRoot(options) {
|
|
15
|
+
return {
|
|
16
|
+
module: StatEventModule_1,
|
|
17
|
+
imports: options.imports,
|
|
18
|
+
controllers: [],
|
|
19
|
+
providers: [
|
|
20
|
+
stats_producer_service_1.StatProducerService,
|
|
21
|
+
{
|
|
22
|
+
provide: 'GLOBAL_MODULE_OPTIONS',
|
|
23
|
+
useValue: options,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
exports: [stats_producer_service_1.StatProducerService],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.StatEventModule = StatEventModule;
|
|
31
|
+
exports.StatEventModule = StatEventModule = StatEventModule_1 = __decorate([
|
|
32
|
+
(0, common_1.Module)({})
|
|
33
|
+
], StatEventModule);
|
|
34
|
+
//# sourceMappingURL=stats.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.module.js","sourceRoot":"","sources":["../../src/jms/stats.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsD;AAItD,qEAA8D;AAGvD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAC1B,MAAM,CAAC,OAAO,CAAC,OAAyB;QACtC,OAAO;YACL,MAAM,EAAE,iBAAe;YACvB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,WAAW,EAAE,EAAE;YACf,SAAS,EAAE;gBACT,4CAAmB;gBACnB;oBACE,OAAO,EAAE,uBAAuB;oBAChC,QAAQ,EAAE,OAAO;iBAClB;aACF;YACD,OAAO,EAAE,CAAC,4CAAmB,CAAC;SAC/B,CAAA;IACH,CAAC;CACF,CAAA;AAhBY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,eAAe,CAgB3B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./message.controller"), exports);
|
|
18
|
+
__exportStar(require("./message.module"), exports);
|
|
19
|
+
__exportStar(require("./message.service"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC;AACpC,mDAAgC;AAChC,oDAAiC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MessageReceived, MessageStateUpdated } from '@verana-labs/vs-agent-model';
|
|
2
|
+
import { MessageEventService } from './message.service';
|
|
3
|
+
export declare class MessageEventController {
|
|
4
|
+
private readonly message;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(message: MessageEventService);
|
|
7
|
+
received(body: MessageReceived): Promise<{
|
|
8
|
+
message: string;
|
|
9
|
+
}>;
|
|
10
|
+
updated(body: MessageStateUpdated): Promise<{
|
|
11
|
+
message: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var MessageEventController_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.MessageEventController = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
19
|
+
const vs_agent_client_1 = require("@verana-labs/vs-agent-client");
|
|
20
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
21
|
+
const message_service_1 = require("./message.service");
|
|
22
|
+
let MessageEventController = MessageEventController_1 = class MessageEventController {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
this.message = message;
|
|
25
|
+
this.logger = new common_1.Logger(MessageEventController_1.name);
|
|
26
|
+
}
|
|
27
|
+
async received(body) {
|
|
28
|
+
try {
|
|
29
|
+
this.logger.log(`messageReceived event: ${JSON.stringify(body)}`);
|
|
30
|
+
await this.message.received(body);
|
|
31
|
+
return { message: 'Message received updated successfully' };
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
vs_agent_client_1.HttpUtils.handleException(this.logger, error, 'Failed to received message state');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async updated(body) {
|
|
38
|
+
try {
|
|
39
|
+
this.logger.log(`messageStateUpdated event: ${JSON.stringify(body)}`);
|
|
40
|
+
await this.message.updated();
|
|
41
|
+
return { message: 'Message state updated successfully' };
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
vs_agent_client_1.HttpUtils.handleException(this.logger, error, 'Failed to update message state');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.MessageEventController = MessageEventController;
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, common_1.Post)(`/${vs_agent_model_1.EventType.MessageReceived}`),
|
|
51
|
+
(0, swagger_1.ApiOperation)({
|
|
52
|
+
summary: 'Handle the MessageReceived event',
|
|
53
|
+
description: 'Processes the MessageReceived event and updates the message state.',
|
|
54
|
+
}),
|
|
55
|
+
(0, swagger_1.ApiResponse)({
|
|
56
|
+
status: common_1.HttpStatus.OK,
|
|
57
|
+
description: 'Message received updated successfully.',
|
|
58
|
+
schema: {
|
|
59
|
+
example: { message: 'Message received updated successfully' },
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.BAD_REQUEST, description: 'Invalid input data.' }),
|
|
63
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.INTERNAL_SERVER_ERROR, description: 'Internal server error.' }),
|
|
64
|
+
__param(0, (0, common_1.Body)()),
|
|
65
|
+
__metadata("design:type", Function),
|
|
66
|
+
__metadata("design:paramtypes", [vs_agent_model_1.MessageReceived]),
|
|
67
|
+
__metadata("design:returntype", Promise)
|
|
68
|
+
], MessageEventController.prototype, "received", null);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, common_1.Post)(`/${vs_agent_model_1.EventType.MessageStateUpdated}`),
|
|
71
|
+
(0, swagger_1.ApiOperation)({
|
|
72
|
+
summary: 'Handle the MessageStateUpdated event',
|
|
73
|
+
description: 'Processes the MessageStateUpdated event and updates the message state.',
|
|
74
|
+
}),
|
|
75
|
+
(0, swagger_1.ApiResponse)({
|
|
76
|
+
status: common_1.HttpStatus.OK,
|
|
77
|
+
description: 'Message state updated successfully.',
|
|
78
|
+
schema: {
|
|
79
|
+
example: { message: 'Message state updated successfully' },
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.BAD_REQUEST, description: 'Invalid input data.' }),
|
|
83
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.INTERNAL_SERVER_ERROR, description: 'Internal server error.' }),
|
|
84
|
+
__param(0, (0, common_1.Body)()),
|
|
85
|
+
__metadata("design:type", Function),
|
|
86
|
+
__metadata("design:paramtypes", [vs_agent_model_1.MessageStateUpdated]),
|
|
87
|
+
__metadata("design:returntype", Promise)
|
|
88
|
+
], MessageEventController.prototype, "updated", null);
|
|
89
|
+
exports.MessageEventController = MessageEventController = MessageEventController_1 = __decorate([
|
|
90
|
+
(0, swagger_1.ApiTags)('Message Event'),
|
|
91
|
+
(0, common_1.Controller)(),
|
|
92
|
+
__param(0, (0, common_1.Inject)(message_service_1.MessageEventService)),
|
|
93
|
+
__metadata("design:paramtypes", [message_service_1.MessageEventService])
|
|
94
|
+
], MessageEventController);
|
|
95
|
+
//# sourceMappingURL=message.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.controller.js","sourceRoot":"","sources":["../../src/messages/message.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,6CAAoE;AACpE,kEAAwD;AACxD,gEAA6F;AAE7F,uDAAuD;AAIhD,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAGjC,YAAyC,OAA6C;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAFrE,WAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAA;IAEwB,CAAC;IAgBpF,AAAN,KAAK,CAAC,QAAQ,CAAS,IAAqB;QAC1C,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAEjE,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YACjC,OAAO,EAAE,OAAO,EAAE,uCAAuC,EAAE,CAAA;QAC7D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,2BAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,kCAAkC,CAAC,CAAA;QACnF,CAAC;IACH,CAAC;IAgBK,AAAN,KAAK,CAAC,OAAO,CAAS,IAAyB;QAC7C,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CA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,EAAE,OAAO,EAAE,oCAAoC,EAAE;SAC3D;KACF,CAAC;IACD,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,mBAAU,CAAC,WAAW,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACnF,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,mBAAU,CAAC,qBAAqB,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;IAClF,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,oCAAmB;;qDAS9C;iCArDU,sBAAsB;IAFlC,IAAA,iBAAO,EAAC,eAAe,CAAC;IACxB,IAAA,mBAAU,GAAE;IAIE,WAAA,IAAA,eAAM,EAAC,qCAAmB,CAAC,CAAA;qCAA2B,qCAAmB;GAH3E,sBAAsB,CAsDlC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var MessageEventModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MessageEventModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const message_controller_1 = require("./message.controller");
|
|
13
|
+
const message_service_1 = require("./message.service");
|
|
14
|
+
let MessageEventModule = MessageEventModule_1 = class MessageEventModule {
|
|
15
|
+
static forRoot(options) {
|
|
16
|
+
if (!options.eventHandler) {
|
|
17
|
+
throw new Error('Event handler is required but not provided.');
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
module: MessageEventModule_1,
|
|
21
|
+
imports: options.imports,
|
|
22
|
+
controllers: [message_controller_1.MessageEventController],
|
|
23
|
+
providers: [
|
|
24
|
+
message_service_1.MessageEventService,
|
|
25
|
+
{
|
|
26
|
+
provide: 'GLOBAL_MODULE_OPTIONS',
|
|
27
|
+
useValue: options,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
provide: 'MESSAGE_EVENT',
|
|
31
|
+
useClass: options.eventHandler,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.MessageEventModule = MessageEventModule;
|
|
38
|
+
exports.MessageEventModule = MessageEventModule = MessageEventModule_1 = __decorate([
|
|
39
|
+
(0, common_1.Module)({})
|
|
40
|
+
], MessageEventModule);
|
|
41
|
+
//# sourceMappingURL=message.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.module.js","sourceRoot":"","sources":["../../src/messages/message.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsD;AAItD,6DAA6D;AAC7D,uDAAuD;AAGhD,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAC7B,MAAM,CAAC,OAAO,CAAC,OAA4B;QACzC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;QAChE,CAAC;QACD,OAAO;YACL,MAAM,EAAE,oBAAkB;YAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,WAAW,EAAE,CAAC,2CAAsB,CAAC;YACrC,SAAS,EAAE;gBACT,qCAAmB;gBACnB;oBACE,OAAO,EAAE,uBAAuB;oBAChC,QAAQ,EAAE,OAAO;iBAClB;gBACD;oBACE,OAAO,EAAE,eAAe;oBACxB,QAAQ,EAAE,OAAO,CAAC,YAAY;iBAC/B;aACF;SACF,CAAA;IACH,CAAC;CACF,CAAA;AAtBY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,kBAAkB,CAsB9B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MessageReceived } from '@verana-labs/vs-agent-model';
|
|
2
|
+
import { ConnectionsEventService, ConnectionsRepository } from '../connections';
|
|
3
|
+
import { CredentialService } from '../credentials';
|
|
4
|
+
import { EventHandler } from '../interfaces';
|
|
5
|
+
import { MessageEventOptions } from '../types';
|
|
6
|
+
export declare class MessageEventService {
|
|
7
|
+
private options;
|
|
8
|
+
private eventHandler?;
|
|
9
|
+
private credentialService?;
|
|
10
|
+
private connectionRepository?;
|
|
11
|
+
private connectionsEventService?;
|
|
12
|
+
private readonly logger;
|
|
13
|
+
private readonly url;
|
|
14
|
+
private readonly version;
|
|
15
|
+
private readonly apiClient;
|
|
16
|
+
constructor(options: MessageEventOptions, eventHandler?: EventHandler | undefined, credentialService?: CredentialService | undefined, connectionRepository?: ConnectionsRepository | undefined, connectionsEventService?: ConnectionsEventService | undefined);
|
|
17
|
+
received(event: MessageReceived): Promise<void>;
|
|
18
|
+
updated(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var MessageEventService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.MessageEventService = void 0;
|
|
17
|
+
const credo_ts_didcomm_receipts_1 = require("@2060.io/credo-ts-didcomm-receipts");
|
|
18
|
+
const core_1 = require("@credo-ts/core");
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
const vs_agent_client_1 = require("@verana-labs/vs-agent-client");
|
|
21
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
22
|
+
const connections_1 = require("../connections");
|
|
23
|
+
const credentials_1 = require("../credentials");
|
|
24
|
+
let MessageEventService = MessageEventService_1 = class MessageEventService {
|
|
25
|
+
constructor(options, eventHandler, credentialService, connectionRepository, connectionsEventService) {
|
|
26
|
+
var _a;
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.eventHandler = eventHandler;
|
|
29
|
+
this.credentialService = credentialService;
|
|
30
|
+
this.connectionRepository = connectionRepository;
|
|
31
|
+
this.connectionsEventService = connectionsEventService;
|
|
32
|
+
this.logger = new common_1.Logger(MessageEventService_1.name);
|
|
33
|
+
if (!options.url)
|
|
34
|
+
throw new Error(`For this module to be used the value url must be added`);
|
|
35
|
+
this.url = options.url;
|
|
36
|
+
this.version = (_a = options.version) !== null && _a !== void 0 ? _a : vs_agent_client_1.ApiVersion.V1;
|
|
37
|
+
if (!credentialService)
|
|
38
|
+
this.logger.warn(`To handle credential events and their revocation, make sure to initialize the CredentialService.`);
|
|
39
|
+
this.apiClient = new vs_agent_client_1.ApiClient(this.url, this.version);
|
|
40
|
+
this.logger.debug(`Initialized with url: ${this.url}, version: ${this.version}`);
|
|
41
|
+
}
|
|
42
|
+
async received(event) {
|
|
43
|
+
var _a;
|
|
44
|
+
const message = event.message;
|
|
45
|
+
const body = new vs_agent_model_1.ReceiptsMessage({
|
|
46
|
+
connectionId: message.connectionId,
|
|
47
|
+
receipts: [
|
|
48
|
+
{
|
|
49
|
+
messageId: message.id,
|
|
50
|
+
state: credo_ts_didcomm_receipts_1.MessageState.Viewed,
|
|
51
|
+
timestamp: new Date(),
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
});
|
|
55
|
+
this.logger.debug(`messageReceived: sent receipts: ${JSON.stringify(body)}`);
|
|
56
|
+
await this.apiClient.messages.send(body);
|
|
57
|
+
if (this.eventHandler) {
|
|
58
|
+
if (message.type === vs_agent_model_1.CredentialReceptionMessage.type) {
|
|
59
|
+
try {
|
|
60
|
+
const msg = core_1.JsonTransformer.fromJSON(message, vs_agent_model_1.CredentialReceptionMessage);
|
|
61
|
+
const isCredentialDone = msg.state === core_1.CredentialState.Done;
|
|
62
|
+
if (this.credentialService) {
|
|
63
|
+
if (!msg.threadId)
|
|
64
|
+
throw new Error('threadId is required for credential');
|
|
65
|
+
if (isCredentialDone)
|
|
66
|
+
await this.credentialService.handleAcceptance(msg.threadId);
|
|
67
|
+
else
|
|
68
|
+
await this.credentialService.handleRejection(msg.threadId);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
this.logger.error(`Cannot create the registry: ${error}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (this.connectionRepository &&
|
|
76
|
+
this.connectionsEventService &&
|
|
77
|
+
message.type === vs_agent_model_1.ProfileMessage.type) {
|
|
78
|
+
const msg = core_1.JsonTransformer.fromJSON(message, vs_agent_model_1.ProfileMessage);
|
|
79
|
+
await this.connectionRepository.updateUserProfile(msg.connectionId, Object.assign({}, msg));
|
|
80
|
+
await ((_a = this.connectionsEventService) === null || _a === void 0 ? void 0 : _a.handleNewConnection(msg.connectionId));
|
|
81
|
+
}
|
|
82
|
+
await this.eventHandler.inputMessage(message);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async updated() { }
|
|
86
|
+
};
|
|
87
|
+
exports.MessageEventService = MessageEventService;
|
|
88
|
+
exports.MessageEventService = MessageEventService = MessageEventService_1 = __decorate([
|
|
89
|
+
(0, common_1.Injectable)(),
|
|
90
|
+
__param(0, (0, common_1.Inject)('GLOBAL_MODULE_OPTIONS')),
|
|
91
|
+
__param(1, (0, common_1.Optional)()),
|
|
92
|
+
__param(1, (0, common_1.Inject)('MESSAGE_EVENT')),
|
|
93
|
+
__param(2, (0, common_1.Optional)()),
|
|
94
|
+
__param(2, (0, common_1.Inject)(credentials_1.CredentialService)),
|
|
95
|
+
__param(3, (0, common_1.Optional)()),
|
|
96
|
+
__param(3, (0, common_1.Inject)(connections_1.ConnectionsRepository)),
|
|
97
|
+
__param(4, (0, common_1.Optional)()),
|
|
98
|
+
__param(4, (0, common_1.Inject)(connections_1.ConnectionsEventService)),
|
|
99
|
+
__metadata("design:paramtypes", [Object, Object, credentials_1.CredentialService,
|
|
100
|
+
connections_1.ConnectionsRepository,
|
|
101
|
+
connections_1.ConnectionsEventService])
|
|
102
|
+
], MessageEventService);
|
|
103
|
+
//# sourceMappingURL=message.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.service.js","sourceRoot":"","sources":["../../src/messages/message.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kFAAiE;AACjE,yCAAiE;AACjE,2CAAqE;AACrE,kEAAoE;AACpE,gEAKoC;AAEpC,gDAA+E;AAC/E,gDAAkD;AAK3C,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAM9B,YACmC,OAAoC,EAChC,YAAmC,EACjC,iBAA6C,EACzC,oBAAoD,EAClD,uBAAyD;;QAJ7D,YAAO,GAAP,OAAO,CAAqB;QACxB,iBAAY,GAAZ,YAAY,CAAe;QACzB,sBAAiB,GAAjB,iBAAiB,CAAoB;QACjC,yBAAoB,GAApB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AAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO,KAAmB,CAAC;CAClC,CAAA;AAvEY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAQR,WAAA,IAAA,eAAM,EAAC,uBAAuB,CAAC,CAAA;IAC/B,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;IACnC,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,+BAAiB,CAAC,CAAA;IACrC,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,mCAAqB,CAAC,CAAA;IACzC,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,qCAAuB,CAAC,CAAA;qDAFuB,+BAAiB;QACV,mCAAqB;QAChB,qCAAuB;GAX7F,mBAAmB,CAuE/B"}
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { DynamicModule, ForwardReference, Type } from '@nestjs/common';
|
|
2
|
+
import { ApiVersion } from '@verana-labs/vs-agent-client';
|
|
3
|
+
import { ProfileMessageOptions } from '@verana-labs/vs-agent-model';
|
|
4
|
+
import { EventHandler } from './interfaces';
|
|
5
|
+
export interface MessageEventOptions {
|
|
6
|
+
eventHandler?: Type<EventHandler>;
|
|
7
|
+
imports?: (DynamicModule | Type<any> | Promise<DynamicModule> | ForwardReference<any>)[];
|
|
8
|
+
url?: string;
|
|
9
|
+
version?: ApiVersion;
|
|
10
|
+
}
|
|
11
|
+
export type UserProfile = Omit<ProfileMessageOptions, 'id' | 'connectionId'>;
|
|
12
|
+
export interface ConnectionEventOptions {
|
|
13
|
+
eventHandler?: Type<EventHandler>;
|
|
14
|
+
imports?: (DynamicModule | Type<any> | Promise<DynamicModule> | ForwardReference<any>)[];
|
|
15
|
+
useMessages?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface StatEventOptions {
|
|
18
|
+
imports?: (DynamicModule | Type<any> | Promise<DynamicModule> | ForwardReference<any>)[];
|
|
19
|
+
statOptions?: {
|
|
20
|
+
host?: string;
|
|
21
|
+
port?: number;
|
|
22
|
+
queue?: string;
|
|
23
|
+
username?: string;
|
|
24
|
+
password?: string;
|
|
25
|
+
reconnectLimit?: number;
|
|
26
|
+
threads?: number;
|
|
27
|
+
delay?: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface CredentialOptions {
|
|
31
|
+
imports?: (DynamicModule | Type<any> | Promise<DynamicModule> | ForwardReference<any>)[];
|
|
32
|
+
url?: string;
|
|
33
|
+
version?: ApiVersion;
|
|
34
|
+
}
|
|
35
|
+
export interface ModulesConfig {
|
|
36
|
+
messages?: boolean;
|
|
37
|
+
connections?: boolean;
|
|
38
|
+
credentials?: boolean;
|
|
39
|
+
stats?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface EventsModuleOptions {
|
|
42
|
+
modules: ModulesConfig;
|
|
43
|
+
options: {
|
|
44
|
+
eventHandler?: Type<EventHandler>;
|
|
45
|
+
imports?: (DynamicModule | Type<any> | Promise<DynamicModule> | ForwardReference<any>)[];
|
|
46
|
+
url?: string;
|
|
47
|
+
version?: ApiVersion;
|
|
48
|
+
statOptions?: {
|
|
49
|
+
host?: string;
|
|
50
|
+
port?: number;
|
|
51
|
+
queue?: string;
|
|
52
|
+
username?: string;
|
|
53
|
+
password?: string;
|
|
54
|
+
reconnectLimit?: number;
|
|
55
|
+
threads?: number;
|
|
56
|
+
delay?: number;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export declare enum CredentialStatus {
|
|
61
|
+
OFFERED = "offered",
|
|
62
|
+
ACCEPTED = "accepted",
|
|
63
|
+
REJECTED = "rejected",
|
|
64
|
+
REVOKED = "revoked"
|
|
65
|
+
}
|
package/build/types.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CredentialStatus = void 0;
|
|
4
|
+
var CredentialStatus;
|
|
5
|
+
(function (CredentialStatus) {
|
|
6
|
+
CredentialStatus["OFFERED"] = "offered";
|
|
7
|
+
CredentialStatus["ACCEPTED"] = "accepted";
|
|
8
|
+
CredentialStatus["REJECTED"] = "rejected";
|
|
9
|
+
CredentialStatus["REVOKED"] = "revoked";
|
|
10
|
+
})(CredentialStatus || (exports.CredentialStatus = CredentialStatus = {}));
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAoEA,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,yCAAqB,CAAA;IACrB,yCAAqB,CAAA;IACrB,uCAAmB,CAAA;AACrB,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B"}
|