@sphereon/ssi-sdk.data-store 0.18.2-unstable.7 → 0.18.2-unstable.85
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/LICENSE +201 -201
- package/README.md +77 -77
- package/dist/contact/AbstractContactStore.d.ts +33 -23
- package/dist/contact/AbstractContactStore.d.ts.map +1 -1
- package/dist/contact/AbstractContactStore.js +6 -6
- package/dist/contact/AbstractContactStore.js.map +1 -1
- package/dist/contact/ContactStore.d.ts +44 -32
- package/dist/contact/ContactStore.d.ts.map +1 -1
- package/dist/contact/ContactStore.js +528 -365
- package/dist/contact/ContactStore.js.map +1 -1
- package/dist/digitalCredential/AbstractDigitalCredentialStore.d.ts +10 -0
- package/dist/digitalCredential/AbstractDigitalCredentialStore.d.ts.map +1 -0
- package/dist/digitalCredential/AbstractDigitalCredentialStore.js +7 -0
- package/dist/digitalCredential/AbstractDigitalCredentialStore.js.map +1 -0
- package/dist/digitalCredential/DigitalCredentialStore.d.ts +15 -0
- package/dist/digitalCredential/DigitalCredentialStore.d.ts.map +1 -0
- package/dist/digitalCredential/DigitalCredentialStore.js +97 -0
- package/dist/digitalCredential/DigitalCredentialStore.js.map +1 -0
- package/dist/entities/contact/BaseConfigEntity.d.ts +6 -6
- package/dist/entities/contact/BaseConfigEntity.js +33 -33
- package/dist/entities/contact/BaseContactEntity.d.ts +9 -9
- package/dist/entities/contact/BaseContactEntity.js +53 -53
- package/dist/entities/contact/ConnectionEntity.d.ts +10 -10
- package/dist/entities/contact/ConnectionEntity.js +46 -46
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +10 -10
- package/dist/entities/contact/CorrelationIdentifierEntity.js +71 -71
- package/dist/entities/contact/DidAuthConfigEntity.d.ts +6 -6
- package/dist/entities/contact/DidAuthConfigEntity.js +32 -32
- package/dist/entities/contact/ElectronicAddressEntity.d.ts +14 -13
- package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.js +95 -91
- package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
- package/dist/entities/contact/IdentityEntity.d.ts +20 -20
- package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityEntity.js +128 -128
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +9 -9
- package/dist/entities/contact/IdentityMetadataItemEntity.js +68 -68
- package/dist/entities/contact/NaturalPersonEntity.d.ts +8 -8
- package/dist/entities/contact/NaturalPersonEntity.js +71 -71
- package/dist/entities/contact/OpenIdConfigEntity.d.ts +10 -10
- package/dist/entities/contact/OpenIdConfigEntity.js +48 -48
- package/dist/entities/contact/OrganizationEntity.d.ts +8 -8
- package/dist/entities/contact/OrganizationEntity.js +66 -66
- package/dist/entities/contact/PartyEntity.d.ts +21 -19
- package/dist/entities/contact/PartyEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyEntity.js +142 -131
- package/dist/entities/contact/PartyEntity.js.map +1 -1
- package/dist/entities/contact/PartyRelationshipEntity.d.ts +12 -12
- package/dist/entities/contact/PartyRelationshipEntity.js +94 -94
- package/dist/entities/contact/PartyTypeEntity.d.ts +14 -14
- package/dist/entities/contact/PartyTypeEntity.js +103 -103
- package/dist/entities/contact/PhysicalAddressEntity.d.ts +21 -0
- package/dist/entities/contact/PhysicalAddressEntity.d.ts.map +1 -0
- package/dist/entities/contact/PhysicalAddressEntity.js +126 -0
- package/dist/entities/contact/PhysicalAddressEntity.js.map +1 -0
- package/dist/entities/digitalCredential/DigitalCredentialEntity.d.ts +23 -0
- package/dist/entities/digitalCredential/DigitalCredentialEntity.d.ts.map +1 -0
- package/dist/entities/digitalCredential/DigitalCredentialEntity.js +93 -0
- package/dist/entities/digitalCredential/DigitalCredentialEntity.js.map +1 -0
- package/dist/entities/eventLogger/AuditEventEntity.d.ts +26 -26
- package/dist/entities/eventLogger/AuditEventEntity.js +123 -123
- package/dist/entities/eventLogger/AuditEventEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/BackgroundAttributesEntity.d.ts +10 -10
- package/dist/entities/issuanceBranding/BackgroundAttributesEntity.js +73 -73
- package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.d.ts +17 -17
- package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.js +119 -119
- package/dist/entities/issuanceBranding/CredentialBrandingEntity.d.ts +14 -14
- package/dist/entities/issuanceBranding/CredentialBrandingEntity.js +101 -101
- package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.js +48 -48
- package/dist/entities/issuanceBranding/ImageAttributesEntity.d.ts +13 -13
- package/dist/entities/issuanceBranding/ImageAttributesEntity.js +91 -91
- package/dist/entities/issuanceBranding/ImageDimensionsEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/ImageDimensionsEntity.js +38 -38
- package/dist/entities/issuanceBranding/IssuerBrandingEntity.d.ts +13 -13
- package/dist/entities/issuanceBranding/IssuerBrandingEntity.js +94 -94
- package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.js +48 -48
- package/dist/entities/issuanceBranding/TextAttributesEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/TextAttributesEntity.js +61 -61
- package/dist/entities/statusList2021/StatusList2021Entity.d.ts +18 -18
- package/dist/entities/statusList2021/StatusList2021Entity.js +114 -114
- package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts +10 -10
- package/dist/entities/statusList2021/StatusList2021EntryEntity.js +50 -50
- package/dist/entities/validators/index.d.ts +6 -6
- package/dist/entities/validators/index.js +26 -26
- package/dist/eventLogger/AbstractEventLoggerStore.d.ts +6 -6
- package/dist/eventLogger/AbstractEventLoggerStore.js +6 -6
- package/dist/eventLogger/EventLoggerStore.d.ts +12 -12
- package/dist/eventLogger/EventLoggerStore.js +43 -43
- package/dist/index.d.ts +45 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -127
- package/dist/index.js.map +1 -1
- package/dist/issuanceBranding/AbstractIssuanceBrandingStore.d.ts +19 -19
- package/dist/issuanceBranding/AbstractIssuanceBrandingStore.js +6 -6
- package/dist/issuanceBranding/IssuanceBrandingStore.d.ts +30 -30
- package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
- package/dist/issuanceBranding/IssuanceBrandingStore.js +390 -374
- package/dist/issuanceBranding/IssuanceBrandingStore.js.map +1 -1
- package/dist/migrations/generic/1-CreateContacts.d.ts +6 -6
- package/dist/migrations/generic/1-CreateContacts.js +77 -77
- package/dist/migrations/generic/2-CreateIssuanceBranding.d.ts +6 -6
- package/dist/migrations/generic/2-CreateIssuanceBranding.js +77 -77
- package/dist/migrations/generic/3-CreateContacts.d.ts +6 -6
- package/dist/migrations/generic/3-CreateContacts.js +77 -77
- package/dist/migrations/generic/4-CreateStatusList.d.ts +6 -6
- package/dist/migrations/generic/4-CreateStatusList.js +71 -71
- package/dist/migrations/generic/5-CreateAuditEvents.d.ts +6 -6
- package/dist/migrations/generic/5-CreateAuditEvents.js +77 -77
- package/dist/migrations/generic/{2-CreateContacts.d.ts → 6-CreateDigitalCredential.d.ts} +2 -2
- package/dist/migrations/generic/6-CreateDigitalCredential.d.ts.map +1 -0
- package/dist/migrations/generic/{2-CreateContacts.js → 6-CreateDigitalCredential.js} +23 -23
- package/dist/migrations/generic/6-CreateDigitalCredential.js.map +1 -0
- package/dist/migrations/generic/index.d.ts +18 -16
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +30 -27
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +10 -5
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/internal-migrations-ormconfig.d.ts +6 -6
- package/dist/migrations/internal-migrations-ormconfig.js +26 -26
- package/dist/migrations/postgres/1659463079428-CreateContacts.d.ts +6 -6
- package/dist/migrations/postgres/1659463079428-CreateContacts.js +56 -56
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.d.ts +6 -6
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js +68 -68
- package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts +6 -6
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +68 -68
- package/dist/migrations/postgres/1693866470001-CreateStatusList.d.ts +6 -6
- package/dist/migrations/postgres/1693866470001-CreateStatusList.js +31 -31
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.d.ts +6 -6
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.js +42 -42
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.js.map +1 -1
- package/dist/migrations/{generic/3-CreateStatusList.d.ts → postgres/1708525189001-CreateDigitalCredential.d.ts} +2 -2
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.d.ts.map +1 -0
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +59 -0
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js.map +1 -0
- package/dist/migrations/sqlite/1659463069549-CreateContacts.d.ts +6 -6
- package/dist/migrations/sqlite/1659463069549-CreateContacts.js +78 -78
- package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.d.ts +6 -6
- package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.js +88 -88
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts +6 -6
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js +104 -107
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts +6 -6
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js +31 -31
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.d.ts +6 -6
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.js +28 -28
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.js.map +1 -1
- package/dist/migrations/{postgres/CreateStatusList1693866470001-CreateStatusList.d.ts → sqlite/1708525189002-CreateDigitalCredential.d.ts} +2 -2
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.d.ts.map +1 -0
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +50 -0
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js.map +1 -0
- package/dist/statusList/IStatusListStore.d.ts +19 -19
- package/dist/statusList/IStatusListStore.js +2 -2
- package/dist/statusList/StatusListStore.d.ts +35 -35
- package/dist/statusList/StatusListStore.js +212 -212
- package/dist/types/contact/IAbstractContactStore.d.ts +109 -74
- package/dist/types/contact/IAbstractContactStore.d.ts.map +1 -1
- package/dist/types/contact/IAbstractContactStore.js +2 -2
- package/dist/types/contact/contact.d.ts +196 -173
- package/dist/types/contact/contact.d.ts.map +1 -1
- package/dist/types/contact/contact.js +25 -25
- package/dist/types/contact/contact.js.map +1 -1
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.d.ts +27 -0
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.d.ts.map +1 -0
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.js +3 -0
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.js.map +1 -0
- package/dist/types/digitalCredential/digitalCredential.d.ts +41 -0
- package/dist/types/digitalCredential/digitalCredential.d.ts.map +1 -0
- package/dist/types/digitalCredential/digitalCredential.js +28 -0
- package/dist/types/digitalCredential/digitalCredential.js.map +1 -0
- package/dist/types/eventLogger/IAbstractEventLoggerStore.d.ts +9 -9
- package/dist/types/eventLogger/IAbstractEventLoggerStore.js +2 -2
- package/dist/types/eventLogger/eventLogger.d.ts +2 -2
- package/dist/types/eventLogger/eventLogger.js +2 -2
- package/dist/types/index.d.ts +9 -9
- package/dist/types/index.js +25 -25
- package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.d.ts +58 -58
- package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.js +2 -2
- package/dist/types/issuanceBranding/issuanceBranding.d.ts +114 -114
- package/dist/types/issuanceBranding/issuanceBranding.js +2 -2
- package/dist/types/statusList/IAbstractStatusListStore.d.ts +37 -37
- package/dist/types/statusList/IAbstractStatusListStore.js +2 -2
- package/dist/types/statusList/statusList.d.ts +24 -24
- package/dist/types/statusList/statusList.js +2 -2
- package/dist/types/validation/validation.d.ts +3 -3
- package/dist/types/validation/validation.js +2 -2
- package/dist/utils/ValidatorUtils.d.ts +3 -3
- package/dist/utils/ValidatorUtils.js +12 -12
- package/dist/utils/contact/MappingUtils.d.ts +49 -46
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
- package/dist/utils/contact/MappingUtils.js +326 -290
- package/dist/utils/contact/MappingUtils.js.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.d.ts +9 -0
- package/dist/utils/digitalCredential/MappingUtils.d.ts.map +1 -0
- package/dist/utils/digitalCredential/MappingUtils.js +92 -0
- package/dist/utils/digitalCredential/MappingUtils.js.map +1 -0
- package/package.json +5 -4
- package/src/__tests__/contact.entities.test.ts +323 -23
- package/src/__tests__/contact.store.test.ts +586 -10
- package/src/__tests__/digitalCredential.entities.test.ts +247 -0
- package/src/__tests__/digitalCredential.store.test.ts +194 -0
- package/src/__tests__/eventLogger.entities.test.ts +73 -73
- package/src/__tests__/eventLogger.store.test.ts +136 -136
- package/src/contact/AbstractContactStore.ts +38 -17
- package/src/contact/ContactStore.ts +715 -501
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +16 -0
- package/src/digitalCredential/DigitalCredentialStore.ts +107 -0
- package/src/entities/contact/ElectronicAddressEntity.ts +3 -0
- package/src/entities/contact/IdentityEntity.ts +1 -1
- package/src/entities/contact/PartyEntity.ts +11 -1
- package/src/entities/contact/PhysicalAddressEntity.ts +87 -0
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +64 -0
- package/src/entities/eventLogger/AuditEventEntity.ts +99 -99
- package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
- package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
- package/src/eventLogger/EventLoggerStore.ts +62 -62
- package/src/index.ts +131 -113
- package/src/issuanceBranding/IssuanceBrandingStore.ts +78 -62
- package/src/migrations/generic/1-CreateContacts.ts +66 -66
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
- package/src/migrations/generic/3-CreateContacts.ts +66 -66
- package/src/migrations/generic/4-CreateStatusList.ts +54 -54
- package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
- package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -0
- package/src/migrations/generic/index.ts +30 -27
- package/src/migrations/index.ts +8 -1
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
- package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
- package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +44 -0
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +158 -163
- package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
- package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +34 -0
- package/src/types/contact/IAbstractContactStore.ts +58 -8
- package/src/types/contact/contact.ts +29 -4
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +26 -0
- package/src/types/digitalCredential/digitalCredential.ts +45 -0
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +9 -9
- package/src/utils/contact/MappingUtils.ts +39 -1
- package/src/utils/digitalCredential/MappingUtils.ts +112 -0
- package/dist/entities/contact/ContactEntity.d.ts +0 -16
- package/dist/entities/contact/ContactEntity.d.ts.map +0 -1
- package/dist/entities/contact/ContactEntity.js +0 -164
- package/dist/entities/contact/ContactEntity.js.map +0 -1
- package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts +0 -7
- package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts.map +0 -1
- package/dist/migrations/generic/1-CreateIssuanceBranding.js +0 -96
- package/dist/migrations/generic/1-CreateIssuanceBranding.js.map +0 -1
- package/dist/migrations/generic/2-CreateContacts.d.ts.map +0 -1
- package/dist/migrations/generic/2-CreateContacts.js.map +0 -1
- package/dist/migrations/generic/3-CreateStatusList.d.ts.map +0 -1
- package/dist/migrations/generic/3-CreateStatusList.js +0 -72
- package/dist/migrations/generic/3-CreateStatusList.js.map +0 -1
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.d.ts.map +0 -1
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js +0 -32
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js.map +0 -1
- package/dist/migrations/postgres/uuid.d.ts +0 -3
- package/dist/migrations/postgres/uuid.d.ts.map +0 -1
- package/dist/migrations/postgres/uuid.js +0 -25
- package/dist/migrations/postgres/uuid.js.map +0 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { DataSource } from 'typeorm'
|
|
2
|
+
import { DataStoreDigitalCredentialEntities } from '../index'
|
|
3
|
+
import { DataStoreDigitalCredentialMigrations } from '../migrations'
|
|
4
|
+
import { DigitalCredentialEntity } from '../entities/digitalCredential/DigitalCredentialEntity'
|
|
5
|
+
import {
|
|
6
|
+
CredentialCorrelationType,
|
|
7
|
+
CredentialDocumentFormat,
|
|
8
|
+
CredentialType,
|
|
9
|
+
NonPersistedDigitalCredential,
|
|
10
|
+
} from '../types/digitalCredential/digitalCredential'
|
|
11
|
+
import { computeEntryHash } from '@veramo/utils'
|
|
12
|
+
import { AddDigitalCredentialArgs } from '../types/digitalCredential/IAbstractDigitalCredentialStore'
|
|
13
|
+
import { nonPersistedDigitalCredentialEntityFromAddArgs } from '../utils/digitalCredential/MappingUtils'
|
|
14
|
+
|
|
15
|
+
describe('Database entities tests', (): void => {
|
|
16
|
+
let dbConnection: DataSource
|
|
17
|
+
|
|
18
|
+
beforeEach(async (): Promise<void> => {
|
|
19
|
+
dbConnection = await new DataSource({
|
|
20
|
+
type: 'sqlite',
|
|
21
|
+
database: ':memory:',
|
|
22
|
+
//logging: 'all',
|
|
23
|
+
migrationsRun: false,
|
|
24
|
+
migrations: DataStoreDigitalCredentialMigrations,
|
|
25
|
+
synchronize: false,
|
|
26
|
+
entities: [...DataStoreDigitalCredentialEntities],
|
|
27
|
+
}).initialize()
|
|
28
|
+
await dbConnection.runMigrations()
|
|
29
|
+
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
afterEach(async (): Promise<void> => {
|
|
33
|
+
await (await dbConnection).destroy()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should save digital credential to database', async (): Promise<void> => {
|
|
37
|
+
const rawCredential: string =
|
|
38
|
+
'eyJraWQiOiJkaWQ6a2V5Ono2TWtyaGt5M3B1c20yNk1laUZhWFUzbjJuZWtyYW13RlVtZ0dyZUdHa0RWNnpRaiN6Nk1rcmhreTNwdXNtMjZNZWlGYVhVM24ybmVrcmFtd0ZVbWdHcmVHR2tEVjZ6UWoiLCJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vc3BoZXJlb24tb3BlbnNvdXJjZS5naXRodWIuaW8vc3NpLW1vYmlsZS13YWxsZXQvY29udGV4dC9zcGhlcmVvbi13YWxsZXQtaWRlbnRpdHktdjEuanNvbmxkIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJTcGhlcmVvbldhbGxldElkZW50aXR5Q3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJmaXJzdE5hbWUiOiJTIiwibGFzdE5hbWUiOiJLIiwiZW1haWxBZGRyZXNzIjoic0BrIn19LCJzdWIiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJqdGkiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJuYmYiOjE3MDg0NDA4MDgsImlzcyI6ImRpZDprZXk6ejZNa3Joa3kzcHVzbTI2TWVpRmFYVTNuMm5la3JhbXdGVW1nR3JlR0drRFY2elFqIn0.G0M84XVAxSmzGY-NQuB9NBofNrINSn6lvxW6761Vlq6ypvYgtc2xNdpiRmw8ryVNfnpzrr4Z5cB1RlrC05rJAw'
|
|
39
|
+
const digitalCredential: AddDigitalCredentialArgs = {
|
|
40
|
+
raw: rawCredential,
|
|
41
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
42
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
43
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
44
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
45
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const digitalCredentialEntity: NonPersistedDigitalCredential = nonPersistedDigitalCredentialEntityFromAddArgs(digitalCredential)
|
|
49
|
+
const fromDb: DigitalCredentialEntity = await dbConnection.getRepository(DigitalCredentialEntity).save(digitalCredentialEntity)
|
|
50
|
+
expect(fromDb).toBeDefined()
|
|
51
|
+
expect(fromDb?.id).not.toBeNull()
|
|
52
|
+
expect(fromDb?.credentialType).toEqual(CredentialType.VC)
|
|
53
|
+
expect(fromDb?.documentFormat).toEqual(CredentialDocumentFormat.JWT)
|
|
54
|
+
expect(fromDb?.raw).toEqual(rawCredential)
|
|
55
|
+
expect(fromDb?.hash).toEqual(computeEntryHash(rawCredential))
|
|
56
|
+
expect(fromDb?.issuerCorrelationType).toEqual(CredentialCorrelationType.DID)
|
|
57
|
+
expect(fromDb?.subjectCorrelationType).toEqual(CredentialCorrelationType.DID)
|
|
58
|
+
expect(fromDb?.issuerCorrelationId).toEqual('did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj')
|
|
59
|
+
expect(fromDb?.subjectCorrelationId).toEqual('did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj')
|
|
60
|
+
expect(fromDb?.tenantId).toEqual('urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('should assign correct values to DigitalCredential: jwt credential 1', () => {
|
|
64
|
+
const digitalCredential: NonPersistedDigitalCredential = nonPersistedDigitalCredentialEntityFromAddArgs({
|
|
65
|
+
raw: 'eyJraWQiOiJkaWQ6a2V5Ono2TWtyaGt5M3B1c20yNk1laUZhWFUzbjJuZWtyYW13RlVtZ0dyZUdHa0RWNnpRaiN6Nk1rcmhreTNwdXNtMjZNZWlGYVhVM24ybmVrcmFtd0ZVbWdHcmVHR2tEVjZ6UWoiLCJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vc3BoZXJlb24tb3BlbnNvdXJjZS5naXRodWIuaW8vc3NpLW1vYmlsZS13YWxsZXQvY29udGV4dC9zcGhlcmVvbi13YWxsZXQtaWRlbnRpdHktdjEuanNvbmxkIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJTcGhlcmVvbldhbGxldElkZW50aXR5Q3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJmaXJzdE5hbWUiOiJTIiwibGFzdE5hbWUiOiJLIiwiZW1haWxBZGRyZXNzIjoic0BrIn19LCJzdWIiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJqdGkiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJuYmYiOjE3MDg0NDA4MDgsImlzcyI6ImRpZDprZXk6ejZNa3Joa3kzcHVzbTI2TWVpRmFYVTNuMm5la3JhbXdGVW1nR3JlR0drRFY2elFqIn0.G0M84XVAxSmzGY-NQuB9NBofNrINSn6lvxW6761Vlq6ypvYgtc2xNdpiRmw8ryVNfnpzrr4Z5cB1RlrC05rJAw',
|
|
66
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
67
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
68
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
69
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
70
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
71
|
+
})
|
|
72
|
+
expect(digitalCredential.credentialType).toEqual(CredentialType.VC)
|
|
73
|
+
expect(digitalCredential.issuedAt).toEqual(new Date('2024-02-20T14:53:28.000Z'))
|
|
74
|
+
expect(digitalCredential.documentFormat).toEqual(CredentialDocumentFormat.JWT)
|
|
75
|
+
expect(digitalCredential.expiresAt).toEqual(undefined)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('should assign correct values to DigitalCredential: jwt credential 2', () => {
|
|
79
|
+
const digitalCredential: NonPersistedDigitalCredential = nonPersistedDigitalCredentialEntityFromAddArgs({
|
|
80
|
+
raw: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImRpZDpleGFtcGxlOmFiZmUxM2Y3MTIxMjA0MzFjMjc2ZTEyZWNhYiNrZXlzLTEif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|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
83
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
84
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
85
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
86
|
+
})
|
|
87
|
+
expect(digitalCredential.credentialType).toEqual(CredentialType.VC)
|
|
88
|
+
expect(digitalCredential.issuedAt).toEqual(new Date('2018-11-06T08:42:04.000Z'))
|
|
89
|
+
expect(digitalCredential.documentFormat).toEqual(CredentialDocumentFormat.JWT)
|
|
90
|
+
expect(digitalCredential.expiresAt).toEqual(new Date('2019-11-06T08:42:03.000Z'))
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('should assign correct values to DigitalCredential: signed ldb credential', () => {
|
|
94
|
+
const digitalCredential: NonPersistedDigitalCredential = nonPersistedDigitalCredentialEntityFromAddArgs({
|
|
95
|
+
raw: JSON.stringify({
|
|
96
|
+
id: 'cred:gatc:NjMxNjc0NTA0ZjVmZmYwY2U0Y2M3NTRk',
|
|
97
|
+
type: ['VerifiableCredential', 'emailCredential'],
|
|
98
|
+
'@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
|
|
99
|
+
issuer: 'did:gatc:24gsRbsURij3edoveHv81jt9EnhggrnR',
|
|
100
|
+
issuanceDate: '2022-01-07T11:54:12.000Z',
|
|
101
|
+
credentialSubject: {
|
|
102
|
+
email: 'jose@gataca.io',
|
|
103
|
+
id: 'did:gatc:YzQxNjRjM2U4YTUzZGVkNjhmNjAxYzk5',
|
|
104
|
+
},
|
|
105
|
+
credentialStatus: {
|
|
106
|
+
id: 'https://backbone.gataca.io/api/v1/group/otp/status',
|
|
107
|
+
type: 'CredentialStatusList2017',
|
|
108
|
+
},
|
|
109
|
+
credentialSchema: [],
|
|
110
|
+
proof: [
|
|
111
|
+
{
|
|
112
|
+
created: '2022-01-07T11:53:21Z',
|
|
113
|
+
creator: 'did:gatc:24gsRbsURij3edoveHv81jt9EnhggrnR#keys-1',
|
|
114
|
+
domain: 'gataca.io',
|
|
115
|
+
nonce: 'sUzybVzzg1ZXFw-xDqSeMP3-TiZqKOtxszk0K4Ag5X8=',
|
|
116
|
+
proofPurpose: 'assertionMethod',
|
|
117
|
+
signatureValue: 'qGIh5JLxollEek5l1yFUcwmHj2H1ZYn3PR8uTa5bDtIcpW6MKKJDpc5_YQjqHGVUKbre8EMDI7e07lgR1ZJ9Bg',
|
|
118
|
+
type: 'JcsEd25519Signature2020',
|
|
119
|
+
verificationMethod: 'did:gatc:24gsRbsURij3edoveHv81jt9EnhggrnR#keys-1',
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
}),
|
|
123
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
124
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
125
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
126
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
127
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
128
|
+
})
|
|
129
|
+
expect(digitalCredential.credentialType).toEqual(CredentialType.VC)
|
|
130
|
+
expect(digitalCredential.issuedAt).toEqual(new Date('2022-01-07T11:54:12.000Z'))
|
|
131
|
+
expect(digitalCredential.documentFormat).toEqual(CredentialDocumentFormat.JSON_LD)
|
|
132
|
+
expect(digitalCredential.expiresAt).toEqual(undefined)
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('should assign correct values to DigitalCredential: signed ldb presentation', () => {
|
|
136
|
+
const digitalCredential: NonPersistedDigitalCredential = nonPersistedDigitalCredentialEntityFromAddArgs({
|
|
137
|
+
raw: JSON.stringify({
|
|
138
|
+
'@context': ['https://www.w3.org/2018/credentials/v1', 'https://identity.foundation/presentation-exchange/submission/v1'],
|
|
139
|
+
type: ['VerifiablePresentation'],
|
|
140
|
+
verifiableCredential: [
|
|
141
|
+
{
|
|
142
|
+
iss: 'did:example:123',
|
|
143
|
+
vc: {
|
|
144
|
+
'@context': 'https://eu.com/claims/DriversLicense',
|
|
145
|
+
id: 'https://eu.com/claims/DriversLicense',
|
|
146
|
+
type: ['EUDriversLicense'],
|
|
147
|
+
issuer: 'did:example:123',
|
|
148
|
+
issuanceDate: '2010-01-01T19:73:24Z',
|
|
149
|
+
credentialSubject: {
|
|
150
|
+
id: 'did:example:ebfeb1f712ebc6f1c276e12ec21',
|
|
151
|
+
accounts: [
|
|
152
|
+
{
|
|
153
|
+
id: '1234567890',
|
|
154
|
+
route: 'DE-9876543210',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: '2457913570',
|
|
158
|
+
route: 'DE-0753197542',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
proof: {
|
|
164
|
+
type: 'EcdsaSecp256k1VerificationKey2019',
|
|
165
|
+
created: '2017-06-18T21:19:10Z',
|
|
166
|
+
proofPurpose: 'assertionMethod',
|
|
167
|
+
verificationMethod: 'https://example.edu/issuers/keys/1',
|
|
168
|
+
jws: '...',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
'@context': 'https://business-standards.org/schemas/employment-history.json',
|
|
173
|
+
id: 'https://business-standards.org/schemas/employment-history.json',
|
|
174
|
+
type: ['VerifiableCredential', 'GenericEmploymentCredential'],
|
|
175
|
+
issuer: 'did:foo:123',
|
|
176
|
+
issuanceDate: '2010-01-01T19:73:24Z',
|
|
177
|
+
credentialSubject: {
|
|
178
|
+
id: 'did:example:ebfeb1f712ebc6f1c276e12ec21',
|
|
179
|
+
active: true,
|
|
180
|
+
},
|
|
181
|
+
proof: {
|
|
182
|
+
type: 'EcdsaSecp256k1VerificationKey2019',
|
|
183
|
+
created: '2017-06-18T21:19:10Z',
|
|
184
|
+
proofPurpose: 'assertionMethod',
|
|
185
|
+
verificationMethod: 'https://example.edu/issuers/keys/1',
|
|
186
|
+
jws: '...',
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
'@context': 'https://www.w3.org/2018/credentials/v1',
|
|
191
|
+
id: 'https://eu.com/claims/DriversLicense',
|
|
192
|
+
type: ['EUDriversLicense'],
|
|
193
|
+
issuer: 'did:foo:123',
|
|
194
|
+
issuanceDate: '2010-01-01T19:73:24Z',
|
|
195
|
+
credentialSubject: {
|
|
196
|
+
id: 'did:example:ebfeb1f712ebc6f1c276e12ec21',
|
|
197
|
+
license: {
|
|
198
|
+
number: '34DGE352',
|
|
199
|
+
dob: '07/13/80',
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
proof: {
|
|
203
|
+
type: 'RsaSignature2018',
|
|
204
|
+
created: '2017-06-18T21:19:10Z',
|
|
205
|
+
proofPurpose: 'assertionMethod',
|
|
206
|
+
verificationMethod: 'https://example.edu/issuers/keys/1',
|
|
207
|
+
jws: '...',
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
proof: {
|
|
212
|
+
type: 'RsaSignature2018',
|
|
213
|
+
created: '2018-09-14T21:19:10Z',
|
|
214
|
+
proofPurpose: 'authentication',
|
|
215
|
+
verificationMethod: 'did:example:ebfeb1f712ebc6f1c276e12ec21#keys-1',
|
|
216
|
+
challenge: '1f44d55f-f161-4938-a659-f8026467f126',
|
|
217
|
+
domain: '4jt78h47fh47',
|
|
218
|
+
jws: '...',
|
|
219
|
+
},
|
|
220
|
+
}),
|
|
221
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
222
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
223
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
224
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
225
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
226
|
+
})
|
|
227
|
+
expect(digitalCredential.credentialType).toEqual(CredentialType.VP)
|
|
228
|
+
expect(digitalCredential.issuedAt).toEqual(new Date('2018-09-14T21:19:10.000Z'))
|
|
229
|
+
expect(digitalCredential.documentFormat).toEqual(CredentialDocumentFormat.JSON_LD)
|
|
230
|
+
expect(digitalCredential.expiresAt).toEqual(undefined)
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
it('should assign correct values to DigitalCredential: signed sd_jwt credential', () => {
|
|
234
|
+
const digitalCredential: NonPersistedDigitalCredential = nonPersistedDigitalCredentialEntityFromAddArgs({
|
|
235
|
+
raw: 'eyJhbGciOiJFZERTQSIsInR5cCI6InZjK3NkLWp3dCIsImtpZCI6IiN6Nk1rdHF0WE5HOENEVVk5UHJydG9TdEZ6ZUNuaHBNbWd4WUwxZ2lrY1czQnp2TlcifQ.eyJ2Y3QiOiJJZGVudGl0eUNyZWRlbnRpYWwiLCJmYW1pbHlfbmFtZSI6IkRvZSIsInBob25lX251bWJlciI6IisxLTIwMi01NTUtMDEwMSIsImFkZHJlc3MiOnsic3RyZWV0X2FkZHJlc3MiOiIxMjMgTWFpbiBTdCIsImxvY2FsaXR5IjoiQW55dG93biIsIl9zZCI6WyJOSm5tY3QwQnFCTUUxSmZCbEM2alJRVlJ1ZXZwRU9OaVl3N0E3TUh1SnlRIiwib201Wnp0WkhCLUdkMDBMRzIxQ1ZfeE00RmFFTlNvaWFPWG5UQUpOY3pCNCJdfSwiY25mIjp7Imp3ayI6eyJrdHkiOiJPS1AiLCJjcnYiOiJFZDI1NTE5IiwieCI6Im9FTlZzeE9VaUg1NFg4d0pMYVZraWND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OQm91a2EwU0R6V2JkS3JYckw1TFVmUlNQTHN2Q2xPMFkifQ.TQQLqc4ZzoKjQfAghAzC_4aaU3KCS8YqzxAJtzT124guzkv9XSHtPN8d3z181_v-ca2ATXjTRoRciozitE6wBA',
|
|
236
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
237
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
238
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
239
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
240
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
241
|
+
})
|
|
242
|
+
expect(digitalCredential.credentialType).toEqual(CredentialType.VC)
|
|
243
|
+
expect(digitalCredential.issuedAt).toEqual(new Date('2023-10-24T12:45:32.000Z'))
|
|
244
|
+
expect(digitalCredential.documentFormat).toEqual(CredentialDocumentFormat.SD_JWT)
|
|
245
|
+
expect(digitalCredential.expiresAt).toEqual(undefined)
|
|
246
|
+
})
|
|
247
|
+
})
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { DataSource } from 'typeorm'
|
|
2
|
+
import { DataStoreDigitalCredentialMigrations } from '../migrations'
|
|
3
|
+
import { DataStoreDigitalCredentialEntities, DigitalCredentialEntity } from '../index'
|
|
4
|
+
import { DigitalCredentialStore } from '../digitalCredential/DigitalCredentialStore'
|
|
5
|
+
import { CredentialCorrelationType, CredentialStateType, CredentialType, DigitalCredential } from '../types/digitalCredential/digitalCredential'
|
|
6
|
+
import { AddDigitalCredentialArgs, GetDigitalCredentialsArgs } from '../types/digitalCredential/IAbstractDigitalCredentialStore'
|
|
7
|
+
import { IVerifiablePresentation } from '@sphereon/ssi-types'
|
|
8
|
+
|
|
9
|
+
describe('Database entities tests', (): void => {
|
|
10
|
+
let dbConnection: DataSource
|
|
11
|
+
let digitalCredentialStore: DigitalCredentialStore
|
|
12
|
+
|
|
13
|
+
beforeEach(async (): Promise<void> => {
|
|
14
|
+
dbConnection = await new DataSource({
|
|
15
|
+
type: 'sqlite',
|
|
16
|
+
database: ':memory:',
|
|
17
|
+
//logging: 'all',
|
|
18
|
+
migrationsRun: false,
|
|
19
|
+
migrations: DataStoreDigitalCredentialMigrations,
|
|
20
|
+
synchronize: false,
|
|
21
|
+
entities: DataStoreDigitalCredentialEntities,
|
|
22
|
+
}).initialize()
|
|
23
|
+
await dbConnection.runMigrations()
|
|
24
|
+
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
25
|
+
digitalCredentialStore = new DigitalCredentialStore(dbConnection)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
afterEach(async (): Promise<void> => {
|
|
29
|
+
await (await dbConnection).destroy()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('should store digital credential', async (): Promise<void> => {
|
|
33
|
+
const rawCredential: string =
|
|
34
|
+
'eyJraWQiOiJkaWQ6a2V5Ono2TWtyaGt5M3B1c20yNk1laUZhWFUzbjJuZWtyYW13RlVtZ0dyZUdHa0RWNnpRaiN6Nk1rcmhreTNwdXNtMjZNZWlGYVhVM24ybmVrcmFtd0ZVbWdHcmVHR2tEVjZ6UWoiLCJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vc3BoZXJlb24tb3BlbnNvdXJjZS5naXRodWIuaW8vc3NpLW1vYmlsZS13YWxsZXQvY29udGV4dC9zcGhlcmVvbi13YWxsZXQtaWRlbnRpdHktdjEuanNvbmxkIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJTcGhlcmVvbldhbGxldElkZW50aXR5Q3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJmaXJzdE5hbWUiOiJTIiwibGFzdE5hbWUiOiJLIiwiZW1haWxBZGRyZXNzIjoic0BrIn19LCJzdWIiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJqdGkiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJuYmYiOjE3MDg0NDA4MDgsImlzcyI6ImRpZDprZXk6ejZNa3Joa3kzcHVzbTI2TWVpRmFYVTNuMm5la3JhbXdGVW1nR3JlR0drRFY2elFqIn0.G0M84XVAxSmzGY-NQuB9NBofNrINSn6lvxW6761Vlq6ypvYgtc2xNdpiRmw8ryVNfnpzrr4Z5cB1RlrC05rJAw'
|
|
35
|
+
const digitalCredential: AddDigitalCredentialArgs = {
|
|
36
|
+
raw: rawCredential,
|
|
37
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
38
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
39
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
40
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
41
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const savedDigitalCredential: DigitalCredential = await digitalCredentialStore.addDigitalCredential(digitalCredential)
|
|
45
|
+
expect(savedDigitalCredential).toBeDefined()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('should get all digital credentials', async (): Promise<void> => {
|
|
49
|
+
const addCredentialArgs1: AddDigitalCredentialArgs = {
|
|
50
|
+
raw: 'eyJraWQiOiJkaWQ6a2V5Ono2TWtyaGt5M3B1c20yNk1laUZhWFUzbjJuZWtyYW13RlVtZ0dyZUdHa0RWNnpRaiN6Nk1rcmhreTNwdXNtMjZNZWlGYVhVM24ybmVrcmFtd0ZVbWdHcmVHR2tEVjZ6UWoiLCJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vc3BoZXJlb24tb3BlbnNvdXJjZS5naXRodWIuaW8vc3NpLW1vYmlsZS13YWxsZXQvY29udGV4dC9zcGhlcmVvbi13YWxsZXQtaWRlbnRpdHktdjEuanNvbmxkIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJTcGhlcmVvbldhbGxldElkZW50aXR5Q3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJmaXJzdE5hbWUiOiJTIiwibGFzdE5hbWUiOiJLIiwiZW1haWxBZGRyZXNzIjoic0BrIn19LCJzdWIiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJqdGkiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJuYmYiOjE3MDg0NDA4MDgsImlzcyI6ImRpZDprZXk6ejZNa3Joa3kzcHVzbTI2TWVpRmFYVTNuMm5la3JhbXdGVW1nR3JlR0drRFY2elFqIn0.G0M84XVAxSmzGY-NQuB9NBofNrINSn6lvxW6761Vlq6ypvYgtc2xNdpiRmw8ryVNfnpzrr4Z5cB1RlrC05rJAw',
|
|
51
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
52
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
53
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
54
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
55
|
+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Wl3aVkzSjJJam9pVUMweU5UWWlMQ0o0SWpvaVZFY3lTREo0TW1SWFdFNHpkVU54V25CeFJqRjVjMEZRVVZaRVNrVk9YMGd0UTAxMFltZHFZaTFPWnlJc0lua2lPaUk1VFRoT2VHUXdVRTR5TWswNWJGQkVlR1J3UkhCdlZFeDZNVFYzWm5sYVNuTTJXbWhMU1ZWS016TTRJbjAifQ.GgLRWHO674wu6QF_xUGbCi_2zDD8jNf_xoWNvH5K605xvBoz6qKx0ndmxLeGQWWUA-4VuAkznf3ROcp9wpgbEw',
|
|
59
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
60
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
61
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
62
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
63
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const digitalCredential1: DigitalCredential = await digitalCredentialStore.addDigitalCredential(addCredentialArgs1)
|
|
67
|
+
expect(digitalCredential1).toBeDefined()
|
|
68
|
+
const digitalCredential2: DigitalCredential = await digitalCredentialStore.addDigitalCredential(addCredentialArgs2)
|
|
69
|
+
expect(digitalCredential2).toBeDefined()
|
|
70
|
+
|
|
71
|
+
const result: Array<DigitalCredential> = await digitalCredentialStore.getDigitalCredentials()
|
|
72
|
+
expect(result.length).toEqual(2)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('should get digital credentials by filter', async (): Promise<void> => {
|
|
76
|
+
const addCredentialArgs1: AddDigitalCredentialArgs = {
|
|
77
|
+
raw: 'eyJraWQiOiJkaWQ6a2V5Ono2TWtyaGt5M3B1c20yNk1laUZhWFUzbjJuZWtyYW13RlVtZ0dyZUdHa0RWNnpRaiN6Nk1rcmhreTNwdXNtMjZNZWlGYVhVM24ybmVrcmFtd0ZVbWdHcmVHR2tEVjZ6UWoiLCJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vc3BoZXJlb24tb3BlbnNvdXJjZS5naXRodWIuaW8vc3NpLW1vYmlsZS13YWxsZXQvY29udGV4dC9zcGhlcmVvbi13YWxsZXQtaWRlbnRpdHktdjEuanNvbmxkIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJTcGhlcmVvbldhbGxldElkZW50aXR5Q3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJmaXJzdE5hbWUiOiJTIiwibGFzdE5hbWUiOiJLIiwiZW1haWxBZGRyZXNzIjoic0BrIn19LCJzdWIiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJqdGkiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJuYmYiOjE3MDg0NDA4MDgsImlzcyI6ImRpZDprZXk6ejZNa3Joa3kzcHVzbTI2TWVpRmFYVTNuMm5la3JhbXdGVW1nR3JlR0drRFY2elFqIn0.G0M84XVAxSmzGY-NQuB9NBofNrINSn6lvxW6761Vlq6ypvYgtc2xNdpiRmw8ryVNfnpzrr4Z5cB1RlrC05rJAw',
|
|
78
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
79
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
80
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
81
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
82
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const sampleVP: IVerifiablePresentation = {
|
|
86
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
87
|
+
type: ['VerifiablePresentation'],
|
|
88
|
+
verifiableCredential: [
|
|
89
|
+
{
|
|
90
|
+
'@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1'],
|
|
91
|
+
id: 'https://example.com/credentials/1872',
|
|
92
|
+
type: ['VerifiableCredential', 'IDCardCredential'],
|
|
93
|
+
issuer: {
|
|
94
|
+
id: 'did:example:issuer',
|
|
95
|
+
},
|
|
96
|
+
issuanceDate: '2010-01-01T19:23:24Z',
|
|
97
|
+
credentialSubject: {
|
|
98
|
+
given_name: 'Fredrik',
|
|
99
|
+
family_name: 'Strömberg',
|
|
100
|
+
birthdate: '1949-01-22',
|
|
101
|
+
},
|
|
102
|
+
proof: {
|
|
103
|
+
type: 'Ed25519Signature2018',
|
|
104
|
+
created: '2021-03-19T15:30:15Z',
|
|
105
|
+
jws: 'eyJhb...IAoDA',
|
|
106
|
+
proofPurpose: 'assertionMethod',
|
|
107
|
+
verificationMethod: 'did:example:issuer#keys-1',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
id: 'ebc6f1c2',
|
|
112
|
+
holder: 'did:example:holder',
|
|
113
|
+
proof: {
|
|
114
|
+
type: 'Ed25519Signature2018',
|
|
115
|
+
created: '2021-03-19T15:30:15Z',
|
|
116
|
+
challenge: 'n-0S6_WzA2Mj',
|
|
117
|
+
domain: 'https://client.example.org/cb',
|
|
118
|
+
jws: 'eyJhb...JQdBw',
|
|
119
|
+
proofPurpose: 'authentication',
|
|
120
|
+
verificationMethod: 'did:example:holder#key-1',
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
const addCredentialArgs2: AddDigitalCredentialArgs = {
|
|
124
|
+
raw: JSON.stringify(sampleVP),
|
|
125
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
126
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
127
|
+
issuerCorrelationId: 'did:example:holder',
|
|
128
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
129
|
+
subjectCorrelationId: 'did:example:holder',
|
|
130
|
+
}
|
|
131
|
+
const savedDigitalCredential1: DigitalCredential = await digitalCredentialStore.addDigitalCredential(addCredentialArgs1)
|
|
132
|
+
expect(savedDigitalCredential1).toBeDefined()
|
|
133
|
+
const savedDigitalCredential2: DigitalCredential = await digitalCredentialStore.addDigitalCredential(addCredentialArgs2)
|
|
134
|
+
expect(savedDigitalCredential2).toBeDefined()
|
|
135
|
+
const args: GetDigitalCredentialsArgs = {
|
|
136
|
+
filter: [{ credentialType: CredentialType.VP }],
|
|
137
|
+
}
|
|
138
|
+
const result: Array<DigitalCredentialEntity> = await digitalCredentialStore.getDigitalCredentials(args)
|
|
139
|
+
|
|
140
|
+
expect(result.length).toEqual(1)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('should return no digital credentials if filter does not match', async (): Promise<void> => {
|
|
144
|
+
const args: GetDigitalCredentialsArgs = {
|
|
145
|
+
filter: [{ issuerCorrelationId: 'unknown_id' }],
|
|
146
|
+
}
|
|
147
|
+
const result: Array<DigitalCredentialEntity> = await digitalCredentialStore.getDigitalCredentials(args)
|
|
148
|
+
|
|
149
|
+
expect(result.length).toEqual(0)
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('should delete stored digital credential', async (): Promise<void> => {
|
|
153
|
+
const rawCredential: string =
|
|
154
|
+
'eyJraWQiOiJkaWQ6a2V5Ono2TWtyaGt5M3B1c20yNk1laUZhWFUzbjJuZWtyYW13RlVtZ0dyZUdHa0RWNnpRaiN6Nk1rcmhreTNwdXNtMjZNZWlGYVhVM24ybmVrcmFtd0ZVbWdHcmVHR2tEVjZ6UWoiLCJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vc3BoZXJlb24tb3BlbnNvdXJjZS5naXRodWIuaW8vc3NpLW1vYmlsZS13YWxsZXQvY29udGV4dC9zcGhlcmVvbi13YWxsZXQtaWRlbnRpdHktdjEuanNvbmxkIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJTcGhlcmVvbldhbGxldElkZW50aXR5Q3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJmaXJzdE5hbWUiOiJTIiwibGFzdE5hbWUiOiJLIiwiZW1haWxBZGRyZXNzIjoic0BrIn19LCJzdWIiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJqdGkiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJuYmYiOjE3MDg0NDA4MDgsImlzcyI6ImRpZDprZXk6ejZNa3Joa3kzcHVzbTI2TWVpRmFYVTNuMm5la3JhbXdGVW1nR3JlR0drRFY2elFqIn0.G0M84XVAxSmzGY-NQuB9NBofNrINSn6lvxW6761Vlq6ypvYgtc2xNdpiRmw8ryVNfnpzrr4Z5cB1RlrC05rJAw'
|
|
155
|
+
const digitalCredential: AddDigitalCredentialArgs = {
|
|
156
|
+
raw: rawCredential,
|
|
157
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
158
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
159
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
160
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
161
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const savedDigitalCredential: DigitalCredential = await digitalCredentialStore.addDigitalCredential(digitalCredential)
|
|
165
|
+
let result = await digitalCredentialStore.removeDigitalCredential({ id: savedDigitalCredential.id })
|
|
166
|
+
expect(result).toEqual(true)
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
it('should not delete stored digital credential if id not found', async (): Promise<void> => {
|
|
170
|
+
const result = await digitalCredentialStore.removeDigitalCredential({ id: 'unknown_id' })
|
|
171
|
+
expect(result).toEqual(false)
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
it('should update stored digital credential', async (): Promise<void> => {
|
|
175
|
+
const rawCredential: string =
|
|
176
|
+
'eyJraWQiOiJkaWQ6a2V5Ono2TWtyaGt5M3B1c20yNk1laUZhWFUzbjJuZWtyYW13RlVtZ0dyZUdHa0RWNnpRaiN6Nk1rcmhreTNwdXNtMjZNZWlGYVhVM24ybmVrcmFtd0ZVbWdHcmVHR2tEVjZ6UWoiLCJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vc3BoZXJlb24tb3BlbnNvdXJjZS5naXRodWIuaW8vc3NpLW1vYmlsZS13YWxsZXQvY29udGV4dC9zcGhlcmVvbi13YWxsZXQtaWRlbnRpdHktdjEuanNvbmxkIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJTcGhlcmVvbldhbGxldElkZW50aXR5Q3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJmaXJzdE5hbWUiOiJTIiwibGFzdE5hbWUiOiJLIiwiZW1haWxBZGRyZXNzIjoic0BrIn19LCJzdWIiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJqdGkiOiJ1cm46dXVpZDpkZGE3YmYyNC04ZTdhLTQxZjgtYjY2Yy1hNDhkYmM1YjEwZmEiLCJuYmYiOjE3MDg0NDA4MDgsImlzcyI6ImRpZDprZXk6ejZNa3Joa3kzcHVzbTI2TWVpRmFYVTNuMm5la3JhbXdGVW1nR3JlR0drRFY2elFqIn0.G0M84XVAxSmzGY-NQuB9NBofNrINSn6lvxW6761Vlq6ypvYgtc2xNdpiRmw8ryVNfnpzrr4Z5cB1RlrC05rJAw'
|
|
177
|
+
const digitalCredential: AddDigitalCredentialArgs = {
|
|
178
|
+
raw: rawCredential,
|
|
179
|
+
issuerCorrelationType: CredentialCorrelationType.DID,
|
|
180
|
+
subjectCorrelationType: CredentialCorrelationType.DID,
|
|
181
|
+
issuerCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
182
|
+
subjectCorrelationId: 'did:key:z6Mkrhky3pusm26MeiFaXU3n2nekramwFUmgGreGGkDV6zQj',
|
|
183
|
+
tenantId: 'urn:uuid:nnag4b43-1e7a-98f8-a32c-a48dbc5b10mj',
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const savedDigitalCredential: DigitalCredential = await digitalCredentialStore.addDigitalCredential(digitalCredential)
|
|
187
|
+
|
|
188
|
+
const result = await digitalCredentialStore.updateDigitalCredentialState({
|
|
189
|
+
id: savedDigitalCredential.id,
|
|
190
|
+
verifiedState: CredentialStateType.REVOKED,
|
|
191
|
+
})
|
|
192
|
+
expect(result.verifiedState).toEqual(CredentialStateType.REVOKED)
|
|
193
|
+
})
|
|
194
|
+
})
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm'
|
|
2
|
-
import { DataStoreEventLoggerEntities } from '../index'
|
|
3
|
-
import { DataStoreEventLoggerMigrations } from '../migrations/generic'
|
|
4
|
-
import { ActionType, InitiatorType, LogLevel, PartyCorrelationType, SubSystem, System, SystemCorrelationIdType } from '@sphereon/ssi-sdk.core'
|
|
5
|
-
import { auditEventEntityFrom, AuditEventEntity } from '../entities/eventLogger/AuditEventEntity'
|
|
6
|
-
import { NonPersistedAuditLoggingEvent } from '../types'
|
|
7
|
-
|
|
8
|
-
describe('Database entities tests', (): void => {
|
|
9
|
-
let dbConnection: DataSource
|
|
10
|
-
|
|
11
|
-
beforeEach(async (): Promise<void> => {
|
|
12
|
-
dbConnection = await new DataSource({
|
|
13
|
-
type: 'sqlite',
|
|
14
|
-
database: ':memory:',
|
|
15
|
-
//logging: 'all',
|
|
16
|
-
migrationsRun: false,
|
|
17
|
-
migrations: DataStoreEventLoggerMigrations,
|
|
18
|
-
synchronize: false,
|
|
19
|
-
entities: [...DataStoreEventLoggerEntities],
|
|
20
|
-
}).initialize()
|
|
21
|
-
await dbConnection.runMigrations()
|
|
22
|
-
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
afterEach(async (): Promise<void> => {
|
|
26
|
-
await (await dbConnection).destroy()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('should save audit event to database', async (): Promise<void> => {
|
|
30
|
-
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
31
|
-
timestamp: new Date(),
|
|
32
|
-
level: LogLevel.DEBUG,
|
|
33
|
-
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
34
|
-
system: System.GENERAL,
|
|
35
|
-
subSystemType: SubSystem.DID_PROVIDER,
|
|
36
|
-
actionType: ActionType.CREATE,
|
|
37
|
-
actionSubType: 'Key generation',
|
|
38
|
-
initiatorType: InitiatorType.EXTERNAL,
|
|
39
|
-
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
40
|
-
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
41
|
-
systemAlias: 'test_alias',
|
|
42
|
-
partyCorrelationType: PartyCorrelationType.DID,
|
|
43
|
-
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
44
|
-
partyAlias: 'test_alias',
|
|
45
|
-
description: 'test_description',
|
|
46
|
-
data: 'test_data_string',
|
|
47
|
-
diagnosticData: { data: 'test_data_string' },
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const auditEventEntity: AuditEventEntity = auditEventEntityFrom(auditEvent)
|
|
51
|
-
const fromDb: AuditEventEntity = await dbConnection.getRepository(AuditEventEntity).save(auditEventEntity)
|
|
52
|
-
|
|
53
|
-
expect(fromDb).toBeDefined()
|
|
54
|
-
expect(fromDb?.id).not.toBeNull()
|
|
55
|
-
expect(fromDb?.timestamp).toEqual(auditEvent.timestamp)
|
|
56
|
-
expect(fromDb?.level).toEqual(auditEvent.level)
|
|
57
|
-
expect(fromDb?.correlationId).toEqual(auditEvent.correlationId)
|
|
58
|
-
expect(fromDb?.system).toEqual(auditEvent.system)
|
|
59
|
-
expect(fromDb?.subSystemType).toEqual(auditEvent.subSystemType)
|
|
60
|
-
expect(fromDb?.actionType).toEqual(auditEvent.actionType)
|
|
61
|
-
expect(fromDb?.actionSubType).toEqual(auditEvent.actionSubType)
|
|
62
|
-
expect(fromDb?.initiatorType).toEqual(auditEvent.initiatorType)
|
|
63
|
-
expect(fromDb?.systemCorrelationIdType).toEqual(auditEvent.systemCorrelationIdType)
|
|
64
|
-
expect(fromDb?.systemCorrelationId).toEqual(auditEvent.systemCorrelationId)
|
|
65
|
-
expect(fromDb?.systemAlias).toEqual(auditEvent.systemAlias)
|
|
66
|
-
expect(fromDb?.partyCorrelationType).toEqual(auditEvent.partyCorrelationType)
|
|
67
|
-
expect(fromDb?.partyCorrelationId).toEqual(auditEvent.partyCorrelationId)
|
|
68
|
-
expect(fromDb?.partyAlias).toEqual(auditEvent.partyAlias)
|
|
69
|
-
expect(fromDb?.description).toEqual(auditEvent.description)
|
|
70
|
-
expect(fromDb?.data).toEqual(JSON.stringify(auditEvent.data))
|
|
71
|
-
expect(fromDb?.diagnosticData).toEqual(JSON.stringify(auditEvent.diagnosticData))
|
|
72
|
-
})
|
|
73
|
-
})
|
|
1
|
+
import { DataSource } from 'typeorm'
|
|
2
|
+
import { DataStoreEventLoggerEntities } from '../index'
|
|
3
|
+
import { DataStoreEventLoggerMigrations } from '../migrations/generic'
|
|
4
|
+
import { ActionType, InitiatorType, LogLevel, PartyCorrelationType, SubSystem, System, SystemCorrelationIdType } from '@sphereon/ssi-sdk.core'
|
|
5
|
+
import { auditEventEntityFrom, AuditEventEntity } from '../entities/eventLogger/AuditEventEntity'
|
|
6
|
+
import { NonPersistedAuditLoggingEvent } from '../types'
|
|
7
|
+
|
|
8
|
+
describe('Database entities tests', (): void => {
|
|
9
|
+
let dbConnection: DataSource
|
|
10
|
+
|
|
11
|
+
beforeEach(async (): Promise<void> => {
|
|
12
|
+
dbConnection = await new DataSource({
|
|
13
|
+
type: 'sqlite',
|
|
14
|
+
database: ':memory:',
|
|
15
|
+
//logging: 'all',
|
|
16
|
+
migrationsRun: false,
|
|
17
|
+
migrations: DataStoreEventLoggerMigrations,
|
|
18
|
+
synchronize: false,
|
|
19
|
+
entities: [...DataStoreEventLoggerEntities],
|
|
20
|
+
}).initialize()
|
|
21
|
+
await dbConnection.runMigrations()
|
|
22
|
+
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
afterEach(async (): Promise<void> => {
|
|
26
|
+
await (await dbConnection).destroy()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should save audit event to database', async (): Promise<void> => {
|
|
30
|
+
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
31
|
+
timestamp: new Date(),
|
|
32
|
+
level: LogLevel.DEBUG,
|
|
33
|
+
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
34
|
+
system: System.GENERAL,
|
|
35
|
+
subSystemType: SubSystem.DID_PROVIDER,
|
|
36
|
+
actionType: ActionType.CREATE,
|
|
37
|
+
actionSubType: 'Key generation',
|
|
38
|
+
initiatorType: InitiatorType.EXTERNAL,
|
|
39
|
+
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
40
|
+
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
41
|
+
systemAlias: 'test_alias',
|
|
42
|
+
partyCorrelationType: PartyCorrelationType.DID,
|
|
43
|
+
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
44
|
+
partyAlias: 'test_alias',
|
|
45
|
+
description: 'test_description',
|
|
46
|
+
data: 'test_data_string',
|
|
47
|
+
diagnosticData: { data: 'test_data_string' },
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const auditEventEntity: AuditEventEntity = auditEventEntityFrom(auditEvent)
|
|
51
|
+
const fromDb: AuditEventEntity = await dbConnection.getRepository(AuditEventEntity).save(auditEventEntity)
|
|
52
|
+
|
|
53
|
+
expect(fromDb).toBeDefined()
|
|
54
|
+
expect(fromDb?.id).not.toBeNull()
|
|
55
|
+
expect(fromDb?.timestamp).toEqual(auditEvent.timestamp)
|
|
56
|
+
expect(fromDb?.level).toEqual(auditEvent.level)
|
|
57
|
+
expect(fromDb?.correlationId).toEqual(auditEvent.correlationId)
|
|
58
|
+
expect(fromDb?.system).toEqual(auditEvent.system)
|
|
59
|
+
expect(fromDb?.subSystemType).toEqual(auditEvent.subSystemType)
|
|
60
|
+
expect(fromDb?.actionType).toEqual(auditEvent.actionType)
|
|
61
|
+
expect(fromDb?.actionSubType).toEqual(auditEvent.actionSubType)
|
|
62
|
+
expect(fromDb?.initiatorType).toEqual(auditEvent.initiatorType)
|
|
63
|
+
expect(fromDb?.systemCorrelationIdType).toEqual(auditEvent.systemCorrelationIdType)
|
|
64
|
+
expect(fromDb?.systemCorrelationId).toEqual(auditEvent.systemCorrelationId)
|
|
65
|
+
expect(fromDb?.systemAlias).toEqual(auditEvent.systemAlias)
|
|
66
|
+
expect(fromDb?.partyCorrelationType).toEqual(auditEvent.partyCorrelationType)
|
|
67
|
+
expect(fromDb?.partyCorrelationId).toEqual(auditEvent.partyCorrelationId)
|
|
68
|
+
expect(fromDb?.partyAlias).toEqual(auditEvent.partyAlias)
|
|
69
|
+
expect(fromDb?.description).toEqual(auditEvent.description)
|
|
70
|
+
expect(fromDb?.data).toEqual(JSON.stringify(auditEvent.data))
|
|
71
|
+
expect(fromDb?.diagnosticData).toEqual(JSON.stringify(auditEvent.diagnosticData))
|
|
72
|
+
})
|
|
73
|
+
})
|