@twin.org/identity-connector-entity-storage 0.0.1-next.23 → 0.0.1-next.24

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.
@@ -251,8 +251,8 @@ class EntityStorageIdentityConnector {
251
251
  core.Guards.stringValue(this.CLASS_NAME, "controller", controller);
252
252
  core.Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
253
253
  try {
254
- const idParts = identityModels.DocumentHelper.parse(verificationMethodId);
255
- if (core.Is.empty(idParts.hash)) {
254
+ const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
255
+ if (core.Is.empty(idParts.fragment)) {
256
256
  throw new core.NotFoundError(this.CLASS_NAME, "missingDid", verificationMethodId);
257
257
  }
258
258
  const didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -300,8 +300,18 @@ class EntityStorageIdentityConnector {
300
300
  core.Guards.stringValue(this.CLASS_NAME, "controller", controller);
301
301
  core.Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
302
302
  core.Guards.stringValue(this.CLASS_NAME, "serviceId", serviceId);
303
- core.Guards.stringValue(this.CLASS_NAME, "serviceType", serviceType);
304
- core.Guards.stringValue(this.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
303
+ if (core.Is.array(serviceType)) {
304
+ core.Guards.arrayValue(this.CLASS_NAME, "serviceType", serviceType);
305
+ }
306
+ else {
307
+ core.Guards.stringValue(this.CLASS_NAME, "serviceType", serviceType);
308
+ }
309
+ if (core.Is.array(serviceEndpoint)) {
310
+ core.Guards.arrayValue(this.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
311
+ }
312
+ else {
313
+ core.Guards.stringValue(this.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
314
+ }
305
315
  try {
306
316
  const didIdentityDocument = await this._didDocumentEntityStorage.get(documentId);
307
317
  if (core.Is.undefined(didIdentityDocument)) {
@@ -341,8 +351,8 @@ class EntityStorageIdentityConnector {
341
351
  core.Guards.stringValue(this.CLASS_NAME, "controller", controller);
342
352
  core.Guards.stringValue(this.CLASS_NAME, "serviceId", serviceId);
343
353
  try {
344
- const idParts = identityModels.DocumentHelper.parse(serviceId);
345
- if (core.Is.empty(idParts.hash)) {
354
+ const idParts = identityModels.DocumentHelper.parseId(serviceId);
355
+ if (core.Is.empty(idParts.fragment)) {
346
356
  throw new core.NotFoundError(this.CLASS_NAME, "missingDid", serviceId);
347
357
  }
348
358
  const didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -374,21 +384,21 @@ class EntityStorageIdentityConnector {
374
384
  * @param controller The controller of the identity who can make changes.
375
385
  * @param verificationMethodId The verification method id to use.
376
386
  * @param id The id of the credential.
377
- * @param credential The credential to store in the verifiable credential.
387
+ * @param subject The credential subject to store in the verifiable credential.
378
388
  * @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
379
389
  * @returns The created verifiable credential and its token.
380
390
  * @throws NotFoundError if the id can not be resolved.
381
391
  */
382
- async createVerifiableCredential(controller, verificationMethodId, id, credential, revocationIndex) {
392
+ async createVerifiableCredential(controller, verificationMethodId, id, subject, revocationIndex) {
383
393
  core.Guards.stringValue(this.CLASS_NAME, "controller", controller);
384
394
  core.Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
385
- core.Guards.object(this.CLASS_NAME, "credential", credential);
395
+ core.Guards.object(this.CLASS_NAME, "subject", subject);
386
396
  if (!core.Is.undefined(revocationIndex)) {
387
397
  core.Guards.number(this.CLASS_NAME, "revocationIndex", revocationIndex);
388
398
  }
389
399
  try {
390
- const idParts = identityModels.DocumentHelper.parse(verificationMethodId);
391
- if (core.Is.empty(idParts.hash)) {
400
+ const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
401
+ if (core.Is.empty(idParts.fragment)) {
392
402
  throw new core.NotFoundError(this.CLASS_NAME, "missingDid", verificationMethodId);
393
403
  }
394
404
  const issuerIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -414,11 +424,13 @@ class EntityStorageIdentityConnector {
414
424
  });
415
425
  }
416
426
  const revocationService = issuerDidDocument.service?.find(s => s.id.endsWith("#revocation"));
417
- const credentialClone = core.ObjectHelper.clone(credential);
427
+ const subjectClone = core.ObjectHelper.clone(subject);
418
428
  const finalTypes = [standardsW3cDid.DidTypes.VerifiableCredential];
419
- const credContext = core.ObjectHelper.extractProperty(credentialClone, ["@context"]);
420
- const credId = core.ObjectHelper.extractProperty(credentialClone, ["@id", "id"], false);
421
- const credType = core.ObjectHelper.extractProperty(credentialClone, ["@type", "type"]);
429
+ const credContext = core.ObjectHelper.extractProperty(subjectClone, [
430
+ "@context"
431
+ ]);
432
+ const credId = core.ObjectHelper.extractProperty(subjectClone, ["@id", "id"], false);
433
+ const credType = core.ObjectHelper.extractProperty(subjectClone, ["@type", "type"]);
422
434
  if (core.Is.stringValue(credType)) {
423
435
  finalTypes.push(credType);
424
436
  }
@@ -426,7 +438,7 @@ class EntityStorageIdentityConnector {
426
438
  "@context": dataJsonLd.JsonLdProcessor.combineContexts(standardsW3cDid.DidContexts.ContextVCv2, credContext),
427
439
  id,
428
440
  type: finalTypes,
429
- credentialSubject: credentialClone,
441
+ credentialSubject: subjectClone,
430
442
  issuer: issuerDidDocument.id,
431
443
  issuanceDate: new Date().toISOString(),
432
444
  credentialStatus: revocationService && !core.Is.undefined(revocationIndex)
@@ -467,7 +479,7 @@ class EntityStorageIdentityConnector {
467
479
  vc: jwtVc
468
480
  };
469
481
  const signature = await web.Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (alg, key, payload) => {
470
- const sig = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.hash ?? ""), payload);
482
+ const sig = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? ""), payload);
471
483
  return sig;
472
484
  });
473
485
  return {
@@ -634,7 +646,7 @@ class EntityStorageIdentityConnector {
634
646
  /**
635
647
  * Create a verifiable presentation from the supplied verifiable credentials.
636
648
  * @param controller The controller of the identity who can make changes.
637
- * @param presentationMethodId The method to associate with the presentation.
649
+ * @param verificationMethodId The method to associate with the presentation.
638
650
  * @param presentationId The id of the presentation.
639
651
  * @param contexts The contexts for the data stored in the verifiable credential.
640
652
  * @param types The types for the data stored in the verifiable credential.
@@ -643,9 +655,9 @@ class EntityStorageIdentityConnector {
643
655
  * @returns The created verifiable presentation and its token.
644
656
  * @throws NotFoundError if the id can not be resolved.
645
657
  */
646
- async createVerifiablePresentation(controller, presentationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes) {
658
+ async createVerifiablePresentation(controller, verificationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes) {
647
659
  core.Guards.stringValue(this.CLASS_NAME, "controller", controller);
648
- core.Guards.stringValue(this.CLASS_NAME, "presentationMethodId", presentationMethodId);
660
+ core.Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
649
661
  if (core.Is.array(types)) {
650
662
  core.Guards.arrayValue(this.CLASS_NAME, "types", types);
651
663
  }
@@ -657,9 +669,9 @@ class EntityStorageIdentityConnector {
657
669
  core.Guards.integer(this.CLASS_NAME, "expiresInMinutes", expiresInMinutes);
658
670
  }
659
671
  try {
660
- const idParts = identityModels.DocumentHelper.parse(presentationMethodId);
661
- if (core.Is.empty(idParts.hash)) {
662
- throw new core.NotFoundError(this.CLASS_NAME, "missingDid", presentationMethodId);
672
+ const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
673
+ if (core.Is.empty(idParts.fragment)) {
674
+ throw new core.NotFoundError(this.CLASS_NAME, "missingDid", verificationMethodId);
663
675
  }
664
676
  const holderIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
665
677
  if (core.Is.undefined(holderIdentityDocument)) {
@@ -670,17 +682,17 @@ class EntityStorageIdentityConnector {
670
682
  const methods = this.getAllMethods(holderDidDocument);
671
683
  const methodAndArray = methods.find(m => {
672
684
  if (core.Is.string(m.method)) {
673
- return m.method === presentationMethodId;
685
+ return m.method === verificationMethodId;
674
686
  }
675
- return m.method.id === presentationMethodId;
687
+ return m.method.id === verificationMethodId;
676
688
  });
677
689
  if (!methodAndArray) {
678
- throw new core.GeneralError(this.CLASS_NAME, "methodMissing", { method: presentationMethodId });
690
+ throw new core.GeneralError(this.CLASS_NAME, "methodMissing", { method: verificationMethodId });
679
691
  }
680
692
  const didMethod = methodAndArray.method;
681
693
  if (!core.Is.stringValue(didMethod.publicKeyJwk?.x)) {
682
694
  throw new core.GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
683
- method: presentationMethodId
695
+ method: verificationMethodId
684
696
  });
685
697
  }
686
698
  const finalTypes = [standardsW3cDid.DidTypes.VerifiablePresentation];
@@ -717,7 +729,7 @@ class EntityStorageIdentityConnector {
717
729
  jwtPayload.exp = Math.floor(Date.now() / 1000) + expiresInSeconds;
718
730
  }
719
731
  const signature = await web.Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (alg, key, payload) => {
720
- const sig = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.hash ?? ""), payload);
732
+ const sig = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? ""), payload);
721
733
  return sig;
722
734
  });
723
735
  return {
@@ -810,8 +822,8 @@ class EntityStorageIdentityConnector {
810
822
  core.Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
811
823
  core.Guards.uint8Array(this.CLASS_NAME, "bytes", bytes);
812
824
  try {
813
- const idParts = identityModels.DocumentHelper.parse(verificationMethodId);
814
- if (core.Is.empty(idParts.hash)) {
825
+ const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
826
+ if (core.Is.empty(idParts.fragment)) {
815
827
  throw new core.NotFoundError(this.CLASS_NAME, "missingDid", verificationMethodId);
816
828
  }
817
829
  const didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -836,7 +848,7 @@ class EntityStorageIdentityConnector {
836
848
  method: verificationMethodId
837
849
  });
838
850
  }
839
- const signature = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(didDocument.id, idParts.hash ?? ""), bytes);
851
+ const signature = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(didDocument.id, idParts.fragment ?? ""), bytes);
840
852
  return {
841
853
  "@context": standardsW3cDid.DidContexts.ContextVCDataIntegrity,
842
854
  type: standardsW3cDid.DidTypes.DataIntegrityProof,
@@ -871,8 +883,8 @@ class EntityStorageIdentityConnector {
871
883
  if (proof.cryptosuite !== standardsW3cDid.DidCryptoSuites.EdDSAJcs2022) {
872
884
  throw new core.GeneralError(this.CLASS_NAME, "cryptoSuite", { cryptosuite: proof.cryptosuite });
873
885
  }
874
- const idParts = identityModels.DocumentHelper.parse(proof.verificationMethod);
875
- if (core.Is.empty(idParts.hash)) {
886
+ const idParts = identityModels.DocumentHelper.parseId(proof.verificationMethod);
887
+ if (core.Is.empty(idParts.fragment)) {
876
888
  throw new core.NotFoundError(this.CLASS_NAME, "missingDid", proof.verificationMethod);
877
889
  }
878
890
  const didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -899,7 +911,7 @@ class EntityStorageIdentityConnector {
899
911
  method: proof.verificationMethodId
900
912
  });
901
913
  }
902
- return this._vaultConnector.verify(EntityStorageIdentityConnector.buildVaultKey(didIdentityDocument.id, idParts.hash), bytes, core.Converter.base58ToBytes(proof.proofValue));
914
+ return this._vaultConnector.verify(EntityStorageIdentityConnector.buildVaultKey(didIdentityDocument.id, idParts.fragment), bytes, core.Converter.base58ToBytes(proof.proofValue));
903
915
  }
904
916
  catch (error) {
905
917
  throw new core.GeneralError(this.CLASS_NAME, "verifyProofFailed", undefined, error);
@@ -249,8 +249,8 @@ class EntityStorageIdentityConnector {
249
249
  Guards.stringValue(this.CLASS_NAME, "controller", controller);
250
250
  Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
251
251
  try {
252
- const idParts = DocumentHelper.parse(verificationMethodId);
253
- if (Is.empty(idParts.hash)) {
252
+ const idParts = DocumentHelper.parseId(verificationMethodId);
253
+ if (Is.empty(idParts.fragment)) {
254
254
  throw new NotFoundError(this.CLASS_NAME, "missingDid", verificationMethodId);
255
255
  }
256
256
  const didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -298,8 +298,18 @@ class EntityStorageIdentityConnector {
298
298
  Guards.stringValue(this.CLASS_NAME, "controller", controller);
299
299
  Guards.stringValue(this.CLASS_NAME, "documentId", documentId);
300
300
  Guards.stringValue(this.CLASS_NAME, "serviceId", serviceId);
301
- Guards.stringValue(this.CLASS_NAME, "serviceType", serviceType);
302
- Guards.stringValue(this.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
301
+ if (Is.array(serviceType)) {
302
+ Guards.arrayValue(this.CLASS_NAME, "serviceType", serviceType);
303
+ }
304
+ else {
305
+ Guards.stringValue(this.CLASS_NAME, "serviceType", serviceType);
306
+ }
307
+ if (Is.array(serviceEndpoint)) {
308
+ Guards.arrayValue(this.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
309
+ }
310
+ else {
311
+ Guards.stringValue(this.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
312
+ }
303
313
  try {
304
314
  const didIdentityDocument = await this._didDocumentEntityStorage.get(documentId);
305
315
  if (Is.undefined(didIdentityDocument)) {
@@ -339,8 +349,8 @@ class EntityStorageIdentityConnector {
339
349
  Guards.stringValue(this.CLASS_NAME, "controller", controller);
340
350
  Guards.stringValue(this.CLASS_NAME, "serviceId", serviceId);
341
351
  try {
342
- const idParts = DocumentHelper.parse(serviceId);
343
- if (Is.empty(idParts.hash)) {
352
+ const idParts = DocumentHelper.parseId(serviceId);
353
+ if (Is.empty(idParts.fragment)) {
344
354
  throw new NotFoundError(this.CLASS_NAME, "missingDid", serviceId);
345
355
  }
346
356
  const didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -372,21 +382,21 @@ class EntityStorageIdentityConnector {
372
382
  * @param controller The controller of the identity who can make changes.
373
383
  * @param verificationMethodId The verification method id to use.
374
384
  * @param id The id of the credential.
375
- * @param credential The credential to store in the verifiable credential.
385
+ * @param subject The credential subject to store in the verifiable credential.
376
386
  * @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
377
387
  * @returns The created verifiable credential and its token.
378
388
  * @throws NotFoundError if the id can not be resolved.
379
389
  */
380
- async createVerifiableCredential(controller, verificationMethodId, id, credential, revocationIndex) {
390
+ async createVerifiableCredential(controller, verificationMethodId, id, subject, revocationIndex) {
381
391
  Guards.stringValue(this.CLASS_NAME, "controller", controller);
382
392
  Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
383
- Guards.object(this.CLASS_NAME, "credential", credential);
393
+ Guards.object(this.CLASS_NAME, "subject", subject);
384
394
  if (!Is.undefined(revocationIndex)) {
385
395
  Guards.number(this.CLASS_NAME, "revocationIndex", revocationIndex);
386
396
  }
387
397
  try {
388
- const idParts = DocumentHelper.parse(verificationMethodId);
389
- if (Is.empty(idParts.hash)) {
398
+ const idParts = DocumentHelper.parseId(verificationMethodId);
399
+ if (Is.empty(idParts.fragment)) {
390
400
  throw new NotFoundError(this.CLASS_NAME, "missingDid", verificationMethodId);
391
401
  }
392
402
  const issuerIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -412,11 +422,13 @@ class EntityStorageIdentityConnector {
412
422
  });
413
423
  }
414
424
  const revocationService = issuerDidDocument.service?.find(s => s.id.endsWith("#revocation"));
415
- const credentialClone = ObjectHelper.clone(credential);
425
+ const subjectClone = ObjectHelper.clone(subject);
416
426
  const finalTypes = [DidTypes.VerifiableCredential];
417
- const credContext = ObjectHelper.extractProperty(credentialClone, ["@context"]);
418
- const credId = ObjectHelper.extractProperty(credentialClone, ["@id", "id"], false);
419
- const credType = ObjectHelper.extractProperty(credentialClone, ["@type", "type"]);
427
+ const credContext = ObjectHelper.extractProperty(subjectClone, [
428
+ "@context"
429
+ ]);
430
+ const credId = ObjectHelper.extractProperty(subjectClone, ["@id", "id"], false);
431
+ const credType = ObjectHelper.extractProperty(subjectClone, ["@type", "type"]);
420
432
  if (Is.stringValue(credType)) {
421
433
  finalTypes.push(credType);
422
434
  }
@@ -424,7 +436,7 @@ class EntityStorageIdentityConnector {
424
436
  "@context": JsonLdProcessor.combineContexts(DidContexts.ContextVCv2, credContext),
425
437
  id,
426
438
  type: finalTypes,
427
- credentialSubject: credentialClone,
439
+ credentialSubject: subjectClone,
428
440
  issuer: issuerDidDocument.id,
429
441
  issuanceDate: new Date().toISOString(),
430
442
  credentialStatus: revocationService && !Is.undefined(revocationIndex)
@@ -465,7 +477,7 @@ class EntityStorageIdentityConnector {
465
477
  vc: jwtVc
466
478
  };
467
479
  const signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (alg, key, payload) => {
468
- const sig = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.hash ?? ""), payload);
480
+ const sig = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? ""), payload);
469
481
  return sig;
470
482
  });
471
483
  return {
@@ -632,7 +644,7 @@ class EntityStorageIdentityConnector {
632
644
  /**
633
645
  * Create a verifiable presentation from the supplied verifiable credentials.
634
646
  * @param controller The controller of the identity who can make changes.
635
- * @param presentationMethodId The method to associate with the presentation.
647
+ * @param verificationMethodId The method to associate with the presentation.
636
648
  * @param presentationId The id of the presentation.
637
649
  * @param contexts The contexts for the data stored in the verifiable credential.
638
650
  * @param types The types for the data stored in the verifiable credential.
@@ -641,9 +653,9 @@ class EntityStorageIdentityConnector {
641
653
  * @returns The created verifiable presentation and its token.
642
654
  * @throws NotFoundError if the id can not be resolved.
643
655
  */
644
- async createVerifiablePresentation(controller, presentationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes) {
656
+ async createVerifiablePresentation(controller, verificationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes) {
645
657
  Guards.stringValue(this.CLASS_NAME, "controller", controller);
646
- Guards.stringValue(this.CLASS_NAME, "presentationMethodId", presentationMethodId);
658
+ Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
647
659
  if (Is.array(types)) {
648
660
  Guards.arrayValue(this.CLASS_NAME, "types", types);
649
661
  }
@@ -655,9 +667,9 @@ class EntityStorageIdentityConnector {
655
667
  Guards.integer(this.CLASS_NAME, "expiresInMinutes", expiresInMinutes);
656
668
  }
657
669
  try {
658
- const idParts = DocumentHelper.parse(presentationMethodId);
659
- if (Is.empty(idParts.hash)) {
660
- throw new NotFoundError(this.CLASS_NAME, "missingDid", presentationMethodId);
670
+ const idParts = DocumentHelper.parseId(verificationMethodId);
671
+ if (Is.empty(idParts.fragment)) {
672
+ throw new NotFoundError(this.CLASS_NAME, "missingDid", verificationMethodId);
661
673
  }
662
674
  const holderIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
663
675
  if (Is.undefined(holderIdentityDocument)) {
@@ -668,17 +680,17 @@ class EntityStorageIdentityConnector {
668
680
  const methods = this.getAllMethods(holderDidDocument);
669
681
  const methodAndArray = methods.find(m => {
670
682
  if (Is.string(m.method)) {
671
- return m.method === presentationMethodId;
683
+ return m.method === verificationMethodId;
672
684
  }
673
- return m.method.id === presentationMethodId;
685
+ return m.method.id === verificationMethodId;
674
686
  });
675
687
  if (!methodAndArray) {
676
- throw new GeneralError(this.CLASS_NAME, "methodMissing", { method: presentationMethodId });
688
+ throw new GeneralError(this.CLASS_NAME, "methodMissing", { method: verificationMethodId });
677
689
  }
678
690
  const didMethod = methodAndArray.method;
679
691
  if (!Is.stringValue(didMethod.publicKeyJwk?.x)) {
680
692
  throw new GeneralError(this.CLASS_NAME, "publicKeyJwkMissing", {
681
- method: presentationMethodId
693
+ method: verificationMethodId
682
694
  });
683
695
  }
684
696
  const finalTypes = [DidTypes.VerifiablePresentation];
@@ -715,7 +727,7 @@ class EntityStorageIdentityConnector {
715
727
  jwtPayload.exp = Math.floor(Date.now() / 1000) + expiresInSeconds;
716
728
  }
717
729
  const signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (alg, key, payload) => {
718
- const sig = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.hash ?? ""), payload);
730
+ const sig = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? ""), payload);
719
731
  return sig;
720
732
  });
721
733
  return {
@@ -808,8 +820,8 @@ class EntityStorageIdentityConnector {
808
820
  Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
809
821
  Guards.uint8Array(this.CLASS_NAME, "bytes", bytes);
810
822
  try {
811
- const idParts = DocumentHelper.parse(verificationMethodId);
812
- if (Is.empty(idParts.hash)) {
823
+ const idParts = DocumentHelper.parseId(verificationMethodId);
824
+ if (Is.empty(idParts.fragment)) {
813
825
  throw new NotFoundError(this.CLASS_NAME, "missingDid", verificationMethodId);
814
826
  }
815
827
  const didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -834,7 +846,7 @@ class EntityStorageIdentityConnector {
834
846
  method: verificationMethodId
835
847
  });
836
848
  }
837
- const signature = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(didDocument.id, idParts.hash ?? ""), bytes);
849
+ const signature = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(didDocument.id, idParts.fragment ?? ""), bytes);
838
850
  return {
839
851
  "@context": DidContexts.ContextVCDataIntegrity,
840
852
  type: DidTypes.DataIntegrityProof,
@@ -869,8 +881,8 @@ class EntityStorageIdentityConnector {
869
881
  if (proof.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {
870
882
  throw new GeneralError(this.CLASS_NAME, "cryptoSuite", { cryptosuite: proof.cryptosuite });
871
883
  }
872
- const idParts = DocumentHelper.parse(proof.verificationMethod);
873
- if (Is.empty(idParts.hash)) {
884
+ const idParts = DocumentHelper.parseId(proof.verificationMethod);
885
+ if (Is.empty(idParts.fragment)) {
874
886
  throw new NotFoundError(this.CLASS_NAME, "missingDid", proof.verificationMethod);
875
887
  }
876
888
  const didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);
@@ -897,7 +909,7 @@ class EntityStorageIdentityConnector {
897
909
  method: proof.verificationMethodId
898
910
  });
899
911
  }
900
- return this._vaultConnector.verify(EntityStorageIdentityConnector.buildVaultKey(didIdentityDocument.id, idParts.hash), bytes, Converter.base58ToBytes(proof.proofValue));
912
+ return this._vaultConnector.verify(EntityStorageIdentityConnector.buildVaultKey(didIdentityDocument.id, idParts.fragment), bytes, Converter.base58ToBytes(proof.proofValue));
901
913
  }
902
914
  catch (error) {
903
915
  throw new GeneralError(this.CLASS_NAME, "verifyProofFailed", undefined, error);
@@ -55,7 +55,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
55
55
  * @returns The service.
56
56
  * @throws NotFoundError if the id can not be resolved.
57
57
  */
58
- addService(controller: string, documentId: string, serviceId: string, serviceType: string, serviceEndpoint: string): Promise<IDidService>;
58
+ addService(controller: string, documentId: string, serviceId: string, serviceType: string | string[], serviceEndpoint: string | string[]): Promise<IDidService>;
59
59
  /**
60
60
  * Remove a service from the document.
61
61
  * @param controller The controller of the identity who can make changes.
@@ -69,12 +69,12 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
69
69
  * @param controller The controller of the identity who can make changes.
70
70
  * @param verificationMethodId The verification method id to use.
71
71
  * @param id The id of the credential.
72
- * @param credential The credential to store in the verifiable credential.
72
+ * @param subject The credential subject to store in the verifiable credential.
73
73
  * @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
74
74
  * @returns The created verifiable credential and its token.
75
75
  * @throws NotFoundError if the id can not be resolved.
76
76
  */
77
- createVerifiableCredential(controller: string, verificationMethodId: string, id: string | undefined, credential: IJsonLdNodeObject, revocationIndex?: number): Promise<{
77
+ createVerifiableCredential(controller: string, verificationMethodId: string, id: string | undefined, subject: IJsonLdNodeObject, revocationIndex?: number): Promise<{
78
78
  verifiableCredential: IDidVerifiableCredential;
79
79
  jwt: string;
80
80
  }>;
@@ -106,7 +106,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
106
106
  /**
107
107
  * Create a verifiable presentation from the supplied verifiable credentials.
108
108
  * @param controller The controller of the identity who can make changes.
109
- * @param presentationMethodId The method to associate with the presentation.
109
+ * @param verificationMethodId The method to associate with the presentation.
110
110
  * @param presentationId The id of the presentation.
111
111
  * @param contexts The contexts for the data stored in the verifiable credential.
112
112
  * @param types The types for the data stored in the verifiable credential.
@@ -115,7 +115,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
115
115
  * @returns The created verifiable presentation and its token.
116
116
  * @throws NotFoundError if the id can not be resolved.
117
117
  */
118
- createVerifiablePresentation(controller: string, presentationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], expiresInMinutes?: number): Promise<{
118
+ createVerifiablePresentation(controller: string, verificationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], expiresInMinutes?: number): Promise<{
119
119
  verifiablePresentation: IDidVerifiablePresentation;
120
120
  jwt: string;
121
121
  }>;
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/identity-connector-entity-storage- Changelog
2
2
 
3
- ## v0.0.1-next.23
3
+ ## v0.0.1-next.24
4
4
 
5
5
  - Initial Release
@@ -194,16 +194,16 @@ The id of the service.
194
194
 
195
195
  ##### serviceType
196
196
 
197
- `string`
198
-
199
197
  The type of the service.
200
198
 
201
- ##### serviceEndpoint
199
+ `string` | `string`[]
202
200
 
203
- `string`
201
+ ##### serviceEndpoint
204
202
 
205
203
  The endpoint for the service.
206
204
 
205
+ `string` | `string`[]
206
+
207
207
  #### Returns
208
208
 
209
209
  `Promise`\<`IDidService`\>
@@ -258,7 +258,7 @@ NotFoundError if the id can not be resolved.
258
258
 
259
259
  ### createVerifiableCredential()
260
260
 
261
- > **createVerifiableCredential**(`controller`, `verificationMethodId`, `id`, `credential`, `revocationIndex`?): `Promise`\<\{ `verifiableCredential`: `IDidVerifiableCredential`; `jwt`: `string`; \}\>
261
+ > **createVerifiableCredential**(`controller`, `verificationMethodId`, `id`, `subject`, `revocationIndex`?): `Promise`\<\{ `verifiableCredential`: `IDidVerifiableCredential`; `jwt`: `string`; \}\>
262
262
 
263
263
  Create a verifiable credential for a verification method.
264
264
 
@@ -282,11 +282,11 @@ The id of the credential.
282
282
 
283
283
  `undefined` | `string`
284
284
 
285
- ##### credential
285
+ ##### subject
286
286
 
287
287
  `IJsonLdNodeObject`
288
288
 
289
- The credential to store in the verifiable credential.
289
+ The credential subject to store in the verifiable credential.
290
290
 
291
291
  ##### revocationIndex?
292
292
 
@@ -414,7 +414,7 @@ Nothing.
414
414
 
415
415
  ### createVerifiablePresentation()
416
416
 
417
- > **createVerifiablePresentation**(`controller`, `presentationMethodId`, `presentationId`, `contexts`, `types`, `verifiableCredentials`, `expiresInMinutes`?): `Promise`\<\{ `verifiablePresentation`: `IDidVerifiablePresentation`; `jwt`: `string`; \}\>
417
+ > **createVerifiablePresentation**(`controller`, `verificationMethodId`, `presentationId`, `contexts`, `types`, `verifiableCredentials`, `expiresInMinutes`?): `Promise`\<\{ `verifiablePresentation`: `IDidVerifiablePresentation`; `jwt`: `string`; \}\>
418
418
 
419
419
  Create a verifiable presentation from the supplied verifiable credentials.
420
420
 
@@ -426,7 +426,7 @@ Create a verifiable presentation from the supplied verifiable credentials.
426
426
 
427
427
  The controller of the identity who can make changes.
428
428
 
429
- ##### presentationMethodId
429
+ ##### verificationMethodId
430
430
 
431
431
  `string`
432
432
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-connector-entity-storage",
3
- "version": "0.0.1-next.23",
3
+ "version": "0.0.1-next.24",
4
4
  "description": "Identity connector implementation using entity storage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "@twin.org/data-core": "next",
20
20
  "@twin.org/data-json-ld": "next",
21
21
  "@twin.org/entity": "next",
22
- "@twin.org/identity-models": "0.0.1-next.23",
22
+ "@twin.org/identity-models": "0.0.1-next.24",
23
23
  "@twin.org/nameof": "next",
24
24
  "@twin.org/standards-w3c-did": "next",
25
25
  "@twin.org/vault-models": "next",