@truvity/sdk 0.28.3 → 0.28.5

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 (211) hide show
  1. package/api/resources/apiKeys/client/Client.d.ts +1 -0
  2. package/api/resources/apiKeys/client/Client.d.ts.map +1 -1
  3. package/api/resources/apiKeys/client/Client.js +16 -8
  4. package/api/resources/apiKeys/client/Client.js.map +1 -1
  5. package/api/resources/apiKeys/client/requests/ApiKeyCreateRequest.d.ts +8 -8
  6. package/api/resources/apiKeys/client/requests/ApiKeyCreateRequest.js.map +1 -1
  7. package/api/resources/apiKeys/client/requests/ApiKeyDeleteRequest.d.ts +8 -8
  8. package/api/resources/apiKeys/client/requests/ApiKeyDeleteRequest.js.map +1 -1
  9. package/api/resources/apiKeys/client/requests/ApiKeyRestoreRequest.d.ts +8 -8
  10. package/api/resources/apiKeys/client/requests/ApiKeyRestoreRequest.js.map +1 -1
  11. package/api/resources/apiKeys/client/requests/ApiKeyUpdateRequest.d.ts +8 -8
  12. package/api/resources/apiKeys/client/requests/ApiKeyUpdateRequest.js.map +1 -1
  13. package/api/resources/credentials/client/Client.d.ts +2 -0
  14. package/api/resources/credentials/client/Client.d.ts.map +1 -1
  15. package/api/resources/credentials/client/Client.js +26 -10
  16. package/api/resources/credentials/client/Client.js.map +1 -1
  17. package/api/resources/credentials/client/requests/CredentialDeleteRequest.d.ts +8 -8
  18. package/api/resources/credentials/client/requests/CredentialDeleteRequest.js.map +1 -1
  19. package/api/resources/credentials/client/requests/CredentialInput.d.ts +8 -8
  20. package/api/resources/credentials/client/requests/CredentialInput.js.map +1 -1
  21. package/api/resources/credentials/client/requests/CredentialRestoreRequest.d.ts +8 -8
  22. package/api/resources/credentials/client/requests/CredentialRestoreRequest.js.map +1 -1
  23. package/api/resources/credentials/client/requests/CredentialUploadRequest.d.ts +8 -8
  24. package/api/resources/credentials/client/requests/CredentialUploadRequest.js.map +1 -1
  25. package/api/resources/desk/client/Client.js +2 -2
  26. package/api/resources/desk/client/Client.js.map +1 -1
  27. package/api/resources/didcommMessages/client/Client.d.ts +3 -0
  28. package/api/resources/didcommMessages/client/Client.d.ts.map +1 -1
  29. package/api/resources/didcommMessages/client/Client.js +31 -7
  30. package/api/resources/didcommMessages/client/Client.js.map +1 -1
  31. package/api/resources/didcommMessages/client/requests/DidCommMessageSendInput.d.ts +8 -8
  32. package/api/resources/didcommMessages/client/requests/DidCommMessageSendInput.js.map +1 -1
  33. package/api/resources/didcommMessages/client/requests/DidcommMessageDeleteRequest.d.ts +8 -8
  34. package/api/resources/didcommMessages/client/requests/DidcommMessageDeleteRequest.js.map +1 -1
  35. package/api/resources/didcommMessages/client/requests/DidcommMessageRestoreRequest.d.ts +8 -8
  36. package/api/resources/didcommMessages/client/requests/DidcommMessageRestoreRequest.js.map +1 -1
  37. package/api/resources/dids/client/Client.js +1 -1
  38. package/api/resources/dids/client/Client.js.map +1 -1
  39. package/api/resources/drafts/client/Client.d.ts +2 -0
  40. package/api/resources/drafts/client/Client.d.ts.map +1 -1
  41. package/api/resources/drafts/client/Client.js +26 -10
  42. package/api/resources/drafts/client/Client.js.map +1 -1
  43. package/api/resources/drafts/client/requests/DraftCreateRequest.d.ts +8 -8
  44. package/api/resources/drafts/client/requests/DraftCreateRequest.js.map +1 -1
  45. package/api/resources/drafts/client/requests/DraftDeleteRequest.d.ts +8 -8
  46. package/api/resources/drafts/client/requests/DraftDeleteRequest.js.map +1 -1
  47. package/api/resources/drafts/client/requests/DraftRestoreRequest.d.ts +8 -8
  48. package/api/resources/drafts/client/requests/DraftRestoreRequest.js.map +1 -1
  49. package/api/resources/drafts/client/requests/DraftUpdateRequest.d.ts +8 -8
  50. package/api/resources/drafts/client/requests/DraftUpdateRequest.js.map +1 -1
  51. package/api/resources/files/client/Client.d.ts +2 -0
  52. package/api/resources/files/client/Client.d.ts.map +1 -1
  53. package/api/resources/files/client/Client.js +26 -10
  54. package/api/resources/files/client/Client.js.map +1 -1
  55. package/api/resources/files/client/requests/FileCreateRequest.d.ts +8 -8
  56. package/api/resources/files/client/requests/FileCreateRequest.js.map +1 -1
  57. package/api/resources/files/client/requests/FileDeleteRequest.d.ts +8 -8
  58. package/api/resources/files/client/requests/FileDeleteRequest.js.map +1 -1
  59. package/api/resources/files/client/requests/FileRestoreRequest.d.ts +8 -8
  60. package/api/resources/files/client/requests/FileRestoreRequest.js.map +1 -1
  61. package/api/resources/files/client/requests/FileUpdateRequest.d.ts +8 -8
  62. package/api/resources/files/client/requests/FileUpdateRequest.js.map +1 -1
  63. package/api/resources/files/client/requests/FileUploadRequest.d.ts +8 -8
  64. package/api/resources/files/client/requests/FileUploadRequest.js.map +1 -1
  65. package/api/resources/gdpr/client/Client.js +1 -1
  66. package/api/resources/gdpr/client/Client.js.map +1 -1
  67. package/api/resources/keys/client/Client.d.ts +4 -4
  68. package/api/resources/keys/client/Client.d.ts.map +1 -1
  69. package/api/resources/keys/client/Client.js +44 -16
  70. package/api/resources/keys/client/Client.js.map +1 -1
  71. package/api/resources/keys/client/requests/KeyDeleteRequest.d.ts +8 -8
  72. package/api/resources/keys/client/requests/KeyDeleteRequest.js.map +1 -1
  73. package/api/resources/keys/client/requests/KeyGenerateInput.d.ts +8 -8
  74. package/api/resources/keys/client/requests/KeyGenerateInput.js.map +1 -1
  75. package/api/resources/keys/client/requests/KeyImportSecretInput.d.ts +8 -8
  76. package/api/resources/keys/client/requests/KeyImportSecretInput.js.map +1 -1
  77. package/api/resources/keys/client/requests/KeyInput.d.ts +8 -8
  78. package/api/resources/keys/client/requests/KeyInput.js.map +1 -1
  79. package/api/resources/keys/client/requests/KeyRestoreRequest.d.ts +8 -8
  80. package/api/resources/keys/client/requests/KeyRestoreRequest.js.map +1 -1
  81. package/api/resources/presentations/client/Client.d.ts +3 -0
  82. package/api/resources/presentations/client/Client.d.ts.map +1 -1
  83. package/api/resources/presentations/client/Client.js +36 -12
  84. package/api/resources/presentations/client/Client.js.map +1 -1
  85. package/api/resources/presentations/client/requests/PresentationDeleteRequest.d.ts +8 -8
  86. package/api/resources/presentations/client/requests/PresentationDeleteRequest.js.map +1 -1
  87. package/api/resources/presentations/client/requests/PresentationInput.d.ts +8 -8
  88. package/api/resources/presentations/client/requests/PresentationInput.js.map +1 -1
  89. package/api/resources/presentations/client/requests/PresentationRestoreRequest.d.ts +8 -8
  90. package/api/resources/presentations/client/requests/PresentationRestoreRequest.js.map +1 -1
  91. package/api/resources/presentations/client/requests/PresentationUploadRequest.d.ts +8 -8
  92. package/api/resources/presentations/client/requests/PresentationUploadRequest.js.map +1 -1
  93. package/api/types/DraftSchema.d.ts +17 -16
  94. package/api/types/DraftSchema.d.ts.map +1 -1
  95. package/api/types/DraftSchema.js.map +1 -1
  96. package/api/types/EqualKeyTypeValue.d.ts +1 -2
  97. package/api/types/EqualKeyTypeValue.d.ts.map +1 -1
  98. package/api/types/EqualKeyTypeValue.js +0 -1
  99. package/api/types/EqualKeyTypeValue.js.map +1 -1
  100. package/api/types/InKeyTypeValuesItem.d.ts +6 -8
  101. package/api/types/InKeyTypeValuesItem.d.ts.map +1 -1
  102. package/api/types/InKeyTypeValuesItem.js +0 -1
  103. package/api/types/InKeyTypeValuesItem.js.map +1 -1
  104. package/api/types/KeyGenerate.d.ts +5 -6
  105. package/api/types/KeyGenerate.d.ts.map +1 -1
  106. package/api/types/KeyGenerate.js.map +1 -1
  107. package/api/types/KeyGenerateType.d.ts +6 -8
  108. package/api/types/KeyGenerateType.d.ts.map +1 -1
  109. package/api/types/KeyGenerateType.js +0 -1
  110. package/api/types/KeyGenerateType.js.map +1 -1
  111. package/api/types/KeyPublic.d.ts +5 -6
  112. package/api/types/KeyPublic.d.ts.map +1 -1
  113. package/api/types/KeyPublic.js.map +1 -1
  114. package/api/types/KeyPublicType.d.ts +6 -8
  115. package/api/types/KeyPublicType.d.ts.map +1 -1
  116. package/api/types/KeyPublicType.js +0 -1
  117. package/api/types/KeyPublicType.js.map +1 -1
  118. package/api/types/NotEqualKeyTypeValue.d.ts +1 -2
  119. package/api/types/NotEqualKeyTypeValue.d.ts.map +1 -1
  120. package/api/types/NotEqualKeyTypeValue.js +0 -1
  121. package/api/types/NotEqualKeyTypeValue.js.map +1 -1
  122. package/api/types/NotInKeyTypeValuesItem.d.ts +6 -8
  123. package/api/types/NotInKeyTypeValuesItem.d.ts.map +1 -1
  124. package/api/types/NotInKeyTypeValuesItem.js +0 -1
  125. package/api/types/NotInKeyTypeValuesItem.js.map +1 -1
  126. package/api/types/ProblemMethodNotAllowedAlive.d.ts +1 -1
  127. package/api/types/ProblemMethodNotAllowedAlive.js.map +1 -1
  128. package/api/types/ProblemMethodNotAllowedDeleted.d.ts +1 -1
  129. package/api/types/ProblemMethodNotAllowedDeleted.js.map +1 -1
  130. package/api/types/ProblemPreconditionFailedBlob.d.ts +1 -1
  131. package/api/types/ProblemPreconditionFailedBlob.js.map +1 -1
  132. package/api/types/ProblemResourceNotFound.d.ts +1 -1
  133. package/api/types/ProblemResourceNotFound.js.map +1 -1
  134. package/documents/credential/baseVerifiableCredential.d.ts +1 -1
  135. package/documents/credential/baseVerifiableCredential.d.ts.map +1 -1
  136. package/documents/credential/baseVerifiableCredential.js +27 -4
  137. package/documents/credential/baseVerifiableCredential.js.map +1 -1
  138. package/documents/credential/document.d.ts +1 -1
  139. package/documents/credential/document.d.ts.map +1 -1
  140. package/documents/credential/document.js +2 -2
  141. package/documents/credential/document.js.map +1 -1
  142. package/documents/credential/document.spec.d.ts +1 -1
  143. package/documents/credential/document.spec.d.ts.map +1 -1
  144. package/documents/credential/document.spec.js +4 -3
  145. package/documents/credential/document.spec.js.map +1 -1
  146. package/documents/credential/draft.d.ts +2 -1
  147. package/documents/credential/draft.d.ts.map +1 -1
  148. package/documents/credential/draft.js +4 -3
  149. package/documents/credential/draft.js.map +1 -1
  150. package/documents/credential/flavor.d.ts.map +1 -1
  151. package/documents/credential/flavor.js +1 -0
  152. package/documents/credential/flavor.js.map +1 -1
  153. package/documents/credential/flavor.spec.js +5 -3
  154. package/documents/credential/flavor.spec.js.map +1 -1
  155. package/documents/credential/issued.d.ts +2 -1
  156. package/documents/credential/issued.d.ts.map +1 -1
  157. package/documents/credential/issued.js +4 -3
  158. package/documents/credential/issued.js.map +1 -1
  159. package/documents/credential/unknown.d.ts +6 -1
  160. package/documents/credential/unknown.d.ts.map +1 -1
  161. package/documents/credential/unknown.js +10 -2
  162. package/documents/credential/unknown.js.map +1 -1
  163. package/documents/credential.d.ts +7 -1
  164. package/documents/credential.d.ts.map +1 -1
  165. package/documents/credential.js +19 -8
  166. package/documents/credential.js.map +1 -1
  167. package/documents/models.d.ts +1 -1
  168. package/documents/models.d.ts.map +1 -1
  169. package/documents/models.js +2 -25
  170. package/documents/models.js.map +1 -1
  171. package/documents/presentation/issued.d.ts +1 -1
  172. package/documents/presentation/issued.d.ts.map +1 -1
  173. package/documents/presentation/issued.js +2 -2
  174. package/documents/presentation/issued.js.map +1 -1
  175. package/documents/presentation.d.ts +7 -1
  176. package/documents/presentation.d.ts.map +1 -1
  177. package/documents/presentation.js +10 -2
  178. package/documents/presentation.js.map +1 -1
  179. package/documents/types.d.ts +1 -0
  180. package/documents/types.d.ts.map +1 -1
  181. package/documents/types.js.map +1 -1
  182. package/package.json +1 -1
  183. package/reference.md +0 -4
  184. package/serialization/types/EqualKeyTypeValue.d.ts +1 -1
  185. package/serialization/types/EqualKeyTypeValue.d.ts.map +1 -1
  186. package/serialization/types/EqualKeyTypeValue.js +1 -1
  187. package/serialization/types/EqualKeyTypeValue.js.map +1 -1
  188. package/serialization/types/InKeyTypeValuesItem.d.ts +1 -1
  189. package/serialization/types/InKeyTypeValuesItem.d.ts.map +1 -1
  190. package/serialization/types/InKeyTypeValuesItem.js +1 -1
  191. package/serialization/types/InKeyTypeValuesItem.js.map +1 -1
  192. package/serialization/types/KeyGenerateType.d.ts +1 -1
  193. package/serialization/types/KeyGenerateType.d.ts.map +1 -1
  194. package/serialization/types/KeyGenerateType.js +1 -1
  195. package/serialization/types/KeyGenerateType.js.map +1 -1
  196. package/serialization/types/KeyPublicType.d.ts +1 -1
  197. package/serialization/types/KeyPublicType.d.ts.map +1 -1
  198. package/serialization/types/KeyPublicType.js +1 -1
  199. package/serialization/types/KeyPublicType.js.map +1 -1
  200. package/serialization/types/NotEqualKeyTypeValue.d.ts +1 -1
  201. package/serialization/types/NotEqualKeyTypeValue.d.ts.map +1 -1
  202. package/serialization/types/NotEqualKeyTypeValue.js +1 -1
  203. package/serialization/types/NotEqualKeyTypeValue.js.map +1 -1
  204. package/serialization/types/NotInKeyTypeValuesItem.d.ts +1 -1
  205. package/serialization/types/NotInKeyTypeValuesItem.d.ts.map +1 -1
  206. package/serialization/types/NotInKeyTypeValuesItem.js +1 -1
  207. package/serialization/types/NotInKeyTypeValuesItem.js.map +1 -1
  208. package/documents/credential/index.d.ts +0 -7
  209. package/documents/credential/index.d.ts.map +0 -1
  210. package/documents/credential/index.js +0 -23
  211. package/documents/credential/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"issued.d.ts","sourceRoot":"","sources":["../../../src/documents/credential/issued.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEpG,OAAO,EAAE,gBAAgB,EAAsB,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,qBAAa,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,wBAAwB;IAK5E,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAJzC,OAAO,CAAC,kBAAkB,CAAoD;gBAG1E,MAAM,EAAE,SAAS,EACP,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACrC,UAAU,EAAE,oBAAoB,EAChC,IAAI,CAAC,EAAE,cAAc;IAKzB,kBAAkB,IAAI,gBAAgB,CAAC,CAAC,CAAC;IASnC,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CAiB5C"}
1
+ {"version":3,"file":"issued.d.ts","sourceRoot":"","sources":["../../../src/documents/credential/issued.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEpG,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,qBAAa,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,wBAAwB;IAK5E,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAJzC,OAAO,CAAC,kBAAkB,CAAoD;gBAG1E,MAAM,EAAE,SAAS,EACP,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACrC,UAAU,EAAE,oBAAoB,EAChC,IAAI,CAAC,EAAE,cAAc;IAKzB,kBAAkB,IAAI,gBAAgB,CAAC,CAAC,CAAC;IASnC,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CAiB5C"}
@@ -10,13 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.VerifiableCredential = void 0;
13
- const index_1 = require("./index");
13
+ const document_1 = require("./document");
14
+ const baseVerifiableCredential_1 = require("./baseVerifiableCredential");
14
15
  const models_1 = require("../models");
15
- class VerifiableCredential extends index_1.BaseVerifiableCredential {
16
+ class VerifiableCredential extends baseVerifiableCredential_1.BaseVerifiableCredential {
16
17
  constructor(client, flavor, descriptor, blob) {
17
18
  super(client, descriptor, blob);
18
19
  this.flavor = flavor;
19
- this.credentialDocument = new index_1.CredentialDocument(this.client, this.flavor);
20
+ this.credentialDocument = new document_1.CredentialDocument(this.client, this.flavor);
20
21
  }
21
22
  toLinkedCredential() {
22
23
  return new models_1.LinkedCredential(this.client, this.flavor.claimsModel, `urn:credential:${this.descriptor.id}`, this.descriptor.data.multihash);
@@ -1 +1 @@
1
- {"version":3,"file":"issued.js","sourceRoot":"","sources":["../../../src/documents/credential/issued.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,mCAAyF;AACzF,sCAA6C;AAE7C,MAAa,oBAAuC,SAAQ,gCAAwB;IAGhF,YACI,MAAiB,EACP,MAA2B,EACrC,UAAgC,EAChC,IAAqB;QAErB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAJtB,WAAM,GAAN,MAAM,CAAqB;QAJjC,uBAAkB,GAAG,IAAI,0BAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAS9E,CAAC;IAED,kBAAkB;QACd,OAAO,IAAI,yBAAgB,CACvB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CAAC,WAAW,EACvB,kBAAkB,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,EACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CACjC,CAAC;IACN,CAAC;IAEK,SAAS;;YACX,OAAO,IAAI,CAAC,kBAAkB,CAAC,qBAAqB,CAChD,IAAI,CAAC,MAAM,CAAC,WAAW,EACvB,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,CACpD,CAAC;QACN,CAAC;KAAA;CAYJ;AAtCD,oDAsCC","sourcesContent":["import type { ApiClient, Claims, CredentialDescriptor, CredentialBlob, ReadClaims } from '../types';\n\nimport { CredentialFlavor, CredentialDocument, BaseVerifiableCredential } from './index';\nimport { LinkedCredential } from '../models';\n\nexport class VerifiableCredential<T extends Claims> extends BaseVerifiableCredential {\n private credentialDocument = new CredentialDocument(this.client, this.flavor);\n\n constructor(\n client: ApiClient,\n protected flavor: CredentialFlavor<T>,\n descriptor: CredentialDescriptor,\n blob?: CredentialBlob,\n ) {\n super(client, descriptor, blob);\n }\n\n toLinkedCredential(): LinkedCredential<T> {\n return new LinkedCredential(\n this.client,\n this.flavor.claimsModel,\n `urn:credential:${this.descriptor.id}`,\n this.descriptor.data.multihash,\n );\n }\n\n async getClaims(): Promise<ReadClaims<T>> {\n return this.credentialDocument.convertApiValuesToUdt(\n this.flavor.claimsModel,\n await this.flavor.getClaims(await this.getBlob()),\n );\n }\n\n //TODO: once credentials.labels + annotations updates are added replace `credentials.credentialUpdate` with those (and add idempotencyKey if available as parameter)\n // async update(request: UpdatePayload): Promise<VerifiableCredential<T>> {\n // const updatedCredential = await this.client.credentials.credentialUpdate(this.descriptor.id, {\n // ifMatch: this.descriptor.etag,\n // annotations: request?.annotations,\n // labels: request?.labels,\n // });\n\n // return new VerifiableCredential(this.client, this.flavor, this.blob, updatedCredential);\n // }\n}\n"]}
1
+ {"version":3,"file":"issued.js","sourceRoot":"","sources":["../../../src/documents/credential/issued.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,yCAAgD;AAChD,yEAAsE;AACtE,sCAA6C;AAE7C,MAAa,oBAAuC,SAAQ,mDAAwB;IAGhF,YACI,MAAiB,EACP,MAA2B,EACrC,UAAgC,EAChC,IAAqB;QAErB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAJtB,WAAM,GAAN,MAAM,CAAqB;QAJjC,uBAAkB,GAAG,IAAI,6BAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAS9E,CAAC;IAED,kBAAkB;QACd,OAAO,IAAI,yBAAgB,CACvB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CAAC,WAAW,EACvB,kBAAkB,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,EACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CACjC,CAAC;IACN,CAAC;IAEK,SAAS;;YACX,OAAO,IAAI,CAAC,kBAAkB,CAAC,qBAAqB,CAChD,IAAI,CAAC,MAAM,CAAC,WAAW,EACvB,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,CACpD,CAAC;QACN,CAAC;KAAA;CAYJ;AAtCD,oDAsCC","sourcesContent":["import type { ApiClient, Claims, CredentialDescriptor, CredentialBlob, ReadClaims } from '../types';\n\nimport { CredentialFlavor } from './flavor';\nimport { CredentialDocument } from './document';\nimport { BaseVerifiableCredential } from './baseVerifiableCredential';\nimport { LinkedCredential } from '../models';\n\nexport class VerifiableCredential<T extends Claims> extends BaseVerifiableCredential {\n private credentialDocument = new CredentialDocument(this.client, this.flavor);\n\n constructor(\n client: ApiClient,\n protected flavor: CredentialFlavor<T>,\n descriptor: CredentialDescriptor,\n blob?: CredentialBlob,\n ) {\n super(client, descriptor, blob);\n }\n\n toLinkedCredential(): LinkedCredential<T> {\n return new LinkedCredential(\n this.client,\n this.flavor.claimsModel,\n `urn:credential:${this.descriptor.id}`,\n this.descriptor.data.multihash,\n );\n }\n\n async getClaims(): Promise<ReadClaims<T>> {\n return this.credentialDocument.convertApiValuesToUdt(\n this.flavor.claimsModel,\n await this.flavor.getClaims(await this.getBlob()),\n );\n }\n\n //TODO: once credentials.labels + annotations updates are added replace `credentials.credentialUpdate` with those (and add idempotencyKey if available as parameter)\n // async update(request: UpdatePayload): Promise<VerifiableCredential<T>> {\n // const updatedCredential = await this.client.credentials.credentialUpdate(this.descriptor.id, {\n // ifMatch: this.descriptor.etag,\n // annotations: request?.annotations,\n // labels: request?.labels,\n // });\n\n // return new VerifiableCredential(this.client, this.flavor, this.blob, updatedCredential);\n // }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { Claims, Ctor } from '../types';
2
- import { BaseVerifiableCredential, VerifiableCredential } from './index';
2
+ import { BaseVerifiableCredential } from './baseVerifiableCredential';
3
+ import { VerifiableCredential } from './issued';
3
4
  declare type ParseSuccessful<T extends Claims> = {
4
5
  ok: true;
5
6
  credential: VerifiableCredential<T>;
@@ -10,7 +11,11 @@ declare type ParseFailed = {
10
11
  };
11
12
  declare type ParseResult<T extends Claims> = ParseSuccessful<T> | ParseFailed;
12
13
  export declare class UnknownVerifiableCredential extends BaseVerifiableCredential {
14
+ /**
15
+ * @deprecated Please use `assertClaims` instead. This method will be removed after January 2025.
16
+ */
13
17
  assert<T extends Claims>(claimsModel: Ctor<T>): Promise<ParseResult<T>>;
18
+ assertClaims<T extends Claims>(claimsModel: Ctor<T>): Promise<ParseResult<T>>;
14
19
  }
15
20
  export {};
16
21
  //# sourceMappingURL=unknown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unknown.d.ts","sourceRoot":"","sources":["../../../src/documents/credential/unknown.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEzE,aAAK,eAAe,CAAC,CAAC,SAAS,MAAM,IAAI;IACrC,EAAE,EAAE,IAAI,CAAC;IACT,UAAU,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF,aAAK,WAAW,GAAG;IACf,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,+BAA+B,CAAC;CAC1C,CAAC;AAEF,aAAK,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;AAEtE,qBAAa,2BAA4B,SAAQ,wBAAwB;IAC/D,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAmBhF"}
1
+ {"version":3,"file":"unknown.d.ts","sourceRoot":"","sources":["../../../src/documents/credential/unknown.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,aAAK,eAAe,CAAC,CAAC,SAAS,MAAM,IAAI;IACrC,EAAE,EAAE,IAAI,CAAC;IACT,UAAU,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF,aAAK,WAAW,GAAG;IACf,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,+BAA+B,CAAC;CAC1C,CAAC;AAEF,aAAK,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;AAEtE,qBAAa,2BAA4B,SAAQ,wBAAwB;IACrE;;OAEG;IACG,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAIvE,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAmBtF"}
@@ -11,9 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UnknownVerifiableCredential = void 0;
13
13
  const credential_1 = require("../credential");
14
- const index_1 = require("./index");
15
- class UnknownVerifiableCredential extends index_1.BaseVerifiableCredential {
14
+ const baseVerifiableCredential_1 = require("./baseVerifiableCredential");
15
+ class UnknownVerifiableCredential extends baseVerifiableCredential_1.BaseVerifiableCredential {
16
+ /**
17
+ * @deprecated Please use `assertClaims` instead. This method will be removed after January 2025.
18
+ */
16
19
  assert(claimsModel) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ return this.assertClaims(claimsModel);
22
+ });
23
+ }
24
+ assertClaims(claimsModel) {
17
25
  return __awaiter(this, void 0, void 0, function* () {
18
26
  const credentialResource = yield this.client.credentials.credentialRevision(this.descriptor.id, this.descriptor.revision);
19
27
  const vcDecorator = new credential_1.VcDecorator(this.client, claimsModel);
@@ -1 +1 @@
1
- {"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../src/documents/credential/unknown.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4C;AAE5C,mCAAyE;AAczE,MAAa,2BAA4B,SAAQ,gCAAwB;IAC/D,MAAM,CAAmB,WAAoB;;YAC/C,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CACvE,IAAI,CAAC,UAAU,CAAC,EAAE,EAClB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAC3B,CAAC;YACF,MAAM,WAAW,GAAG,IAAI,wBAAW,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAE9D,IAAI,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE;gBACxC,OAAO;oBACH,EAAE,EAAE,IAAI;oBACR,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,kBAAkB,CAAC;iBAClD,CAAC;aACL;YAED,OAAO;gBACH,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,+BAA+B;aACzC,CAAC;QACN,CAAC;KAAA;CACJ;AApBD,kEAoBC","sourcesContent":["import { VcDecorator } from '../credential';\nimport type { Claims, Ctor } from '../types';\nimport { BaseVerifiableCredential, VerifiableCredential } from './index';\n\ntype ParseSuccessful<T extends Claims> = {\n ok: true;\n credential: VerifiableCredential<T>;\n};\n\ntype ParseFailed = {\n ok: false;\n error: 'WRONG_CREDENTIAL_SUBJECT_TYPE';\n};\n\ntype ParseResult<T extends Claims> = ParseSuccessful<T> | ParseFailed;\n\nexport class UnknownVerifiableCredential extends BaseVerifiableCredential {\n async assert<T extends Claims>(claimsModel: Ctor<T>): Promise<ParseResult<T>> {\n const credentialResource = await this.client.credentials.credentialRevision(\n this.descriptor.id,\n this.descriptor.revision,\n );\n const vcDecorator = new VcDecorator(this.client, claimsModel);\n\n if (vcDecorator.canMap(credentialResource)) {\n return {\n ok: true,\n credential: vcDecorator.map(credentialResource),\n };\n }\n\n return {\n ok: false,\n error: 'WRONG_CREDENTIAL_SUBJECT_TYPE',\n };\n }\n}\n"]}
1
+ {"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../src/documents/credential/unknown.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4C;AAE5C,yEAAsE;AAetE,MAAa,2BAA4B,SAAQ,mDAAwB;IACrE;;OAEG;IACG,MAAM,CAAmB,WAAoB;;YAC/C,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAC1C,CAAC;KAAA;IAEK,YAAY,CAAmB,WAAoB;;YACrD,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CACvE,IAAI,CAAC,UAAU,CAAC,EAAE,EAClB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAC3B,CAAC;YACF,MAAM,WAAW,GAAG,IAAI,wBAAW,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAE9D,IAAI,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE;gBACxC,OAAO;oBACH,EAAE,EAAE,IAAI;oBACR,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,kBAAkB,CAAC;iBAClD,CAAC;aACL;YAED,OAAO;gBACH,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,+BAA+B;aACzC,CAAC;QACN,CAAC;KAAA;CACJ;AA3BD,kEA2BC","sourcesContent":["import { VcDecorator } from '../credential';\nimport type { Claims, Ctor } from '../types';\nimport { BaseVerifiableCredential } from './baseVerifiableCredential';\nimport { VerifiableCredential } from './issued';\n\ntype ParseSuccessful<T extends Claims> = {\n ok: true;\n credential: VerifiableCredential<T>;\n};\n\ntype ParseFailed = {\n ok: false;\n error: 'WRONG_CREDENTIAL_SUBJECT_TYPE';\n};\n\ntype ParseResult<T extends Claims> = ParseSuccessful<T> | ParseFailed;\n\nexport class UnknownVerifiableCredential extends BaseVerifiableCredential {\n /**\n * @deprecated Please use `assertClaims` instead. This method will be removed after January 2025.\n */\n async assert<T extends Claims>(claimsModel: Ctor<T>): Promise<ParseResult<T>> {\n return this.assertClaims(claimsModel);\n }\n\n async assertClaims<T extends Claims>(claimsModel: Ctor<T>): Promise<ParseResult<T>> {\n const credentialResource = await this.client.credentials.credentialRevision(\n this.descriptor.id,\n this.descriptor.revision,\n );\n const vcDecorator = new VcDecorator(this.client, claimsModel);\n\n if (vcDecorator.canMap(credentialResource)) {\n return {\n ok: true,\n credential: vcDecorator.map(credentialResource),\n };\n }\n\n return {\n ok: false,\n error: 'WRONG_CREDENTIAL_SUBJECT_TYPE',\n };\n }\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  import { DraftSchema, ResourceCredential, ResourceDraft } from '../api';
2
- import { CredentialFlavor, DraftCredential, VerifiableCredential } from './credential/';
2
+ import { DraftCredential } from './credential/draft';
3
+ import { VerifiableCredential } from './credential/issued';
4
+ import { CredentialFlavor } from './credential/flavor';
3
5
  import type { ApiClient, BlobInput, Claims, Ctor, UpdatePayload, UpdatePayloadWithClaims } from './types';
4
6
  export declare type CredentialEnvelope<T extends Claims> = {
5
7
  isVerifiable: false;
@@ -29,7 +31,11 @@ export declare class VcDecorator<T extends Claims> {
29
31
  loadAsDraft(id: string, revision?: number): Promise<DraftCredential<T>>;
30
32
  loadAsCredential(id: string, revision?: number): Promise<VerifiableCredential<T>>;
31
33
  load(id: string, revision?: number): Promise<LoadedCredential<T>>;
34
+ /**
35
+ * @deprecated Please use `importCredential` instead. This method will be removed after January 2025.
36
+ */
32
37
  import(blob: BlobInput, request?: UpdatePayload): Promise<VerifiableCredential<T>>;
38
+ importCredential(blob: BlobInput, request?: UpdatePayload): Promise<VerifiableCredential<T>>;
33
39
  }
34
40
  export { VerifiableCredential };
35
41
  //# sourceMappingURL=credential.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"credential.d.ts","sourceRoot":"","sources":["../../src/documents/credential.ts"],"names":[],"mappings":"AAEA,OAAO,EASH,WAAW,EAGX,kBAAkB,EAClB,aAAa,EAChB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAsB,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAY5G,OAAO,KAAK,EACR,SAAS,EACT,SAAS,EACT,MAAM,EAEN,IAAI,EACJ,aAAa,EACb,uBAAuB,EAC1B,MAAM,SAAS,CAAC;AAajB,oBAAY,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI;IAC/C,YAAY,EAAE,KAAK,CAAC;IACpB,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF,oBAAY,4BAA4B,CAAC,CAAC,SAAS,MAAM,IAAI;IACzD,YAAY,EAAE,IAAI,CAAC;IACnB,UAAU,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF,oBAAY,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAAC;AAEzG,qBAAa,WAAW,CAAC,CAAC,SAAS,MAAM;IAKjC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,WAAW;IALvB,QAAQ,CAAC,MAAM,sBAAiD;IAChE,OAAO,CAAC,kBAAkB,CAAoD;gBAGlE,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;IAGhC,SAAS,CAAC,sBAAsB,CAAC,WAAW,EAAE,IAAI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xB,OAAO,CAAC,aAAa;IAoGrB,SAAS,CAAC,cAAc,IAAI,WAAW,GAAG,SAAS;IAe7C,MAAM,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAoBzE,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAQvE,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAQjF,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IA2BvE;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAIlF,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;CAKrG;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -39,8 +39,11 @@ exports.VerifiableCredential = exports.VcDecorator = void 0;
39
39
  const node_fetch_1 = __importDefault(require("node-fetch"));
40
40
  const api_1 = require("../api");
41
41
  const serialization = __importStar(require("../serialization"));
42
- const credential_1 = require("./credential/");
43
- Object.defineProperty(exports, "VerifiableCredential", { enumerable: true, get: function () { return credential_1.VerifiableCredential; } });
42
+ const draft_1 = require("./credential/draft");
43
+ const issued_1 = require("./credential/issued");
44
+ Object.defineProperty(exports, "VerifiableCredential", { enumerable: true, get: function () { return issued_1.VerifiableCredential; } });
45
+ const document_1 = require("./credential/document");
46
+ const flavor_1 = require("./credential/flavor");
44
47
  const decorators_1 = require("./decorators");
45
48
  const helpers_1 = require("./helpers");
46
49
  const models_1 = require("./models");
@@ -50,10 +53,10 @@ class VcDecorator {
50
53
  this.client = client;
51
54
  this.claimsModel = claimsModel;
52
55
  this.flavor = this.createCredentialFlavor(this.claimsModel);
53
- this.credentialDocument = new credential_1.CredentialDocument(this.client, this.flavor);
56
+ this.credentialDocument = new document_1.CredentialDocument(this.client, this.flavor);
54
57
  }
55
58
  createCredentialFlavor(claimsModel) {
56
- return new credential_1.CredentialFlavor(claimsModel);
59
+ return new flavor_1.CredentialFlavor(claimsModel);
57
60
  }
58
61
  getIri() {
59
62
  const vcContextMetadata = (0, decorators_1.getContextJsonLdMetadata)(this.claimsModel);
@@ -76,14 +79,14 @@ class VcDecorator {
76
79
  if (!this.canMap(input)) {
77
80
  throw new Error(`The received ResourceCredential is incompatible with the current VcDecorator instance claims model`);
78
81
  }
79
- return new credential_1.VerifiableCredential(this.client, this.flavor, input);
82
+ return new issued_1.VerifiableCredential(this.client, this.flavor, input);
80
83
  }
81
84
  else {
82
85
  // ResourceDraft
83
86
  if (!this.canMap(input)) {
84
87
  throw new Error(`The received ResourceDraft is incompatible with the current VcDecorator instance claims model`);
85
88
  }
86
- return new credential_1.DraftCredential(this.client, this.flavor, input.data, input);
89
+ return new draft_1.DraftCredential(this.client, this.flavor, input.data, input);
87
90
  }
88
91
  }
89
92
  importBlob(blob, request) {
@@ -194,7 +197,7 @@ class VcDecorator {
194
197
  },
195
198
  idempotencyKey: (0, helpers_1.generateIdempotencyKey)('create'),
196
199
  });
197
- return new credential_1.DraftCredential(this.client, this.flavor, data, { id, etag, revision });
200
+ return new draft_1.DraftCredential(this.client, this.flavor, data, { id, etag, revision });
198
201
  });
199
202
  }
200
203
  loadAsDraft(id, revision) {
@@ -243,10 +246,18 @@ class VcDecorator {
243
246
  }
244
247
  });
245
248
  }
249
+ /**
250
+ * @deprecated Please use `importCredential` instead. This method will be removed after January 2025.
251
+ */
246
252
  import(blob, request) {
253
+ return __awaiter(this, void 0, void 0, function* () {
254
+ return this.importCredential(blob, request);
255
+ });
256
+ }
257
+ importCredential(blob, request) {
247
258
  return __awaiter(this, void 0, void 0, function* () {
248
259
  const credential = yield this.importBlob(blob, request);
249
- return new credential_1.VerifiableCredential(this.client, this.flavor, credential);
260
+ return new issued_1.VerifiableCredential(this.client, this.flavor, credential);
250
261
  });
251
262
  }
252
263
  }
@@ -1 +1 @@
1
- {"version":3,"file":"credential.js","sourceRoot":"","sources":["../../src/documents/credential.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA+B;AAE/B,gCAcgB;AAChB,gEAAkD;AAClD,8CAA4G;AAiUnG,qGAjUuD,iCAAoB,OAiUvD;AAhU7B,6CAQsB;AACtB,uCAAmD;AACnD,qCAAwD;AAUxD,mDAA0G;AAwB1G,MAAa,WAAW;IAIpB,YACY,MAAiB,EACjB,WAAoB;QADpB,WAAM,GAAN,MAAM,CAAW;QACjB,gBAAW,GAAX,WAAW,CAAS;QALvB,WAAM,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxD,uBAAkB,GAAG,IAAI,+BAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAK3E,CAAC;IAEM,sBAAsB,CAAC,WAAoB;QACjD,OAAO,IAAI,6BAAgB,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM;QACF,MAAM,iBAAiB,GAAG,IAAA,qCAAwB,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAErE,IAAI,CAAC,iBAAiB;YAClB,MAAM,IAAI,KAAK,CACX,uGAAuG,CAC1G,CAAC;QAEN,OAAO,GAAG,iBAAiB,CAAC,SAAS,IAAI,iBAAiB,CAAC,IAAI,EAAE,CAAC;IACtE,CAAC;IAED,iBAAiB;QACb,MAAM,iBAAiB,GAAG,IAAA,qC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B;;YACjD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAExD,OAAO,IAAI,iCAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC1E,CAAC;KAAA;CACJ;AAlRD,kCAkRC","sourcesContent":["import fetch from 'node-fetch';\n\nimport {\n DraftFieldBooleanValue,\n DraftFieldDateTimeValue,\n DraftFieldDateValue,\n DraftFieldFileValue,\n DraftFieldLinkValue,\n DraftFieldNumberValue,\n DraftFieldStringValue,\n DraftFieldStructValue,\n DraftSchema,\n DraftSchemaFieldsItem,\n NotFoundError,\n ResourceCredential,\n ResourceDraft,\n} from '../api';\nimport * as serialization from '../serialization';\nimport { CredentialDocument, CredentialFlavor, DraftCredential, VerifiableCredential } from './credential/';\nimport {\n ClaimDescriptor,\n getClaimJsonLdTypeMetadata,\n getClaimLinkedCredentialMetadata,\n getClaimLinkedFileMetadata,\n getContextJsonLdMetadata,\n getRegisteredClaimsList,\n getTsDataTypeMetadata,\n} from './decorators';\nimport { generateIdempotencyKey } from './helpers';\nimport { Rfc3339Date, Rfc3339DateTime } from './models';\nimport type {\n ApiClient,\n BlobInput,\n Claims,\n CredentialDescriptor,\n Ctor,\n UpdatePayload,\n UpdatePayloadWithClaims,\n} from './types';\nimport { draftMetadataToApiDraftMeta, strictlyConvertToApiType, StrictPartial } from './utils/converters';\n\ntype DraftFieldValue =\n | DraftFieldBooleanValue\n | DraftFieldDateTimeValue\n | DraftFieldDateValue\n | DraftFieldFileValue\n | DraftFieldLinkValue\n | DraftFieldNumberValue\n | DraftFieldStringValue\n | DraftFieldStructValue;\n\nexport type CredentialEnvelope<T extends Claims> = {\n isVerifiable: false;\n credential: DraftCredential<T>;\n};\n\nexport type VerifiableCredentialEnvelope<T extends Claims> = {\n isVerifiable: true;\n credential: VerifiableCredential<T>;\n};\n\nexport type LoadedCredential<T extends Claims> = CredentialEnvelope<T> | VerifiableCredentialEnvelope<T>;\n\nexport class VcDecorator<T extends Claims> {\n readonly flavor = this.createCredentialFlavor(this.claimsModel);\n private credentialDocument = new CredentialDocument(this.client, this.flavor);\n\n constructor(\n private client: ApiClient,\n private claimsModel: Ctor<T>,\n ) {}\n\n protected createCredentialFlavor(claimsModel: Ctor<T>): CredentialFlavor<T> {\n return new CredentialFlavor(claimsModel);\n }\n\n getIri(): string {\n const vcContextMetadata = getContextJsonLdMetadata(this.claimsModel);\n\n if (!vcContextMetadata)\n throw new Error(\n `Can't find IRI information. Make sure you have defined the claims model with the @VcContext decorator`,\n );\n\n return `${vcContextMetadata.namespace}#${vcContextMetadata.name}`;\n }\n\n getCredentialTerm(): string {\n const vcContextMetadata = getContextJsonLdMetadata(this.claimsModel);\n\n if (!vcContextMetadata)\n throw new Error(\n `Can't find credential term information. Make sure you have defined the claims model with the @VcContext decorator`,\n );\n\n return `${vcContextMetadata.name}Credential`;\n }\n\n canMap(input: ResourceDraft | ResourceCredential): boolean {\n return input.data.type.includes(this.getCredentialTerm());\n }\n\n map(input: ResourceCredential): VerifiableCredential<T>;\n map(input: ResourceDraft): DraftCredential<T>;\n map(input: ResourceDraft | ResourceCredential): VerifiableCredential<T> | DraftCredential<T> {\n if ('type' in input.data) {\n // ResourceCredential\n if (!this.canMap(input)) {\n throw new Error(\n `The received ResourceCredential is incompatible with the current VcDecorator instance claims model`,\n );\n }\n\n return new VerifiableCredential(this.client, this.flavor, input);\n } else {\n // ResourceDraft\n if (!this.canMap(input)) {\n throw new Error(\n `The received ResourceDraft is incompatible with the current VcDecorator instance claims model`,\n );\n }\n\n return new DraftCredential(this.client, this.flavor, input.data, input);\n }\n }\n\n private async importBlob(blob: BlobInput, request?: UpdatePayload): Promise<CredentialDescriptor> {\n const idempotencyKey = generateIdempotencyKey('importBlob');\n const { blobId, uploadUri } = await this.client.credentials.credentialUpload({\n idempotencyKey,\n });\n\n await fetch(uploadUri, {\n method: 'PUT',\n body: blob,\n });\n\n const resourceCredential = await this.client.credentials.credentialImport({\n annotations: request?.annotations,\n labels: request?.labels,\n blobId,\n idempotencyKey,\n });\n\n return {\n data: {\n multihash: resourceCredential.data.multihash ?? undefined,\n },\n id: resourceCredential.id,\n etag: resourceCredential.etag,\n revision: resourceCredential.revision,\n };\n }\n\n private mapClaimToApi(claim: ClaimDescriptor, claimsModel: Ctor<any>): DraftSchemaFieldsItem {\n const claimJsonLdType = getClaimJsonLdTypeMetadata(claimsModel, claim.name);\n const draftBaseFieldValue: StrictPartial<DraftFieldValue> = {\n name: claim.name,\n title: claim.title,\n notEmpty: claim.notEmpty,\n isArray: claim.isArray || undefined,\n };\n\n if (\n claim.nestedType &&\n !Array.of<Ctor<any>>(String, Number, Date, Rfc3339DateTime, Rfc3339Date, Boolean).includes(claim.nestedType)\n ) {\n const claimNestedType = claim.nestedType;\n const linkedModel = getClaimLinkedCredentialMetadata(claimsModel, claim.name);\n\n if (linkedModel) {\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'LINK',\n linkType: undefined,\n });\n } else {\n const nestedContextInfo = getContextJsonLdMetadata(claimNestedType);\n\n if (!nestedContextInfo) {\n throw new Error(\n `The information about the VC context was not found in the \"${claimNestedType.name}\" model. Please use the \"@VcContext\" decorator to define the necessary information.`,\n );\n }\n\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'STRUCT',\n fields: getRegisteredClaimsList(claimNestedType).map((nestedClaim) => {\n return this.mapClaimToApi(nestedClaim, claimNestedType);\n }),\n vocabNamespace: nestedContextInfo.namespace,\n vocabName: nestedContextInfo.name,\n });\n }\n } else {\n const isLinkedFile = getClaimLinkedFileMetadata(claimsModel, claim.name);\n\n if (isLinkedFile) {\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'FILE',\n });\n } else {\n const tsDataType = claim.nestedType || getTsDataTypeMetadata(claimsModel, claim.name);\n\n if (!tsDataType) {\n throw new Error(\n `The information about the VC claim data type was not found for the \"${claim.name}\" property. Ensure that \"emitDecoratorMetadata\" is enabled in your \"tsconfig.json\".`,\n );\n }\n\n switch (tsDataType) {\n case String:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'STRING',\n type: claimJsonLdType,\n enum: claim.enumValuesDescriptor,\n });\n case Number:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'NUMBER',\n type: claimJsonLdType,\n });\n case Boolean:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'BOOLEAN',\n type: claimJsonLdType,\n });\n case Rfc3339Date:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'DATE',\n type: claimJsonLdType,\n });\n case Rfc3339DateTime:\n case Date:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'DATETIME',\n type: claimJsonLdType,\n });\n default:\n throw new Error(\n `Unsupported primitive data type: ${tsDataType.name}. Please use one of the supported types. You can find more information in the documentation.`,\n );\n }\n }\n }\n }\n\n protected getDraftSchema(): DraftSchema | undefined {\n const vcContextMetadata = getContextJsonLdMetadata(this.claimsModel);\n\n if (!vcContextMetadata) return undefined;\n\n return strictlyConvertToApiType(serialization.DraftSchema, {\n fields: getRegisteredClaimsList(this.claimsModel).map((claim) =>\n this.mapClaimToApi(claim, this.claimsModel),\n ),\n vocabNamespace: vcContextMetadata.namespace,\n vocabName: vcContextMetadata.name,\n vcType: vcContextMetadata.vcType,\n });\n }\n\n async create(request?: UpdatePayloadWithClaims<T>): Promise<DraftCredential<T>> {\n const apiClaims = request?.claims\n ? this.credentialDocument.convertUdtToApiValues(this.claimsModel, request.claims as T)\n : undefined;\n const { id, etag, revision, data } = await this.client.drafts.draftCreate({\n body: {\n data: {\n schema: this.getDraftSchema(),\n values: apiClaims,\n meta: draftMetadataToApiDraftMeta(request?.metadata),\n },\n annotations: request?.annotations,\n labels: request?.labels,\n },\n idempotencyKey: generateIdempotencyKey('create'),\n });\n\n return new DraftCredential(this.client, this.flavor, data, { id, etag, revision });\n }\n\n async loadAsDraft(id: string, revision?: number): Promise<DraftCredential<T>> {\n const resourceDraft = revision\n ? await this.client.drafts.draftRevision(id, revision)\n : await this.client.drafts.draftLatest(id);\n\n return this.map(resourceDraft);\n }\n\n async loadAsCredential(id: string, revision?: number): Promise<VerifiableCredential<T>> {\n const resourceCredential = revision\n ? await this.client.credentials.credentialRevision(id, revision)\n : await this.client.credentials.credentialLatest(id);\n\n return this.map(resourceCredential);\n }\n\n async load(id: string, revision?: number): Promise<LoadedCredential<T>> {\n let verifiableCredential: VerifiableCredential<T> | undefined;\n let draftCredential: DraftCredential<T> | undefined;\n\n try {\n verifiableCredential = await this.loadAsCredential(id, revision);\n } catch (error) {\n if (error instanceof NotFoundError) {\n draftCredential = await this.loadAsDraft(id, revision);\n } else throw error;\n }\n\n if (!draftCredential) {\n if (!verifiableCredential) throw new Error(`Resource with id '${id}' could not be found.`);\n\n return {\n isVerifiable: true,\n credential: verifiableCredential,\n };\n } else {\n return {\n isVerifiable: false,\n credential: draftCredential,\n };\n }\n }\n\n async import(blob: BlobInput, request?: UpdatePayload): Promise<VerifiableCredential<T>> {\n const credential = await this.importBlob(blob, request);\n\n return new VerifiableCredential(this.client, this.flavor, credential);\n }\n}\n\nexport { VerifiableCredential };\n"]}
1
+ {"version":3,"file":"credential.js","sourceRoot":"","sources":["../../src/documents/credential.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA+B;AAE/B,gCAcgB;AAChB,gEAAkD;AAClD,8CAAqD;AACrD,gDAA2D;AA0UlD,qGA1UA,6BAAoB,OA0UA;AAzU7B,oDAA2D;AAC3D,gDAAuD;AACvD,6CAQs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AC;KAAA;IAEK,IAAI,CAAC,EAAU,EAAE,QAAiB;;YACpC,IAAI,oBAAyD,CAAC;YAC9D,IAAI,eAA+C,CAAC;YAEpD,IAAI;gBACA,oBAAoB,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;aACpE;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,KAAK,YAAY,mBAAa,EAAE;oBAChC,eAAe,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;iBAC1D;;oBAAM,MAAM,KAAK,CAAC;aACtB;YAED,IAAI,CAAC,eAAe,EAAE;gBAClB,IAAI,CAAC,oBAAoB;oBAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;gBAE3F,OAAO;oBACH,YAAY,EAAE,IAAI;oBAClB,UAAU,EAAE,oBAAoB;iBACnC,CAAC;aACL;iBAAM;gBACH,OAAO;oBACH,YAAY,EAAE,KAAK;oBACnB,UAAU,EAAE,eAAe;iBAC9B,CAAC;aACL;QACL,CAAC;KAAA;IAED;;OAEG;IACG,MAAM,CAAC,IAAe,EAAE,OAAuB;;YACjD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;KAAA;IAEK,gBAAgB,CAAC,IAAe,EAAE,OAAuB;;YAC3D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAExD,OAAO,IAAI,6BAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC1E,CAAC;KAAA;CACJ;AAzRD,kCAyRC","sourcesContent":["import fetch from 'node-fetch';\n\nimport {\n DraftFieldBooleanValue,\n DraftFieldDateTimeValue,\n DraftFieldDateValue,\n DraftFieldFileValue,\n DraftFieldLinkValue,\n DraftFieldNumberValue,\n DraftFieldStringValue,\n DraftFieldStructValue,\n DraftSchema,\n DraftSchemaFieldsItem,\n NotFoundError,\n ResourceCredential,\n ResourceDraft,\n} from '../api';\nimport * as serialization from '../serialization';\nimport { DraftCredential } from './credential/draft';\nimport { VerifiableCredential } from './credential/issued';\nimport { CredentialDocument } from './credential/document';\nimport { CredentialFlavor } from './credential/flavor';\nimport {\n ClaimDescriptor,\n getClaimJsonLdTypeMetadata,\n getClaimLinkedCredentialMetadata,\n getClaimLinkedFileMetadata,\n getContextJsonLdMetadata,\n getRegisteredClaimsList,\n getTsDataTypeMetadata,\n} from './decorators';\nimport { generateIdempotencyKey } from './helpers';\nimport { Rfc3339Date, Rfc3339DateTime } from './models';\nimport type {\n ApiClient,\n BlobInput,\n Claims,\n CredentialDescriptor,\n Ctor,\n UpdatePayload,\n UpdatePayloadWithClaims,\n} from './types';\nimport { draftMetadataToApiDraftMeta, strictlyConvertToApiType, StrictPartial } from './utils/converters';\n\ntype DraftFieldValue =\n | DraftFieldBooleanValue\n | DraftFieldDateTimeValue\n | DraftFieldDateValue\n | DraftFieldFileValue\n | DraftFieldLinkValue\n | DraftFieldNumberValue\n | DraftFieldStringValue\n | DraftFieldStructValue;\n\nexport type CredentialEnvelope<T extends Claims> = {\n isVerifiable: false;\n credential: DraftCredential<T>;\n};\n\nexport type VerifiableCredentialEnvelope<T extends Claims> = {\n isVerifiable: true;\n credential: VerifiableCredential<T>;\n};\n\nexport type LoadedCredential<T extends Claims> = CredentialEnvelope<T> | VerifiableCredentialEnvelope<T>;\n\nexport class VcDecorator<T extends Claims> {\n readonly flavor = this.createCredentialFlavor(this.claimsModel);\n private credentialDocument = new CredentialDocument(this.client, this.flavor);\n\n constructor(\n private client: ApiClient,\n private claimsModel: Ctor<T>,\n ) {}\n\n protected createCredentialFlavor(claimsModel: Ctor<T>): CredentialFlavor<T> {\n return new CredentialFlavor(claimsModel);\n }\n\n getIri(): string {\n const vcContextMetadata = getContextJsonLdMetadata(this.claimsModel);\n\n if (!vcContextMetadata)\n throw new Error(\n `Can't find IRI information. Make sure you have defined the claims model with the @VcContext decorator`,\n );\n\n return `${vcContextMetadata.namespace}#${vcContextMetadata.name}`;\n }\n\n getCredentialTerm(): string {\n const vcContextMetadata = getContextJsonLdMetadata(this.claimsModel);\n\n if (!vcContextMetadata)\n throw new Error(\n `Can't find credential term information. Make sure you have defined the claims model with the @VcContext decorator`,\n );\n\n return `${vcContextMetadata.name}Credential`;\n }\n\n canMap(input: ResourceDraft | ResourceCredential): boolean {\n return input.data.type.includes(this.getCredentialTerm());\n }\n\n map(input: ResourceCredential): VerifiableCredential<T>;\n map(input: ResourceDraft): DraftCredential<T>;\n map(input: ResourceDraft | ResourceCredential): VerifiableCredential<T> | DraftCredential<T> {\n if ('type' in input.data) {\n // ResourceCredential\n if (!this.canMap(input)) {\n throw new Error(\n `The received ResourceCredential is incompatible with the current VcDecorator instance claims model`,\n );\n }\n\n return new VerifiableCredential(this.client, this.flavor, input);\n } else {\n // ResourceDraft\n if (!this.canMap(input)) {\n throw new Error(\n `The received ResourceDraft is incompatible with the current VcDecorator instance claims model`,\n );\n }\n\n return new DraftCredential(this.client, this.flavor, input.data, input);\n }\n }\n\n private async importBlob(blob: BlobInput, request?: UpdatePayload): Promise<CredentialDescriptor> {\n const idempotencyKey = generateIdempotencyKey('importBlob');\n const { blobId, uploadUri } = await this.client.credentials.credentialUpload({\n idempotencyKey,\n });\n\n await fetch(uploadUri, {\n method: 'PUT',\n body: blob,\n });\n\n const resourceCredential = await this.client.credentials.credentialImport({\n annotations: request?.annotations,\n labels: request?.labels,\n blobId,\n idempotencyKey,\n });\n\n return {\n data: {\n multihash: resourceCredential.data.multihash ?? undefined,\n },\n id: resourceCredential.id,\n etag: resourceCredential.etag,\n revision: resourceCredential.revision,\n };\n }\n\n private mapClaimToApi(claim: ClaimDescriptor, claimsModel: Ctor<any>): DraftSchemaFieldsItem {\n const claimJsonLdType = getClaimJsonLdTypeMetadata(claimsModel, claim.name);\n const draftBaseFieldValue: StrictPartial<DraftFieldValue> = {\n name: claim.name,\n title: claim.title,\n notEmpty: claim.notEmpty,\n isArray: claim.isArray || undefined,\n };\n\n if (\n claim.nestedType &&\n !Array.of<Ctor<any>>(String, Number, Date, Rfc3339DateTime, Rfc3339Date, Boolean).includes(claim.nestedType)\n ) {\n const claimNestedType = claim.nestedType;\n const linkedModel = getClaimLinkedCredentialMetadata(claimsModel, claim.name);\n\n if (linkedModel) {\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'LINK',\n linkType: undefined,\n });\n } else {\n const nestedContextInfo = getContextJsonLdMetadata(claimNestedType);\n\n if (!nestedContextInfo) {\n throw new Error(\n `The information about the VC context was not found in the \"${claimNestedType.name}\" model. Please use the \"@VcContext\" decorator to define the necessary information.`,\n );\n }\n\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'STRUCT',\n fields: getRegisteredClaimsList(claimNestedType).map((nestedClaim) => {\n return this.mapClaimToApi(nestedClaim, claimNestedType);\n }),\n vocabNamespace: nestedContextInfo.namespace,\n vocabName: nestedContextInfo.name,\n });\n }\n } else {\n const isLinkedFile = getClaimLinkedFileMetadata(claimsModel, claim.name);\n\n if (isLinkedFile) {\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'FILE',\n });\n } else {\n const tsDataType = claim.nestedType || getTsDataTypeMetadata(claimsModel, claim.name);\n\n if (!tsDataType) {\n throw new Error(\n `The information about the VC claim data type was not found for the \"${claim.name}\" property. Ensure that \"emitDecoratorMetadata\" is enabled in your \"tsconfig.json\".`,\n );\n }\n\n switch (tsDataType) {\n case String:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'STRING',\n type: claimJsonLdType,\n enum: claim.enumValuesDescriptor,\n });\n case Number:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'NUMBER',\n type: claimJsonLdType,\n });\n case Boolean:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'BOOLEAN',\n type: claimJsonLdType,\n });\n case Rfc3339Date:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'DATE',\n type: claimJsonLdType,\n });\n case Rfc3339DateTime:\n case Date:\n return strictlyConvertToApiType(serialization.DraftSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'DATETIME',\n type: claimJsonLdType,\n });\n default:\n throw new Error(\n `Unsupported primitive data type: ${tsDataType.name}. Please use one of the supported types. You can find more information in the documentation.`,\n );\n }\n }\n }\n }\n\n protected getDraftSchema(): DraftSchema | undefined {\n const vcContextMetadata = getContextJsonLdMetadata(this.claimsModel);\n\n if (!vcContextMetadata) return undefined;\n\n return strictlyConvertToApiType(serialization.DraftSchema, {\n fields: getRegisteredClaimsList(this.claimsModel).map((claim) =>\n this.mapClaimToApi(claim, this.claimsModel),\n ),\n vocabNamespace: vcContextMetadata.namespace,\n vocabName: vcContextMetadata.name,\n vcType: vcContextMetadata.vcType,\n });\n }\n\n async create(request?: UpdatePayloadWithClaims<T>): Promise<DraftCredential<T>> {\n const apiClaims = request?.claims\n ? this.credentialDocument.convertUdtToApiValues(this.claimsModel, request.claims as T)\n : undefined;\n const { id, etag, revision, data } = await this.client.drafts.draftCreate({\n body: {\n data: {\n schema: this.getDraftSchema(),\n values: apiClaims,\n meta: draftMetadataToApiDraftMeta(request?.metadata),\n },\n annotations: request?.annotations,\n labels: request?.labels,\n },\n idempotencyKey: generateIdempotencyKey('create'),\n });\n\n return new DraftCredential(this.client, this.flavor, data, { id, etag, revision });\n }\n\n async loadAsDraft(id: string, revision?: number): Promise<DraftCredential<T>> {\n const resourceDraft = revision\n ? await this.client.drafts.draftRevision(id, revision)\n : await this.client.drafts.draftLatest(id);\n\n return this.map(resourceDraft);\n }\n\n async loadAsCredential(id: string, revision?: number): Promise<VerifiableCredential<T>> {\n const resourceCredential = revision\n ? await this.client.credentials.credentialRevision(id, revision)\n : await this.client.credentials.credentialLatest(id);\n\n return this.map(resourceCredential);\n }\n\n async load(id: string, revision?: number): Promise<LoadedCredential<T>> {\n let verifiableCredential: VerifiableCredential<T> | undefined;\n let draftCredential: DraftCredential<T> | undefined;\n\n try {\n verifiableCredential = await this.loadAsCredential(id, revision);\n } catch (error) {\n if (error instanceof NotFoundError) {\n draftCredential = await this.loadAsDraft(id, revision);\n } else throw error;\n }\n\n if (!draftCredential) {\n if (!verifiableCredential) throw new Error(`Resource with id '${id}' could not be found.`);\n\n return {\n isVerifiable: true,\n credential: verifiableCredential,\n };\n } else {\n return {\n isVerifiable: false,\n credential: draftCredential,\n };\n }\n }\n\n /**\n * @deprecated Please use `importCredential` instead. This method will be removed after January 2025.\n */\n async import(blob: BlobInput, request?: UpdatePayload): Promise<VerifiableCredential<T>> {\n return this.importCredential(blob, request);\n }\n\n async importCredential(blob: BlobInput, request?: UpdatePayload): Promise<VerifiableCredential<T>> {\n const credential = await this.importBlob(blob, request);\n\n return new VerifiableCredential(this.client, this.flavor, credential);\n }\n}\n\nexport { VerifiableCredential };\n"]}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import type { ApiClient, Claims, Ctor, FileBlob, FileDescriptor, LinkedEntityDescriptor } from './types';
3
- import type { VerifiableCredential } from './credential/';
3
+ import type { VerifiableCredential } from './credential/issued';
4
4
  import { Readable } from 'stream';
5
5
  declare type NormalizedLinkedEntityId = {
6
6
  linkedId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/documents/models.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACzG,OAAO,KAAK,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M,EAAE,GAAG,EAAE,MAAM;gBACxC,UAAU,EAAE,MAAM;gBAClB,IAAI,EAAE,IAAI;;IAsBtB,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;IAIhB,MAAM,IAAI,IAAI;CAGjB;AAED,qBAAa,eAAe;IACxB,OAAO,CAAC,IAAI,CAAO;gBAEP,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;gBACxC,UAAU,EAAE,MAAM;gBAClB,IAAI,EAAE,IAAI;;IAkBtB,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;IAIhB,MAAM,IAAI,IAAI;CAGjB"}
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- 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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -33,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
33
10
  };
34
11
  Object.defineProperty(exports, "__esModule", { value: true });
35
12
  exports.Rfc3339DateTime = exports.Rfc3339Date = exports.LinkedFile = exports.LinkedCredential = void 0;
13
+ const credential_1 = require("./credential");
36
14
  const stream_1 = require("./utils/stream");
37
15
  class LinkedCredential {
38
16
  constructor(client, claimsModel, id, digestMultibase) {
@@ -70,8 +48,7 @@ class LinkedCredential {
70
48
  }
71
49
  dereference() {
72
50
  return __awaiter(this, void 0, void 0, function* () {
73
- const { VcDecorator } = yield Promise.resolve().then(() => __importStar(require('./credential')));
74
- const loadedCredential = yield new VcDecorator(this.client, this.claimsModel).load(LinkedCredential.normalizeLinkedCredentialId(this.id).resourceId);
51
+ const loadedCredential = yield new credential_1.VcDecorator(this.client, this.claimsModel).load(LinkedCredential.normalizeLinkedCredentialId(this.id).resourceId);
75
52
  // TODO: add support for working with both issued and draft creds
76
53
  if (!loadedCredential.isVerifiable) {
77
54
  throw new Error(`The linked credential is not a VC: ${this.id}`);
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/documents/models.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,2CAAwC;AAQxC,MAAa,gBAAgB;IAgCzB,YACY,MAAiB,EACjB,WAAoB,EAC5B,EAAU,EACH,eAAwB;QAHvB,WAAM,GAAN,MAAM,CAAW;QACjB,gBAAW,GAAX,WAAW,CAAS;QAErB,oBAAe,GAAf,eAAe,CAAS;QAN5B,SAAI,GAAmC,kBAAkB,CAAC;QAQ7D,IAAI,CAAC,EAAE,GAAG,gBAAgB,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC;IACxE,CAAC;IAtCD,MAAM,CAAC,2BAA2B,CAAC,EAAU;QACzC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;QAEnD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YAC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AI,IAAI,EAAE,CAAC;SAC1B;IACL,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM;QACF,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACJ;AAlCD,0CAkCC","sourcesContent":["import type { ApiClient, Claims, Ctor, FileBlob, FileDescriptor, LinkedEntityDescriptor } from './types';\nimport type { VerifiableCredential } from './credential/';\nimport { buffer } from './utils/stream';\nimport { Readable } from 'stream';\n\ntype NormalizedLinkedEntityId = {\n linkedId: string;\n resourceId: string;\n};\n\nexport class LinkedCredential<T extends Claims> implements LinkedEntityDescriptor {\n static normalizeLinkedCredentialId(id: string): NormalizedLinkedEntityId {\n const expectedCredentialPrefix = 'urn:credential:';\n\n if (id.startsWith('urn:')) {\n if (!id.startsWith(expectedCredentialPrefix)) {\n throw new Error(`The ID does not refer to a credential: ${id}`);\n }\n\n return {\n linkedId: id,\n resourceId: id.slice(expectedCredentialPrefix.length),\n };\n }\n\n return {\n linkedId: expectedCredentialPrefix + id,\n resourceId: id,\n };\n }\n\n static createLinkedEntityDescriptor(id: string, digestMultibase?: string): LinkedEntityDescriptor {\n return {\n id: LinkedCredential.normalizeLinkedCredentialId(id).linkedId,\n digestMultibase,\n type: 'LinkedCredential',\n };\n }\n\n public id: string;\n public type: LinkedEntityDescriptor['type'] = 'LinkedCredential';\n\n constructor(\n private client: ApiClient,\n private claimsModel: Ctor<T>,\n id: string,\n public digestMultibase?: string,\n ) {\n this.id = LinkedCredential.normalizeLinkedCredentialId(id).linkedId;\n }\n\n toJSON(): LinkedEntityDescriptor {\n return LinkedCredential.createLinkedEntityDescriptor(this.id, this.digestMultibase);\n }\n\n async dereference(): Promise<VerifiableCredential<T>> {\n const { VcDecorator } = await import('./credential');\n\n const loadedCredential = await new VcDecorator(this.client, this.claimsModel).load(\n LinkedCredential.normalizeLinkedCredentialId(this.id).resourceId,\n );\n\n // TODO: add support for working with both issued and draft creds\n if (!loadedCredential.isVerifiable) {\n throw new Error(`The linked credential is not a VC: ${this.id}`);\n }\n\n return loadedCredential.credential;\n }\n}\n\ntype DownloadableFile = FileDescriptor & {\n getReader: () => Promise<Readable>;\n download: () => Promise<FileBlob>;\n};\n\nexport class LinkedFile implements LinkedEntityDescriptor {\n static normalizeLinkedFileId(id: string): NormalizedLinkedEntityId {\n const expectedCredentialPrefix = 'urn:file:';\n\n if (id.startsWith('urn:')) {\n if (!id.startsWith(expectedCredentialPrefix)) {\n throw new Error(`The ID does not refer to a file: ${id}`);\n }\n\n return {\n linkedId: id,\n resourceId: id.slice(expectedCredentialPrefix.length),\n };\n }\n\n return {\n linkedId: expectedCredentialPrefix + id,\n resourceId: id,\n };\n }\n\n static createLinkedEntityDescriptor(id: string, digestMultibase?: string): LinkedEntityDescriptor {\n return {\n id: LinkedFile.normalizeLinkedFileId(id).linkedId,\n digestMultibase,\n type: 'LinkedFile',\n };\n }\n\n public id: string;\n public type: LinkedEntityDescriptor['type'] = 'LinkedFile';\n\n constructor(\n private client: ApiClient,\n id: string,\n public digestMultibase?: string,\n ) {\n this.id = LinkedFile.normalizeLinkedFileId(id).linkedId;\n }\n\n toJSON(): LinkedEntityDescriptor {\n return LinkedFile.createLinkedEntityDescriptor(this.id, this.digestMultibase);\n }\n\n async dereference(): Promise<DownloadableFile> {\n const file = await this.client.files.fileLatest(LinkedFile.normalizeLinkedFileId(this.id).resourceId);\n\n return {\n id: file.id,\n revision: file.revision,\n etag: file.etag,\n data: file.data,\n\n getReader: () => this.client.files.fileDownload(file.id, file.revision),\n download: async () => {\n const response = await this.client.files.fileDownload(file.id, file.revision);\n return buffer(response);\n },\n };\n }\n}\n\nexport class Rfc3339Date {\n private date: Date;\n\n constructor(year: number, month: number, day: number);\n constructor(dateString: string);\n constructor(date: Date);\n constructor();\n\n constructor(...args: any[]) {\n if (args.length === 1 && (typeof args[0] === 'string' || args[0] instanceof Date)) {\n const parsedDate = new Date(args[0]);\n\n this.date = new Date(Date.UTC(parsedDate.getFullYear(), parsedDate.getMonth(), parsedDate.getUTCDate()));\n } else if (\n args.length === 3 &&\n typeof args[0] === 'number' &&\n typeof args[1] === 'number' &&\n typeof args[2] === 'number'\n ) {\n this.date = new Date(Date.UTC(args[0], args[1], args[2]));\n } else {\n this.date = new Date();\n }\n\n this.date.setUTCHours(0, 0, 0, 0);\n }\n\n toString(): string {\n return this.date.toISOString().split('T')[0];\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n toDate(): Date {\n return new Date(this.date);\n }\n}\n\nexport class Rfc3339DateTime {\n private date: Date;\n\n constructor(year: number, month: number, day: number);\n constructor(dateString: string);\n constructor(date: Date);\n constructor();\n\n constructor(...args: any[]) {\n if (args.length === 1 && (typeof args[0] === 'string' || args[0] instanceof Date)) {\n this.date = new Date(args[0]);\n } else if (\n args.length === 3 &&\n typeof args[0] === 'number' &&\n typeof args[1] === 'number' &&\n typeof args[2] === 'number'\n ) {\n this.date = new Date(args[0], args[1], args[2]);\n } else {\n this.date = new Date();\n }\n }\n\n toString(): string {\n return this.date.toISOString();\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n toDate(): Date {\n return new Date(this.date);\n }\n}\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/documents/models.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,6CAA2C;AAC3C,2CAAwC;AAQxC,MAAa,gBAAgB;IAgCzB,YACY,MAAiB,EACjB,WAAoB,EAC5B,EAAU,EACH,eAAwB;QAHvB,WAAM,GAAN,MAAM,CAAW;QACjB,gBAAW,GAAX,WAAW,CAAS;QAErB,oBAAe,GAAf,eAAe,CAAS;QAN5B,SAAI,GAAmC,kBAAkB,CAAC;QAQ7D,IAAI,CAAC,EAAE,GAAG,gBAAgB,CAAC,2BAA2B,CAAC,EAAE,CAAC,C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AAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACnD;aAAM;YACH,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;SAC1B;IACL,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM;QACF,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACJ;AAlCD,0CAkCC","sourcesContent":["import type { ApiClient, Claims, Ctor, FileBlob, FileDescriptor, LinkedEntityDescriptor } from './types';\nimport type { VerifiableCredential } from './credential/issued';\nimport { VcDecorator } from './credential';\nimport { buffer } from './utils/stream';\nimport { Readable } from 'stream';\n\ntype NormalizedLinkedEntityId = {\n linkedId: string;\n resourceId: string;\n};\n\nexport class LinkedCredential<T extends Claims> implements LinkedEntityDescriptor {\n static normalizeLinkedCredentialId(id: string): NormalizedLinkedEntityId {\n const expectedCredentialPrefix = 'urn:credential:';\n\n if (id.startsWith('urn:')) {\n if (!id.startsWith(expectedCredentialPrefix)) {\n throw new Error(`The ID does not refer to a credential: ${id}`);\n }\n\n return {\n linkedId: id,\n resourceId: id.slice(expectedCredentialPrefix.length),\n };\n }\n\n return {\n linkedId: expectedCredentialPrefix + id,\n resourceId: id,\n };\n }\n\n static createLinkedEntityDescriptor(id: string, digestMultibase?: string): LinkedEntityDescriptor {\n return {\n id: LinkedCredential.normalizeLinkedCredentialId(id).linkedId,\n digestMultibase,\n type: 'LinkedCredential',\n };\n }\n\n public id: string;\n public type: LinkedEntityDescriptor['type'] = 'LinkedCredential';\n\n constructor(\n private client: ApiClient,\n private claimsModel: Ctor<T>,\n id: string,\n public digestMultibase?: string,\n ) {\n this.id = LinkedCredential.normalizeLinkedCredentialId(id).linkedId;\n }\n\n toJSON(): LinkedEntityDescriptor {\n return LinkedCredential.createLinkedEntityDescriptor(this.id, this.digestMultibase);\n }\n\n async dereference(): Promise<VerifiableCredential<T>> {\n const loadedCredential = await new VcDecorator(this.client, this.claimsModel).load(\n LinkedCredential.normalizeLinkedCredentialId(this.id).resourceId,\n );\n\n // TODO: add support for working with both issued and draft creds\n if (!loadedCredential.isVerifiable) {\n throw new Error(`The linked credential is not a VC: ${this.id}`);\n }\n\n return loadedCredential.credential;\n }\n}\n\ntype DownloadableFile = FileDescriptor & {\n getReader: () => Promise<Readable>;\n download: () => Promise<FileBlob>;\n};\n\nexport class LinkedFile implements LinkedEntityDescriptor {\n static normalizeLinkedFileId(id: string): NormalizedLinkedEntityId {\n const expectedCredentialPrefix = 'urn:file:';\n\n if (id.startsWith('urn:')) {\n if (!id.startsWith(expectedCredentialPrefix)) {\n throw new Error(`The ID does not refer to a file: ${id}`);\n }\n\n return {\n linkedId: id,\n resourceId: id.slice(expectedCredentialPrefix.length),\n };\n }\n\n return {\n linkedId: expectedCredentialPrefix + id,\n resourceId: id,\n };\n }\n\n static createLinkedEntityDescriptor(id: string, digestMultibase?: string): LinkedEntityDescriptor {\n return {\n id: LinkedFile.normalizeLinkedFileId(id).linkedId,\n digestMultibase,\n type: 'LinkedFile',\n };\n }\n\n public id: string;\n public type: LinkedEntityDescriptor['type'] = 'LinkedFile';\n\n constructor(\n private client: ApiClient,\n id: string,\n public digestMultibase?: string,\n ) {\n this.id = LinkedFile.normalizeLinkedFileId(id).linkedId;\n }\n\n toJSON(): LinkedEntityDescriptor {\n return LinkedFile.createLinkedEntityDescriptor(this.id, this.digestMultibase);\n }\n\n async dereference(): Promise<DownloadableFile> {\n const file = await this.client.files.fileLatest(LinkedFile.normalizeLinkedFileId(this.id).resourceId);\n\n return {\n id: file.id,\n revision: file.revision,\n etag: file.etag,\n data: file.data,\n\n getReader: () => this.client.files.fileDownload(file.id, file.revision),\n download: async () => {\n const response = await this.client.files.fileDownload(file.id, file.revision);\n return buffer(response);\n },\n };\n }\n}\n\nexport class Rfc3339Date {\n private date: Date;\n\n constructor(year: number, month: number, day: number);\n constructor(dateString: string);\n constructor(date: Date);\n constructor();\n\n constructor(...args: any[]) {\n if (args.length === 1 && (typeof args[0] === 'string' || args[0] instanceof Date)) {\n const parsedDate = new Date(args[0]);\n\n this.date = new Date(Date.UTC(parsedDate.getFullYear(), parsedDate.getMonth(), parsedDate.getUTCDate()));\n } else if (\n args.length === 3 &&\n typeof args[0] === 'number' &&\n typeof args[1] === 'number' &&\n typeof args[2] === 'number'\n ) {\n this.date = new Date(Date.UTC(args[0], args[1], args[2]));\n } else {\n this.date = new Date();\n }\n\n this.date.setUTCHours(0, 0, 0, 0);\n }\n\n toString(): string {\n return this.date.toISOString().split('T')[0];\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n toDate(): Date {\n return new Date(this.date);\n }\n}\n\nexport class Rfc3339DateTime {\n private date: Date;\n\n constructor(year: number, month: number, day: number);\n constructor(dateString: string);\n constructor(date: Date);\n constructor();\n\n constructor(...args: any[]) {\n if (args.length === 1 && (typeof args[0] === 'string' || args[0] instanceof Date)) {\n this.date = new Date(args[0]);\n } else if (\n args.length === 3 &&\n typeof args[0] === 'number' &&\n typeof args[1] === 'number' &&\n typeof args[2] === 'number'\n ) {\n this.date = new Date(args[0], args[1], args[2]);\n } else {\n this.date = new Date();\n }\n }\n\n toString(): string {\n return this.date.toISOString();\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n toDate(): Date {\n return new Date(this.date);\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { UnknownVerifiableCredential } from '../credential/';
1
+ import { UnknownVerifiableCredential } from '../credential/unknown';
2
2
  import { ApiClient, PresentationDescriptor, VerificationResult } from '../types';
3
3
  export declare class VerifiablePresentation {
4
4
  private client;
@@ -1 +1 @@
1
- {"version":3,"file":"issued.d.ts","sourceRoot":"","sources":["../../../src/documents/presentation/issued.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEjF,qBAAa,sBAAsB;IAE3B,OAAO,CAAC,MAAM;IACP,UAAU,EAAE,sBAAsB;gBADjC,MAAM,EAAE,SAAS,EAClB,UAAU,EAAE,sBAAsB;IAGvC,cAAc,IAAI,OAAO,CAAC,2BAA2B,EAAE,CAAC;IAYxD,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAQrC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUpE"}
1
+ {"version":3,"file":"issued.d.ts","sourceRoot":"","sources":["../../../src/documents/presentation/issued.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEjF,qBAAa,sBAAsB;IAE3B,OAAO,CAAC,MAAM;IACP,UAAU,EAAE,sBAAsB;gBADjC,MAAM,EAAE,SAAS,EAClB,UAAU,EAAE,sBAAsB;IAGvC,cAAc,IAAI,OAAO,CAAC,2BAA2B,EAAE,CAAC;IAYxD,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAQrC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUpE"}
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.VerifiablePresentation = void 0;
13
- const credential_1 = require("../credential/");
13
+ const unknown_1 = require("../credential/unknown");
14
14
  const helpers_1 = require("../helpers");
15
15
  class VerifiablePresentation {
16
16
  constructor(client, descriptor) {
@@ -20,7 +20,7 @@ class VerifiablePresentation {
20
20
  getCredentials() {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  const credentialResources = yield Promise.all(this.descriptor.data.linkedCredentials.map((credentialId) => this.client.credentials.credentialLatest(credentialId)));
23
- return credentialResources.map((credentialResource) => new credential_1.UnknownVerifiableCredential(this.client, credentialResource));
23
+ return credentialResources.map((credentialResource) => new unknown_1.UnknownVerifiableCredential(this.client, credentialResource));
24
24
  });
25
25
  }
26
26
  verify() {
@@ -1 +1 @@
1
- {"version":3,"file":"issued.js","sourceRoot":"","sources":["../../../src/documents/presentation/issued.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6D;AAC7D,wCAAoD;AAGpD,MAAa,sBAAsB;IAC/B,YACY,MAAiB,EAClB,UAAkC;QADjC,WAAM,GAAN,MAAM,CAAW;QAClB,eAAU,GAAV,UAAU,CAAwB;IAC1C,CAAC;IAEE,cAAc;;YAChB,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,GAAG,CACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CACxD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CACzD,CACJ,CAAC;YAEF,OAAO,mBAAmB,CAAC,GAAG,CAC1B,CAAC,kBAAkB,EAAE,EAAE,CAAC,IAAI,wCAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAC3F,CAAC;QACN,CAAC;KAAA;IAEK,MAAM;;YACR,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAEtF,OAAO;gBACH,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;aACrC,CAAC;QACN,CAAC;KAAA;IAEK,IAAI,CAAC,QAAgB,EAAE,YAAoB;;YAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,kBAAkB,CAAC;gBACjD,IAAI,EAAE;oBACF,EAAE,EAAE,QAAQ;oBACZ,KAAK,EAAE,YAAY;oBACnB,aAAa,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;iBACtC;gBACD,cAAc,EAAE,IAAA,gCAAsB,EAAC,MAAM,CAAC;aACjD,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AApCD,wDAoCC","sourcesContent":["import { UnknownVerifiableCredential } from '../credential/';\nimport { generateIdempotencyKey } from '../helpers';\nimport { ApiClient, PresentationDescriptor, VerificationResult } from '../types';\n\nexport class VerifiablePresentation {\n constructor(\n private client: ApiClient,\n public descriptor: PresentationDescriptor,\n ) {}\n\n async getCredentials(): Promise<UnknownVerifiableCredential[]> {\n const credentialResources = await Promise.all(\n this.descriptor.data.linkedCredentials.map((credentialId) =>\n this.client.credentials.credentialLatest(credentialId),\n ),\n );\n\n return credentialResources.map(\n (credentialResource) => new UnknownVerifiableCredential(this.client, credentialResource),\n );\n }\n\n async verify(): Promise<VerificationResult> {\n const result = await this.client.presentations.presentationVerify(this.descriptor.id);\n\n return {\n verified: result.verified || false,\n };\n }\n\n async send(targetId: string, privateKeyId: string): Promise<void> {\n await this.client.didcommMessages.didCommMessageSend({\n data: {\n to: targetId,\n keyId: privateKeyId,\n presentations: [this.descriptor.id],\n },\n idempotencyKey: generateIdempotencyKey('send'),\n });\n }\n}\n"]}
1
+ {"version":3,"file":"issued.js","sourceRoot":"","sources":["../../../src/documents/presentation/issued.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAoE;AACpE,wCAAoD;AAGpD,MAAa,sBAAsB;IAC/B,YACY,MAAiB,EAClB,UAAkC;QADjC,WAAM,GAAN,MAAM,CAAW;QAClB,eAAU,GAAV,UAAU,CAAwB;IAC1C,CAAC;IAEE,cAAc;;YAChB,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,GAAG,CACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CACxD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CACzD,CACJ,CAAC;YAEF,OAAO,mBAAmB,CAAC,GAAG,CAC1B,CAAC,kBAAkB,EAAE,EAAE,CAAC,IAAI,qCAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAC3F,CAAC;QACN,CAAC;KAAA;IAEK,MAAM;;YACR,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAEtF,OAAO;gBACH,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;aACrC,CAAC;QACN,CAAC;KAAA;IAEK,IAAI,CAAC,QAAgB,EAAE,YAAoB;;YAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,kBAAkB,CAAC;gBACjD,IAAI,EAAE;oBACF,EAAE,EAAE,QAAQ;oBACZ,KAAK,EAAE,YAAY;oBACnB,aAAa,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;iBACtC;gBACD,cAAc,EAAE,IAAA,gCAAsB,EAAC,MAAM,CAAC;aACjD,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AApCD,wDAoCC","sourcesContent":["import { UnknownVerifiableCredential } from '../credential/unknown';\nimport { generateIdempotencyKey } from '../helpers';\nimport { ApiClient, PresentationDescriptor, VerificationResult } from '../types';\n\nexport class VerifiablePresentation {\n constructor(\n private client: ApiClient,\n public descriptor: PresentationDescriptor,\n ) {}\n\n async getCredentials(): Promise<UnknownVerifiableCredential[]> {\n const credentialResources = await Promise.all(\n this.descriptor.data.linkedCredentials.map((credentialId) =>\n this.client.credentials.credentialLatest(credentialId),\n ),\n );\n\n return credentialResources.map(\n (credentialResource) => new UnknownVerifiableCredential(this.client, credentialResource),\n );\n }\n\n async verify(): Promise<VerificationResult> {\n const result = await this.client.presentations.presentationVerify(this.descriptor.id);\n\n return {\n verified: result.verified || false,\n };\n }\n\n async send(targetId: string, privateKeyId: string): Promise<void> {\n await this.client.didcommMessages.didCommMessageSend({\n data: {\n to: targetId,\n keyId: privateKeyId,\n presentations: [this.descriptor.id],\n },\n idempotencyKey: generateIdempotencyKey('send'),\n });\n }\n}\n"]}
@@ -1,12 +1,18 @@
1
1
  import { ResourceCredential, ResourcePresentation } from '../api';
2
- import { BaseVerifiableCredential, UnknownVerifiableCredential, VerifiableCredential } from './credential/';
2
+ import { BaseVerifiableCredential } from './credential/baseVerifiableCredential';
3
+ import { UnknownVerifiableCredential } from './credential/unknown';
4
+ import { VerifiableCredential } from './credential/issued';
3
5
  import { VerifiablePresentation } from './presentation/issued';
4
6
  import { ApiClient, BlobInput, UpdatePayload } from './types';
5
7
  export declare class VpDecorator {
6
8
  private client;
7
9
  constructor(client: ApiClient);
8
10
  private importBlob;
11
+ /**
12
+ * @deprecated Please use `importPresentation` instead. This method will be removed after January 2025.
13
+ */
9
14
  import(blob: BlobInput, request?: UpdatePayload): Promise<VerifiablePresentation>;
15
+ importPresentation(blob: BlobInput, request?: UpdatePayload): Promise<VerifiablePresentation>;
10
16
  map(input: ResourcePresentation): VerifiablePresentation;
11
17
  load(id: string, revision?: number): Promise<VerifiablePresentation>;
12
18
  issue(credentials: ResourceCredential[], privateKeyId: string): Promise<VerifiablePresentation>;
@@ -1 +1 @@
1
- {"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../src/documents/presentation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC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ecorator = void 0;
16
16
  const node_fetch_1 = __importDefault(require("node-fetch"));
17
- const credential_1 = require("./credential/");
17
+ const baseVerifiableCredential_1 = require("./credential/baseVerifiableCredential");
18
18
  const helpers_1 = require("./helpers");
19
19
  const issued_1 = require("./presentation/issued");
20
20
  class VpDecorator {
@@ -48,7 +48,15 @@ class VpDecorator {
48
48
  };
49
49
  });
50
50
  }
51
+ /**
52
+ * @deprecated Please use `importPresentation` instead. This method will be removed after January 2025.
53
+ */
51
54
  import(blob, request) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ return this.importPresentation(blob, request);
57
+ });
58
+ }
59
+ importPresentation(blob, request) {
52
60
  return __awaiter(this, void 0, void 0, function* () {
53
61
  const resourcePresentation = yield this.importBlob(blob, request);
54
62
  return new issued_1.VerifiablePresentation(this.client, resourcePresentation);
@@ -79,7 +87,7 @@ class VpDecorator {
79
87
  const credentialIds = credentials.map((item) => {
80
88
  if (typeof item === 'string')
81
89
  return item;
82
- if (item instanceof credential_1.BaseVerifiableCredential)
90
+ if (item instanceof baseVerifiableCredential_1.BaseVerifiableCredential)
83
91
  return item.descriptor.id;
84
92
  return item.id;
85
93
  });
@@ -1 +1 @@
1
- {"version":3,"file":"presentation.js","sourceRoot":"","sources":["../../src/documents/presentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAA+B;AAG/B,8CAA4G;AAC5G,uCAAmD;AACnD,kDAA+D;AAG/D,MAAa,WAAW;IACpB,YAAoB,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAE3B,UAAU,CAAC,IAAe,EAAE,OAAuB;;;YAC7D,MAAM,cAAc,GAAG,IAAA,gCAAsB,EAAC,YAAY,CAAC,CAAC;YAC5D,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC;gBAC7E,cAAc;aACjB,CAAC,CAAC;YAEH,MAAM,IAAA,oBAA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AAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,EAAE,QAAQ,CAAC;gBACpE,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;YAE7D,OAAO,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAC1C,CAAC;KAAA;IAOK,KAAK,CACP,WAAyE,EACzE,YAAoB;;;YAEpB,MAAM,aAAa,GAAa,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACrD,IAAI,OAAO,IAAI,KAAK,QAAQ;oBAAE,OAAO,IAAI,CAAC;gBAC1C,IAAI,IAAI,YAAY,qCAAwB;oBAAE,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,OAAO,IAAI,CAAC,EAAE,CAAC;YACnB,CAAC,CAAC,CAAC;YAEH,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC;gBAC3E,aAAa;gBACb,KAAK,EAAE,YAAY;aACtB,CAAC,CAAC;YAEH,OAAO,IAAI,+BAAsB,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC3C,EAAE,EAAE,oBAAoB,CAAC,EAAE;gBAC3B,IAAI,EAAE,oBAAoB,CAAC,IAAI;gBAC/B,QAAQ,EAAE,oBAAoB,CAAC,QAAQ;gBACvC,IAAI,EAAE;oBACF,iBAAiB,EAAE,MAAA,oBAAoB,CAAC,IAAI,CAAC,iBAAiB,mCAAI,EAAE;iBACvE;aACJ,CAAC,CAAC;;KACN;CACJ;AArFD,kCAqFC","sourcesContent":["import fetch from 'node-fetch';\n\nimport { ResourceCredential, ResourcePresentation } from '../api';\nimport { BaseVerifiableCredential, UnknownVerifiableCredential, VerifiableCredential } from './credential/';\nimport { generateIdempotencyKey } from './helpers';\nimport { VerifiablePresentation } from './presentation/issued';\nimport { ApiClient, BlobInput, PresentationDescriptor, UpdatePayload } from './types';\n\nexport class VpDecorator {\n constructor(private client: ApiClient) {}\n\n private async importBlob(blob: BlobInput, request?: UpdatePayload): Promise<PresentationDescriptor> {\n const idempotencyKey = generateIdempotencyKey('importBlob');\n const { blobId, uploadUri } = await this.client.presentations.presentationUpload({\n idempotencyKey,\n });\n\n await fetch(uploadUri, {\n method: 'PUT',\n body: blob,\n });\n\n const resourcePresentation = await this.client.presentations.presentationImport({\n annotations: request?.annotations,\n labels: request?.labels,\n blobId,\n idempotencyKey,\n });\n\n return {\n id: resourcePresentation.id,\n etag: resourcePresentation.etag,\n revision: resourcePresentation.revision,\n data: {\n linkedCredentials: resourcePresentation.data.linkedCredentials ?? [],\n },\n };\n }\n\n async import(blob: BlobInput, request?: UpdatePayload): Promise<VerifiablePresentation> {\n const resourcePresentation = await this.importBlob(blob, request);\n\n return new VerifiablePresentation(this.client, resourcePresentation);\n }\n\n map(input: ResourcePresentation): VerifiablePresentation {\n return new VerifiablePresentation(this.client, {\n id: input.id,\n etag: input.etag,\n revision: input.revision,\n data: {\n linkedCredentials: input.data.linkedCredentials ?? [],\n },\n });\n }\n\n async load(id: string, revision?: number): Promise<VerifiablePresentation> {\n const resourcePresentation = revision\n ? await this.client.presentations.presentationRevision(id, revision)\n : await this.client.presentations.presentationLatest(id);\n\n return this.map(resourcePresentation);\n }\n\n issue(credentials: ResourceCredential[], privateKeyId: string): Promise<VerifiablePresentation>;\n issue(credentials: VerifiableCredential<any>[], privateKeyId: string): Promise<VerifiablePresentation>;\n issue(credentials: UnknownVerifiableCredential[], privateKeyId: string): Promise<VerifiablePresentation>;\n issue(credentials: BaseVerifiableCredential[], privateKeyId: string): Promise<VerifiablePresentation>;\n issue(credentials: string[], privateKeyId: string): Promise<VerifiablePresentation>;\n async issue(\n credentials: string[] | BaseVerifiableCredential[] | ResourceCredential[],\n privateKeyId: string,\n ): Promise<VerifiablePresentation> {\n const credentialIds: string[] = credentials.map((item) => {\n if (typeof item === 'string') return item;\n if (item instanceof BaseVerifiableCredential) return item.descriptor.id;\n return item.id;\n });\n\n const resourcePresentation = await this.client.presentations.presentationIssue({\n credentialIds,\n keyId: privateKeyId,\n });\n\n return new VerifiablePresentation(this.client, {\n id: resourcePresentation.id,\n etag: resourcePresentation.etag,\n revision: resourcePresentation.revision,\n data: {\n linkedCredentials: resourcePresentation.data.linkedCredentials ?? [],\n },\n });\n }\n}\n"]}
1
+ {"version":3,"file":"presentation.js","sourceRoot":"","sources":["../../src/documents/presentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAA+B;AAG/B,oFAAiF;AAGjF,uCAAmD;AACnD,kDAA+D;AAG/D,MAAa,WAAW;IACpB,YAAoB,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAE3B,UAAU,CAAC,IAAe,EAAE,OAAuB;;;YAC7D,MAAM,cAAc,GAAG,IAAA,gCAAsB,EAAC,YAAY,CAAC,CAAC;YAC5D,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC;gBAC7E,cAAc;aACjB,CAAC,CAAC;YAEH,MAAM,IAAA,oBAAK,EAAC,SAAS,EAAE;gBACnB,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,IAAI;aACb,CAAC,CAAC;YAEH,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC;gBAC5E,WAAW,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW;gBACjC,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM;gBACvB,MAAM;gBACN,cAAc;aACjB,CAAC,CAAC;YAEH,OAAO;gBACH,EAAE,EAAE,oBAAoB,CAAC,EAAE;gBAC3B,IAAI,EAAE,oBAAoB,CAAC,IAAI;gBAC/B,QAAQ,EAAE,oBAAoB,CAAC,QAAQ;gBACvC,I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AI,EAAE,EAAE;gBACrD,IAAI,OAAO,IAAI,KAAK,QAAQ;oBAAE,OAAO,IAAI,CAAC;gBAC1C,IAAI,IAAI,YAAY,mDAAwB;oBAAE,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,OAAO,IAAI,CAAC,EAAE,CAAC;YACnB,CAAC,CAAC,CAAC;YAEH,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC;gBAC3E,aAAa;gBACb,KAAK,EAAE,YAAY;aACtB,CAAC,CAAC;YAEH,OAAO,IAAI,+BAAsB,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC3C,EAAE,EAAE,oBAAoB,CAAC,EAAE;gBAC3B,IAAI,EAAE,oBAAoB,CAAC,IAAI;gBAC/B,QAAQ,EAAE,oBAAoB,CAAC,QAAQ;gBACvC,IAAI,EAAE;oBACF,iBAAiB,EAAE,MAAA,oBAAoB,CAAC,IAAI,CAAC,iBAAiB,mCAAI,EAAE;iBACvE;aACJ,CAAC,CAAC;;KACN;CACJ;AA5FD,kCA4FC","sourcesContent":["import fetch from 'node-fetch';\n\nimport { ResourceCredential, ResourcePresentation } from '../api';\nimport { BaseVerifiableCredential } from './credential/baseVerifiableCredential';\nimport { UnknownVerifiableCredential } from './credential/unknown';\nimport { VerifiableCredential } from './credential/issued';\nimport { generateIdempotencyKey } from './helpers';\nimport { VerifiablePresentation } from './presentation/issued';\nimport { ApiClient, BlobInput, PresentationDescriptor, UpdatePayload } from './types';\n\nexport class VpDecorator {\n constructor(private client: ApiClient) {}\n\n private async importBlob(blob: BlobInput, request?: UpdatePayload): Promise<PresentationDescriptor> {\n const idempotencyKey = generateIdempotencyKey('importBlob');\n const { blobId, uploadUri } = await this.client.presentations.presentationUpload({\n idempotencyKey,\n });\n\n await fetch(uploadUri, {\n method: 'PUT',\n body: blob,\n });\n\n const resourcePresentation = await this.client.presentations.presentationImport({\n annotations: request?.annotations,\n labels: request?.labels,\n blobId,\n idempotencyKey,\n });\n\n return {\n id: resourcePresentation.id,\n etag: resourcePresentation.etag,\n revision: resourcePresentation.revision,\n data: {\n linkedCredentials: resourcePresentation.data.linkedCredentials ?? [],\n },\n };\n }\n\n /**\n * @deprecated Please use `importPresentation` instead. This method will be removed after January 2025.\n */\n async import(blob: BlobInput, request?: UpdatePayload): Promise<VerifiablePresentation> {\n return this.importPresentation(blob, request);\n }\n\n async importPresentation(blob: BlobInput, request?: UpdatePayload): Promise<VerifiablePresentation> {\n const resourcePresentation = await this.importBlob(blob, request);\n\n return new VerifiablePresentation(this.client, resourcePresentation);\n }\n\n map(input: ResourcePresentation): VerifiablePresentation {\n return new VerifiablePresentation(this.client, {\n id: input.id,\n etag: input.etag,\n revision: input.revision,\n data: {\n linkedCredentials: input.data.linkedCredentials ?? [],\n },\n });\n }\n\n async load(id: string, revision?: number): Promise<VerifiablePresentation> {\n const resourcePresentation = revision\n ? await this.client.presentations.presentationRevision(id, revision)\n : await this.client.presentations.presentationLatest(id);\n\n return this.map(resourcePresentation);\n }\n\n issue(credentials: ResourceCredential[], privateKeyId: string): Promise<VerifiablePresentation>;\n issue(credentials: VerifiableCredential<any>[], privateKeyId: string): Promise<VerifiablePresentation>;\n issue(credentials: UnknownVerifiableCredential[], privateKeyId: string): Promise<VerifiablePresentation>;\n issue(credentials: BaseVerifiableCredential[], privateKeyId: string): Promise<VerifiablePresentation>;\n issue(credentials: string[], privateKeyId: string): Promise<VerifiablePresentation>;\n async issue(\n credentials: string[] | BaseVerifiableCredential[] | ResourceCredential[],\n privateKeyId: string,\n ): Promise<VerifiablePresentation> {\n const credentialIds: string[] = credentials.map((item) => {\n if (typeof item === 'string') return item;\n if (item instanceof BaseVerifiableCredential) return item.descriptor.id;\n return item.id;\n });\n\n const resourcePresentation = await this.client.presentations.presentationIssue({\n credentialIds,\n keyId: privateKeyId,\n });\n\n return new VerifiablePresentation(this.client, {\n id: resourcePresentation.id,\n etag: resourcePresentation.etag,\n revision: resourcePresentation.revision,\n data: {\n linkedCredentials: resourcePresentation.data.linkedCredentials ?? [],\n },\n });\n }\n}\n"]}
@@ -17,6 +17,7 @@ export declare type CredentialMetadata = DraftMetadata & {
17
17
  id: string;
18
18
  issuer: string;
19
19
  issuanceDate: Date;
20
+ holder?: string;
20
21
  };
21
22
  export declare type ValueWithId = {
22
23
  id: string;