@2060.io/vs-agent-client 1.6.0-dev.2 → 1.6.0-dev.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,5 @@
1
- import { RevocationRegistryService } from './services';
2
- import { CredentialTypeService } from './services/CredentialTypeService';
3
- import { InvitationService } from './services/InvitationService';
4
- import { MessageService } from './services/MessageService';
5
- import { ApiVersion } from './types/enums';
1
+ import { CredentialTypeService, InvitationService, MessageService, RevocationRegistryService, TrustCredentialService } from './services';
2
+ import { ApiVersion } from './types';
6
3
  /**
7
4
  * `ApiClient` class for easy access to the available endpoints in the Agent Service.
8
5
  * This class simplifies the interaction with the service by providing methods
@@ -39,5 +36,6 @@ export declare class ApiClient {
39
36
  readonly credentialTypes: CredentialTypeService;
40
37
  readonly revocationRegistries: RevocationRegistryService;
41
38
  readonly invitations: InvitationService;
39
+ readonly trustCredentials: TrustCredentialService;
42
40
  constructor(baseURL: string, version?: ApiVersion);
43
41
  }
@@ -3,10 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.ApiClient = void 0;
5
5
  const services_1 = require("./services");
6
- const CredentialTypeService_1 = require("./services/CredentialTypeService");
7
- const InvitationService_1 = require("./services/InvitationService");
8
- const MessageService_1 = require("./services/MessageService");
9
- const enums_1 = require("./types/enums");
6
+ const types_1 = require("./types");
10
7
  /**
11
8
  * `ApiClient` class for easy access to the available endpoints in the Agent Service.
12
9
  * This class simplifies the interaction with the service by providing methods
@@ -37,13 +34,14 @@ const enums_1 = require("./types/enums");
37
34
  * - `revocationRegistries`: Query and manage the revocation registry for credential definitions.
38
35
  */
39
36
  class ApiClient {
40
- constructor(baseURL, version = enums_1.ApiVersion.V1) {
37
+ constructor(baseURL, version = types_1.ApiVersion.V1) {
41
38
  this.baseURL = baseURL;
42
39
  this.version = version;
43
- this.invitations = new InvitationService_1.InvitationService(baseURL, version);
44
- this.messages = new MessageService_1.MessageService(baseURL, version);
45
- this.credentialTypes = new CredentialTypeService_1.CredentialTypeService(baseURL, version);
40
+ this.invitations = new services_1.InvitationService(baseURL, version);
41
+ this.messages = new services_1.MessageService(baseURL, version);
42
+ this.credentialTypes = new services_1.CredentialTypeService(baseURL, version);
46
43
  this.revocationRegistries = new services_1.RevocationRegistryService(baseURL, version);
44
+ this.trustCredentials = new services_1.TrustCredentialService(baseURL, version);
47
45
  }
48
46
  }
49
47
  exports.ApiClient = ApiClient;
@@ -1 +1 @@
1
- {"version":3,"file":"ApiClient.js","sourceRoot":"","sources":["../src/ApiClient.ts"],"names":[],"mappings":";AAAA,mBAAmB;;;AAEnB,yCAAsD;AACtD,4EAAwE;AACxE,oEAAgE;AAChE,8DAA0D;AAC1D,yCAA0C;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,SAAS;IAMpB,YACU,OAAe,EACf,UAAsB,kBAAU,CAAC,EAAE;QADnC,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAA4B;QAE3C,IAAI,CAAC,WAAW,GAAG,IAAI,qCAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC1D,IAAI,CAAC,QAAQ,GAAG,IAAI,+BAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACpD,IAAI,CAAC,eAAe,GAAG,IAAI,6CAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAClE,IAAI,CAAC,oBAAoB,GAAG,IAAI,oCAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7E,CAAC;CACF;AAfD,8BAeC"}
1
+ {"version":3,"file":"ApiClient.js","sourceRoot":"","sources":["../src/ApiClient.ts"],"names":[],"mappings":";AAAA,mBAAmB;;;AAEnB,yCAMmB;AACnB,mCAAoC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,SAAS;IAOpB,YACU,OAAe,EACf,UAAsB,kBAAU,CAAC,EAAE;QADnC,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAA4B;QAE3C,IAAI,CAAC,WAAW,GAAG,IAAI,4BAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC1D,IAAI,CAAC,QAAQ,GAAG,IAAI,yBAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACpD,IAAI,CAAC,eAAe,GAAG,IAAI,gCAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAClE,IAAI,CAAC,oBAAoB,GAAG,IAAI,oCAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC3E,IAAI,CAAC,gBAAgB,GAAG,IAAI,iCAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACtE,CAAC;CACF;AAjBD,8BAiBC"}
@@ -0,0 +1,33 @@
1
+ import { CredentialIssuanceRequest, CredentialIssuanceResponse } from '@2060.io/vs-agent-model';
2
+ import { ApiVersion } from '../types/enums';
3
+ /**
4
+ * Service responsible for managing verifiable credential issuance and revocation
5
+ * through the Trust Credential API.
6
+ *
7
+ * This service interacts with the Verifiable Trust (VT) endpoint of the agent API
8
+ * to issue credentials based on a given JSON schema and claim values.
9
+ */
10
+ export declare class TrustCredentialService {
11
+ private baseURL;
12
+ private version;
13
+ private url;
14
+ constructor(baseURL: string, version: ApiVersion);
15
+ /**
16
+ * Issues a verifiable credential (either W3C JSON-LD or Anoncreds) by sending
17
+ * a POST request to the `/issue-credential` endpoint of the Trust Credential API.
18
+ *
19
+ * This method supports both `jsonld` and `anoncreds` credential formats.
20
+ * It requires a JSON Schema credential definition and a set of claims,
21
+ * optionally linked to a DID.
22
+ *
23
+ * @param type - The credential format. Accepted values: `'jsonld' | 'anoncreds'`.
24
+ * @param jsonSchemaCredential - The URL of the credential JSON schema definition.
25
+ * @param claims - A JSON object containing the credential claims.
26
+ * @param did - (Optional) A decentralized identifier (DID) associated with the holder.
27
+ *
28
+ * @returns A `CredentialIssuanceResponse` containing either the DIDComm invitation URL
29
+ * or the issued verifiable credential, depending on the credential type.
30
+ */
31
+ issuance({ type, jsonSchemaCredential, claims, did, }: CredentialIssuanceRequest): Promise<CredentialIssuanceResponse>;
32
+ revoke(): Promise<void>;
33
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ // src/services/TrustCredentialService.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.TrustCredentialService = void 0;
5
+ const tslog_1 = require("tslog");
6
+ const logger = new tslog_1.Logger({
7
+ name: 'CredentialTypeService',
8
+ type: 'pretty',
9
+ prettyLogTemplate: '{{logLevelName}} [{{name}}]: ',
10
+ });
11
+ /**
12
+ * Service responsible for managing verifiable credential issuance and revocation
13
+ * through the Trust Credential API.
14
+ *
15
+ * This service interacts with the Verifiable Trust (VT) endpoint of the agent API
16
+ * to issue credentials based on a given JSON schema and claim values.
17
+ */
18
+ class TrustCredentialService {
19
+ constructor(baseURL, version) {
20
+ this.baseURL = baseURL;
21
+ this.version = version;
22
+ this.url = `${this.baseURL.replace(/\/$/, '')}/${this.version}/vt`;
23
+ }
24
+ /**
25
+ * Issues a verifiable credential (either W3C JSON-LD or Anoncreds) by sending
26
+ * a POST request to the `/issue-credential` endpoint of the Trust Credential API.
27
+ *
28
+ * This method supports both `jsonld` and `anoncreds` credential formats.
29
+ * It requires a JSON Schema credential definition and a set of claims,
30
+ * optionally linked to a DID.
31
+ *
32
+ * @param type - The credential format. Accepted values: `'jsonld' | 'anoncreds'`.
33
+ * @param jsonSchemaCredential - The URL of the credential JSON schema definition.
34
+ * @param claims - A JSON object containing the credential claims.
35
+ * @param did - (Optional) A decentralized identifier (DID) associated with the holder.
36
+ *
37
+ * @returns A `CredentialIssuanceResponse` containing either the DIDComm invitation URL
38
+ * or the issued verifiable credential, depending on the credential type.
39
+ */
40
+ async issuance({ type, jsonSchemaCredential, claims, did, }) {
41
+ try {
42
+ logger.info(`issue credential with schema: ${jsonSchemaCredential}`);
43
+ const response = await fetch(`${this.url}/issue-credential`, {
44
+ method: 'POST',
45
+ headers: { 'Content-Type': 'application/json' },
46
+ body: JSON.stringify({
47
+ type,
48
+ jsonSchemaCredential,
49
+ claims,
50
+ did,
51
+ }),
52
+ });
53
+ if (!response.ok) {
54
+ const responseText = await response.text();
55
+ throw new Error(`Failed to issue credential.\n` +
56
+ `Status: ${response.status} ${response.statusText}\n` +
57
+ `Response body: ${responseText || 'No response body returned'}`);
58
+ }
59
+ const data = (await response.json());
60
+ logger.info('Credential issued successfully.');
61
+ return data;
62
+ }
63
+ catch (error) {
64
+ logger.error(`Failed to send message: ${error}`);
65
+ throw new Error('Failed to send message');
66
+ }
67
+ }
68
+ // TODO: Implement revocation when the revocation method is supported.
69
+ // Update the NestJS client once the backend endpoint is available.
70
+ async revoke() {
71
+ throw new Error('This method is not implemented yet');
72
+ }
73
+ }
74
+ exports.TrustCredentialService = TrustCredentialService;
75
+ //# sourceMappingURL=TrustCredentialService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrustCredentialService.js","sourceRoot":"","sources":["../../src/services/TrustCredentialService.ts"],"names":[],"mappings":";AAAA,yCAAyC;;;AAGzC,iCAA8B;AAI9B,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC;IACxB,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE,QAAQ;IACd,iBAAiB,EAAE,+BAA+B;CACnD,CAAC,CAAA;AAEF;;;;;;GAMG;AACH,MAAa,sBAAsB;IAGjC,YACU,OAAe,EACf,OAAmB;QADnB,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAY;QAE3B,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,OAAO,KAAK,CAAA;IACpE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,QAAQ,CAAC,EACpB,IAAI,EACJ,oBAAoB,EACpB,MAAM,EACN,GAAG,GACuB;QAC1B,IAAI,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,iCAAiC,oBAAoB,EAAE,CAAC,CAAA;YACpE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,mBAAmB,EAAE;gBAC3D,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,IAAI;oBACJ,oBAAoB;oBACpB,MAAM;oBACN,GAAG;iBACJ,CAAC;aACH,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;gBAC1C,MAAM,IAAI,KAAK,CACb,+BAA+B;oBAC7B,WAAW,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,IAAI;oBACrD,kBAAkB,YAAY,IAAI,2BAA2B,EAAE,CAClE,CAAA;YACH,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA+B,CAAA;YAClE,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YAC9C,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAA;YAChD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;QAC3C,CAAC;IACH,CAAC;IAED,sEAAsE;IACtE,yEAAyE;IAClE,KAAK,CAAC,MAAM;QACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACvD,CAAC;CACF;AApED,wDAoEC"}
@@ -1,3 +1,5 @@
1
1
  export * from './CredentialTypeService';
2
+ export * from './InvitationService';
2
3
  export * from './MessageService';
3
4
  export * from './RevocationRegistryService';
5
+ export * from './TrustCredentialService';
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./CredentialTypeService"), exports);
18
+ __exportStar(require("./InvitationService"), exports);
18
19
  __exportStar(require("./MessageService"), exports);
19
20
  __exportStar(require("./RevocationRegistryService"), exports);
21
+ __exportStar(require("./TrustCredentialService"), exports);
20
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC;AACvC,mDAAgC;AAChC,8DAA2C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC;AACvC,sDAAmC;AACnC,mDAAgC;AAChC,8DAA2C;AAC3C,2DAAwC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@2060.io/vs-agent-client",
3
3
  "main": "build/index",
4
4
  "types": "build/index",
5
- "version": "1.6.0-dev.2",
5
+ "version": "1.6.0-dev.21",
6
6
  "files": [
7
7
  "build"
8
8
  ],
@@ -15,7 +15,7 @@
15
15
  "class-validator": "0.14.1",
16
16
  "express": "^4.18.1",
17
17
  "tslog": "^4.8.2",
18
- "@2060.io/vs-agent-model": "1.6.0-dev.2"
18
+ "@2060.io/vs-agent-model": "1.6.0-dev.21"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@nestjs/common": "^10.0.0",