@twin.org/identity-service 0.0.2-next.3 → 0.0.2-next.4

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.
@@ -998,7 +998,7 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
998
998
  response: {
999
999
  body: {
1000
1000
  verifiableCredential: {
1001
- "@context": ["https://www.w3.org/ns/credentials/v2", "https://schema.org"],
1001
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
1002
1002
  id: "https://example.com/credentials/3732",
1003
1003
  type: ["VerifiableCredential", "Person"],
1004
1004
  credentialSubject: {
@@ -1051,7 +1051,7 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1051
1051
  body: {
1052
1052
  revoked: false,
1053
1053
  verifiableCredential: {
1054
- "@context": ["https://www.w3.org/ns/credentials/v2", "https://schema.org"],
1054
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
1055
1055
  id: "https://example.com/credentials/3732",
1056
1056
  type: ["VerifiableCredential", "Person"],
1057
1057
  credentialSubject: {
@@ -1178,7 +1178,7 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1178
1178
  response: {
1179
1179
  body: {
1180
1180
  verifiablePresentation: {
1181
- "@context": ["https://www.w3.org/ns/credentials/v2", "https://schema.org"],
1181
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
1182
1182
  id: "presentationId",
1183
1183
  type: ["VerifiablePresentation", "Person"],
1184
1184
  verifiableCredential: ["eyJraWQiOi...D1Z3AQ"],
@@ -1222,7 +1222,7 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1222
1222
  body: {
1223
1223
  revoked: false,
1224
1224
  verifiablePresentation: {
1225
- "@context": ["https://www.w3.org/ns/credentials/v2", "https://schema.org"],
1225
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
1226
1226
  id: "presentationId",
1227
1227
  type: ["VerifiablePresentation", "Person"],
1228
1228
  verifiableCredential: ["eyJraWQiOi...D1Z3AQ"],
@@ -1257,8 +1257,8 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1257
1257
  proofType: "DataIntegrityProof",
1258
1258
  document: {
1259
1259
  "@context": [
1260
- "https://www.w3.org/ns/credentials/v2",
1261
- "https://www.w3.org/ns/credentials/examples/v2"
1260
+ "https://www.w3.org/2018/credentials/v1",
1261
+ "https://www.w3.org/2018/credentials/examples/v1"
1262
1262
  ],
1263
1263
  id: "urn:uuid:58172aac-d8ba-11ed-83dd-0b3aef56cc33",
1264
1264
  type: ["VerifiableCredential", "AlumniCredential"],
@@ -1317,8 +1317,8 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1317
1317
  body: {
1318
1318
  document: {
1319
1319
  "@context": [
1320
- "https://www.w3.org/ns/credentials/v2",
1321
- "https://www.w3.org/ns/credentials/examples/v2"
1320
+ "https://www.w3.org/2018/credentials/v1",
1321
+ "https://www.w3.org/2018/credentials/examples/v1"
1322
1322
  ],
1323
1323
  id: "urn:uuid:58172aac-d8ba-11ed-83dd-0b3aef56cc33",
1324
1324
  type: ["VerifiableCredential", "AlumniCredential"],
@@ -1500,7 +1500,10 @@ async function identityVerifiableCredentialCreate(httpRequestContext, componentN
1500
1500
  core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
1501
1501
  core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.verificationMethodId", request.pathParams.verificationMethodId);
1502
1502
  const component = core.ComponentFactory.get(componentName);
1503
- const result = await component.verifiableCredentialCreate(identityModels.DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), request.body.credentialId, request.body.subject, request.body.revocationIndex, httpRequestContext.userIdentity);
1503
+ const result = await component.verifiableCredentialCreate(identityModels.DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), request.body.credentialId, request.body.subject, {
1504
+ revocationIndex: request.body.revocationIndex,
1505
+ expirationDate: core.Coerce.date(request.body.expirationDate)
1506
+ }, httpRequestContext.userIdentity);
1504
1507
  return {
1505
1508
  body: result
1506
1509
  };
@@ -1798,19 +1801,21 @@ class IdentityService {
1798
1801
  * @param verificationMethodId The verification method id to use.
1799
1802
  * @param id The id of the credential.
1800
1803
  * @param subject The credential subject to store in the verifiable credential.
1801
- * @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
1804
+ * @param options Additional options for creating the verifiable credential.
1805
+ * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
1806
+ * @param options.expirationDate The date the verifiable credential is valid until.
1802
1807
  * @param controller The controller of the identity who can make changes.
1803
1808
  * @returns The created verifiable credential and its token.
1804
1809
  * @throws NotFoundError if the id can not be resolved.
1805
1810
  */
1806
- async verifiableCredentialCreate(verificationMethodId, id, subject, revocationIndex, controller) {
1811
+ async verifiableCredentialCreate(verificationMethodId, id, subject, options, controller) {
1807
1812
  core.Guards.stringValue(this.CLASS_NAME, "controller", controller);
1808
1813
  core.Urn.guard(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
1809
1814
  core.Guards.objectValue(this.CLASS_NAME, "subject", subject);
1810
1815
  try {
1811
1816
  const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
1812
1817
  const identityConnector = this.getConnectorByUri(idParts.id);
1813
- const service = await identityConnector.createVerifiableCredential(controller, verificationMethodId, id, subject, revocationIndex);
1818
+ const service = await identityConnector.createVerifiableCredential(controller, verificationMethodId, id, subject, options);
1814
1819
  return service;
1815
1820
  }
1816
1821
  catch (error) {
@@ -996,7 +996,7 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
996
996
  response: {
997
997
  body: {
998
998
  verifiableCredential: {
999
- "@context": ["https://www.w3.org/ns/credentials/v2", "https://schema.org"],
999
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
1000
1000
  id: "https://example.com/credentials/3732",
1001
1001
  type: ["VerifiableCredential", "Person"],
1002
1002
  credentialSubject: {
@@ -1049,7 +1049,7 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1049
1049
  body: {
1050
1050
  revoked: false,
1051
1051
  verifiableCredential: {
1052
- "@context": ["https://www.w3.org/ns/credentials/v2", "https://schema.org"],
1052
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
1053
1053
  id: "https://example.com/credentials/3732",
1054
1054
  type: ["VerifiableCredential", "Person"],
1055
1055
  credentialSubject: {
@@ -1176,7 +1176,7 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1176
1176
  response: {
1177
1177
  body: {
1178
1178
  verifiablePresentation: {
1179
- "@context": ["https://www.w3.org/ns/credentials/v2", "https://schema.org"],
1179
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
1180
1180
  id: "presentationId",
1181
1181
  type: ["VerifiablePresentation", "Person"],
1182
1182
  verifiableCredential: ["eyJraWQiOi...D1Z3AQ"],
@@ -1220,7 +1220,7 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1220
1220
  body: {
1221
1221
  revoked: false,
1222
1222
  verifiablePresentation: {
1223
- "@context": ["https://www.w3.org/ns/credentials/v2", "https://schema.org"],
1223
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
1224
1224
  id: "presentationId",
1225
1225
  type: ["VerifiablePresentation", "Person"],
1226
1226
  verifiableCredential: ["eyJraWQiOi...D1Z3AQ"],
@@ -1255,8 +1255,8 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1255
1255
  proofType: "DataIntegrityProof",
1256
1256
  document: {
1257
1257
  "@context": [
1258
- "https://www.w3.org/ns/credentials/v2",
1259
- "https://www.w3.org/ns/credentials/examples/v2"
1258
+ "https://www.w3.org/2018/credentials/v1",
1259
+ "https://www.w3.org/2018/credentials/examples/v1"
1260
1260
  ],
1261
1261
  id: "urn:uuid:58172aac-d8ba-11ed-83dd-0b3aef56cc33",
1262
1262
  type: ["VerifiableCredential", "AlumniCredential"],
@@ -1315,8 +1315,8 @@ function generateRestRoutesIdentity(baseRouteName, componentName) {
1315
1315
  body: {
1316
1316
  document: {
1317
1317
  "@context": [
1318
- "https://www.w3.org/ns/credentials/v2",
1319
- "https://www.w3.org/ns/credentials/examples/v2"
1318
+ "https://www.w3.org/2018/credentials/v1",
1319
+ "https://www.w3.org/2018/credentials/examples/v1"
1320
1320
  ],
1321
1321
  id: "urn:uuid:58172aac-d8ba-11ed-83dd-0b3aef56cc33",
1322
1322
  type: ["VerifiableCredential", "AlumniCredential"],
@@ -1498,7 +1498,10 @@ async function identityVerifiableCredentialCreate(httpRequestContext, componentN
1498
1498
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
1499
1499
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.verificationMethodId", request.pathParams.verificationMethodId);
1500
1500
  const component = ComponentFactory.get(componentName);
1501
- const result = await component.verifiableCredentialCreate(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), request.body.credentialId, request.body.subject, request.body.revocationIndex, httpRequestContext.userIdentity);
1501
+ const result = await component.verifiableCredentialCreate(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), request.body.credentialId, request.body.subject, {
1502
+ revocationIndex: request.body.revocationIndex,
1503
+ expirationDate: Coerce.date(request.body.expirationDate)
1504
+ }, httpRequestContext.userIdentity);
1502
1505
  return {
1503
1506
  body: result
1504
1507
  };
@@ -1796,19 +1799,21 @@ class IdentityService {
1796
1799
  * @param verificationMethodId The verification method id to use.
1797
1800
  * @param id The id of the credential.
1798
1801
  * @param subject The credential subject to store in the verifiable credential.
1799
- * @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
1802
+ * @param options Additional options for creating the verifiable credential.
1803
+ * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
1804
+ * @param options.expirationDate The date the verifiable credential is valid until.
1800
1805
  * @param controller The controller of the identity who can make changes.
1801
1806
  * @returns The created verifiable credential and its token.
1802
1807
  * @throws NotFoundError if the id can not be resolved.
1803
1808
  */
1804
- async verifiableCredentialCreate(verificationMethodId, id, subject, revocationIndex, controller) {
1809
+ async verifiableCredentialCreate(verificationMethodId, id, subject, options, controller) {
1805
1810
  Guards.stringValue(this.CLASS_NAME, "controller", controller);
1806
1811
  Urn.guard(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
1807
1812
  Guards.objectValue(this.CLASS_NAME, "subject", subject);
1808
1813
  try {
1809
1814
  const idParts = DocumentHelper.parseId(verificationMethodId);
1810
1815
  const identityConnector = this.getConnectorByUri(idParts.id);
1811
- const service = await identityConnector.createVerifiableCredential(controller, verificationMethodId, id, subject, revocationIndex);
1816
+ const service = await identityConnector.createVerifiableCredential(controller, verificationMethodId, id, subject, options);
1812
1817
  return service;
1813
1818
  }
1814
1819
  catch (error) {
@@ -1,5 +1,5 @@
1
1
  import type { IHttpRequestContext, INoContentResponse, IRestRoute, ITag } from "@twin.org/api-models";
2
- import { type IIdentityRemoveRequest, type IIdentityCreateRequest, type IIdentityCreateResponse, type IIdentityProofCreateRequest, type IIdentityProofCreateResponse, type IIdentityProofVerifyRequest, type IIdentityProofVerifyResponse, type IIdentityServiceCreateRequest, type IIdentityServiceCreateResponse, type IIdentityServiceRemoveRequest, type IIdentityVerifiableCredentialCreateRequest, type IIdentityVerifiableCredentialCreateResponse, type IIdentityVerifiableCredentialRevokeRequest, type IIdentityVerifiableCredentialUnrevokeRequest, type IIdentityVerifiableCredentialVerifyRequest, type IIdentityVerifiableCredentialVerifyResponse, type IIdentityVerifiablePresentationCreateRequest, type IIdentityVerifiablePresentationCreateResponse, type IIdentityVerifiablePresentationVerifyRequest, type IIdentityVerifiablePresentationVerifyResponse, type IIdentityVerificationMethodCreateRequest, type IIdentityVerificationMethodCreateResponse, type IIdentityVerificationMethodRemoveRequest } from "@twin.org/identity-models";
2
+ import { type IIdentityCreateRequest, type IIdentityCreateResponse, type IIdentityProofCreateRequest, type IIdentityProofCreateResponse, type IIdentityProofVerifyRequest, type IIdentityProofVerifyResponse, type IIdentityRemoveRequest, type IIdentityServiceCreateRequest, type IIdentityServiceCreateResponse, type IIdentityServiceRemoveRequest, type IIdentityVerifiableCredentialCreateRequest, type IIdentityVerifiableCredentialCreateResponse, type IIdentityVerifiableCredentialRevokeRequest, type IIdentityVerifiableCredentialUnrevokeRequest, type IIdentityVerifiableCredentialVerifyRequest, type IIdentityVerifiableCredentialVerifyResponse, type IIdentityVerifiablePresentationCreateRequest, type IIdentityVerifiablePresentationCreateResponse, type IIdentityVerifiablePresentationVerifyRequest, type IIdentityVerifiablePresentationVerifyResponse, type IIdentityVerificationMethodCreateRequest, type IIdentityVerificationMethodCreateResponse, type IIdentityVerificationMethodRemoveRequest } from "@twin.org/identity-models";
3
3
  /**
4
4
  * The tag to associate with the routes.
5
5
  */
@@ -73,12 +73,17 @@ export declare class IdentityService implements IIdentityComponent {
73
73
  * @param verificationMethodId The verification method id to use.
74
74
  * @param id The id of the credential.
75
75
  * @param subject The credential subject to store in the verifiable credential.
76
- * @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
76
+ * @param options Additional options for creating the verifiable credential.
77
+ * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
78
+ * @param options.expirationDate The date the verifiable credential is valid until.
77
79
  * @param controller The controller of the identity who can make changes.
78
80
  * @returns The created verifiable credential and its token.
79
81
  * @throws NotFoundError if the id can not be resolved.
80
82
  */
81
- verifiableCredentialCreate(verificationMethodId: string, id: string | undefined, subject: IJsonLdNodeObject, revocationIndex?: number, controller?: string): Promise<{
83
+ verifiableCredentialCreate(verificationMethodId: string, id: string | undefined, subject: IJsonLdNodeObject, options?: {
84
+ revocationIndex?: number;
85
+ expirationDate?: Date;
86
+ }, controller?: string): Promise<{
82
87
  verifiableCredential: IDidVerifiableCredential;
83
88
  jwt: string;
84
89
  }>;
package/docs/changelog.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @twin.org/identity-service - Changelog
2
2
 
3
+ ## [0.0.2-next.4](https://github.com/twinfoundation/identity/compare/identity-service-v0.0.2-next.3...identity-service-v0.0.2-next.4) (2025-09-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * add expiration date option to vc creation ([73e05e1](https://github.com/twinfoundation/identity/commit/73e05e1ae61112c7e056889969751f4ff82d9f29))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/identity-models bumped from 0.0.2-next.3 to 0.0.2-next.4
16
+ * @twin.org/identity-connector-entity-storage bumped from 0.0.2-next.3 to 0.0.2-next.4
17
+
3
18
  ## [0.0.2-next.3](https://github.com/twinfoundation/identity/compare/identity-service-v0.0.2-next.2...identity-service-v0.0.2-next.3) (2025-08-29)
4
19
 
5
20
 
@@ -828,7 +828,7 @@
828
828
  "value": {
829
829
  "verifiableCredential": {
830
830
  "@context": [
831
- "https://www.w3.org/ns/credentials/v2",
831
+ "https://www.w3.org/2018/credentials/v1",
832
832
  "https://schema.org"
833
833
  ],
834
834
  "id": "https://example.com/credentials/3732",
@@ -948,7 +948,7 @@
948
948
  "revoked": false,
949
949
  "verifiableCredential": {
950
950
  "@context": [
951
- "https://www.w3.org/ns/credentials/v2",
951
+ "https://www.w3.org/2018/credentials/v1",
952
952
  "https://schema.org"
953
953
  ],
954
954
  "id": "https://example.com/credentials/3732",
@@ -1275,7 +1275,7 @@
1275
1275
  "value": {
1276
1276
  "verifiablePresentation": {
1277
1277
  "@context": [
1278
- "https://www.w3.org/ns/credentials/v2",
1278
+ "https://www.w3.org/2018/credentials/v1",
1279
1279
  "https://schema.org"
1280
1280
  ],
1281
1281
  "id": "presentationId",
@@ -1388,7 +1388,7 @@
1388
1388
  "revoked": false,
1389
1389
  "verifiablePresentation": {
1390
1390
  "@context": [
1391
- "https://www.w3.org/ns/credentials/v2",
1391
+ "https://www.w3.org/2018/credentials/v1",
1392
1392
  "https://schema.org"
1393
1393
  ],
1394
1394
  "id": "presentationId",
@@ -1488,8 +1488,8 @@
1488
1488
  "proofType": "DataIntegrityProof",
1489
1489
  "document": {
1490
1490
  "@context": [
1491
- "https://www.w3.org/ns/credentials/v2",
1492
- "https://www.w3.org/ns/credentials/examples/v2"
1491
+ "https://www.w3.org/2018/credentials/v1",
1492
+ "https://www.w3.org/2018/credentials/examples/v1"
1493
1493
  ],
1494
1494
  "id": "urn:uuid:58172aac-d8ba-11ed-83dd-0b3aef56cc33",
1495
1495
  "type": [
@@ -1618,8 +1618,8 @@
1618
1618
  "value": {
1619
1619
  "document": {
1620
1620
  "@context": [
1621
- "https://www.w3.org/ns/credentials/v2",
1622
- "https://www.w3.org/ns/credentials/examples/v2"
1621
+ "https://www.w3.org/2018/credentials/v1",
1622
+ "https://www.w3.org/2018/credentials/examples/v1"
1623
1623
  ],
1624
1624
  "id": "urn:uuid:58172aac-d8ba-11ed-83dd-0b3aef56cc33",
1625
1625
  "type": [
@@ -2745,6 +2745,10 @@
2745
2745
  "revocationIndex": {
2746
2746
  "type": "number",
2747
2747
  "description": "The bitmap revocation index of the credential, if undefined will not have revocation status."
2748
+ },
2749
+ "expirationDate": {
2750
+ "type": "string",
2751
+ "description": "The date the verifiable credential is valid until."
2748
2752
  }
2749
2753
  },
2750
2754
  "required": [
@@ -3222,11 +3226,6 @@
3222
3226
  "name"
3223
3227
  ],
3224
3228
  "description": "The body which contains the error."
3225
- },
3226
- "ProofSignerVerifier": {
3227
- "type": "object",
3228
- "additionalProperties": false,
3229
- "description": "Interface describing a proof signer and verifier."
3230
3229
  }
3231
3230
  },
3232
3231
  "securitySchemes": {
@@ -288,7 +288,7 @@ NotFoundError if the id can not be resolved.
288
288
 
289
289
  ### verifiableCredentialCreate()
290
290
 
291
- > **verifiableCredentialCreate**(`verificationMethodId`, `id`, `subject`, `revocationIndex?`, `controller?`): `Promise`\<\{ `verifiableCredential`: `IDidVerifiableCredential`; `jwt`: `string`; \}\>
291
+ > **verifiableCredentialCreate**(`verificationMethodId`, `id`, `subject`, `options?`, `controller?`): `Promise`\<\{ `verifiableCredential`: `IDidVerifiableCredential`; `jwt`: `string`; \}\>
292
292
 
293
293
  Create a verifiable credential for a verification method.
294
294
 
@@ -312,12 +312,22 @@ The id of the credential.
312
312
 
313
313
  The credential subject to store in the verifiable credential.
314
314
 
315
- ##### revocationIndex?
315
+ ##### options?
316
+
317
+ Additional options for creating the verifiable credential.
318
+
319
+ ###### revocationIndex?
316
320
 
317
321
  `number`
318
322
 
319
323
  The bitmap revocation index of the credential, if undefined will not have revocation status.
320
324
 
325
+ ###### expirationDate?
326
+
327
+ `Date`
328
+
329
+ The date the verifiable credential is valid until.
330
+
321
331
  ##### controller?
322
332
 
323
333
  `string`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-service",
3
- "version": "0.0.2-next.3",
3
+ "version": "0.0.2-next.4",
4
4
  "description": "Identity contract implementation and REST endpoint definitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,8 +22,8 @@
22
22
  "@twin.org/entity": "next",
23
23
  "@twin.org/entity-storage-connector-memory": "next",
24
24
  "@twin.org/entity-storage-models": "next",
25
- "@twin.org/identity-connector-entity-storage": "0.0.2-next.3",
26
- "@twin.org/identity-models": "0.0.2-next.3",
25
+ "@twin.org/identity-connector-entity-storage": "0.0.2-next.4",
26
+ "@twin.org/identity-models": "0.0.2-next.4",
27
27
  "@twin.org/standards-w3c-did": "next",
28
28
  "@twin.org/vault-connector-entity-storage": "next",
29
29
  "@twin.org/vault-models": "next",