@sphereon/ssi-sdk.data-store 0.32.1-fix.160 → 0.32.1-next.113
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/entities/statusList2021/StatusList2021Entity.d.ts +19 -0
- package/dist/entities/statusList2021/StatusList2021Entity.d.ts.map +1 -0
- package/dist/entities/{statusList/StatusListEntities.js → statusList2021/StatusList2021Entity.js} +16 -44
- package/dist/entities/statusList2021/StatusList2021Entity.js.map +1 -0
- package/dist/entities/{statusList → statusList2021}/StatusList2021EntryEntity.d.ts +1 -1
- package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts.map +1 -0
- package/dist/entities/{statusList → statusList2021}/StatusList2021EntryEntity.js +3 -3
- package/dist/entities/statusList2021/StatusList2021EntryEntity.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/4-CreateStatusList.d.ts.map +1 -1
- package/dist/migrations/generic/4-CreateStatusList.js +12 -22
- package/dist/migrations/generic/4-CreateStatusList.js.map +1 -1
- package/dist/migrations/postgres/1693866470001-CreateStatusList.d.ts.map +1 -1
- package/dist/migrations/postgres/1693866470001-CreateStatusList.js +7 -43
- package/dist/migrations/postgres/1693866470001-CreateStatusList.js.map +1 -1
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts.map +1 -1
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js +5 -45
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js.map +1 -1
- package/dist/statusList/IStatusListStore.d.ts +2 -2
- package/dist/statusList/IStatusListStore.d.ts.map +1 -1
- package/dist/statusList/StatusListStore.d.ts +7 -8
- package/dist/statusList/StatusListStore.d.ts.map +1 -1
- package/dist/statusList/StatusListStore.js +31 -53
- package/dist/statusList/StatusListStore.js.map +1 -1
- package/dist/types/statusList/IAbstractStatusListStore.d.ts +2 -2
- package/dist/types/statusList/IAbstractStatusListStore.d.ts.map +1 -1
- package/dist/types/statusList/statusList.d.ts +4 -9
- package/dist/types/statusList/statusList.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/entities/{statusList/StatusListEntities.ts → statusList2021/StatusList2021Entity.ts} +18 -37
- package/src/entities/{statusList → statusList2021}/StatusList2021EntryEntity.ts +1 -1
- package/src/index.ts +3 -3
- package/src/migrations/generic/4-CreateStatusList.ts +12 -22
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +9 -45
- package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +5 -45
- package/src/statusList/IStatusListStore.ts +2 -2
- package/src/statusList/StatusListStore.ts +40 -66
- package/src/types/statusList/IAbstractStatusListStore.ts +2 -2
- package/src/types/statusList/statusList.ts +4 -12
- package/dist/entities/statusList/StatusList2021EntryEntity.d.ts.map +0 -1
- package/dist/entities/statusList/StatusList2021EntryEntity.js.map +0 -1
- package/dist/entities/statusList/StatusListEntities.d.ts +0 -23
- package/dist/entities/statusList/StatusListEntities.d.ts.map +0 -1
- package/dist/entities/statusList/StatusListEntities.js.map +0 -1
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.d.ts +0 -7
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.d.ts.map +0 -1
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.js +0 -39
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.js.map +0 -1
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.d.ts +0 -7
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.d.ts.map +0 -1
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.js +0 -88
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.js.map +0 -1
- package/dist/utils/statusList/MappingUtils.d.ts +0 -5
- package/dist/utils/statusList/MappingUtils.d.ts.map +0 -1
- package/dist/utils/statusList/MappingUtils.js +0 -69
- package/dist/utils/statusList/MappingUtils.js.map +0 -1
- package/src/__tests__/statusList.entities.test.ts +0 -215
- package/src/__tests__/statusList.store.test.ts +0 -232
- package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +0 -25
- package/src/migrations/sqlite/1737110469000-UpdateStatusList.ts +0 -84
- package/src/utils/statusList/MappingUtils.ts +0 -82
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm'
|
|
2
|
-
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
-
import { DataStoreStatusListEntities, StatusListEntryEntity } from '../index'
|
|
4
|
-
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
|
-
import { OAuthStatusListEntity, StatusList2021Entity } from '../entities/statusList/StatusListEntities'
|
|
6
|
-
import { IIssuer, StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types'
|
|
7
|
-
|
|
8
|
-
describe('Status list entities tests', () => {
|
|
9
|
-
let dbConnection: DataSource
|
|
10
|
-
|
|
11
|
-
beforeEach(async () => {
|
|
12
|
-
DataSources.singleInstance().defaultDbType = 'sqlite'
|
|
13
|
-
dbConnection = await new DataSource({
|
|
14
|
-
type: 'sqlite',
|
|
15
|
-
database: ':memory:',
|
|
16
|
-
migrationsRun: false,
|
|
17
|
-
migrations: DataStoreStatusListMigrations,
|
|
18
|
-
synchronize: false,
|
|
19
|
-
entities: [...DataStoreStatusListEntities],
|
|
20
|
-
}).initialize()
|
|
21
|
-
await dbConnection.runMigrations()
|
|
22
|
-
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
afterEach(async () => {
|
|
26
|
-
await dbConnection.destroy()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('should save status list to database', async () => {
|
|
30
|
-
const statusList = new StatusList2021Entity()
|
|
31
|
-
statusList.id = 'test-list-1'
|
|
32
|
-
statusList.correlationId = 'correlation-1'
|
|
33
|
-
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
34
|
-
statusList.length = 100000
|
|
35
|
-
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
36
|
-
statusList.proofFormat = 'jwt'
|
|
37
|
-
statusList.statusPurpose = 'revocation'
|
|
38
|
-
statusList.indexingDirection = 'rightToLeft'
|
|
39
|
-
statusList.issuer = 'did:example:123'
|
|
40
|
-
|
|
41
|
-
const fromDb = await dbConnection.getRepository(StatusList2021Entity).save(statusList)
|
|
42
|
-
expect(fromDb).toBeDefined()
|
|
43
|
-
expect(fromDb.id).toEqual(statusList.id)
|
|
44
|
-
expect(fromDb.correlationId).toEqual(statusList.correlationId)
|
|
45
|
-
expect(fromDb.length).toEqual(statusList.length)
|
|
46
|
-
expect(fromDb.credentialIdMode).toEqual(statusList.credentialIdMode)
|
|
47
|
-
expect(fromDb.statusPurpose).toEqual(statusList.statusPurpose)
|
|
48
|
-
expect(fromDb.indexingDirection).toEqual(statusList.indexingDirection)
|
|
49
|
-
expect(fromDb.issuer).toEqual(statusList.issuer)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('should save status list entry to database', async () => {
|
|
53
|
-
const statusList = new StatusList2021Entity()
|
|
54
|
-
statusList.id = 'test-list-1'
|
|
55
|
-
statusList.correlationId = 'correlation-1'
|
|
56
|
-
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
57
|
-
statusList.length = 100000
|
|
58
|
-
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
59
|
-
statusList.proofFormat = 'jwt'
|
|
60
|
-
statusList.statusPurpose = 'revocation'
|
|
61
|
-
statusList.indexingDirection = 'rightToLeft'
|
|
62
|
-
statusList.issuer = 'did:example:123'
|
|
63
|
-
|
|
64
|
-
await dbConnection.getRepository(StatusList2021Entity).save(statusList)
|
|
65
|
-
|
|
66
|
-
const entry = new StatusListEntryEntity()
|
|
67
|
-
entry.statusList = statusList
|
|
68
|
-
entry.statusListIndex = 1
|
|
69
|
-
entry.credentialId = 'credential-1'
|
|
70
|
-
entry.credentialHash = 'hash-1'
|
|
71
|
-
entry.correlationId = 'correlation-1'
|
|
72
|
-
entry.value = '1'
|
|
73
|
-
|
|
74
|
-
const fromDb = await dbConnection.getRepository(StatusListEntryEntity).save(entry)
|
|
75
|
-
expect(fromDb).toBeDefined()
|
|
76
|
-
expect(fromDb.statusListIndex).toEqual(entry.statusListIndex)
|
|
77
|
-
expect(fromDb.credentialId).toEqual(entry.credentialId)
|
|
78
|
-
expect(fromDb.credentialHash).toEqual(entry.credentialHash)
|
|
79
|
-
expect(fromDb.correlationId).toEqual(entry.correlationId)
|
|
80
|
-
expect(fromDb.value).toEqual(entry.value)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
it('should handle complex issuer object', async () => {
|
|
84
|
-
const statusList = new StatusList2021Entity()
|
|
85
|
-
statusList.id = 'test-list-1'
|
|
86
|
-
statusList.correlationId = 'correlation-1'
|
|
87
|
-
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
88
|
-
statusList.length = 100000
|
|
89
|
-
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
90
|
-
statusList.proofFormat = 'jwt'
|
|
91
|
-
statusList.statusPurpose = 'revocation'
|
|
92
|
-
statusList.indexingDirection = 'rightToLeft'
|
|
93
|
-
statusList.issuer = { id: 'did:example:123', name: 'Test Issuer' }
|
|
94
|
-
|
|
95
|
-
const fromDb = await dbConnection.getRepository(StatusList2021Entity).save(statusList)
|
|
96
|
-
expect(fromDb).toBeDefined()
|
|
97
|
-
expect(fromDb.issuer).toEqual(statusList.issuer)
|
|
98
|
-
expect(typeof fromDb.issuer).toEqual('object')
|
|
99
|
-
expect((fromDb.issuer as IIssuer).id).toEqual('did:example:123')
|
|
100
|
-
expect((fromDb.issuer as IIssuer).name).toEqual('Test Issuer')
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
it('should save OAuth status list to database', async () => {
|
|
104
|
-
const statusList = new OAuthStatusListEntity()
|
|
105
|
-
statusList.id = 'oauth-list-1'
|
|
106
|
-
statusList.correlationId = 'correlation-oauth-1'
|
|
107
|
-
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
108
|
-
statusList.length = 100000
|
|
109
|
-
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
110
|
-
statusList.proofFormat = 'jwt'
|
|
111
|
-
statusList.bitsPerStatus = 1
|
|
112
|
-
statusList.expiresAt = new Date('2025-01-01T00:00:00Z')
|
|
113
|
-
statusList.issuer = 'did:example:123'
|
|
114
|
-
|
|
115
|
-
const fromDb = await dbConnection.getRepository(OAuthStatusListEntity).save(statusList)
|
|
116
|
-
expect(fromDb).toBeDefined()
|
|
117
|
-
expect(fromDb.id).toEqual(statusList.id)
|
|
118
|
-
expect(fromDb.correlationId).toEqual(statusList.correlationId)
|
|
119
|
-
expect(fromDb.length).toEqual(statusList.length)
|
|
120
|
-
expect(fromDb.credentialIdMode).toEqual(statusList.credentialIdMode)
|
|
121
|
-
expect(fromDb.bitsPerStatus).toEqual(statusList.bitsPerStatus)
|
|
122
|
-
expect(fromDb.expiresAt).toEqual(statusList.expiresAt)
|
|
123
|
-
expect(fromDb.issuer).toEqual(statusList.issuer)
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
it('should handle both status list types having entries', async () => {
|
|
127
|
-
const statusList2021 = new StatusList2021Entity()
|
|
128
|
-
statusList2021.id = 'test-list-1'
|
|
129
|
-
statusList2021.correlationId = 'correlation-1'
|
|
130
|
-
statusList2021.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
131
|
-
statusList2021.length = 100000
|
|
132
|
-
statusList2021.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
133
|
-
statusList2021.proofFormat = 'jwt'
|
|
134
|
-
statusList2021.statusPurpose = 'revocation'
|
|
135
|
-
statusList2021.indexingDirection = 'rightToLeft'
|
|
136
|
-
statusList2021.issuer = 'did:example:123'
|
|
137
|
-
await dbConnection.getRepository(StatusList2021Entity).save(statusList2021)
|
|
138
|
-
|
|
139
|
-
const oauthStatusList = new OAuthStatusListEntity()
|
|
140
|
-
oauthStatusList.id = 'oauth-list-1'
|
|
141
|
-
oauthStatusList.correlationId = 'correlation-oauth-1'
|
|
142
|
-
oauthStatusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
143
|
-
oauthStatusList.length = 100000
|
|
144
|
-
oauthStatusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
145
|
-
oauthStatusList.proofFormat = 'jwt'
|
|
146
|
-
oauthStatusList.bitsPerStatus = 1
|
|
147
|
-
oauthStatusList.issuer = 'did:example:456'
|
|
148
|
-
await dbConnection.getRepository(OAuthStatusListEntity).save(oauthStatusList)
|
|
149
|
-
|
|
150
|
-
const entry2021 = new StatusListEntryEntity()
|
|
151
|
-
entry2021.statusList = statusList2021
|
|
152
|
-
entry2021.statusListIndex = 1
|
|
153
|
-
entry2021.credentialId = 'credential-1'
|
|
154
|
-
entry2021.credentialHash = 'hash-1'
|
|
155
|
-
entry2021.value = '1'
|
|
156
|
-
await dbConnection.getRepository(StatusListEntryEntity).save(entry2021)
|
|
157
|
-
|
|
158
|
-
const entryOAuth = new StatusListEntryEntity()
|
|
159
|
-
entryOAuth.statusList = oauthStatusList
|
|
160
|
-
entryOAuth.statusListIndex = 1
|
|
161
|
-
entryOAuth.credentialId = 'credential-2'
|
|
162
|
-
entryOAuth.credentialHash = 'hash-2'
|
|
163
|
-
entryOAuth.value = '1'
|
|
164
|
-
await dbConnection.getRepository(StatusListEntryEntity).save(entryOAuth)
|
|
165
|
-
|
|
166
|
-
const found2021Entry = await dbConnection.getRepository(StatusListEntryEntity).findOne({
|
|
167
|
-
where: { statusList: statusList2021.id, statusListIndex: 1 },
|
|
168
|
-
})
|
|
169
|
-
const foundOAuthEntry = await dbConnection.getRepository(StatusListEntryEntity).findOne({
|
|
170
|
-
where: { statusList: oauthStatusList.id, statusListIndex: 1 },
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
expect(found2021Entry).toBeDefined()
|
|
174
|
-
expect(found2021Entry?.credentialId).toEqual('credential-1')
|
|
175
|
-
expect(foundOAuthEntry).toBeDefined()
|
|
176
|
-
expect(foundOAuthEntry?.credentialId).toEqual('credential-2')
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
it('should cascade delete entries when status list is deleted', async () => {
|
|
180
|
-
const statusList = new StatusList2021Entity()
|
|
181
|
-
statusList.id = 'test-list-1'
|
|
182
|
-
statusList.correlationId = 'correlation-1'
|
|
183
|
-
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
184
|
-
statusList.length = 100000
|
|
185
|
-
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
186
|
-
statusList.proofFormat = 'jwt'
|
|
187
|
-
statusList.statusPurpose = 'revocation'
|
|
188
|
-
statusList.indexingDirection = 'rightToLeft'
|
|
189
|
-
statusList.issuer = 'did:example:123'
|
|
190
|
-
|
|
191
|
-
const savedStatusList = await dbConnection.getRepository(StatusList2021Entity).save(statusList)
|
|
192
|
-
|
|
193
|
-
const entry = new StatusListEntryEntity()
|
|
194
|
-
entry.statusList = statusList
|
|
195
|
-
entry.statusListIndex = 1
|
|
196
|
-
entry.credentialId = 'credential-1'
|
|
197
|
-
entry.credentialHash = 'hash-1'
|
|
198
|
-
entry.correlationId = 'correlation-1'
|
|
199
|
-
entry.value = '1'
|
|
200
|
-
|
|
201
|
-
await dbConnection.getRepository(StatusListEntryEntity).save(entry)
|
|
202
|
-
|
|
203
|
-
// First delete entry, otherwise constraint fails
|
|
204
|
-
await dbConnection.getRepository(StatusListEntryEntity).delete({ statusList: savedStatusList.id })
|
|
205
|
-
await dbConnection.getRepository(StatusList2021Entity).remove(savedStatusList)
|
|
206
|
-
|
|
207
|
-
const foundEntry = await dbConnection.getRepository(StatusListEntryEntity).findOne({
|
|
208
|
-
where: {
|
|
209
|
-
statusList: statusList.id,
|
|
210
|
-
statusListIndex: entry.statusListIndex,
|
|
211
|
-
},
|
|
212
|
-
})
|
|
213
|
-
expect(foundEntry).toBeNull()
|
|
214
|
-
})
|
|
215
|
-
})
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm'
|
|
2
|
-
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
-
import { DataStoreStatusListEntities } from '../index'
|
|
4
|
-
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
|
-
import { StatusListStore } from '../statusList/StatusListStore'
|
|
6
|
-
import { IStatusList2021Entity, IStatusListEntryEntity, IOAuthStatusListEntity } from '../types'
|
|
7
|
-
import { StatusListCredentialIdMode, StatusListDriverType, StatusListType } from '@sphereon/ssi-types'
|
|
8
|
-
|
|
9
|
-
describe('Status list store tests', () => {
|
|
10
|
-
let dbConnection: DataSource
|
|
11
|
-
let statusListStore: StatusListStore
|
|
12
|
-
|
|
13
|
-
beforeEach(async () => {
|
|
14
|
-
DataSources.singleInstance().defaultDbType = 'sqlite'
|
|
15
|
-
dbConnection = await new DataSource({
|
|
16
|
-
type: 'sqlite',
|
|
17
|
-
database: ':memory:',
|
|
18
|
-
migrationsRun: false,
|
|
19
|
-
migrations: DataStoreStatusListMigrations,
|
|
20
|
-
synchronize: false,
|
|
21
|
-
entities: DataStoreStatusListEntities,
|
|
22
|
-
}).initialize()
|
|
23
|
-
await dbConnection.runMigrations()
|
|
24
|
-
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
25
|
-
statusListStore = new StatusListStore(dbConnection)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
afterEach(async () => {
|
|
29
|
-
await dbConnection.destroy()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('should store status list', async () => {
|
|
33
|
-
const statusList: IStatusList2021Entity = {
|
|
34
|
-
id: 'test-list-1',
|
|
35
|
-
correlationId: 'correlation-1',
|
|
36
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
37
|
-
length: 100000,
|
|
38
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
39
|
-
type: StatusListType.StatusList2021,
|
|
40
|
-
proofFormat: 'jwt',
|
|
41
|
-
statusPurpose: 'revocation',
|
|
42
|
-
indexingDirection: 'rightToLeft',
|
|
43
|
-
issuer: 'did:example:123',
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const result = await statusListStore.addStatusList(statusList)
|
|
47
|
-
expect(result).toBeDefined()
|
|
48
|
-
expect(result.id).toEqual(statusList.id)
|
|
49
|
-
expect(result.correlationId).toEqual(statusList.correlationId)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('should store status list entry', async () => {
|
|
53
|
-
const statusList: IStatusList2021Entity = {
|
|
54
|
-
id: 'test-list-1',
|
|
55
|
-
correlationId: 'correlation-1',
|
|
56
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
57
|
-
length: 100000,
|
|
58
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
59
|
-
type: StatusListType.StatusList2021,
|
|
60
|
-
proofFormat: 'jwt',
|
|
61
|
-
statusPurpose: 'revocation',
|
|
62
|
-
indexingDirection: 'rightToLeft',
|
|
63
|
-
issuer: 'did:example:123',
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
await statusListStore.addStatusList(statusList)
|
|
67
|
-
|
|
68
|
-
const entry: IStatusListEntryEntity = {
|
|
69
|
-
statusList: statusList.id,
|
|
70
|
-
statusListIndex: 1,
|
|
71
|
-
credentialId: 'credential-1',
|
|
72
|
-
credentialHash: 'hash-1',
|
|
73
|
-
correlationId: 'correlation-1',
|
|
74
|
-
value: '1',
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const result = await statusListStore.addStatusListEntry(entry)
|
|
78
|
-
expect(result).toBeDefined()
|
|
79
|
-
expect(result.statusListIndex).toEqual(entry.statusListIndex)
|
|
80
|
-
expect(result.credentialId).toEqual(entry.credentialId)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
it('should store OAuth status list', async () => {
|
|
84
|
-
const statusList: IOAuthStatusListEntity = {
|
|
85
|
-
id: 'oauth-list-1',
|
|
86
|
-
correlationId: 'correlation-oauth-1',
|
|
87
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
88
|
-
length: 100000,
|
|
89
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
90
|
-
type: StatusListType.OAuthStatusList,
|
|
91
|
-
proofFormat: 'jwt',
|
|
92
|
-
bitsPerStatus: 1,
|
|
93
|
-
expiresAt: new Date('2025-01-01T00:00:00Z'),
|
|
94
|
-
issuer: 'did:example:123',
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const result = (await statusListStore.addStatusList(statusList)) as IOAuthStatusListEntity
|
|
98
|
-
expect(result).toBeDefined()
|
|
99
|
-
expect(result.id).toEqual(statusList.id)
|
|
100
|
-
expect(result.correlationId).toEqual(statusList.correlationId)
|
|
101
|
-
expect(result.bitsPerStatus).toEqual(statusList.bitsPerStatus)
|
|
102
|
-
expect(result.expiresAt).toEqual(statusList.expiresAt)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
it('should store and retrieve both types of status lists', async () => {
|
|
106
|
-
const statusList2021: IStatusList2021Entity = {
|
|
107
|
-
id: 'test-list-1',
|
|
108
|
-
correlationId: 'correlation-1',
|
|
109
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
110
|
-
length: 100000,
|
|
111
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
112
|
-
type: StatusListType.StatusList2021,
|
|
113
|
-
proofFormat: 'jwt',
|
|
114
|
-
statusPurpose: 'revocation',
|
|
115
|
-
indexingDirection: 'rightToLeft',
|
|
116
|
-
issuer: 'did:example:123',
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const oauthStatusList: IOAuthStatusListEntity = {
|
|
120
|
-
id: 'oauth-list-1',
|
|
121
|
-
correlationId: 'correlation-oauth-1',
|
|
122
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
123
|
-
length: 100000,
|
|
124
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
125
|
-
type: StatusListType.OAuthStatusList,
|
|
126
|
-
proofFormat: 'jwt',
|
|
127
|
-
bitsPerStatus: 1,
|
|
128
|
-
issuer: 'did:example:456',
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
await statusListStore.addStatusList(statusList2021)
|
|
132
|
-
await statusListStore.addStatusList(oauthStatusList)
|
|
133
|
-
|
|
134
|
-
const found2021 = (await statusListStore.getStatusList({ id: statusList2021.id })) as IStatusList2021Entity
|
|
135
|
-
const foundOAuth = (await statusListStore.getStatusList({ id: oauthStatusList.id })) as IOAuthStatusListEntity
|
|
136
|
-
|
|
137
|
-
expect(found2021.type).toEqual(StatusListType.StatusList2021)
|
|
138
|
-
expect(found2021.statusPurpose).toEqual('revocation')
|
|
139
|
-
expect(foundOAuth.type).toEqual(StatusListType.OAuthStatusList)
|
|
140
|
-
expect((foundOAuth as IOAuthStatusListEntity).bitsPerStatus).toEqual(1)
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
it('should get status list by id', async () => {
|
|
144
|
-
const statusList: IStatusList2021Entity = {
|
|
145
|
-
id: 'test-list-1',
|
|
146
|
-
correlationId: 'correlation-1',
|
|
147
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
148
|
-
length: 100000,
|
|
149
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
150
|
-
type: StatusListType.StatusList2021,
|
|
151
|
-
proofFormat: 'jwt',
|
|
152
|
-
statusPurpose: 'revocation',
|
|
153
|
-
indexingDirection: 'rightToLeft',
|
|
154
|
-
issuer: 'did:example:123',
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
await statusListStore.addStatusList(statusList)
|
|
158
|
-
|
|
159
|
-
const result = await statusListStore.getStatusList({ id: statusList.id })
|
|
160
|
-
expect(result).toBeDefined()
|
|
161
|
-
expect(result.id).toEqual(statusList.id)
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
it('should get status lists with filter', async () => {
|
|
165
|
-
const statusList1: IStatusList2021Entity = {
|
|
166
|
-
id: 'test-list-1',
|
|
167
|
-
correlationId: 'correlation-1',
|
|
168
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
169
|
-
length: 100000,
|
|
170
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
171
|
-
type: StatusListType.StatusList2021,
|
|
172
|
-
proofFormat: 'jwt',
|
|
173
|
-
statusPurpose: 'revocation',
|
|
174
|
-
indexingDirection: 'rightToLeft',
|
|
175
|
-
issuer: 'did:example:123',
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const statusList2: IStatusList2021Entity = {
|
|
179
|
-
id: 'test-list-2',
|
|
180
|
-
correlationId: 'correlation-2',
|
|
181
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
182
|
-
length: 100000,
|
|
183
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
184
|
-
type: StatusListType.StatusList2021,
|
|
185
|
-
proofFormat: 'jwt',
|
|
186
|
-
statusPurpose: 'suspension',
|
|
187
|
-
indexingDirection: 'rightToLeft',
|
|
188
|
-
issuer: 'did:example:456',
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
await statusListStore.addStatusList(statusList1)
|
|
192
|
-
await statusListStore.addStatusList(statusList2)
|
|
193
|
-
|
|
194
|
-
const result = await statusListStore.getStatusLists({
|
|
195
|
-
filter: [{ statusPurpose: 'revocation' }],
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
expect(result.length).toEqual(1)
|
|
199
|
-
expect(result[0].id).toEqual(statusList1.id)
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
it('should delete status list', async () => {
|
|
203
|
-
const statusList: IStatusList2021Entity = {
|
|
204
|
-
id: 'test-list-1',
|
|
205
|
-
correlationId: 'correlation-1',
|
|
206
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
207
|
-
length: 100000,
|
|
208
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
209
|
-
type: StatusListType.StatusList2021,
|
|
210
|
-
proofFormat: 'jwt',
|
|
211
|
-
statusPurpose: 'revocation',
|
|
212
|
-
indexingDirection: 'rightToLeft',
|
|
213
|
-
issuer: 'did:example:123',
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
await statusListStore.addStatusList(statusList)
|
|
217
|
-
const entry: IStatusListEntryEntity = {
|
|
218
|
-
statusList: statusList.id,
|
|
219
|
-
statusListIndex: 1,
|
|
220
|
-
credentialId: 'credential-1',
|
|
221
|
-
credentialHash: 'hash-1',
|
|
222
|
-
correlationId: 'correlation-1',
|
|
223
|
-
value: '1',
|
|
224
|
-
}
|
|
225
|
-
await statusListStore.addStatusListEntry(entry)
|
|
226
|
-
|
|
227
|
-
const result = await statusListStore.removeStatusList({ id: statusList.id })
|
|
228
|
-
expect(result).toEqual(true)
|
|
229
|
-
|
|
230
|
-
await expect(statusListStore.getStatusList({ id: statusList.id })).rejects.toThrow(`No status list found for id ${statusList.id}`)
|
|
231
|
-
})
|
|
232
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
export class UpdateStatusList1737110469001 implements MigrationInterface {
|
|
4
|
-
name = 'UpdateStatusList1737110469001'
|
|
5
|
-
|
|
6
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
-
// Add new enum value
|
|
8
|
-
await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'OAuthStatusList'`)
|
|
9
|
-
|
|
10
|
-
// Make columns nullable and add new columns
|
|
11
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" DROP NOT NULL`)
|
|
12
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" DROP NOT NULL`)
|
|
13
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ADD "bitsPerStatus" integer`)
|
|
14
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ADD "expiresAt" timestamp with time zone`)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
18
|
-
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`)
|
|
19
|
-
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`)
|
|
20
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`)
|
|
21
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`)
|
|
22
|
-
|
|
23
|
-
// Note: Cannot remove enum value in Postgres, would need to recreate the type
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
export class UpdateStatusList1737110469000 implements MigrationInterface {
|
|
4
|
-
name = 'UpdateStatusList1737110469000'
|
|
5
|
-
|
|
6
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
-
// Create temporary table with new schema
|
|
8
|
-
await queryRunner.query(
|
|
9
|
-
`CREATE TABLE "temporary_StatusList" (
|
|
10
|
-
"id" varchar PRIMARY KEY NOT NULL,
|
|
11
|
-
"correlationId" varchar NOT NULL,
|
|
12
|
-
"length" integer NOT NULL,
|
|
13
|
-
"issuer" text NOT NULL,
|
|
14
|
-
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
15
|
-
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
16
|
-
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
17
|
-
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
|
|
18
|
-
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
|
|
19
|
-
"statusPurpose" varchar,
|
|
20
|
-
"statusListCredential" text,
|
|
21
|
-
"bitsPerStatus" integer,
|
|
22
|
-
"expiresAt" datetime,
|
|
23
|
-
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
24
|
-
)`,
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
// Copy data from old table to temporary table
|
|
28
|
-
await queryRunner.query(
|
|
29
|
-
`INSERT INTO "temporary_StatusList"(
|
|
30
|
-
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
31
|
-
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
32
|
-
"statusListCredential"
|
|
33
|
-
)
|
|
34
|
-
SELECT
|
|
35
|
-
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
36
|
-
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
37
|
-
"statusListCredential"
|
|
38
|
-
FROM "StatusList"`,
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
// Drop old table and rename temporary table
|
|
42
|
-
await queryRunner.query(`DROP TABLE "StatusList"`)
|
|
43
|
-
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
47
|
-
// Create temporary table with old schema
|
|
48
|
-
await queryRunner.query(
|
|
49
|
-
`CREATE TABLE "temporary_StatusList" (
|
|
50
|
-
"id" varchar PRIMARY KEY NOT NULL,
|
|
51
|
-
"correlationId" varchar NOT NULL,
|
|
52
|
-
"length" integer NOT NULL,
|
|
53
|
-
"issuer" text NOT NULL,
|
|
54
|
-
"type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
55
|
-
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
56
|
-
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
57
|
-
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
|
|
58
|
-
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
|
|
59
|
-
"statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
|
|
60
|
-
"statusListCredential" text,
|
|
61
|
-
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
62
|
-
)`,
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
// Copy data back, excluding new columns
|
|
66
|
-
await queryRunner.query(
|
|
67
|
-
`INSERT INTO "temporary_StatusList"(
|
|
68
|
-
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
69
|
-
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
70
|
-
"statusListCredential"
|
|
71
|
-
)
|
|
72
|
-
SELECT
|
|
73
|
-
"id", "correlationId", "length", "issuer",
|
|
74
|
-
CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
|
|
75
|
-
"driverType", "credentialIdMode", "proofFormat", "indexingDirection",
|
|
76
|
-
COALESCE("statusPurpose", 'revocation'), "statusListCredential"
|
|
77
|
-
FROM "StatusList"`,
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
// Drop new table and rename temporary table back
|
|
81
|
-
await queryRunner.query(`DROP TABLE "StatusList"`)
|
|
82
|
-
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntity } from '../../types'
|
|
2
|
-
import { OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../../entities/statusList/StatusListEntities'
|
|
3
|
-
import { StatusListType } from '@sphereon/ssi-types'
|
|
4
|
-
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
5
|
-
|
|
6
|
-
export const statusListEntityFrom = (args: IStatusListEntity): StatusListEntity => {
|
|
7
|
-
if (args.type === StatusListType.StatusList2021) {
|
|
8
|
-
const entity = new StatusList2021Entity()
|
|
9
|
-
const sl2021 = args as IStatusList2021Entity
|
|
10
|
-
entity.indexingDirection = sl2021.indexingDirection
|
|
11
|
-
entity.statusPurpose = sl2021.statusPurpose
|
|
12
|
-
setBaseFields(entity, args)
|
|
13
|
-
Object.defineProperty(entity, 'type', {
|
|
14
|
-
value: StatusListType.StatusList2021,
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
})
|
|
18
|
-
return entity
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (args.type === StatusListType.OAuthStatusList) {
|
|
22
|
-
const entity = new OAuthStatusListEntity()
|
|
23
|
-
const oauthSl = args as IOAuthStatusListEntity
|
|
24
|
-
entity.bitsPerStatus = oauthSl.bitsPerStatus
|
|
25
|
-
entity.expiresAt = oauthSl.expiresAt
|
|
26
|
-
setBaseFields(entity, args)
|
|
27
|
-
Object.defineProperty(entity, 'type', {
|
|
28
|
-
value: StatusListType.OAuthStatusList,
|
|
29
|
-
enumerable: true,
|
|
30
|
-
configurable: true,
|
|
31
|
-
})
|
|
32
|
-
return entity
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
throw new Error(`Invalid status list type ${args.type}`)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
|
|
39
|
-
if (entity instanceof StatusList2021Entity) {
|
|
40
|
-
const result: IStatusList2021Entity = {
|
|
41
|
-
...getBaseFields(entity),
|
|
42
|
-
type: StatusListType.StatusList2021,
|
|
43
|
-
indexingDirection: entity.indexingDirection,
|
|
44
|
-
statusPurpose: entity.statusPurpose,
|
|
45
|
-
}
|
|
46
|
-
return replaceNullWithUndefined(result)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (entity instanceof OAuthStatusListEntity) {
|
|
50
|
-
const result: IOAuthStatusListEntity = {
|
|
51
|
-
...getBaseFields(entity),
|
|
52
|
-
type: StatusListType.OAuthStatusList,
|
|
53
|
-
bitsPerStatus: entity.bitsPerStatus,
|
|
54
|
-
expiresAt: entity.expiresAt,
|
|
55
|
-
}
|
|
56
|
-
return replaceNullWithUndefined(result)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
throw new Error(`Invalid status list type ${typeof entity}`)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const setBaseFields = (entity: StatusListEntity, args: IStatusListEntity) => {
|
|
63
|
-
entity.id = args.id
|
|
64
|
-
entity.correlationId = args.correlationId
|
|
65
|
-
entity.length = args.length
|
|
66
|
-
entity.issuer = args.issuer
|
|
67
|
-
entity.driverType = args.driverType
|
|
68
|
-
entity.credentialIdMode = args.credentialIdMode
|
|
69
|
-
entity.proofFormat = args.proofFormat
|
|
70
|
-
entity.statusListCredential = args.statusListCredential
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const getBaseFields = (entity: StatusListEntity): Omit<IStatusListEntity, 'type'> => ({
|
|
74
|
-
id: entity.id,
|
|
75
|
-
correlationId: entity.correlationId,
|
|
76
|
-
length: entity.length,
|
|
77
|
-
issuer: entity.issuer,
|
|
78
|
-
driverType: entity.driverType,
|
|
79
|
-
credentialIdMode: entity.credentialIdMode,
|
|
80
|
-
proofFormat: entity.proofFormat,
|
|
81
|
-
statusListCredential: entity.statusListCredential,
|
|
82
|
-
})
|