@sphereon/ssi-sdk.data-store 0.32.1-feature.new.develop.280 → 0.32.1-feature.new.develop.281
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/utils/digitalCredential/MappingUtils.d.ts.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.js +7 -6
- package/dist/utils/digitalCredential/MappingUtils.js.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/digitalCredential.entities.test.ts +2 -2
- package/src/__tests__/digitalCredential.store.test.ts +2 -2
- package/src/utils/digitalCredential/MappingUtils.ts +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MappingUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,4BAA4B,EAC5B,8BAA8B,EAE/B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAA;AAClG,OAAO,EACL,iBAAiB,EAEjB,iBAAiB,EAEjB,6BAA6B,EAE9B,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"MappingUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,4BAA4B,EAC5B,8BAA8B,EAE/B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAA;AAClG,OAAO,EACL,iBAAiB,EAEjB,iBAAiB,EAEjB,6BAA6B,EAE9B,MAAM,aAAa,CAAA;AAsBpB,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,WAElC;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,4BAA4B,GAAG,8BAA8B,CAY3G;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAgBhE;AAgDD,eAAO,MAAM,8CAA8C,sBAAuB,iBAAiB,KAAG,6BA4BrG,CAAA;AAED,eAAO,MAAM,qBAAqB,qBAAsB,uBAAuB,KAAG,iBAMjF,CAAA;AAED,eAAO,MAAM,sBAAsB,uBAAwB,KAAK,CAAC,uBAAuB,CAAC,KAAG,iBAAiB,EAE5G,CAAA"}
|
|
@@ -8,6 +8,7 @@ const ssi_types_1 = require("@sphereon/ssi-types");
|
|
|
8
8
|
const utils_1 = require("@veramo/utils");
|
|
9
9
|
const types_1 = require("../../types");
|
|
10
10
|
const FormattingUtils_1 = require("../FormattingUtils");
|
|
11
|
+
const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
|
|
11
12
|
function determineDocumentType(raw) {
|
|
12
13
|
const rawDocument = parseRawDocument(raw);
|
|
13
14
|
if (!rawDocument) {
|
|
@@ -108,22 +109,22 @@ const safeStringify = (object) => {
|
|
|
108
109
|
return JSON.stringify(object);
|
|
109
110
|
};
|
|
110
111
|
const nonPersistedDigitalCredentialEntityFromAddArgs = (addCredentialArgs) => {
|
|
111
|
-
var _a, _b, _c, _d;
|
|
112
|
+
var _a, _b, _c, _d, _e;
|
|
112
113
|
const documentType = determineDocumentType(addCredentialArgs.rawDocument);
|
|
113
114
|
const documentFormat = ssi_types_1.CredentialMapper.detectDocumentType(addCredentialArgs.rawDocument);
|
|
114
|
-
|
|
115
|
+
const hasher = (_b = (_a = addCredentialArgs === null || addCredentialArgs === void 0 ? void 0 : addCredentialArgs.opts) === null || _a === void 0 ? void 0 : _a.hasher) !== null && _b !== void 0 ? _b : ssi_sdk_core_1.defaultHasher;
|
|
116
|
+
if (documentFormat === 2 /* DocumentFormat.SD_JWT_VC */ && !((_c = addCredentialArgs.opts) === null || _c === void 0 ? void 0 : _c.hasher)) {
|
|
115
117
|
throw new Error('No hasher function is provided for SD_JWT credential.');
|
|
116
118
|
}
|
|
117
|
-
const hasher = (_b = addCredentialArgs.opts) === null || _b === void 0 ? void 0 : _b.hasher;
|
|
118
119
|
const uniformDocument = documentType === types_1.DocumentType.VC || documentType === types_1.DocumentType.C
|
|
119
120
|
? ssi_types_1.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, { hasher })
|
|
120
|
-
: ssi_types_1.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument);
|
|
121
|
+
: ssi_types_1.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument, { hasher });
|
|
121
122
|
const validFrom = getValidFrom(uniformDocument);
|
|
122
123
|
const validUntil = getValidUntil(uniformDocument);
|
|
123
124
|
const hash = (0, utils_1.computeEntryHash)(addCredentialArgs.rawDocument);
|
|
124
|
-
const regulationType = (
|
|
125
|
+
const regulationType = (_d = addCredentialArgs.regulationType) !== null && _d !== void 0 ? _d : types_1.RegulationType.NON_REGULATED;
|
|
125
126
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, addCredentialArgs), { regulationType,
|
|
126
|
-
documentType, documentFormat: determineCredentialDocumentFormat(documentFormat), createdAt: new Date(), credentialId: (
|
|
127
|
+
documentType, documentFormat: determineCredentialDocumentFormat(documentFormat), createdAt: new Date(), credentialId: (_e = uniformDocument.id) !== null && _e !== void 0 ? _e : hash, hash, uniformDocument: safeStringify(uniformDocument), validFrom }), (validUntil && { validUntil })), { lastUpdatedAt: new Date() });
|
|
127
128
|
};
|
|
128
129
|
exports.nonPersistedDigitalCredentialEntityFromAddArgs = nonPersistedDigitalCredentialEntityFromAddArgs;
|
|
129
130
|
const digitalCredentialFrom = (credentialEntity) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MappingUtils.js","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"MappingUtils.js","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":";;;AAyCA,sBAEC;AAED,4CAYC;AAED,8CAgBC;AA3ED,mDAS4B;AAC5B,yCAAgD;AAEhD,uCAOo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AC,cAAc,mCAAI,sBAAc,CAAC,aAAa,CAAA;IACvF,mEACK,iBAAiB,KACpB,cAAc;QACd,YAAY,EACZ,cAAc,EAAE,iCAAiC,CAAC,cAAc,CAAC,EACjE,SAAS,EAAE,IAAI,IAAI,EAAE,EACrB,YAAY,EAAE,MAAA,eAAe,CAAC,EAAE,mCAAI,IAAI,EACxC,IAAI,EACJ,eAAe,EAAE,aAAa,CAAC,eAAe,CAAC,EAC/C,SAAS,KACN,CAAC,UAAU,IAAI,EAAE,UAAU,EAAE,CAAC,KACjC,aAAa,EAAE,IAAI,IAAI,EAAE,IAC1B;AACH,CAAC,CAAA;AA5BY,QAAA,8CAA8C,kDA4B1D;AAEM,MAAM,qBAAqB,GAAG,CAAC,gBAAyC,EAAqB,EAAE;IACpG,MAAM,MAAM,qBACP,gBAAgB,CACpB,CAAA;IAED,OAAO,IAAA,0CAAwB,EAAC,MAAM,CAAC,CAAA;AACzC,CAAC,CAAA;AANY,QAAA,qBAAqB,yBAMjC;AAEM,MAAM,sBAAsB,GAAG,CAAC,kBAAkD,EAAuB,EAAE;IAChH,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,IAAA,6BAAqB,EAAC,gBAAgB,CAAC,CAAC,CAAA;AAC9F,CAAC,CAAA;AAFY,QAAA,sBAAsB,0BAElC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.data-store",
|
|
3
|
-
"version": "0.32.1-feature.new.develop.
|
|
3
|
+
"version": "0.32.1-feature.new.develop.281+ad3a60d9",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
19
19
|
"@sphereon/ssi-sdk-ext.did-utils": "0.27.1-next.21",
|
|
20
20
|
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.1-next.21",
|
|
21
|
-
"@sphereon/ssi-sdk.agent-config": "0.32.1-feature.new.develop.
|
|
22
|
-
"@sphereon/ssi-sdk.core": "0.32.1-feature.new.develop.
|
|
23
|
-
"@sphereon/ssi-types": "0.32.1-feature.new.develop.
|
|
21
|
+
"@sphereon/ssi-sdk.agent-config": "0.32.1-feature.new.develop.281+ad3a60d9",
|
|
22
|
+
"@sphereon/ssi-sdk.core": "0.32.1-feature.new.develop.281+ad3a60d9",
|
|
23
|
+
"@sphereon/ssi-types": "0.32.1-feature.new.develop.281+ad3a60d9",
|
|
24
24
|
"@veramo/core": "4.2.0",
|
|
25
25
|
"@veramo/utils": "4.2.0",
|
|
26
26
|
"blakejs": "^1.2.1",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"Contact Store"
|
|
55
55
|
],
|
|
56
56
|
"nx": {},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "ad3a60d95aced138cf228a2d3eb16e4103c09eb6"
|
|
58
58
|
}
|
|
@@ -5,8 +5,8 @@ import { DataStoreDigitalCredentialMigrations } from '../migrations'
|
|
|
5
5
|
import { DigitalCredentialEntity } from '../entities/digitalCredential/DigitalCredentialEntity'
|
|
6
6
|
import { computeEntryHash } from '@veramo/utils'
|
|
7
7
|
import { nonPersistedDigitalCredentialEntityFromAddArgs } from '../utils/digitalCredential/MappingUtils'
|
|
8
|
-
import { createHash } from 'crypto'
|
|
9
8
|
import { AddCredentialArgs, CredentialCorrelationType, CredentialDocumentFormat, DocumentType, NonPersistedDigitalCredential } from '../types'
|
|
9
|
+
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
10
10
|
|
|
11
11
|
describe('Database entities tests', (): void => {
|
|
12
12
|
let dbConnection: DataSource
|
|
@@ -257,7 +257,7 @@ describe('Database entities tests', (): void => {
|
|
|
257
257
|
credentialRole: CredentialRole.VERIFIER,
|
|
258
258
|
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
259
259
|
opts: {
|
|
260
|
-
hasher:
|
|
260
|
+
hasher: defaultHasher,
|
|
261
261
|
},
|
|
262
262
|
})
|
|
263
263
|
expect(digitalCredential.documentType).toEqual(DocumentType.VC)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
2
|
import { IVerifiablePresentation } from '@sphereon/ssi-types'
|
|
3
|
-
import { createHash } from 'crypto'
|
|
4
3
|
import { DataSource } from 'typeorm'
|
|
5
4
|
import { DataStoreDigitalCredentialMigrations } from '../migrations'
|
|
6
5
|
import { CredentialRole, DataStoreDigitalCredentialEntities } from '../index'
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
GetCredentialsArgs,
|
|
16
15
|
GetCredentialsResponse,
|
|
17
16
|
} from '../types'
|
|
17
|
+
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
18
18
|
|
|
19
19
|
describe('Database entities tests', (): void => {
|
|
20
20
|
let dbConnection: DataSource
|
|
@@ -188,7 +188,7 @@ describe('Database entities tests', (): void => {
|
|
|
188
188
|
credentialRole: CredentialRole.VERIFIER,
|
|
189
189
|
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
190
190
|
opts: {
|
|
191
|
-
hasher:
|
|
191
|
+
hasher: defaultHasher,
|
|
192
192
|
},
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
RegulationType,
|
|
20
20
|
} from '../../types'
|
|
21
21
|
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
22
|
+
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
22
23
|
|
|
23
24
|
function determineDocumentType(raw: string): DocumentType {
|
|
24
25
|
const rawDocument = parseRawDocument(raw)
|
|
@@ -123,14 +124,14 @@ const safeStringify = (object: any): string => {
|
|
|
123
124
|
export const nonPersistedDigitalCredentialEntityFromAddArgs = (addCredentialArgs: AddCredentialArgs): NonPersistedDigitalCredential => {
|
|
124
125
|
const documentType: DocumentType = determineDocumentType(addCredentialArgs.rawDocument)
|
|
125
126
|
const documentFormat: DocumentFormat = CredentialMapper.detectDocumentType(addCredentialArgs.rawDocument)
|
|
127
|
+
const hasher = addCredentialArgs?.opts?.hasher ?? defaultHasher
|
|
126
128
|
if (documentFormat === DocumentFormat.SD_JWT_VC && !addCredentialArgs.opts?.hasher) {
|
|
127
129
|
throw new Error('No hasher function is provided for SD_JWT credential.')
|
|
128
130
|
}
|
|
129
|
-
const hasher = addCredentialArgs.opts?.hasher
|
|
130
131
|
const uniformDocument =
|
|
131
132
|
documentType === DocumentType.VC || documentType === DocumentType.C
|
|
132
133
|
? CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, { hasher })
|
|
133
|
-
: CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument)
|
|
134
|
+
: CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument, { hasher })
|
|
134
135
|
const validFrom: Date | undefined = getValidFrom(uniformDocument)
|
|
135
136
|
const validUntil: Date | undefined = getValidUntil(uniformDocument)
|
|
136
137
|
const hash = computeEntryHash(addCredentialArgs.rawDocument)
|