@twin.org/identity-connector-entity-storage 0.10.1-next.4 → 0.10.1-next.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.
- package/dist/es/entities/identityDocument.js +17 -1
- package/dist/es/entities/identityDocument.js.map +1 -1
- package/dist/es/entities/identityDocumentV0.js +46 -0
- package/dist/es/entities/identityDocumentV0.js.map +1 -0
- package/dist/es/entities/identityProfile.js +17 -1
- package/dist/es/entities/identityProfile.js.map +1 -1
- package/dist/es/entities/identityProfileV0.js +38 -0
- package/dist/es/entities/identityProfileV0.js.map +1 -0
- package/dist/es/entityStorageIdentityConnector.js +14 -10
- package/dist/es/entityStorageIdentityConnector.js.map +1 -1
- package/dist/es/entityStorageIdentityProfileConnector.js +5 -1
- package/dist/es/entityStorageIdentityProfileConnector.js.map +1 -1
- package/dist/es/index.js +2 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/schema.js +4 -0
- package/dist/es/schema.js.map +1 -1
- package/dist/types/entities/identityDocument.d.ts +8 -0
- package/dist/types/entities/identityDocumentV0.d.ts +23 -0
- package/dist/types/entities/identityProfile.d.ts +8 -0
- package/dist/types/entities/identityProfileV0.d.ts +18 -0
- package/dist/types/index.d.ts +2 -0
- package/docs/changelog.md +14 -0
- package/docs/reference/classes/IdentityDocument.md +16 -0
- package/docs/reference/classes/IdentityDocumentV0.md +46 -0
- package/docs/reference/classes/IdentityProfile.md +16 -0
- package/docs/reference/classes/IdentityProfileV0.md +38 -0
- package/docs/reference/index.md +2 -0
- 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;
|
|
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;
|
|
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"]}
|
|
@@ -258,7 +258,7 @@ export class EntityStorageIdentityConnector {
|
|
|
258
258
|
};
|
|
259
259
|
didDocument[verificationMethodType] ??= [];
|
|
260
260
|
didDocument[verificationMethodType]?.push(didVerificationMethod);
|
|
261
|
-
await this.updateDocument(controller, didDocument);
|
|
261
|
+
await this.updateDocument(controller, didDocument, didIdentityDocument);
|
|
262
262
|
return didVerificationMethod;
|
|
263
263
|
}
|
|
264
264
|
catch (error) {
|
|
@@ -297,7 +297,7 @@ export class EntityStorageIdentityConnector {
|
|
|
297
297
|
if (!this.removeMethodById(didDocument, verificationMethodId)) {
|
|
298
298
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "verificationMethodNotFound", verificationMethodId);
|
|
299
299
|
}
|
|
300
|
-
await this.updateDocument(controller, didDocument);
|
|
300
|
+
await this.updateDocument(controller, didDocument, didIdentityDocument);
|
|
301
301
|
if (options?.removeKeys ?? false) {
|
|
302
302
|
try {
|
|
303
303
|
await this._vaultConnector.removeKey(EntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment));
|
|
@@ -352,7 +352,7 @@ export class EntityStorageIdentityConnector {
|
|
|
352
352
|
};
|
|
353
353
|
didDocument.service ??= [];
|
|
354
354
|
didDocument.service.push(didService);
|
|
355
|
-
await this.updateDocument(controller, didDocument);
|
|
355
|
+
await this.updateDocument(controller, didDocument, didIdentityDocument);
|
|
356
356
|
return didService;
|
|
357
357
|
}
|
|
358
358
|
catch (error) {
|
|
@@ -391,7 +391,7 @@ export class EntityStorageIdentityConnector {
|
|
|
391
391
|
else {
|
|
392
392
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "serviceNotFound", serviceId);
|
|
393
393
|
}
|
|
394
|
-
await this.updateDocument(controller, didDocument);
|
|
394
|
+
await this.updateDocument(controller, didDocument, didIdentityDocument);
|
|
395
395
|
}
|
|
396
396
|
catch (error) {
|
|
397
397
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "removeServiceFailed", undefined, error);
|
|
@@ -422,7 +422,7 @@ export class EntityStorageIdentityConnector {
|
|
|
422
422
|
return;
|
|
423
423
|
}
|
|
424
424
|
didDocument.alsoKnownAs = [...existing, alias];
|
|
425
|
-
await this.updateDocument(controller, didDocument);
|
|
425
|
+
await this.updateDocument(controller, didDocument, didIdentityDocument);
|
|
426
426
|
}
|
|
427
427
|
catch (error) {
|
|
428
428
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "addAlsoKnownAsFailed", undefined, error);
|
|
@@ -458,7 +458,7 @@ export class EntityStorageIdentityConnector {
|
|
|
458
458
|
else {
|
|
459
459
|
didDocument.alsoKnownAs = filtered;
|
|
460
460
|
}
|
|
461
|
-
await this.updateDocument(controller, didDocument);
|
|
461
|
+
await this.updateDocument(controller, didDocument, didIdentityDocument);
|
|
462
462
|
}
|
|
463
463
|
catch (error) {
|
|
464
464
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "removeAlsoKnownAsFailed", undefined, error);
|
|
@@ -718,7 +718,7 @@ export class EntityStorageIdentityConnector {
|
|
|
718
718
|
revocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
|
-
await this.updateDocument(controller, issuerDidDocument);
|
|
721
|
+
await this.updateDocument(controller, issuerDidDocument, issuerIdentityDocument);
|
|
722
722
|
}
|
|
723
723
|
catch (error) {
|
|
724
724
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "revokeVerifiableCredentialsFailed", undefined, error);
|
|
@@ -754,7 +754,7 @@ export class EntityStorageIdentityConnector {
|
|
|
754
754
|
revocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
await this.updateDocument(controller, issuerDidDocument);
|
|
757
|
+
await this.updateDocument(controller, issuerDidDocument, issuerIdentityDocument);
|
|
758
758
|
}
|
|
759
759
|
catch (error) {
|
|
760
760
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "unrevokeVerifiableCredentialsFailed", undefined, error);
|
|
@@ -1278,18 +1278,22 @@ export class EntityStorageIdentityConnector {
|
|
|
1278
1278
|
* Update the document in storage.
|
|
1279
1279
|
* @param controller The controller of the document.
|
|
1280
1280
|
* @param didDocument The did document to store.
|
|
1281
|
+
* @param existingDocument The currently stored entity, undefined when creating.
|
|
1281
1282
|
* @returns A promise that resolves when the document has been signed and persisted.
|
|
1282
1283
|
* @internal
|
|
1283
1284
|
*/
|
|
1284
|
-
async updateDocument(controller, didDocument) {
|
|
1285
|
+
async updateDocument(controller, didDocument, existingDocument) {
|
|
1285
1286
|
const stringifiedDocument = JsonHelper.canonicalize(didDocument);
|
|
1286
1287
|
const docBytes = Converter.utf8ToBytes(stringifiedDocument);
|
|
1287
1288
|
const signature = await this._vaultConnector.sign(EntityStorageIdentityConnector.buildVaultKey(didDocument.id, "did"), docBytes);
|
|
1289
|
+
const now = new Date(Date.now()).toISOString();
|
|
1288
1290
|
const identityDocument = {
|
|
1289
1291
|
id: didDocument.id,
|
|
1290
1292
|
document: didDocument,
|
|
1291
1293
|
signature: Converter.bytesToBase64(signature),
|
|
1292
|
-
controller
|
|
1294
|
+
controller,
|
|
1295
|
+
dateCreated: Is.undefined(existingDocument) ? now : existingDocument.dateCreated,
|
|
1296
|
+
dateModified: now
|
|
1293
1297
|
};
|
|
1294
1298
|
await this._didDocumentEntityStorage.set(identityDocument);
|
|
1295
1299
|
this._didResolutionCache?.set(this.ownDidCacheKey(didDocument.id), ObjectHelper.clone(identityDocument));
|