@verana-labs/vs-agent-nestjs-client 2.0.0-dev.70 → 2.0.0-dev.73

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.
Files changed (71) hide show
  1. package/README.md +61 -201
  2. package/build/app.module.js +26 -34
  3. package/build/app.module.js.map +1 -1
  4. package/build/connections/connection.entity.d.ts +4 -5
  5. package/build/connections/connection.entity.js +2 -10
  6. package/build/connections/connection.entity.js.map +1 -1
  7. package/build/connections/connection.repository.d.ts +6 -20
  8. package/build/connections/connection.repository.js +12 -40
  9. package/build/connections/connection.repository.js.map +1 -1
  10. package/build/connections/connection.service.d.ts +8 -17
  11. package/build/connections/connection.service.js +33 -54
  12. package/build/connections/connection.service.js.map +1 -1
  13. package/build/connections/index.d.ts +0 -2
  14. package/build/connections/index.js +0 -2
  15. package/build/connections/index.js.map +1 -1
  16. package/build/credentials/credential.entity.d.ts +1 -1
  17. package/build/credentials/credential.entity.js +1 -1
  18. package/build/credentials/credential.entity.js.map +1 -1
  19. package/build/credentials/credential.service.d.ts +22 -90
  20. package/build/credentials/credential.service.js +106 -205
  21. package/build/credentials/credential.service.js.map +1 -1
  22. package/build/credentials/index.d.ts +0 -1
  23. package/build/credentials/index.js +0 -1
  24. package/build/credentials/index.js.map +1 -1
  25. package/build/events.controller.d.ts +9 -0
  26. package/build/events.controller.js +47 -0
  27. package/build/events.controller.js.map +1 -0
  28. package/build/events.service.d.ts +12 -0
  29. package/build/events.service.js +80 -0
  30. package/build/events.service.js.map +1 -0
  31. package/build/index.d.ts +4 -3
  32. package/build/index.js +4 -3
  33. package/build/index.js.map +1 -1
  34. package/build/interfaces.d.ts +2 -28
  35. package/build/jms/index.d.ts +1 -1
  36. package/build/jms/index.js +4 -1
  37. package/build/jms/index.js.map +1 -1
  38. package/build/jms/stats-producer.service.d.ts +3 -4
  39. package/build/jms/stats-producer.service.js +3 -4
  40. package/build/jms/stats-producer.service.js.map +1 -1
  41. package/build/tokens.d.ts +3 -0
  42. package/build/tokens.js +7 -0
  43. package/build/tokens.js.map +1 -0
  44. package/build/types.d.ts +25 -53
  45. package/build/types.js +7 -1
  46. package/build/types.js.map +1 -1
  47. package/package.json +3 -9
  48. package/build/connections/connection.controller.d.ts +0 -10
  49. package/build/connections/connection.controller.js +0 -65
  50. package/build/connections/connection.controller.js.map +0 -1
  51. package/build/connections/connection.module.d.ts +0 -5
  52. package/build/connections/connection.module.js +0 -44
  53. package/build/connections/connection.module.js.map +0 -1
  54. package/build/credentials/credential.module.d.ts +0 -5
  55. package/build/credentials/credential.module.js +0 -34
  56. package/build/credentials/credential.module.js.map +0 -1
  57. package/build/jms/stats.module.d.ts +0 -5
  58. package/build/jms/stats.module.js +0 -34
  59. package/build/jms/stats.module.js.map +0 -1
  60. package/build/messages/index.d.ts +0 -3
  61. package/build/messages/index.js +0 -20
  62. package/build/messages/index.js.map +0 -1
  63. package/build/messages/message.controller.d.ts +0 -10
  64. package/build/messages/message.controller.js +0 -65
  65. package/build/messages/message.controller.js.map +0 -1
  66. package/build/messages/message.module.d.ts +0 -5
  67. package/build/messages/message.module.js +0 -41
  68. package/build/messages/message.module.js.map +0 -1
  69. package/build/messages/message.service.d.ts +0 -18
  70. package/build/messages/message.service.js +0 -103
  71. package/build/messages/message.service.js.map +0 -1
@@ -11,76 +11,55 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
- var ConnectionsEventService_1;
14
+ var ConnectionsService_1;
15
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");
16
+ exports.ConnectionsService = void 0;
18
17
  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");
18
+ const tokens_1 = require("../tokens");
19
+ const types_1 = require("../types");
21
20
  const connection_repository_1 = require("./connection.repository");
22
- let ConnectionsEventService = ConnectionsEventService_1 = class ConnectionsEventService {
21
+ let ConnectionsService = ConnectionsService_1 = class ConnectionsService {
23
22
  constructor(options, repository, eventHandler) {
24
- var _a;
25
- this.options = options;
23
+ var _a, _b;
26
24
  this.repository = repository;
27
25
  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;
26
+ this.logger = new common_1.Logger(ConnectionsService_1.name);
27
+ const connections = (_a = options.modules) === null || _a === void 0 ? void 0 : _a.connections;
28
+ this.requireProfile = typeof connections === 'object' ? ((_b = connections.requireProfile) !== null && _b !== void 0 ? _b : true) : true;
30
29
  }
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;
30
+ async handleStateUpdated(data, timestamp) {
31
+ if (data.state === 'completed' && data.previousState !== 'completed') {
32
+ await this.repository.create({
33
+ id: data.id,
34
+ status: types_1.ConnectionStatus.Start,
35
+ createdTs: new Date(timestamp),
36
+ });
37
+ await this.handleNewConnection(data.id);
55
38
  }
56
- return null;
39
+ else if (data.state === 'abandoned') {
40
+ const existed = await this.repository.updateStatus(data.id, types_1.ConnectionStatus.Terminated);
41
+ if (existed)
42
+ await this.eventHandler.closeConnection(data.id);
43
+ }
44
+ }
45
+ async handleProfileReceived(data) {
46
+ await this.repository.create({ id: data.connectionId, status: types_1.ConnectionStatus.Start });
47
+ await this.repository.updateUserProfile(data.connectionId, data.profile);
48
+ await this.handleNewConnection(data.connectionId);
57
49
  }
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
50
  async handleNewConnection(connectionId) {
68
- if (!this.eventHandler)
69
- return;
70
- const isCompleted = await this.repository.isCompleted(connectionId, !!this.messageEvent);
71
- if (isCompleted) {
51
+ if (await this.repository.isCompleted(connectionId, this.requireProfile)) {
72
52
  this.logger.log(`A new connection has been completed with connection id: ${connectionId}`);
73
53
  await this.eventHandler.newConnection(connectionId);
74
54
  }
75
55
  }
76
56
  };
77
- exports.ConnectionsEventService = ConnectionsEventService;
78
- exports.ConnectionsEventService = ConnectionsEventService = ConnectionsEventService_1 = __decorate([
57
+ exports.ConnectionsService = ConnectionsService;
58
+ exports.ConnectionsService = ConnectionsService = ConnectionsService_1 = __decorate([
79
59
  (0, common_1.Injectable)(),
80
- __param(0, (0, common_1.Inject)('GLOBAL_MODULE_OPTIONS')),
60
+ __param(0, (0, common_1.Inject)(tokens_1.EVENTS_MODULE_OPTIONS)),
81
61
  __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')),
62
+ __param(2, (0, common_1.Inject)(tokens_1.EVENT_HANDLER)),
84
63
  __metadata("design:paramtypes", [Object, connection_repository_1.ConnectionsRepository, Object])
85
- ], ConnectionsEventService);
64
+ ], ConnectionsService);
86
65
  //# sourceMappingURL=connection.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.service.js","sourceRoot":"","sources":["../../src/connections/connection.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0EAAiE;AACjE,2CAAqE;AACrE,gEAA8F;AAK9F,2DAAsD;AACtD,mEAA+D;AAGxD,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IAIlC,YACmC,OAAuC,EACzC,UAAkD,EACxC,YAAmC;;QAFnC,YAAO,GAAP,OAAO,CAAwB;QACxB,eAAU,GAAV,UAAU,CAAuB;QAChC,iBAAY,GAAZ,YAAY,CAAe;QAN7D,WAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAA;QAQhE,IAAI,CAAC,YAAY,GAAG,MAAA,OAAO,CAAC,WAAW,mCAAI,KAAK,CAAA;IAClD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAA6B;;QACxC,QAAQ,KAAK,CAAC,KAAK,EAAE,CAAC;YACpB,KAAK,yCAAwB,CAAC,OAAO;gBACnC,IAAI,MAAA,KAAK,CAAC,QAAQ,0CAAG,wCAAgB,CAAC,gBAAgB,CAAC;oBACrD,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;gBAC1E,MAAM,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;gBAClD,MAAK;YACP,KAAK,yCAAwB,CAAC,SAAS;gBACrC,MAAM,aAAa,GAAG,IAAI,oCAAgB,EAAE,CAAA;gBAC5C,aAAa,CAAC,EAAE,GAAG,KAAK,CAAC,YAAY,CAAA;gBACrC,aAAa,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;gBACzC,aAAa,CAAC,MAAM,GAAG,yCAAwB,CAAC,K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AI,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC/D,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,IAAyB;QAC1D,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,wBAAgB,CAAC,KAAK,EAAE,CAAC,CAAA;QACvF,MAAM,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACxE,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IACnD,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,YAAoB;QACnD,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,2DAA2D,YAAY,EAAE,CAAC,CAAA;YAC1F,MAAM,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;CACF,CAAA;AAvCY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,8BAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,eAAM,EAAC,6CAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,eAAM,EAAC,sBAAa,CAAC,CAAA;6CADsC,6CAAqB;GANxE,kBAAkB,CAuC9B"}
@@ -1,5 +1,3 @@
1
- export * from './connection.controller';
2
1
  export * from './connection.entity';
3
- export * from './connection.module';
4
2
  export * from './connection.repository';
5
3
  export * from './connection.service';
@@ -14,9 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./connection.controller"), exports);
18
17
  __exportStar(require("./connection.entity"), exports);
19
- __exportStar(require("./connection.module"), exports);
20
18
  __exportStar(require("./connection.repository"), exports);
21
19
  __exportStar(require("./connection.service"), exports);
22
20
  //# sourceMappingURL=index.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connections/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC;AACnC,0DAAuC;AACvC,uDAAoC"}
@@ -3,7 +3,7 @@ import { RevocationRegistryEntity } from './revocation-registry.entity';
3
3
  export declare class CredentialEntity {
4
4
  id: string;
5
5
  connectionId?: string;
6
- threadId?: string;
6
+ credentialExchangeId?: string;
7
7
  refIdHash?: string;
8
8
  status?: CredentialStatus;
9
9
  revocationRegistryIndex?: number;
@@ -27,7 +27,7 @@ __decorate([
27
27
  __decorate([
28
28
  (0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
29
29
  __metadata("design:type", String)
30
- ], CredentialEntity.prototype, "threadId", void 0);
30
+ ], CredentialEntity.prototype, "credentialExchangeId", void 0);
31
31
  __decorate([
32
32
  (0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
33
33
  __metadata("design:type", String)
@@ -1 +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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C,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;;8DACf;AAG7B;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"}
@@ -1,100 +1,32 @@
1
- import { JsonObject } from '@credo-ts/core';
1
+ import { ApiClient, CreateCredentialOfferResponse, CredentialDefinition } from '@verana-labs/vs-agent-client';
2
2
  import { Repository } from 'typeorm';
3
- import { CredentialOptions } from '../types';
4
3
  import { CredentialEntity } from './credential.entity';
5
4
  import { RevocationRegistryEntity } from './revocation-registry.entity';
5
+ export interface CreateCredentialDefinitionOptions {
6
+ supportRevocation?: boolean;
7
+ maximumCredentialNumber?: number;
8
+ }
9
+ export interface IssueOptions {
10
+ connectionId?: string;
11
+ refId?: string;
12
+ credentialDefinitionId?: string;
13
+ jsonSchemaCredentialId?: string;
14
+ revokeIfAlreadyIssued?: boolean;
15
+ }
6
16
  export declare class CredentialService {
7
17
  private readonly credentialRepository;
8
18
  private readonly revocationRepository;
9
- private options;
19
+ private readonly client;
10
20
  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>;
21
+ constructor(credentialRepository: Repository<CredentialEntity>, revocationRepository: Repository<RevocationRegistryEntity>, client: ApiClient);
22
+ createCredentialDefinition(relatedJsonSchemaCredentialId: string, options?: CreateCredentialDefinitionOptions): Promise<CredentialDefinition>;
23
+ issue(claims: Record<string, unknown>, options?: IssueOptions): Promise<CreateCredentialOfferResponse>;
24
+ handleAcceptance(credentialExchangeId: string): Promise<void>;
25
+ handleRejection(credentialExchangeId: string): Promise<void>;
26
+ revoke(connectionId: string, credentialExchangeId?: string): Promise<void>;
27
+ private revokeCredential;
28
+ private findOffered;
29
+ private listCredentialDefinitions;
98
30
  private createRevocationRegistry;
99
31
  private hash;
100
32
  }