@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,44 @@
|
|
|
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 ConnectionsEventModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ConnectionsEventModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const connection_controller_1 = require("./connection.controller");
|
|
13
|
+
const connection_repository_1 = require("./connection.repository");
|
|
14
|
+
const connection_service_1 = require("./connection.service");
|
|
15
|
+
let ConnectionsEventModule = ConnectionsEventModule_1 = class ConnectionsEventModule {
|
|
16
|
+
static forRoot(options) {
|
|
17
|
+
if (!options.eventHandler) {
|
|
18
|
+
throw new Error('Event handler is required but not provided.');
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
module: ConnectionsEventModule_1,
|
|
22
|
+
imports: options.imports,
|
|
23
|
+
controllers: [connection_controller_1.ConnectionsEventController],
|
|
24
|
+
providers: [
|
|
25
|
+
connection_service_1.ConnectionsEventService,
|
|
26
|
+
connection_repository_1.ConnectionsRepository,
|
|
27
|
+
{
|
|
28
|
+
provide: 'GLOBAL_MODULE_OPTIONS',
|
|
29
|
+
useValue: options,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
provide: 'CONNECTIONS_EVENT',
|
|
33
|
+
useClass: options.eventHandler,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
exports: [connection_repository_1.ConnectionsRepository, connection_service_1.ConnectionsEventService],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.ConnectionsEventModule = ConnectionsEventModule;
|
|
41
|
+
exports.ConnectionsEventModule = ConnectionsEventModule = ConnectionsEventModule_1 = __decorate([
|
|
42
|
+
(0, common_1.Module)({})
|
|
43
|
+
], ConnectionsEventModule);
|
|
44
|
+
//# sourceMappingURL=connection.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.module.js","sourceRoot":"","sources":["../../src/connections/connection.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsD;AAItD,mEAAoE;AACpE,mEAA+D;AAC/D,6DAA8D;AAGvD,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IACjC,MAAM,CAAC,OAAO,CAAC,OAA+B;QAC5C,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;QAChE,CAAC;QACD,OAAO;YACL,MAAM,EAAE,wBAAsB;YAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,WAAW,EAAE,CAAC,kDAA0B,CAAC;YACzC,SAAS,EAAE;gBACT,4CAAuB;gBACvB,6CAAqB;gBACrB;oBACE,OAAO,EAAE,uBAAuB;oBAChC,QAAQ,EAAE,OAAO;iBAClB;gBACD;oBACE,OAAO,EAAE,mBAAmB;oBAC5B,QAAQ,EAAE,OAAO,CAAC,YAAY;iBAC/B;aACF;YACD,OAAO,EAAE,CAAC,6CAAqB,EAAE,4CAAuB,CAAC;SAC1D,CAAA;IACH,CAAC;CACF,CAAA;AAxBY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,sBAAsB,CAwBlC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ExtendedDidExchangeState } from '@verana-labs/vs-agent-model';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { UserProfile } from '../types';
|
|
4
|
+
import { ConnectionEntity } from './connection.entity';
|
|
5
|
+
export declare class ConnectionsRepository {
|
|
6
|
+
private readonly repository;
|
|
7
|
+
constructor(repository: Repository<ConnectionEntity>);
|
|
8
|
+
create(connection: Partial<ConnectionEntity>): Promise<ConnectionEntity>;
|
|
9
|
+
findAll(): Promise<ConnectionEntity[]>;
|
|
10
|
+
findById(id: string): Promise<ConnectionEntity | undefined>;
|
|
11
|
+
updateStatus(id: string, status: ExtendedDidExchangeState): Promise<ConnectionEntity | undefined>;
|
|
12
|
+
updateUserProfile(id: string, userProfile: UserProfile): Promise<ConnectionEntity | undefined>;
|
|
13
|
+
updateMetadata(id: string, metadata: Record<string, any>): Promise<ConnectionEntity | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if a connection has been completed.
|
|
16
|
+
*
|
|
17
|
+
* This method verifies whether the connection's `lang` (if required)
|
|
18
|
+
* and `metadata` meet the completion criteria.
|
|
19
|
+
* @param id The unique identifier of the connection to validate
|
|
20
|
+
* @param requireLang If `true`, ensures that `lang` is not `null`
|
|
21
|
+
* @returns A promise that resolves to `true` if:
|
|
22
|
+
* - `metadata` is either `undefined` or a non-empty object.
|
|
23
|
+
* - If `requireLang` is `true`, `lang` must not be `null`.
|
|
24
|
+
* @throws Error if the connection is not found or if `createdTs` is missing.
|
|
25
|
+
*/
|
|
26
|
+
isCompleted(id: string, requireLang: boolean): Promise<boolean>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ConnectionsRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
19
|
+
const typeorm_2 = require("typeorm");
|
|
20
|
+
const connection_entity_1 = require("./connection.entity");
|
|
21
|
+
// TypeORM
|
|
22
|
+
let ConnectionsRepository = class ConnectionsRepository {
|
|
23
|
+
constructor(repository) {
|
|
24
|
+
this.repository = repository;
|
|
25
|
+
}
|
|
26
|
+
async create(connection) {
|
|
27
|
+
const entity = this.repository.create(connection);
|
|
28
|
+
return await this.repository.save(entity);
|
|
29
|
+
}
|
|
30
|
+
async findAll() {
|
|
31
|
+
return await this.repository.find();
|
|
32
|
+
}
|
|
33
|
+
async findById(id) {
|
|
34
|
+
var _a;
|
|
35
|
+
return (_a = (await this.repository.findOne({ where: { id } }))) !== null && _a !== void 0 ? _a : undefined;
|
|
36
|
+
}
|
|
37
|
+
async updateStatus(id, status) {
|
|
38
|
+
var _a;
|
|
39
|
+
await this.repository.update(id, { status });
|
|
40
|
+
return (_a = (await this.repository.findOne({ where: { id } }))) !== null && _a !== void 0 ? _a : undefined;
|
|
41
|
+
}
|
|
42
|
+
async updateUserProfile(id, userProfile) {
|
|
43
|
+
var _a;
|
|
44
|
+
await this.repository.update(id, { userProfile });
|
|
45
|
+
return (_a = (await this.repository.findOne({ where: { id } }))) !== null && _a !== void 0 ? _a : undefined;
|
|
46
|
+
}
|
|
47
|
+
async updateMetadata(id, metadata) {
|
|
48
|
+
var _a;
|
|
49
|
+
await this.repository.update(id, { metadata });
|
|
50
|
+
return (_a = (await this.repository.findOne({ where: { id } }))) !== null && _a !== void 0 ? _a : undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Checks if a connection has been completed.
|
|
54
|
+
*
|
|
55
|
+
* This method verifies whether the connection's `lang` (if required)
|
|
56
|
+
* and `metadata` meet the completion criteria.
|
|
57
|
+
* @param id The unique identifier of the connection to validate
|
|
58
|
+
* @param requireLang If `true`, ensures that `lang` is not `null`
|
|
59
|
+
* @returns A promise that resolves to `true` if:
|
|
60
|
+
* - `metadata` is either `undefined` or a non-empty object.
|
|
61
|
+
* - If `requireLang` is `true`, `lang` must not be `null`.
|
|
62
|
+
* @throws Error if the connection is not found or if `createdTs` is missing.
|
|
63
|
+
*/
|
|
64
|
+
async isCompleted(id, requireLang) {
|
|
65
|
+
var _a;
|
|
66
|
+
const conn = await this.findById(id);
|
|
67
|
+
if (!(conn === null || conn === void 0 ? void 0 : conn.id)) {
|
|
68
|
+
throw new Error(`No connection found with id: ${id}. The connection may not have been created properly`);
|
|
69
|
+
}
|
|
70
|
+
if (conn.status === vs_agent_model_1.ExtendedDidExchangeState.Completed)
|
|
71
|
+
return false;
|
|
72
|
+
const isMetadataValid = !conn.metadata || Object.keys(conn.metadata).length > 0;
|
|
73
|
+
const isLangValid = !requireLang || ((_a = conn.userProfile) === null || _a === void 0 ? void 0 : _a.preferredLanguage) != null;
|
|
74
|
+
if (isLangValid && isMetadataValid) {
|
|
75
|
+
this.updateStatus(conn.id, vs_agent_model_1.ExtendedDidExchangeState.Completed);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.ConnectionsRepository = ConnectionsRepository;
|
|
82
|
+
exports.ConnectionsRepository = ConnectionsRepository = __decorate([
|
|
83
|
+
(0, common_1.Injectable)(),
|
|
84
|
+
__param(0, (0, typeorm_1.InjectRepository)(connection_entity_1.ConnectionEntity)),
|
|
85
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
86
|
+
], ConnectionsRepository);
|
|
87
|
+
//# sourceMappingURL=connection.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.repository.js","sourceRoot":"","sources":["../../src/connections/connection.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2C;AAC3C,6CAAkD;AAClD,gEAAsE;AACtE,qCAAoC;AAIpC,2DAAsD;AAEtD,UAAU;AAEH,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAEmB,UAAwC;QAAxC,eAAU,GAAV,UAAU,CAA8B;IACxD,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,UAAqC;QAChD,MAA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C,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,mCAAI,SAAS,CAAA;IACxE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,WAAW,CAAC,EAAU,EAAE,WAAoB;;QAChD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QACpC,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,EAAE,CAAA,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,gCAAgC,EAAE,qDAAqD,CAAC,CAAA;QAC1G,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,yCAAwB,CAAC,SAAS;YAAE,OAAO,KAAK,CAAA;QAEpE,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;QAC/E,MAAM,WAAW,GAAG,CAAC,WAAW,IAAI,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,iBAAiB,KAAI,IAAI,CAAA;QAC/E,IAAI,WAAW,IAAI,eAAe,EAAE,CAAC;YACnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,yCAAwB,CAAC,SAAS,CAAC,CAAA;YAC9D,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF,CAAA;AA7DY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,oCAAgB,CAAC,CAAA;qCACN,oBAAU;GAH9B,qBAAqB,CA6DjC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ConnectionStateUpdated } from '@verana-labs/vs-agent-model';
|
|
2
|
+
import { EventHandler } from '../interfaces';
|
|
3
|
+
import { ConnectionEventOptions } from '../types';
|
|
4
|
+
import { ConnectionsRepository } from './connection.repository';
|
|
5
|
+
export declare class ConnectionsEventService {
|
|
6
|
+
private options;
|
|
7
|
+
private readonly repository;
|
|
8
|
+
private eventHandler?;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private readonly messageEvent;
|
|
11
|
+
constructor(options: ConnectionEventOptions, repository: ConnectionsRepository, eventHandler?: EventHandler | undefined);
|
|
12
|
+
update(event: ConnectionStateUpdated): Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Handles a new connection by verifying its completion status.
|
|
15
|
+
*
|
|
16
|
+
* If the connection is considered completed, it triggers the event handler
|
|
17
|
+
* and logs the connection initiation.
|
|
18
|
+
*
|
|
19
|
+
* @param connectionId The unique identifier of the connection.
|
|
20
|
+
* @returns A promise that resolves when the connection is processed.
|
|
21
|
+
*/
|
|
22
|
+
handleNewConnection(connectionId: string): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 ConnectionsEventService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ConnectionsEventService = void 0;
|
|
17
|
+
const credo_ts_didcomm_mrtd_1 = require("@2060.io/credo-ts-didcomm-mrtd");
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
20
|
+
const connection_entity_1 = require("./connection.entity");
|
|
21
|
+
const connection_repository_1 = require("./connection.repository");
|
|
22
|
+
let ConnectionsEventService = ConnectionsEventService_1 = class ConnectionsEventService {
|
|
23
|
+
constructor(options, repository, eventHandler) {
|
|
24
|
+
var _a;
|
|
25
|
+
this.options = options;
|
|
26
|
+
this.repository = repository;
|
|
27
|
+
this.eventHandler = eventHandler;
|
|
28
|
+
this.logger = new common_1.Logger(ConnectionsEventService_1.name);
|
|
29
|
+
this.messageEvent = (_a = options.useMessages) !== null && _a !== void 0 ? _a : false;
|
|
30
|
+
}
|
|
31
|
+
async update(event) {
|
|
32
|
+
var _a;
|
|
33
|
+
switch (event.state) {
|
|
34
|
+
case vs_agent_model_1.ExtendedDidExchangeState.Updated:
|
|
35
|
+
if ((_a = event.metadata) === null || _a === void 0 ? void 0 : _a[credo_ts_didcomm_mrtd_1.MrtdCapabilities.EMrtdReadSupport])
|
|
36
|
+
await this.repository.updateMetadata(event.connectionId, event.metadata);
|
|
37
|
+
await this.handleNewConnection(event.connectionId);
|
|
38
|
+
break;
|
|
39
|
+
case vs_agent_model_1.ExtendedDidExchangeState.Completed:
|
|
40
|
+
const newConnection = new connection_entity_1.ConnectionEntity();
|
|
41
|
+
newConnection.id = event.connectionId;
|
|
42
|
+
newConnection.createdTs = event.timestamp;
|
|
43
|
+
newConnection.status = vs_agent_model_1.ExtendedDidExchangeState.Start;
|
|
44
|
+
newConnection.metadata = event.metadata;
|
|
45
|
+
await this.repository.create(newConnection);
|
|
46
|
+
break;
|
|
47
|
+
case vs_agent_model_1.ExtendedDidExchangeState.Terminated:
|
|
48
|
+
await this.repository.updateStatus(event.connectionId, event.state);
|
|
49
|
+
if (this.eventHandler) {
|
|
50
|
+
await this.eventHandler.closeConnection(event.connectionId);
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Handles a new connection by verifying its completion status.
|
|
60
|
+
*
|
|
61
|
+
* If the connection is considered completed, it triggers the event handler
|
|
62
|
+
* and logs the connection initiation.
|
|
63
|
+
*
|
|
64
|
+
* @param connectionId The unique identifier of the connection.
|
|
65
|
+
* @returns A promise that resolves when the connection is processed.
|
|
66
|
+
*/
|
|
67
|
+
async handleNewConnection(connectionId) {
|
|
68
|
+
if (!this.eventHandler)
|
|
69
|
+
return;
|
|
70
|
+
const isCompleted = await this.repository.isCompleted(connectionId, !!this.messageEvent);
|
|
71
|
+
if (isCompleted) {
|
|
72
|
+
this.logger.log(`A new connection has been completed with connection id: ${connectionId}`);
|
|
73
|
+
await this.eventHandler.newConnection(connectionId);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.ConnectionsEventService = ConnectionsEventService;
|
|
78
|
+
exports.ConnectionsEventService = ConnectionsEventService = ConnectionsEventService_1 = __decorate([
|
|
79
|
+
(0, common_1.Injectable)(),
|
|
80
|
+
__param(0, (0, common_1.Inject)('GLOBAL_MODULE_OPTIONS')),
|
|
81
|
+
__param(1, (0, common_1.Inject)(connection_repository_1.ConnectionsRepository)),
|
|
82
|
+
__param(2, (0, common_1.Optional)()),
|
|
83
|
+
__param(2, (0, common_1.Inject)('CONNECTIONS_EVENT')),
|
|
84
|
+
__metadata("design:paramtypes", [Object, connection_repository_1.ConnectionsRepository, Object])
|
|
85
|
+
], ConnectionsEventService);
|
|
86
|
+
//# sourceMappingURL=connection.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.service.js","sourceRoot":"","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
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("./connection.controller"), exports);
|
|
18
|
+
__exportStar(require("./connection.entity"), exports);
|
|
19
|
+
__exportStar(require("./connection.module"), exports);
|
|
20
|
+
__exportStar(require("./connection.repository"), exports);
|
|
21
|
+
__exportStar(require("./connection.service"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connections/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC;AACvC,sDAAmC;AACnC,sDAAmC;AACnC,0DAAuC;AACvC,uDAAoC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CredentialStatus } from '../types';
|
|
2
|
+
import { RevocationRegistryEntity } from './revocation-registry.entity';
|
|
3
|
+
export declare class CredentialEntity {
|
|
4
|
+
id: string;
|
|
5
|
+
connectionId?: string;
|
|
6
|
+
threadId?: string;
|
|
7
|
+
refIdHash?: string;
|
|
8
|
+
status?: CredentialStatus;
|
|
9
|
+
revocationRegistryIndex?: number;
|
|
10
|
+
revocationRegistry?: RevocationRegistryEntity;
|
|
11
|
+
createdTs?: Date;
|
|
12
|
+
updatedTs?: Date;
|
|
13
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CredentialEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const types_1 = require("../types");
|
|
15
|
+
const revocation_registry_entity_1 = require("./revocation-registry.entity");
|
|
16
|
+
let CredentialEntity = class CredentialEntity {
|
|
17
|
+
};
|
|
18
|
+
exports.CredentialEntity = CredentialEntity;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], CredentialEntity.prototype, "id", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], CredentialEntity.prototype, "connectionId", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], CredentialEntity.prototype, "threadId", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], CredentialEntity.prototype, "refIdHash", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.Column)({ type: 'enum', enum: types_1.CredentialStatus, nullable: true }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], CredentialEntity.prototype, "status", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({ type: 'integer', nullable: true }),
|
|
41
|
+
__metadata("design:type", Number)
|
|
42
|
+
], CredentialEntity.prototype, "revocationRegistryIndex", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.ManyToOne)(() => revocation_registry_entity_1.RevocationRegistryEntity, { nullable: true }),
|
|
45
|
+
(0, typeorm_1.JoinColumn)({ name: 'revocationRegistryId' }),
|
|
46
|
+
__metadata("design:type", revocation_registry_entity_1.RevocationRegistryEntity)
|
|
47
|
+
], CredentialEntity.prototype, "revocationRegistry", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
50
|
+
__metadata("design:type", Date)
|
|
51
|
+
], CredentialEntity.prototype, "createdTs", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
54
|
+
__metadata("design:type", Date)
|
|
55
|
+
], CredentialEntity.prototype, "updatedTs", void 0);
|
|
56
|
+
exports.CredentialEntity = CredentialEntity = __decorate([
|
|
57
|
+
(0, typeorm_1.Entity)('credentials')
|
|
58
|
+
], CredentialEntity);
|
|
59
|
+
//# sourceMappingURL=credential.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.entity.js","sourceRoot":"","sources":["../../src/credentials/credential.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAQgB;AAEhB,oCAA2C;AAE3C,6EAAuE;AAGhE,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CA4B5B,CAAA;AA5BY,4CAAgB;AAE3B;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;4CACpB;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACvB;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDAC3B;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDAC1B;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACxC;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iEACZ;AAIhC;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,qDAAwB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC7D,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC;8BACxB,qDAAwB;4DAAA;AAG7C;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;mDAAA;AAGhB;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;mDAAA;2BA3BL,gBAAgB;IAD5B,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,gBAAgB,CA4B5B"}
|
|
@@ -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 CredentialModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.CredentialModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const credential_service_1 = require("./credential.service");
|
|
13
|
+
let CredentialModule = CredentialModule_1 = class CredentialModule {
|
|
14
|
+
static forRoot(options) {
|
|
15
|
+
return {
|
|
16
|
+
module: CredentialModule_1,
|
|
17
|
+
imports: options.imports,
|
|
18
|
+
controllers: [],
|
|
19
|
+
providers: [
|
|
20
|
+
credential_service_1.CredentialService,
|
|
21
|
+
{
|
|
22
|
+
provide: 'GLOBAL_MODULE_OPTIONS',
|
|
23
|
+
useValue: options,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
exports: [credential_service_1.CredentialService],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.CredentialModule = CredentialModule;
|
|
31
|
+
exports.CredentialModule = CredentialModule = CredentialModule_1 = __decorate([
|
|
32
|
+
(0, common_1.Module)({})
|
|
33
|
+
], CredentialModule);
|
|
34
|
+
//# sourceMappingURL=credential.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.module.js","sourceRoot":"","sources":["../../src/credentials/credential.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsD;AAItD,6DAAwD;AAGjD,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO,CAAC,OAA0B;QACvC,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,WAAW,EAAE,EAAE;YACf,SAAS,EAAE;gBACT,sCAAiB;gBACjB;oBACE,OAAO,EAAE,uBAAuB;oBAChC,QAAQ,EAAE,OAAO;iBAClB;aACF;YACD,OAAO,EAAE,CAAC,sCAAiB,CAAC;SAC7B,CAAA;IACH,CAAC;CACF,CAAA;AAhBY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CAgB5B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { JsonObject } from '@credo-ts/core';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { CredentialOptions } from '../types';
|
|
4
|
+
import { CredentialEntity } from './credential.entity';
|
|
5
|
+
import { RevocationRegistryEntity } from './revocation-registry.entity';
|
|
6
|
+
export declare class CredentialService {
|
|
7
|
+
private readonly credentialRepository;
|
|
8
|
+
private readonly revocationRepository;
|
|
9
|
+
private options;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
private readonly url;
|
|
12
|
+
private readonly apiVersion;
|
|
13
|
+
private readonly apiClient;
|
|
14
|
+
constructor(credentialRepository: Repository<CredentialEntity>, revocationRepository: Repository<RevocationRegistryEntity>, options: CredentialOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Creates and initializes a credential type (credential definition) with optional revocation registry support.
|
|
17
|
+
*
|
|
18
|
+
* This method specifically handles the creation of credential types/definitions, which serve as templates
|
|
19
|
+
* for issuing actual credentials.
|
|
20
|
+
*
|
|
21
|
+
* When revocation support is enabled:
|
|
22
|
+
* - Two default revocation registries will be created
|
|
23
|
+
* - This ensures continuity if one registry reaches capacity
|
|
24
|
+
*
|
|
25
|
+
* @param attributes - List of attributes that credentials of this type will support
|
|
26
|
+
* @param options.name - Name identifier for the credential type
|
|
27
|
+
* @param options.version - Version of the credential type
|
|
28
|
+
* @param options.supportRevocation - Whether credentials can be revoked
|
|
29
|
+
* @param options.maximumCredentialNumber - Maximum number of credentials that can be issued
|
|
30
|
+
*
|
|
31
|
+
* @returns Promise<void> - Resolves when the credential type and revocation registries are created
|
|
32
|
+
*/
|
|
33
|
+
createType(name: string, version: string, attributes: string[], options?: {
|
|
34
|
+
supportRevocation?: boolean;
|
|
35
|
+
maximumCredentialNumber?: number;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Sends a credential issuance to the specified connection using the provided claims.
|
|
39
|
+
* This method initiates the issuance process by sending claims as part of a credential
|
|
40
|
+
* to the recipient identified by the connection ID.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} connectionId - The unique identifier of the connection to which the credential
|
|
43
|
+
* will be issued. This represents the recipient of the credential.
|
|
44
|
+
*
|
|
45
|
+
* @param {Claim[]} claims - An array of claims representing the data to be included in the credential.
|
|
46
|
+
* Each claim has a `name` (key) and a `value` (data). Example:
|
|
47
|
+
* ```javascript
|
|
48
|
+
* const claims = [
|
|
49
|
+
* { name: "email", value: "john.doe@example.com" },
|
|
50
|
+
* { name: "name", value: "John Doe" }
|
|
51
|
+
* ];
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @param {object} [options] - Additional options for credential issuance.
|
|
55
|
+
*
|
|
56
|
+
* ### Options
|
|
57
|
+
* - `refId` (optional, `string`): A unique identifier for the credential. If provided:
|
|
58
|
+
* - When `revokeIfAlreadyIssued` is set to `true`, any existing credential with the same `refId`
|
|
59
|
+
* will be revoked, ensuring the credential is unique.
|
|
60
|
+
* - If `revokeIfAlreadyIssued` is set to `false` (default), multiple credentials with the same `refId` can exist
|
|
61
|
+
* - Used for managing unique credentials like official documents.
|
|
62
|
+
* - Hashed in the database for security.
|
|
63
|
+
* - `credentialDefinitionId` (optional, `string`): Specifies the ID of the credential definition to use.
|
|
64
|
+
* - If not provided, the first available credential definition is used.
|
|
65
|
+
* - `revokeIfAlreadyIssued` (optional, `boolean`): Whether automatic revocation is enabled (default false)
|
|
66
|
+
*
|
|
67
|
+
* @returns {Promise<void>} A promise that resolves when the credential issuance is successfully sent.
|
|
68
|
+
* If an error occurs during the process, the promise will be rejected with the relevant error message.
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
issue(connectionId: string, claims: JsonObject, options?: {
|
|
72
|
+
refId?: string;
|
|
73
|
+
credentialDefinitionId?: string;
|
|
74
|
+
revokeIfAlreadyIssued?: boolean;
|
|
75
|
+
jsonSchemaCredentialId?: string;
|
|
76
|
+
}): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Accepts a credential by associating it with the provided thread ID.
|
|
79
|
+
* @param connectionId - The connection ID associated with the credential.
|
|
80
|
+
* @param threadId - The thread ID to link with the credential.
|
|
81
|
+
* @throws Error if no credential is found with the specified connection ID.
|
|
82
|
+
*/
|
|
83
|
+
handleAcceptance(threadId: string): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Rejected a credential by associating it with the provided thread ID.
|
|
86
|
+
* @param connectionId - The connection ID associated with the credential.
|
|
87
|
+
* @param threadId - The thread ID to link with the credential.
|
|
88
|
+
* @throws Error if no credential is found with the specified connection ID.
|
|
89
|
+
*/
|
|
90
|
+
handleRejection(threadId: string): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Revokes a credential associated with the provided thread ID.
|
|
93
|
+
* @param connectionId - The connection ID to send the revoke. (Search by connection ID if no thread ID)
|
|
94
|
+
* @param threadId - (Optional) The thread ID linked to the credential to revoke.
|
|
95
|
+
* @throws Error if no credential is found with the specified thread ID or connection ID, or if the credential has no connection ID.
|
|
96
|
+
*/
|
|
97
|
+
revoke(connectionId: string, threadId?: string): Promise<void>;
|
|
98
|
+
private createRevocationRegistry;
|
|
99
|
+
private hash;
|
|
100
|
+
}
|