@twin.org/identity-connector-entity-storage 0.10.1-next.4 → 0.10.1-next.6

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 (30) hide show
  1. package/dist/es/entities/identityDocument.js +17 -1
  2. package/dist/es/entities/identityDocument.js.map +1 -1
  3. package/dist/es/entities/identityDocumentV0.js +46 -0
  4. package/dist/es/entities/identityDocumentV0.js.map +1 -0
  5. package/dist/es/entities/identityProfile.js +17 -1
  6. package/dist/es/entities/identityProfile.js.map +1 -1
  7. package/dist/es/entities/identityProfileV0.js +38 -0
  8. package/dist/es/entities/identityProfileV0.js.map +1 -0
  9. package/dist/es/entityStorageIdentityConnector.js +21 -10
  10. package/dist/es/entityStorageIdentityConnector.js.map +1 -1
  11. package/dist/es/entityStorageIdentityProfileConnector.js +5 -1
  12. package/dist/es/entityStorageIdentityProfileConnector.js.map +1 -1
  13. package/dist/es/index.js +2 -0
  14. package/dist/es/index.js.map +1 -1
  15. package/dist/es/schema.js +4 -0
  16. package/dist/es/schema.js.map +1 -1
  17. package/dist/types/entities/identityDocument.d.ts +8 -0
  18. package/dist/types/entities/identityDocumentV0.d.ts +23 -0
  19. package/dist/types/entities/identityProfile.d.ts +8 -0
  20. package/dist/types/entities/identityProfileV0.d.ts +18 -0
  21. package/dist/types/entityStorageIdentityConnector.d.ts +2 -0
  22. package/dist/types/index.d.ts +2 -0
  23. package/docs/changelog.md +28 -0
  24. package/docs/reference/classes/EntityStorageIdentityConnector.md +6 -0
  25. package/docs/reference/classes/IdentityDocument.md +16 -0
  26. package/docs/reference/classes/IdentityDocumentV0.md +46 -0
  27. package/docs/reference/classes/IdentityProfile.md +16 -0
  28. package/docs/reference/classes/IdentityProfileV0.md +38 -0
  29. package/docs/reference/index.md +2 -0
  30. package/package.json +2 -2
@@ -21,6 +21,14 @@ let IdentityDocument = class IdentityDocument {
21
21
  * The controller of the document.
22
22
  */
23
23
  controller;
24
+ /**
25
+ * The date the document was created, undefined for documents stored before it was captured.
26
+ */
27
+ dateCreated;
28
+ /**
29
+ * The date the document was last modified.
30
+ */
31
+ dateModified;
24
32
  };
25
33
  __decorate([
26
34
  property({ type: "string", isPrimary: true, maxLength: 255 }),
@@ -38,8 +46,16 @@ __decorate([
38
46
  property({ type: "string", maxLength: 255 }),
39
47
  __metadata("design:type", String)
40
48
  ], IdentityDocument.prototype, "controller", void 0);
49
+ __decorate([
50
+ property({ type: "string", format: "date-time", optional: true }),
51
+ __metadata("design:type", String)
52
+ ], IdentityDocument.prototype, "dateCreated", void 0);
53
+ __decorate([
54
+ property({ type: "string", format: "date-time", optional: true }),
55
+ __metadata("design:type", String)
56
+ ], IdentityDocument.prototype, "dateModified", void 0);
41
57
  IdentityDocument = __decorate([
42
- entity()
58
+ entity({ version: 1 })
43
59
  ], IdentityDocument);
44
60
  export { IdentityDocument };
45
61
  //# sourceMappingURL=identityDocument.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identityDocument.js","sourceRoot":"","sources":["../../../src/entities/identityDocument.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGpD;;GAEG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC5B;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,QAAQ,CAAgB;IAE/B;;OAEG;IAEI,SAAS,CAAU;IAE1B;;OAEG;IAEI,UAAU,CAAU;CAC3B,CAAA;AAnBO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;4CAC3C;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;kDACE;AAMxB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;mDACH;AAMnB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;oDAClB;AAvBf,gBAAgB;IAD5B,MAAM,EAAE;GACI,gBAAgB,CAwB5B","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { entity, property } from \"@twin.org/entity\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\n\n/**\n * Class describing the identity document.\n */\n@entity()\nexport class IdentityDocument {\n\t/**\n\t * The identity of the document.\n\t */\n\t@property({ type: \"string\", isPrimary: true, maxLength: 255 })\n\tpublic id!: string;\n\n\t/**\n\t * The DID document.\n\t */\n\t@property({ type: \"object\" })\n\tpublic document!: IDidDocument;\n\n\t/**\n\t * The signature of the document.\n\t */\n\t@property({ type: \"string\" })\n\tpublic signature!: string;\n\n\t/**\n\t * The controller of the document.\n\t */\n\t@property({ type: \"string\", maxLength: 255 })\n\tpublic controller!: string;\n}\n"]}
1
+ {"version":3,"file":"identityDocument.js","sourceRoot":"","sources":["../../../src/entities/identityDocument.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGpD;;GAEG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC5B;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,QAAQ,CAAgB;IAE/B;;OAEG;IAEI,SAAS,CAAU;IAE1B;;OAEG;IAEI,UAAU,CAAU;IAE3B;;OAEG;IAEI,WAAW,CAAU;IAE5B;;OAEG;IAEI,YAAY,CAAU;CAC7B,CAAA;AA/BO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;4CAC3C;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;kDACE;AAMxB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;mDACH;AAMnB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;oDAClB;AAMpB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACtC;AAMrB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACrC;AAnCjB,gBAAgB;IAD5B,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;GACV,gBAAgB,CAoC5B","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { entity, property } from \"@twin.org/entity\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\n\n/**\n * Class describing the identity document.\n */\n@entity({ version: 1 })\nexport class IdentityDocument {\n\t/**\n\t * The identity of the document.\n\t */\n\t@property({ type: \"string\", isPrimary: true, maxLength: 255 })\n\tpublic id!: string;\n\n\t/**\n\t * The DID document.\n\t */\n\t@property({ type: \"object\" })\n\tpublic document!: IDidDocument;\n\n\t/**\n\t * The signature of the document.\n\t */\n\t@property({ type: \"string\" })\n\tpublic signature!: string;\n\n\t/**\n\t * The controller of the document.\n\t */\n\t@property({ type: \"string\", maxLength: 255 })\n\tpublic controller!: string;\n\n\t/**\n\t * The date the document was created, undefined for documents stored before it was captured.\n\t */\n\t@property({ type: \"string\", format: \"date-time\", optional: true })\n\tpublic dateCreated?: string;\n\n\t/**\n\t * The date the document was last modified.\n\t */\n\t@property({ type: \"string\", format: \"date-time\", optional: true })\n\tpublic dateModified?: string;\n}\n"]}
@@ -0,0 +1,46 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { entity, property } from "@twin.org/entity";
4
+ /**
5
+ * Class describing the identity document, version 0. Covers every row written before the
6
+ * version record existed, without the created and modified dates.
7
+ */
8
+ let IdentityDocumentV0 = class IdentityDocumentV0 {
9
+ /**
10
+ * The identity of the document.
11
+ */
12
+ id;
13
+ /**
14
+ * The DID document.
15
+ */
16
+ document;
17
+ /**
18
+ * The signature of the document.
19
+ */
20
+ signature;
21
+ /**
22
+ * The controller of the document.
23
+ */
24
+ controller;
25
+ };
26
+ __decorate([
27
+ property({ type: "string", isPrimary: true }),
28
+ __metadata("design:type", String)
29
+ ], IdentityDocumentV0.prototype, "id", void 0);
30
+ __decorate([
31
+ property({ type: "object" }),
32
+ __metadata("design:type", Object)
33
+ ], IdentityDocumentV0.prototype, "document", void 0);
34
+ __decorate([
35
+ property({ type: "string" }),
36
+ __metadata("design:type", String)
37
+ ], IdentityDocumentV0.prototype, "signature", void 0);
38
+ __decorate([
39
+ property({ type: "string" }),
40
+ __metadata("design:type", String)
41
+ ], IdentityDocumentV0.prototype, "controller", void 0);
42
+ IdentityDocumentV0 = __decorate([
43
+ entity({ version: 0 })
44
+ ], IdentityDocumentV0);
45
+ export { IdentityDocumentV0 };
46
+ //# sourceMappingURL=identityDocumentV0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityDocumentV0.js","sourceRoot":"","sources":["../../../src/entities/identityDocumentV0.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGpD;;;GAGG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC9B;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,QAAQ,CAAgB;IAE/B;;OAEG;IAEI,SAAS,CAAU;IAE1B;;OAEG;IAEI,UAAU,CAAU;CAC3B,CAAA;AAnBO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;8CAC3B;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;oDACE;AAMxB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;qDACH;AAMnB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;sDACF;AAvBf,kBAAkB;IAD9B,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;GACV,kBAAkB,CAwB9B","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { entity, property } from \"@twin.org/entity\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\n\n/**\n * Class describing the identity document, version 0. Covers every row written before the\n * version record existed, without the created and modified dates.\n */\n@entity({ version: 0 })\nexport class IdentityDocumentV0 {\n\t/**\n\t * The identity of the document.\n\t */\n\t@property({ type: \"string\", isPrimary: true })\n\tpublic id!: string;\n\n\t/**\n\t * The DID document.\n\t */\n\t@property({ type: \"object\" })\n\tpublic document!: IDidDocument;\n\n\t/**\n\t * The signature of the document.\n\t */\n\t@property({ type: \"string\" })\n\tpublic signature!: string;\n\n\t/**\n\t * The controller of the document.\n\t */\n\t@property({ type: \"string\" })\n\tpublic controller!: string;\n}\n"]}
@@ -17,6 +17,14 @@ let IdentityProfile = class IdentityProfile {
17
17
  * The private profile data.
18
18
  */
19
19
  privateProfile;
20
+ /**
21
+ * The date the profile was created, undefined for profiles stored before it was captured.
22
+ */
23
+ dateCreated;
24
+ /**
25
+ * The date the profile was last modified.
26
+ */
27
+ dateModified;
20
28
  };
21
29
  __decorate([
22
30
  property({ type: "string", isPrimary: true, maxLength: 255 }),
@@ -30,8 +38,16 @@ __decorate([
30
38
  property({ type: "object", optional: true }),
31
39
  __metadata("design:type", Object)
32
40
  ], IdentityProfile.prototype, "privateProfile", void 0);
41
+ __decorate([
42
+ property({ type: "string", format: "date-time", optional: true }),
43
+ __metadata("design:type", String)
44
+ ], IdentityProfile.prototype, "dateCreated", void 0);
45
+ __decorate([
46
+ property({ type: "string", format: "date-time", optional: true }),
47
+ __metadata("design:type", String)
48
+ ], IdentityProfile.prototype, "dateModified", void 0);
33
49
  IdentityProfile = __decorate([
34
- entity()
50
+ entity({ version: 1 })
35
51
  ], IdentityProfile);
36
52
  export { IdentityProfile };
37
53
  //# sourceMappingURL=identityProfile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identityProfile.js","sourceRoot":"","sources":["../../../src/entities/identityProfile.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAC3B;;OAEG;IAEI,QAAQ,CAAU;IAEzB;;OAEG;IAEI,aAAa,CAAW;IAE/B;;OAEG;IAEI,cAAc,CAAW;CAChC,CAAA;AAbO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;iDACrC;AAMlB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACd;AAMxB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDACb;AAjBpB,eAAe;IAD3B,MAAM,EAAE;GACI,eAAe,CAkB3B","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { entity, property } from \"@twin.org/entity\";\n\n/**\n * Class representing profile details for the identity.\n */\n@entity()\nexport class IdentityProfile {\n\t/**\n\t * The id for the identity.\n\t */\n\t@property({ type: \"string\", isPrimary: true, maxLength: 255 })\n\tpublic identity!: string;\n\n\t/**\n\t * The public profile data.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic publicProfile?: unknown;\n\n\t/**\n\t * The private profile data.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic privateProfile?: unknown;\n}\n"]}
1
+ {"version":3,"file":"identityProfile.js","sourceRoot":"","sources":["../../../src/entities/identityProfile.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAC3B;;OAEG;IAEI,QAAQ,CAAU;IAEzB;;OAEG;IAEI,aAAa,CAAW;IAE/B;;OAEG;IAEI,cAAc,CAAW;IAEhC;;OAEG;IAEI,WAAW,CAAU;IAE5B;;OAEG;IAEI,YAAY,CAAU;CAC7B,CAAA;AAzBO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;iDACrC;AAMlB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACd;AAMxB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDACb;AAMzB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACtC;AAMrB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACrC;AA7BjB,eAAe;IAD3B,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;GACV,eAAe,CA8B3B","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { entity, property } from \"@twin.org/entity\";\n\n/**\n * Class representing profile details for the identity.\n */\n@entity({ version: 1 })\nexport class IdentityProfile {\n\t/**\n\t * The id for the identity.\n\t */\n\t@property({ type: \"string\", isPrimary: true, maxLength: 255 })\n\tpublic identity!: string;\n\n\t/**\n\t * The public profile data.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic publicProfile?: unknown;\n\n\t/**\n\t * The private profile data.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic privateProfile?: unknown;\n\n\t/**\n\t * The date the profile was created, undefined for profiles stored before it was captured.\n\t */\n\t@property({ type: \"string\", format: \"date-time\", optional: true })\n\tpublic dateCreated?: string;\n\n\t/**\n\t * The date the profile was last modified.\n\t */\n\t@property({ type: \"string\", format: \"date-time\", optional: true })\n\tpublic dateModified?: string;\n}\n"]}
@@ -0,0 +1,38 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { entity, property } from "@twin.org/entity";
4
+ /**
5
+ * Class representing profile details for the identity, version 0. Covers every row written
6
+ * before the version record existed, without the created and modified dates.
7
+ */
8
+ let IdentityProfileV0 = class IdentityProfileV0 {
9
+ /**
10
+ * The id for the identity.
11
+ */
12
+ identity;
13
+ /**
14
+ * The public profile data.
15
+ */
16
+ publicProfile;
17
+ /**
18
+ * The private profile data.
19
+ */
20
+ privateProfile;
21
+ };
22
+ __decorate([
23
+ property({ type: "string", isPrimary: true }),
24
+ __metadata("design:type", String)
25
+ ], IdentityProfileV0.prototype, "identity", void 0);
26
+ __decorate([
27
+ property({ type: "object", optional: true }),
28
+ __metadata("design:type", Object)
29
+ ], IdentityProfileV0.prototype, "publicProfile", void 0);
30
+ __decorate([
31
+ property({ type: "object", optional: true }),
32
+ __metadata("design:type", Object)
33
+ ], IdentityProfileV0.prototype, "privateProfile", void 0);
34
+ IdentityProfileV0 = __decorate([
35
+ entity({ version: 0 })
36
+ ], IdentityProfileV0);
37
+ export { IdentityProfileV0 };
38
+ //# sourceMappingURL=identityProfileV0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityProfileV0.js","sourceRoot":"","sources":["../../../src/entities/identityProfileV0.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC7B;;OAEG;IAEI,QAAQ,CAAU;IAEzB;;OAEG;IAEI,aAAa,CAAW;IAE/B;;OAEG;IAEI,cAAc,CAAW;CAChC,CAAA;AAbO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;mDACrB;AAMlB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wDACd;AAMxB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yDACb;AAjBpB,iBAAiB;IAD7B,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;GACV,iBAAiB,CAkB7B","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { entity, property } from \"@twin.org/entity\";\n\n/**\n * Class representing profile details for the identity, version 0. Covers every row written\n * before the version record existed, without the created and modified dates.\n */\n@entity({ version: 0 })\nexport class IdentityProfileV0 {\n\t/**\n\t * The id for the identity.\n\t */\n\t@property({ type: \"string\", isPrimary: true })\n\tpublic identity!: string;\n\n\t/**\n\t * The public profile data.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic publicProfile?: unknown;\n\n\t/**\n\t * The private profile data.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic privateProfile?: unknown;\n}\n"]}
@@ -167,6 +167,7 @@ export class EntityStorageIdentityConnector {
167
167
  * @param documentId The id of the document to remove.
168
168
  * @param options Optional settings.
169
169
  * @param options.removeKeys Also remove any associated private keys from the vault.
170
+ * @param options.removeDocumentKey Also remove the document key from the vault.
170
171
  * @returns A promise that resolves when the document has been removed.
171
172
  */
172
173
  async removeDocument(controller, documentId, options) {
@@ -195,6 +196,12 @@ export class EntityStorageIdentityConnector {
195
196
  }
196
197
  }
197
198
  }
199
+ if (options?.removeDocumentKey ?? false) {
200
+ const documentKey = EntityStorageIdentityConnector.buildVaultKey(documentId, "did");
201
+ if (await this._vaultConnector.keyExists(documentKey)) {
202
+ await this._vaultConnector.removeKey(documentKey);
203
+ }
204
+ }
198
205
  }
199
206
  catch (error) {
200
207
  throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "removeDocumentFailed", undefined, error);
@@ -258,7 +265,7 @@ export class EntityStorageIdentityConnector {
258
265
  };
259
266
  didDocument[verificationMethodType] ??= [];
260
267
  didDocument[verificationMethodType]?.push(didVerificationMethod);
261
- await this.updateDocument(controller, didDocument);
268
+ await this.updateDocument(controller, didDocument, didIdentityDocument);
262
269
  return didVerificationMethod;
263
270
  }
264
271
  catch (error) {
@@ -297,7 +304,7 @@ export class EntityStorageIdentityConnector {
297
304
  if (!this.removeMethodById(didDocument, verificationMethodId)) {
298
305
  throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "verificationMethodNotFound", verificationMethodId);
299
306
  }
300
- await this.updateDocument(controller, didDocument);
307
+ await this.updateDocument(controller, didDocument, didIdentityDocument);
301
308
  if (options?.removeKeys ?? false) {
302
309
  try {
303
310
  await this._vaultConnector.removeKey(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment));
@@ -352,7 +359,7 @@ export class EntityStorageIdentityConnector {
352
359
  };
353
360
  didDocument.service ??= [];
354
361
  didDocument.service.push(didService);
355
- await this.updateDocument(controller, didDocument);
362
+ await this.updateDocument(controller, didDocument, didIdentityDocument);
356
363
  return didService;
357
364
  }
358
365
  catch (error) {
@@ -391,7 +398,7 @@ export class EntityStorageIdentityConnector {
391
398
  else {
392
399
  throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "serviceNotFound", serviceId);
393
400
  }
394
- await this.updateDocument(controller, didDocument);
401
+ await this.updateDocument(controller, didDocument, didIdentityDocument);
395
402
  }
396
403
  catch (error) {
397
404
  throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "removeServiceFailed", undefined, error);
@@ -422,7 +429,7 @@ export class EntityStorageIdentityConnector {
422
429
  return;
423
430
  }
424
431
  didDocument.alsoKnownAs = [...existing, alias];
425
- await this.updateDocument(controller, didDocument);
432
+ await this.updateDocument(controller, didDocument, didIdentityDocument);
426
433
  }
427
434
  catch (error) {
428
435
  throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "addAlsoKnownAsFailed", undefined, error);
@@ -458,7 +465,7 @@ export class EntityStorageIdentityConnector {
458
465
  else {
459
466
  didDocument.alsoKnownAs = filtered;
460
467
  }
461
- await this.updateDocument(controller, didDocument);
468
+ await this.updateDocument(controller, didDocument, didIdentityDocument);
462
469
  }
463
470
  catch (error) {
464
471
  throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "removeAlsoKnownAsFailed", undefined, error);
@@ -718,7 +725,7 @@ export class EntityStorageIdentityConnector {
718
725
  revocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;
719
726
  }
720
727
  }
721
- await this.updateDocument(controller, issuerDidDocument);
728
+ await this.updateDocument(controller, issuerDidDocument, issuerIdentityDocument);
722
729
  }
723
730
  catch (error) {
724
731
  throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "revokeVerifiableCredentialsFailed", undefined, error);
@@ -754,7 +761,7 @@ export class EntityStorageIdentityConnector {
754
761
  revocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;
755
762
  }
756
763
  }
757
- await this.updateDocument(controller, issuerDidDocument);
764
+ await this.updateDocument(controller, issuerDidDocument, issuerIdentityDocument);
758
765
  }
759
766
  catch (error) {
760
767
  throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "unrevokeVerifiableCredentialsFailed", undefined, error);
@@ -1278,18 +1285,22 @@ export class EntityStorageIdentityConnector {
1278
1285
  * Update the document in storage.
1279
1286
  * @param controller The controller of the document.
1280
1287
  * @param didDocument The did document to store.
1288
+ * @param existingDocument The currently stored entity, undefined when creating.
1281
1289
  * @returns A promise that resolves when the document has been signed and persisted.
1282
1290
  * @internal
1283
1291
  */
1284
- async updateDocument(controller, didDocument) {
1292
+ async updateDocument(controller, didDocument, existingDocument) {
1285
1293
  const stringifiedDocument = JsonHelper.canonicalize(didDocument);
1286
1294
  const docBytes = Converter.utf8ToBytes(stringifiedDocument);
1287
1295
  const signature = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(didDocument.id, "did"), docBytes);
1296
+ const now = new Date(Date.now()).toISOString();
1288
1297
  const identityDocument = {
1289
1298
  id: didDocument.id,
1290
1299
  document: didDocument,
1291
1300
  signature: Converter.bytesToBase64(signature),
1292
- controller
1301
+ controller,
1302
+ dateCreated: Is.undefined(existingDocument) ? now : existingDocument.dateCreated,
1303
+ dateModified: now
1293
1304
  };
1294
1305
  await this._didDocumentEntityStorage.set(identityDocument);
1295
1306
  this._didResolutionCache?.set(this.ownDidCacheKey(didDocument.id), ObjectHelper.clone(identityDocument));