@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.82.linkedVP.328 → 0.34.1-feature.SSISDK.82.linkedVP.341
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/index.cjs +53 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +54 -26
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/digitalCredential/DigitalCredentialStore.ts +24 -24
- package/src/utils/digitalCredential/MappingUtils.ts +69 -2
package/dist/index.cjs
CHANGED
|
@@ -133,6 +133,7 @@ __export(index_exports, {
|
|
|
133
133
|
naturalPersonEntityFrom: () => naturalPersonEntityFrom,
|
|
134
134
|
naturalPersonFrom: () => naturalPersonFrom,
|
|
135
135
|
nonPersistedDigitalCredentialEntityFromAddArgs: () => nonPersistedDigitalCredentialEntityFromAddArgs,
|
|
136
|
+
normalizeNullableFields: () => normalizeNullableFields,
|
|
136
137
|
openIdConfigEntityFrom: () => openIdConfigEntityFrom,
|
|
137
138
|
openIdConfigFrom: () => openIdConfigFrom,
|
|
138
139
|
organizationEntityFrom: () => organizationEntityFrom,
|
|
@@ -144,6 +145,8 @@ __export(index_exports, {
|
|
|
144
145
|
partyRelationshipFrom: () => partyRelationshipFrom,
|
|
145
146
|
partyTypeEntityFrom: () => partyTypeEntityFrom,
|
|
146
147
|
partyTypeFrom: () => partyTypeFrom,
|
|
148
|
+
persistedDigitalCredentialEntityFromStateArgs: () => persistedDigitalCredentialEntityFromStateArgs,
|
|
149
|
+
persistedDigitalCredentialEntityFromUpdateArgs: () => persistedDigitalCredentialEntityFromUpdateArgs,
|
|
147
150
|
physicalAddressEntityFrom: () => physicalAddressEntityFrom,
|
|
148
151
|
physicalAddressFrom: () => physicalAddressFrom,
|
|
149
152
|
textAttributesEntityFrom: () => textAttributesEntityFrom
|
|
@@ -5463,17 +5466,14 @@ var DigitalCredentialStore = class extends import_ssi_sdk26.AbstractDigitalCrede
|
|
|
5463
5466
|
if (!credential) {
|
|
5464
5467
|
return Promise.reject(Error(`No credential found for args: ${JSON.stringify(whereClause)}`));
|
|
5465
5468
|
}
|
|
5466
|
-
const
|
|
5467
|
-
const
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
};
|
|
5475
|
-
debug2("Updating credential", updatedCredential);
|
|
5476
|
-
const updatedResult = await dcRepo.save(updatedCredential, {
|
|
5469
|
+
const updates = Object.fromEntries(Object.entries(args).filter(([key]) => key !== "id" && key !== "hash"));
|
|
5470
|
+
const entityToSave = persistedDigitalCredentialEntityFromUpdateArgs(credential, updates);
|
|
5471
|
+
const validationError = this.assertValidDigitalCredential(entityToSave);
|
|
5472
|
+
if (validationError) {
|
|
5473
|
+
return Promise.reject(validationError);
|
|
5474
|
+
}
|
|
5475
|
+
debug2("Updating credential", entityToSave);
|
|
5476
|
+
const updatedResult = await dcRepo.save(entityToSave, {
|
|
5477
5477
|
transaction: true
|
|
5478
5478
|
});
|
|
5479
5479
|
return digitalCredentialFrom(updatedResult);
|
|
@@ -5548,20 +5548,9 @@ var DigitalCredentialStore = class extends import_ssi_sdk26.AbstractDigitalCrede
|
|
|
5548
5548
|
if (!credential) {
|
|
5549
5549
|
return Promise.reject(Error(`No credential found for args: ${JSON.stringify(whereClause)}`));
|
|
5550
5550
|
}
|
|
5551
|
-
const
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
verifiedAt: args.verifiedAt
|
|
5555
|
-
},
|
|
5556
|
-
...args.verifiedState === import_ssi_sdk26.CredentialStateType.REVOKED && {
|
|
5557
|
-
revokedAt: args.revokedAt
|
|
5558
|
-
},
|
|
5559
|
-
identifierMethod: credential.identifierMethod,
|
|
5560
|
-
lastUpdatedAt: /* @__PURE__ */ new Date(),
|
|
5561
|
-
verifiedState: args.verifiedState
|
|
5562
|
-
};
|
|
5563
|
-
debug2("Updating credential", credential);
|
|
5564
|
-
const updatedResult = await credentialRepository.save(updatedCredential, {
|
|
5551
|
+
const entityToSave = persistedDigitalCredentialEntityFromStateArgs(credential, args);
|
|
5552
|
+
debug2("Updating credential state", entityToSave);
|
|
5553
|
+
const updatedResult = await credentialRepository.save(entityToSave, {
|
|
5565
5554
|
transaction: true
|
|
5566
5555
|
});
|
|
5567
5556
|
return digitalCredentialFrom(updatedResult);
|
|
@@ -9532,6 +9521,18 @@ function determineCredentialDocumentFormat(documentFormat) {
|
|
|
9532
9521
|
}
|
|
9533
9522
|
}
|
|
9534
9523
|
__name(determineCredentialDocumentFormat, "determineCredentialDocumentFormat");
|
|
9524
|
+
function normalizeNullableFields(obj, nullableKeys) {
|
|
9525
|
+
const normalized = {
|
|
9526
|
+
...obj
|
|
9527
|
+
};
|
|
9528
|
+
for (const key of nullableKeys) {
|
|
9529
|
+
if (normalized[key] === void 0) {
|
|
9530
|
+
normalized[key] = null;
|
|
9531
|
+
}
|
|
9532
|
+
}
|
|
9533
|
+
return normalized;
|
|
9534
|
+
}
|
|
9535
|
+
__name(normalizeNullableFields, "normalizeNullableFields");
|
|
9535
9536
|
function getValidUntil(uniformDocument) {
|
|
9536
9537
|
if ("expirationDate" in uniformDocument && uniformDocument.expirationDate) {
|
|
9537
9538
|
return new Date(uniformDocument.expirationDate);
|
|
@@ -9594,6 +9595,33 @@ var nonPersistedDigitalCredentialEntityFromAddArgs = /* @__PURE__ */ __name((add
|
|
|
9594
9595
|
lastUpdatedAt: /* @__PURE__ */ new Date()
|
|
9595
9596
|
};
|
|
9596
9597
|
}, "nonPersistedDigitalCredentialEntityFromAddArgs");
|
|
9598
|
+
var persistedDigitalCredentialEntityFromUpdateArgs = /* @__PURE__ */ __name((existingCredential, updates) => {
|
|
9599
|
+
const entity = new DigitalCredentialEntity();
|
|
9600
|
+
Object.assign(entity, existingCredential);
|
|
9601
|
+
const normalizedUpdates = normalizeNullableFields(updates, [
|
|
9602
|
+
"linkedVpId",
|
|
9603
|
+
"linkedVpFrom"
|
|
9604
|
+
]);
|
|
9605
|
+
Object.assign(entity, normalizedUpdates);
|
|
9606
|
+
entity.id = existingCredential.id;
|
|
9607
|
+
entity.hash = existingCredential.hash;
|
|
9608
|
+
entity.createdAt = existingCredential.createdAt;
|
|
9609
|
+
entity.lastUpdatedAt = /* @__PURE__ */ new Date();
|
|
9610
|
+
return entity;
|
|
9611
|
+
}, "persistedDigitalCredentialEntityFromUpdateArgs");
|
|
9612
|
+
var persistedDigitalCredentialEntityFromStateArgs = /* @__PURE__ */ __name((existingCredential, args) => {
|
|
9613
|
+
const entity = new DigitalCredentialEntity();
|
|
9614
|
+
Object.assign(entity, existingCredential);
|
|
9615
|
+
entity.verifiedState = args.verifiedState;
|
|
9616
|
+
entity.lastUpdatedAt = /* @__PURE__ */ new Date();
|
|
9617
|
+
if (args.verifiedState === import_ssi_sdk35.CredentialStateType.REVOKED && args.revokedAt) {
|
|
9618
|
+
entity.revokedAt = args.revokedAt;
|
|
9619
|
+
}
|
|
9620
|
+
if (args.verifiedState !== import_ssi_sdk35.CredentialStateType.REVOKED && args.verifiedAt) {
|
|
9621
|
+
entity.verifiedAt = args.verifiedAt;
|
|
9622
|
+
}
|
|
9623
|
+
return entity;
|
|
9624
|
+
}, "persistedDigitalCredentialEntityFromStateArgs");
|
|
9597
9625
|
var digitalCredentialFrom = /* @__PURE__ */ __name((credentialEntity) => {
|
|
9598
9626
|
const result = {
|
|
9599
9627
|
...credentialEntity
|