@sphereon/ssi-sdk.data-store 0.29.1-unstable.94 → 0.29.1-unstable.99
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/types/digitalCredential/digitalCredential.d.ts.map +1 -1
- package/dist/types/digitalCredential/digitalCredential.js +8 -4
- package/dist/types/digitalCredential/digitalCredential.js.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.d.ts.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.js +11 -10
- package/dist/utils/digitalCredential/MappingUtils.js.map +1 -1
- package/package.json +5 -5
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +1 -1
- package/src/types/digitalCredential/digitalCredential.ts +10 -6
- package/src/utils/digitalCredential/MappingUtils.ts +15 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digitalCredential.d.ts","sourceRoot":"","sources":["../../../src/types/digitalCredential/digitalCredential.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAA;AAEzE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,YAAY,CAAA;IAC1B,cAAc,EAAE,wBAAwB,CAAA;IACxC,cAAc,EAAE,cAAc,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,qBAAqB,EAAE,yBAAyB,CAAA;IAChD,sBAAsB,CAAC,EAAE,yBAAyB,CAAA;IAClD,mBAAmB,EAAE,MAAM,CAAA;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,IAAI,CAAA;IACf,aAAa,EAAE,IAAI,CAAA;IACnB,UAAU,CAAC,EAAE,IAAI,CAAA;IACjB,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,UAAU,CAAC,EAAE,IAAI,CAAA;IACjB,SAAS,CAAC,EAAE,IAAI,CAAA;CACjB,CAAA;AAED,oBAAY,YAAY;IACtB,EAAE,OAAO;IACT,EAAE,OAAO;IACT,CAAC,MAAM;IACP,CAAC,MAAM;CACR;AAED,oBAAY,wBAAwB;IAClC,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED,yBAAiB,wBAAwB,CAAC;IACxC,SAAgB,aAAa,CAAC,gBAAgB,EAAE,MAAM,4BAarD;IAED,SAAgB,WAAW,CAAC,cAAc,EAAE,wBAAwB,EAAE,YAAY,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"digitalCredential.d.ts","sourceRoot":"","sources":["../../../src/types/digitalCredential/digitalCredential.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAA;AAEzE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,YAAY,CAAA;IAC1B,cAAc,EAAE,wBAAwB,CAAA;IACxC,cAAc,EAAE,cAAc,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,qBAAqB,EAAE,yBAAyB,CAAA;IAChD,sBAAsB,CAAC,EAAE,yBAAyB,CAAA;IAClD,mBAAmB,EAAE,MAAM,CAAA;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,IAAI,CAAA;IACf,aAAa,EAAE,IAAI,CAAA;IACnB,UAAU,CAAC,EAAE,IAAI,CAAA;IACjB,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,UAAU,CAAC,EAAE,IAAI,CAAA;IACjB,SAAS,CAAC,EAAE,IAAI,CAAA;CACjB,CAAA;AAED,oBAAY,YAAY;IACtB,EAAE,OAAO;IACT,EAAE,OAAO;IACT,CAAC,MAAM;IACP,CAAC,MAAM;CACR;AAED,oBAAY,wBAAwB;IAClC,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED,yBAAiB,wBAAwB,CAAC;IACxC,SAAgB,aAAa,CAAC,gBAAgB,EAAE,MAAM,4BAarD;IAED,SAAgB,WAAW,CAAC,cAAc,EAAE,wBAAwB,EAAE,YAAY,EAAE,YAAY,kFAW/F;CACF;AAED,oBAAY,yBAAyB;IACnC,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,GAAG,QAAQ;CACZ;AAED,oBAAY,cAAc;IACxB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAED,oBAAY,mBAAmB;IAC7B,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB"}
|
|
@@ -37,10 +37,14 @@ var CredentialDocumentFormat;
|
|
|
37
37
|
CredentialDocumentFormat.fromSpecValue = fromSpecValue;
|
|
38
38
|
function toSpecValue(documentFormat, documentType) {
|
|
39
39
|
switch (documentFormat) {
|
|
40
|
-
case CredentialDocumentFormat.SD_JWT:
|
|
41
|
-
|
|
42
|
-
case CredentialDocumentFormat.
|
|
43
|
-
|
|
40
|
+
case CredentialDocumentFormat.SD_JWT:
|
|
41
|
+
return 'vc+sd-jwt';
|
|
42
|
+
case CredentialDocumentFormat.MDOC:
|
|
43
|
+
return 'mso_mdoc';
|
|
44
|
+
case CredentialDocumentFormat.JSON_LD:
|
|
45
|
+
return documentType === DocumentType.C || documentType === DocumentType.VC ? 'ldp_vc' : 'ldp_vp';
|
|
46
|
+
case CredentialDocumentFormat.JWT:
|
|
47
|
+
return documentType === DocumentType.C || documentType === DocumentType.VC ? 'jwt_vc_json' : 'jwt_vp_json';
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
CredentialDocumentFormat.toSpecValue = toSpecValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digitalCredential.js","sourceRoot":"","sources":["../../../src/types/digitalCredential/digitalCredential.ts"],"names":[],"mappings":";;;AAyBA,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,yBAAS,CAAA;IACT,yBAAS,CAAA;IACT,uBAAO,CAAA;IACP,uBAAO,CAAA;AACT,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAED,IAAY,wBAKX;AALD,WAAY,wBAAwB;IAClC,+CAAmB,CAAA;IACnB,uCAAW,CAAA;IACX,6CAAiB,CAAA;IACjB,yCAAa,CAAA;AACf,CAAC,EALW,wBAAwB,wCAAxB,wBAAwB,QAKnC;AAED,WAAiB,wBAAwB;IACvC,SAAgB,aAAa,CAAC,gBAAwB;QACpD,MAAM,MAAM,GAAG,gBAAgB,CAAC,WAAW,EAAE,CAAA;QAC7C,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,OAAO,wBAAwB,CAAC,MAAM,CAAA;QACxC,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,OAAO,wBAAwB,CAAC,OAAO,CAAA;QACzC,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACvE,OAAO,wBAAwB,CAAC,IAAI,CAAA;QACtC,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,OAAO,wBAAwB,CAAC,GAAG,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,CAAC,wBAAwB,MAAM,kBAAkB,CAAC,CAAA;QAC/D,CAAC;IACH,CAAC;IAbe,sCAAa,gBAa5B,CAAA;IAED,SAAgB,WAAW,CAAC,cAAwC,EAAE,YAA0B;QAC9F,QAAQ,cAAc,EAAE,CAAC;YACvB,KAAK,wBAAwB,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"digitalCredential.js","sourceRoot":"","sources":["../../../src/types/digitalCredential/digitalCredential.ts"],"names":[],"mappings":";;;AAyBA,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,yBAAS,CAAA;IACT,yBAAS,CAAA;IACT,uBAAO,CAAA;IACP,uBAAO,CAAA;AACT,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAED,IAAY,wBAKX;AALD,WAAY,wBAAwB;IAClC,+CAAmB,CAAA;IACnB,uCAAW,CAAA;IACX,6CAAiB,CAAA;IACjB,yCAAa,CAAA;AACf,CAAC,EALW,wBAAwB,wCAAxB,wBAAwB,QAKnC;AAED,WAAiB,wBAAwB;IACvC,SAAgB,aAAa,CAAC,gBAAwB;QACpD,MAAM,MAAM,GAAG,gBAAgB,CAAC,WAAW,EAAE,CAAA;QAC7C,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,OAAO,wBAAwB,CAAC,MAAM,CAAA;QACxC,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,OAAO,wBAAwB,CAAC,OAAO,CAAA;QACzC,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACvE,OAAO,wBAAwB,CAAC,IAAI,CAAA;QACtC,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,OAAO,w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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MappingUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAA;AAClG,OAAO,
|
|
1
|
+
{"version":3,"file":"MappingUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAA;AAClG,OAAO,EAAE,iBAAiB,EAA4B,iBAAiB,EAAgB,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAoEzI,eAAO,MAAM,8CAA8C,sBAAuB,iBAAiB,KAAG,6BA0BrG,CAAA;AAED,eAAO,MAAM,qBAAqB,qBAAsB,uBAAuB,KAAG,iBAIjF,CAAA;AAED,eAAO,MAAM,sBAAsB,uBAAwB,MAAM,uBAAuB,CAAC,KAAG,iBAAiB,EAE5G,CAAA"}
|
|
@@ -44,28 +44,28 @@ function determineCredentialDocumentFormat(documentFormat) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
function getValidUntil(uniformDocument) {
|
|
47
|
-
if ('expirationDate' in uniformDocument) {
|
|
47
|
+
if ('expirationDate' in uniformDocument && uniformDocument.expirationDate) {
|
|
48
48
|
return new Date(uniformDocument.expirationDate);
|
|
49
49
|
}
|
|
50
|
-
else if ('validUntil' in uniformDocument) {
|
|
50
|
+
else if ('validUntil' in uniformDocument && uniformDocument.validUntil) {
|
|
51
51
|
return new Date(uniformDocument.validUntil);
|
|
52
52
|
}
|
|
53
|
-
else if ('exp' in uniformDocument) {
|
|
53
|
+
else if ('exp' in uniformDocument && uniformDocument.exp) {
|
|
54
54
|
return new Date(uniformDocument.exp * 1000);
|
|
55
55
|
}
|
|
56
56
|
return undefined;
|
|
57
57
|
}
|
|
58
58
|
function getValidFrom(uniformDocument) {
|
|
59
|
-
if ('issuanceDate' in uniformDocument) {
|
|
59
|
+
if ('issuanceDate' in uniformDocument && uniformDocument.issuanceDate) {
|
|
60
60
|
return new Date(uniformDocument.issuanceDate);
|
|
61
61
|
}
|
|
62
|
-
else if ('validFrom' in uniformDocument) {
|
|
62
|
+
else if ('validFrom' in uniformDocument && uniformDocument.validFrom) {
|
|
63
63
|
return new Date(uniformDocument['validFrom']);
|
|
64
64
|
}
|
|
65
|
-
else if ('nbf' in uniformDocument) {
|
|
65
|
+
else if ('nbf' in uniformDocument && uniformDocument.nbf) {
|
|
66
66
|
return new Date(uniformDocument['nbf'] * 1000);
|
|
67
67
|
}
|
|
68
|
-
else if ('iat' in uniformDocument) {
|
|
68
|
+
else if ('iat' in uniformDocument && uniformDocument.iat) {
|
|
69
69
|
return new Date(uniformDocument['iat'] * 1000);
|
|
70
70
|
}
|
|
71
71
|
return undefined;
|
|
@@ -78,12 +78,13 @@ const nonPersistedDigitalCredentialEntityFromAddArgs = (addCredentialArgs) => {
|
|
|
78
78
|
throw new Error('No hasher function is provided for SD_JWT credential.');
|
|
79
79
|
}
|
|
80
80
|
const hasher = (_b = addCredentialArgs.opts) === null || _b === void 0 ? void 0 : _b.hasher;
|
|
81
|
-
const uniformDocument =
|
|
81
|
+
const uniformDocument = documentType === types_1.DocumentType.VC || documentType === types_1.DocumentType.C
|
|
82
|
+
? ssi_types_1.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, { hasher })
|
|
83
|
+
: ssi_types_1.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument);
|
|
82
84
|
const validFrom = getValidFrom(uniformDocument);
|
|
83
85
|
const validUntil = getValidUntil(uniformDocument);
|
|
84
86
|
const hash = (0, utils_1.computeEntryHash)(addCredentialArgs.rawDocument);
|
|
85
|
-
return Object.assign(Object.assign({}, addCredentialArgs), { documentType, documentFormat: determineCredentialDocumentFormat(documentFormat), createdAt: new Date(), credentialId: (_c = uniformDocument.id) !== null && _c !== void 0 ? _c : hash, hash, uniformDocument: JSON.stringify(uniformDocument), validFrom,
|
|
86
|
-
validUntil, lastUpdatedAt: new Date() });
|
|
87
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, addCredentialArgs), { documentType, documentFormat: determineCredentialDocumentFormat(documentFormat), createdAt: new Date(), credentialId: (_c = uniformDocument.id) !== null && _c !== void 0 ? _c : hash, hash, uniformDocument: JSON.stringify(uniformDocument), validFrom }), (validUntil && { validUntil })), { lastUpdatedAt: new Date() });
|
|
87
88
|
};
|
|
88
89
|
exports.nonPersistedDigitalCredentialEntityFromAddArgs = nonPersistedDigitalCredentialEntityFromAddArgs;
|
|
89
90
|
const digitalCredentialFrom = (credentialEntity) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MappingUtils.js","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":";;;AAAA,mDAQ4B;AAC5B,yCAAgD;AAEhD,
|
|
1
|
+
{"version":3,"file":"MappingUtils.js","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":";;;AAAA,mDAQ4B;AAC5B,yCAAgD;AAEhD,uCAAyI;AAEzI,SAAS,qBAAqB,CAAC,GAAW;IACxC,MAAM,WAAW,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;IACzC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,kCAAkC,GAAG,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM,QAAQ,GAAG,4BAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACvD,MAAM,YAAY,GAAG,4BAAgB,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;IAC/D,MAAM,cAAc,GAAG,4BAAgB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;IAEnE,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,QAAQ,CAAC,CAAC,CAAC,oBAAY,CAAC,EAAE,CAAC,CAAC,CAAC,o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QAAA,sBAAsB,0BAElC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.data-store",
|
|
3
|
-
"version": "0.29.1-unstable.
|
|
3
|
+
"version": "0.29.1-unstable.99+44c80a0f",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"@sphereon/pex": "^4.0.1",
|
|
18
18
|
"@sphereon/ssi-sdk-ext.did-utils": "0.24.1-next.96",
|
|
19
19
|
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.24.1-next.96",
|
|
20
|
-
"@sphereon/ssi-sdk.agent-config": "0.29.1-unstable.
|
|
21
|
-
"@sphereon/ssi-sdk.core": "0.29.1-unstable.
|
|
22
|
-
"@sphereon/ssi-types": "0.29.1-unstable.
|
|
20
|
+
"@sphereon/ssi-sdk.agent-config": "0.29.1-unstable.99+44c80a0f",
|
|
21
|
+
"@sphereon/ssi-sdk.core": "0.29.1-unstable.99+44c80a0f",
|
|
22
|
+
"@sphereon/ssi-types": "0.29.1-unstable.99+44c80a0f",
|
|
23
23
|
"@veramo/core": "4.2.0",
|
|
24
24
|
"@veramo/utils": "4.2.0",
|
|
25
25
|
"blakejs": "^1.2.1",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"PostgreSQL",
|
|
51
51
|
"Contact Store"
|
|
52
52
|
],
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "44c80a0f3f6ec6e58ea761155d0511beabf6dfed"
|
|
54
54
|
}
|
|
@@ -34,7 +34,7 @@ export enum CredentialDocumentFormat {
|
|
|
34
34
|
JSON_LD = 'JSON_LD',
|
|
35
35
|
JWT = 'JWT',
|
|
36
36
|
SD_JWT = 'SD_JWT',
|
|
37
|
-
MDOC = 'MDOC'
|
|
37
|
+
MDOC = 'MDOC',
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export namespace CredentialDocumentFormat {
|
|
@@ -55,10 +55,14 @@ export namespace CredentialDocumentFormat {
|
|
|
55
55
|
|
|
56
56
|
export function toSpecValue(documentFormat: CredentialDocumentFormat, documentType: DocumentType) {
|
|
57
57
|
switch (documentFormat) {
|
|
58
|
-
case CredentialDocumentFormat.SD_JWT:
|
|
59
|
-
|
|
60
|
-
case CredentialDocumentFormat.
|
|
61
|
-
|
|
58
|
+
case CredentialDocumentFormat.SD_JWT:
|
|
59
|
+
return 'vc+sd-jwt'
|
|
60
|
+
case CredentialDocumentFormat.MDOC:
|
|
61
|
+
return 'mso_mdoc'
|
|
62
|
+
case CredentialDocumentFormat.JSON_LD:
|
|
63
|
+
return documentType === DocumentType.C || documentType === DocumentType.VC ? 'ldp_vc' : 'ldp_vp'
|
|
64
|
+
case CredentialDocumentFormat.JWT:
|
|
65
|
+
return documentType === DocumentType.C || documentType === DocumentType.VC ? 'jwt_vc_json' : 'jwt_vp_json'
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -66,7 +70,7 @@ export namespace CredentialDocumentFormat {
|
|
|
66
70
|
export enum CredentialCorrelationType {
|
|
67
71
|
DID = 'DID',
|
|
68
72
|
X509_CN = 'X509_CN',
|
|
69
|
-
URL = 'URL'
|
|
73
|
+
URL = 'URL',
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
export enum CredentialRole {
|
|
@@ -5,17 +5,11 @@ import {
|
|
|
5
5
|
IVerifiablePresentation,
|
|
6
6
|
OriginalVerifiableCredential,
|
|
7
7
|
OriginalVerifiablePresentation,
|
|
8
|
-
SdJwtDecodedVerifiableCredentialPayload
|
|
8
|
+
SdJwtDecodedVerifiableCredentialPayload,
|
|
9
9
|
} from '@sphereon/ssi-types'
|
|
10
10
|
import { computeEntryHash } from '@veramo/utils'
|
|
11
11
|
import { DigitalCredentialEntity } from '../../entities/digitalCredential/DigitalCredentialEntity'
|
|
12
|
-
import {
|
|
13
|
-
AddCredentialArgs,
|
|
14
|
-
CredentialDocumentFormat,
|
|
15
|
-
DigitalCredential,
|
|
16
|
-
DocumentType,
|
|
17
|
-
NonPersistedDigitalCredential
|
|
18
|
-
} from '../../types'
|
|
12
|
+
import { AddCredentialArgs, CredentialDocumentFormat, DigitalCredential, DocumentType, NonPersistedDigitalCredential } from '../../types'
|
|
19
13
|
|
|
20
14
|
function determineDocumentType(raw: string): DocumentType {
|
|
21
15
|
const rawDocument = parseRawDocument(raw)
|
|
@@ -60,24 +54,24 @@ function determineCredentialDocumentFormat(documentFormat: DocumentFormat): Cred
|
|
|
60
54
|
}
|
|
61
55
|
|
|
62
56
|
function getValidUntil(uniformDocument: IVerifiableCredential | IVerifiablePresentation | SdJwtDecodedVerifiableCredentialPayload): Date | undefined {
|
|
63
|
-
if ('expirationDate' in uniformDocument) {
|
|
57
|
+
if ('expirationDate' in uniformDocument && uniformDocument.expirationDate) {
|
|
64
58
|
return new Date(uniformDocument.expirationDate)
|
|
65
|
-
} else if ('validUntil' in uniformDocument) {
|
|
59
|
+
} else if ('validUntil' in uniformDocument && uniformDocument.validUntil) {
|
|
66
60
|
return new Date(uniformDocument.validUntil)
|
|
67
|
-
} else if ('exp' in uniformDocument) {
|
|
61
|
+
} else if ('exp' in uniformDocument && uniformDocument.exp) {
|
|
68
62
|
return new Date(uniformDocument.exp * 1000)
|
|
69
63
|
}
|
|
70
64
|
return undefined
|
|
71
65
|
}
|
|
72
66
|
|
|
73
67
|
function getValidFrom(uniformDocument: IVerifiableCredential | IVerifiablePresentation | SdJwtDecodedVerifiableCredentialPayload): Date | undefined {
|
|
74
|
-
if ('issuanceDate' in uniformDocument) {
|
|
68
|
+
if ('issuanceDate' in uniformDocument && uniformDocument.issuanceDate) {
|
|
75
69
|
return new Date(uniformDocument.issuanceDate)
|
|
76
|
-
} else if ('validFrom' in uniformDocument) {
|
|
70
|
+
} else if ('validFrom' in uniformDocument && uniformDocument.validFrom) {
|
|
77
71
|
return new Date(uniformDocument['validFrom'])
|
|
78
|
-
} else if ('nbf' in uniformDocument) {
|
|
72
|
+
} else if ('nbf' in uniformDocument && uniformDocument.nbf) {
|
|
79
73
|
return new Date(uniformDocument['nbf'] * 1000)
|
|
80
|
-
} else if ('iat' in uniformDocument) {
|
|
74
|
+
} else if ('iat' in uniformDocument && uniformDocument.iat) {
|
|
81
75
|
return new Date(uniformDocument['iat'] * 1000)
|
|
82
76
|
}
|
|
83
77
|
return undefined
|
|
@@ -91,7 +85,9 @@ export const nonPersistedDigitalCredentialEntityFromAddArgs = (addCredentialArgs
|
|
|
91
85
|
}
|
|
92
86
|
const hasher = addCredentialArgs.opts?.hasher
|
|
93
87
|
const uniformDocument =
|
|
94
|
-
|
|
88
|
+
documentType === DocumentType.VC || documentType === DocumentType.C
|
|
89
|
+
? CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, { hasher })
|
|
90
|
+
: CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument)
|
|
95
91
|
const validFrom: Date | undefined = getValidFrom(uniformDocument)
|
|
96
92
|
const validUntil: Date | undefined = getValidUntil(uniformDocument)
|
|
97
93
|
const hash = computeEntryHash(addCredentialArgs.rawDocument)
|
|
@@ -104,14 +100,14 @@ export const nonPersistedDigitalCredentialEntityFromAddArgs = (addCredentialArgs
|
|
|
104
100
|
hash,
|
|
105
101
|
uniformDocument: JSON.stringify(uniformDocument),
|
|
106
102
|
validFrom,
|
|
107
|
-
validUntil,
|
|
108
|
-
lastUpdatedAt: new Date()
|
|
103
|
+
...(validUntil && { validUntil }),
|
|
104
|
+
lastUpdatedAt: new Date(),
|
|
109
105
|
}
|
|
110
106
|
}
|
|
111
107
|
|
|
112
108
|
export const digitalCredentialFrom = (credentialEntity: DigitalCredentialEntity): DigitalCredential => {
|
|
113
109
|
return {
|
|
114
|
-
...credentialEntity
|
|
110
|
+
...credentialEntity,
|
|
115
111
|
}
|
|
116
112
|
}
|
|
117
113
|
|