@sphereon/ssi-sdk.data-store 0.32.1-feature.VDX.341.56 → 0.32.1-feature.new.develop.273

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.
Files changed (72) hide show
  1. package/dist/entities/oid4vcState/Oid4vcStateEntity.d.ts +13 -0
  2. package/dist/entities/oid4vcState/Oid4vcStateEntity.d.ts.map +1 -0
  3. package/dist/entities/oid4vcState/Oid4vcStateEntity.js +57 -0
  4. package/dist/entities/oid4vcState/Oid4vcStateEntity.js.map +1 -0
  5. package/dist/entities/{statusList2021 → statusList}/StatusList2021EntryEntity.d.ts +4 -3
  6. package/dist/entities/statusList/StatusList2021EntryEntity.d.ts.map +1 -0
  7. package/dist/entities/{statusList2021 → statusList}/StatusList2021EntryEntity.js +11 -6
  8. package/dist/entities/statusList/StatusList2021EntryEntity.js.map +1 -0
  9. package/dist/entities/statusList/StatusListEntities.d.ts +23 -0
  10. package/dist/entities/statusList/StatusListEntities.d.ts.map +1 -0
  11. package/dist/entities/{statusList2021/StatusList2021Entity.js → statusList/StatusListEntities.js} +45 -16
  12. package/dist/entities/statusList/StatusListEntities.js.map +1 -0
  13. package/dist/index.d.ts +5 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +10 -6
  16. package/dist/index.js.map +1 -1
  17. package/dist/migrations/generic/4-CreateStatusList.d.ts.map +1 -1
  18. package/dist/migrations/generic/4-CreateStatusList.js +22 -12
  19. package/dist/migrations/generic/4-CreateStatusList.js.map +1 -1
  20. package/dist/migrations/postgres/1693866470001-CreateStatusList.d.ts.map +1 -1
  21. package/dist/migrations/postgres/1693866470001-CreateStatusList.js +40 -7
  22. package/dist/migrations/postgres/1693866470001-CreateStatusList.js.map +1 -1
  23. package/dist/migrations/postgres/1737110469001-UpdateStatusList.d.ts +7 -0
  24. package/dist/migrations/postgres/1737110469001-UpdateStatusList.d.ts.map +1 -0
  25. package/dist/migrations/postgres/1737110469001-UpdateStatusList.js +39 -0
  26. package/dist/migrations/postgres/1737110469001-UpdateStatusList.js.map +1 -0
  27. package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts.map +1 -1
  28. package/dist/migrations/sqlite/1693866470000-CreateStatusList.js +45 -5
  29. package/dist/migrations/sqlite/1693866470000-CreateStatusList.js.map +1 -1
  30. package/dist/migrations/sqlite/1737110469000-UpdateStatusList.d.ts +7 -0
  31. package/dist/migrations/sqlite/1737110469000-UpdateStatusList.d.ts.map +1 -0
  32. package/dist/migrations/sqlite/1737110469000-UpdateStatusList.js +96 -0
  33. package/dist/migrations/sqlite/1737110469000-UpdateStatusList.js.map +1 -0
  34. package/dist/statusList/IStatusListStore.d.ts +2 -2
  35. package/dist/statusList/IStatusListStore.d.ts.map +1 -1
  36. package/dist/statusList/StatusListStore.d.ts +9 -8
  37. package/dist/statusList/StatusListStore.d.ts.map +1 -1
  38. package/dist/statusList/StatusListStore.js +72 -42
  39. package/dist/statusList/StatusListStore.js.map +1 -1
  40. package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.d.ts +2 -2
  41. package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.d.ts.map +1 -1
  42. package/dist/types/statusList/IAbstractStatusListStore.d.ts +5 -4
  43. package/dist/types/statusList/IAbstractStatusListStore.d.ts.map +1 -1
  44. package/dist/types/statusList/statusList.d.ts +13 -7
  45. package/dist/types/statusList/statusList.d.ts.map +1 -1
  46. package/dist/utils/statusList/MappingUtils.d.ts +5 -0
  47. package/dist/utils/statusList/MappingUtils.d.ts.map +1 -0
  48. package/dist/utils/statusList/MappingUtils.js +69 -0
  49. package/dist/utils/statusList/MappingUtils.js.map +1 -0
  50. package/package.json +7 -7
  51. package/src/__tests__/statusList.entities.test.ts +216 -0
  52. package/src/__tests__/statusList.store.test.ts +232 -0
  53. package/src/entities/oid4vcState/Oid4vcStateEntity.ts +32 -0
  54. package/src/entities/{statusList2021 → statusList}/StatusList2021EntryEntity.ts +10 -6
  55. package/src/entities/{statusList2021/StatusList2021Entity.ts → statusList/StatusListEntities.ts} +38 -18
  56. package/src/index.ts +8 -3
  57. package/src/migrations/generic/4-CreateStatusList.ts +22 -12
  58. package/src/migrations/postgres/1693866470001-CreateStatusList.ts +42 -9
  59. package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +25 -0
  60. package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +45 -5
  61. package/src/migrations/sqlite/1737110469000-UpdateStatusList.ts +94 -0
  62. package/src/statusList/IStatusListStore.ts +2 -2
  63. package/src/statusList/StatusListStore.ts +94 -51
  64. package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +2 -2
  65. package/src/types/statusList/IAbstractStatusListStore.ts +5 -4
  66. package/src/types/statusList/statusList.ts +24 -16
  67. package/src/utils/statusList/MappingUtils.ts +82 -0
  68. package/dist/entities/statusList2021/StatusList2021Entity.d.ts +0 -19
  69. package/dist/entities/statusList2021/StatusList2021Entity.d.ts.map +0 -1
  70. package/dist/entities/statusList2021/StatusList2021Entity.js.map +0 -1
  71. package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts.map +0 -1
  72. package/dist/entities/statusList2021/StatusList2021EntryEntity.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { OrPromise } from '@sphereon/ssi-types'
1
+ import { OrPromise, StatusListType } from '@sphereon/ssi-types'
2
2
  import Debug from 'debug'
3
3
  import { DataSource, In, Repository } from 'typeorm'
4
- import { StatusListEntity } from '../entities/statusList2021/StatusList2021Entity'
5
- import { StatusListEntryEntity } from '../entities/statusList2021/StatusList2021EntryEntity'
4
+ import { OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
5
+ import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
6
6
  import {
7
7
  IAddStatusListArgs,
8
8
  IAddStatusListEntryArgs,
@@ -12,12 +12,13 @@ import {
12
12
  IGetStatusListEntryByIndexArgs,
13
13
  IGetStatusListsArgs,
14
14
  IRemoveStatusListArgs,
15
- IStatusListEntryAvailableArgs,
16
- IUpdateStatusListIndexArgs,
17
15
  IStatusListEntity,
16
+ IStatusListEntryAvailableArgs,
18
17
  IStatusListEntryEntity,
18
+ IUpdateStatusListIndexArgs,
19
19
  } from '../types'
20
20
  import { IStatusListStore } from './IStatusListStore'
21
+ import { statusListEntityFrom, statusListFrom } from '../utils/statusList/MappingUtils'
21
22
 
22
23
  const debug = Debug('sphereon:ssi-sdk:data-store:status-list')
23
24
 
@@ -57,7 +58,7 @@ export class StatusListStore implements IStatusListStore {
57
58
  }
58
59
 
59
60
  async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity> {
60
- const statusListId = typeof args.statusList === 'string' ? args.statusList : args.statusList.id
61
+ const statusListId = args.statusListId ?? args.statusList?.id
61
62
  const result = await this.getStatusListEntryByIndex({ ...args, statusListId, errorOnNotFound: false })
62
63
  const updatedEntry: Partial<IStatusListEntryEntity> = {
63
64
  value: args.value,
@@ -66,56 +67,55 @@ export class StatusListStore implements IStatusListStore {
66
67
  credentialId: args.credentialId,
67
68
  }
68
69
 
70
+ const updStatusListId = result?.statusListId ?? statusListId
69
71
  const updateResult = await (
70
72
  await this.getStatusListEntryRepo()
71
73
  ).upsert(
72
- { ...(result ?? { statusList: args.statusList, statusListIndex: args.statusListIndex }), ...updatedEntry },
74
+ { ...(result ?? { statusListId: updStatusListId, statusListIndex: args.statusListIndex }), ...updatedEntry },
73
75
  { conflictPaths: ['statusList', 'statusListIndex'] },
74
76
  )
75
77
  console.log(updateResult)
76
- return (await this.getStatusListEntryByIndex({ ...args, statusListId, errorOnNotFound: true })) as IStatusListEntryEntity
78
+ return (await this.getStatusListEntryByIndex({
79
+ ...args,
80
+ statusListId: updStatusListId,
81
+ errorOnNotFound: true,
82
+ })) as IStatusListEntryEntity
77
83
  }
78
84
 
79
- async getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<StatusListEntryEntity | undefined> {
80
- if (!args.statusListId && !args.correlationId) {
81
- throw Error(`Cannot get statusList entry if not either a statusList id or correlationId is provided`)
85
+ async getStatusListEntryByIndex({
86
+ statusListId,
87
+ statusListCorrelationId,
88
+ statusListIndex,
89
+ entryCorrelationId,
90
+ errorOnNotFound,
91
+ }: IGetStatusListEntryByIndexArgs): Promise<StatusListEntryEntity | undefined> {
92
+ if (!statusListId && !statusListCorrelationId) {
93
+ throw Error(`Cannot get statusList entry without either a statusList id or statusListCorrelationId`)
82
94
  }
95
+
96
+ if (!statusListIndex && !entryCorrelationId) {
97
+ throw Error(`Cannot get statusList entry without either a statusListIndex or entryCorrelationId`)
98
+ }
99
+
83
100
  const result = await (
84
101
  await this.getStatusListEntryRepo()
85
102
  ).findOne({
86
103
  where: {
87
- ...(args.statusListId && { statusList: args.statusListId }),
88
- ...(args.correlationId && { correlationId: args.correlationId }),
89
- statusListIndex: args.statusListIndex,
104
+ ...(statusListId && { statusListId }),
105
+ ...(!statusListId && statusListCorrelationId && { statusList: { correlationId: statusListCorrelationId } }),
106
+ ...(statusListIndex && { statusListIndex }),
107
+ ...(entryCorrelationId && { entryCorrelationId }),
108
+ },
109
+ relations: {
110
+ statusList: true,
90
111
  },
91
112
  })
92
113
 
93
- if (!result && args.errorOnNotFound) {
94
- throw Error(`Could not find status list index ${args.statusListIndex} for status list id ${args.statusListId}`)
114
+ if (!result && errorOnNotFound) {
115
+ throw Error(`Could not find status list entry with provided filters`)
95
116
  }
96
- return result ?? undefined
97
- }
98
117
 
99
- async removeStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<boolean> {
100
- let error = false
101
- try {
102
- await this.getStatusListEntryByIndex(args) // only used to check it exists
103
- } catch (error) {
104
- error = true
105
- }
106
- if (error) {
107
- console.log(`Could not delete statusList ${args.statusListId} entry by index ${args.statusListIndex}`)
108
- } else {
109
- const result = await (
110
- await this.getStatusListEntryRepo()
111
- ).delete({
112
- ...(args.statusListId && { statusList: args.statusListId }),
113
- ...(args.correlationId && { correlationId: args.correlationId }),
114
- statusListIndex: args.statusListIndex,
115
- })
116
- error = !result.affected || result.affected !== 1
117
- }
118
- return !error
118
+ return result ?? undefined
119
119
  }
120
120
 
121
121
  async getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<StatusListEntryEntity | undefined> {
@@ -123,9 +123,12 @@ export class StatusListStore implements IStatusListStore {
123
123
  if (!credentialId) {
124
124
  throw Error('Can only get a credential by credentialId when a credentialId is supplied')
125
125
  }
126
- const statusList = await this.getStatusList({ id: args.statusListId, correlationId: args.statusListCorrelationId })
126
+ const statusList = await this.getStatusList({
127
+ id: args.statusListId,
128
+ correlationId: args.statusListCorrelationId,
129
+ })
127
130
  const where = {
128
- statusList: statusList.id,
131
+ statusList: { id: statusList.id },
129
132
  ...(args.entryCorrelationId && { correlationId: args.entryCorrelationId }),
130
133
  credentialId,
131
134
  }
@@ -158,11 +161,37 @@ export class StatusListStore implements IStatusListStore {
158
161
  return !error
159
162
  }
160
163
 
164
+ async removeStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<boolean> {
165
+ let error = false
166
+ try {
167
+ await this.getStatusListEntryByIndex(args)
168
+ } catch (error) {
169
+ error = true
170
+ }
171
+ if (error) {
172
+ console.log(`Could not delete statusList ${args.statusListId} entry by index ${args.statusListIndex}`)
173
+ } else {
174
+ const result = await (
175
+ await this.getStatusListEntryRepo()
176
+ ).delete({
177
+ ...(args.statusListId && { statusList: args.statusListId }),
178
+ ...(args.entryCorrelationId && { correlationId: args.entryCorrelationId }),
179
+ statusListIndex: args.statusListIndex,
180
+ })
181
+ error = !result.affected || result.affected !== 1
182
+ }
183
+ return !error
184
+ }
185
+
161
186
  async getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<StatusListEntryEntity[]> {
162
187
  return (await this.getStatusListEntryRepo()).find({ where: { ...args?.filter, statusList: args.statusListId } })
163
188
  }
164
189
 
165
190
  async getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity> {
191
+ return statusListFrom(await this.getStatusListEntity(args))
192
+ }
193
+
194
+ private async getStatusListEntity(args: IGetStatusListArgs): Promise<StatusListEntity> {
166
195
  if (!args.id && !args.correlationId) {
167
196
  throw Error(`At least and 'id' or 'correlationId' needs to be provided to lookup a status list`)
168
197
  }
@@ -189,7 +218,8 @@ export class StatusListStore implements IStatusListStore {
189
218
  if (!result) {
190
219
  return []
191
220
  }
192
- return result
221
+
222
+ return result.map((entity) => statusListFrom(entity))
193
223
  }
194
224
 
195
225
  async addStatusList(args: IAddStatusListArgs): Promise<IStatusListEntity> {
@@ -205,29 +235,42 @@ export class StatusListStore implements IStatusListStore {
205
235
  }
206
236
 
207
237
  debug('Adding status list ', id)
208
- const createdResult = await (await this.getStatusListRepo()).save(args)
209
-
210
- return createdResult
238
+ const entity = statusListEntityFrom(args)
239
+ const createdResult = await (await this.getStatusListRepo(args.type)).save(entity)
240
+ return statusListFrom(createdResult)
211
241
  }
212
242
 
213
243
  async updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity> {
214
244
  const result = await this.getStatusList(args)
215
245
  debug('Updating status list', result)
216
- const updatedResult = await (await this.getStatusListRepo()).save(args, { transaction: true })
217
- return updatedResult
246
+ const entity = statusListEntityFrom(args)
247
+ const updatedResult = await (await this.getStatusListRepo(args.type)).save(entity, { transaction: true })
248
+ return statusListFrom(updatedResult)
218
249
  }
219
250
 
220
- async removeStatusList(args: IRemoveStatusListArgs): Promise<void> {
221
- const result = await this.getStatusList(args)
222
- await (await this.getStatusListRepo()).delete(result)
251
+ async removeStatusList(args: IRemoveStatusListArgs): Promise<boolean> {
252
+ const result = await this.getStatusListEntity(args)
253
+
254
+ await (await this.getStatusListEntryRepo()).delete({ statusListId: result.id })
255
+ const deletedEntity = await (await this.getStatusListRepo()).remove(result)
256
+
257
+ return Boolean(deletedEntity)
223
258
  }
224
259
 
225
260
  private async getDS(): Promise<DataSource> {
226
261
  return this._dbConnection
227
262
  }
228
263
 
229
- async getStatusListRepo(): Promise<Repository<StatusListEntity>> {
230
- return (await this.getDS()).getRepository(StatusListEntity)
264
+ async getStatusListRepo(type?: StatusListType): Promise<Repository<StatusListEntity>> {
265
+ const dataSource = await this.getDS()
266
+ switch (type) {
267
+ case StatusListType.StatusList2021:
268
+ return dataSource.getRepository(StatusList2021Entity)
269
+ case StatusListType.OAuthStatusList:
270
+ return dataSource.getRepository(OAuthStatusListEntity)
271
+ default:
272
+ return dataSource.getRepository(StatusListEntity)
273
+ }
231
274
  }
232
275
 
233
276
  async getStatusListEntryRepo(): Promise<Repository<StatusListEntryEntity>> {
@@ -1,5 +1,5 @@
1
1
  import { CredentialCorrelationType, CredentialRole, CredentialStateType, DigitalCredential, RegulationType } from './digitalCredential'
2
- import { Hasher } from '@sphereon/ssi-types'
2
+ import { HasherSync } from '@sphereon/ssi-types'
3
3
  import { FindOptionsOrder } from 'typeorm'
4
4
  import { DigitalCredentialEntity } from '../../entities/digitalCredential/DigitalCredentialEntity'
5
5
 
@@ -34,7 +34,7 @@ export type AddCredentialArgs = {
34
34
  state?: CredentialStateType
35
35
  verifiedAt?: Date
36
36
  revokedAt?: Date
37
- opts?: { maxTimeSkewInMS?: number; hasher?: Hasher }
37
+ opts?: { maxTimeSkewInMS?: number; hasher?: HasherSync }
38
38
  }
39
39
 
40
40
  export type UpdateCredentialStateArgs = GetCredentialArgs & { verifiedState: CredentialStateType; verifiedAt?: Date; revokedAt?: Date }
@@ -1,7 +1,7 @@
1
1
  import { FindOptionsWhere } from 'typeorm'
2
- import { IStatusListEntity, IStatusListEntryEntity } from './statusList'
2
+ import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntity, IStatusListEntryEntity } from './statusList'
3
3
 
4
- export type FindStatusListArgs = FindOptionsWhere<IStatusListEntity>[]
4
+ export type FindStatusListArgs = FindOptionsWhere<IStatusList2021Entity | IOAuthStatusListEntity>[]
5
5
  export type FindStatusListEntryArgs = FindOptionsWhere<IStatusListEntryEntity>[] | FindOptionsWhere<IStatusListEntryEntity>
6
6
 
7
7
  export interface IStatusListEntryAvailableArgs {
@@ -12,8 +12,9 @@ export interface IStatusListEntryAvailableArgs {
12
12
 
13
13
  export interface IGetStatusListEntryByIndexArgs {
14
14
  statusListId?: string
15
- correlationId?: string
16
- statusListIndex: number
15
+ statusListCorrelationId?: string
16
+ statusListIndex?: number
17
+ entryCorrelationId?: string
17
18
  errorOnNotFound?: boolean
18
19
  }
19
20
 
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  IIssuer,
3
- OriginalVerifiableCredential,
3
+ StatusListCredential,
4
4
  StatusListCredentialIdMode,
5
5
  StatusListDriverType,
6
6
  StatusListIndexingDirection,
7
7
  StatusListType,
8
8
  StatusPurpose2021,
9
+ ProofFormat,
10
+ RequireOneOf,
9
11
  } from '@sphereon/ssi-types'
10
- import { ProofFormat } from '@veramo/core'
11
- import { StatusListEntity } from '../../entities/statusList2021/StatusList2021Entity'
12
+ import { StatusListEntity } from '../../entities/statusList/StatusListEntities'
12
13
 
13
14
  export interface IStatusListEntity {
14
15
  id: string
@@ -19,21 +20,28 @@ export interface IStatusListEntity {
19
20
  issuer: string | IIssuer
20
21
  type: StatusListType
21
22
  proofFormat: ProofFormat
23
+ statusListCredential?: StatusListCredential
24
+ }
25
+
26
+ export interface IStatusList2021Entity extends IStatusListEntity {
22
27
  indexingDirection: StatusListIndexingDirection
23
28
  statusPurpose: StatusPurpose2021
24
- statusListCredential?: OriginalVerifiableCredential
25
29
  }
26
30
 
27
- export interface IStatusListEntryEntity {
28
- statusList: StatusListEntity | string // string is here to accept the id, so we can query it easily with typeorm
29
-
30
- value?: string
31
-
32
- statusListIndex: number
33
-
34
- credentialHash?: string
35
-
36
- credentialId?: string
37
-
38
- correlationId?: string
31
+ export interface IOAuthStatusListEntity extends IStatusListEntity {
32
+ bitsPerStatus: number
33
+ expiresAt?: Date
39
34
  }
35
+
36
+ export type IStatusListEntryEntity = RequireOneOf<
37
+ {
38
+ statusList: StatusListEntity
39
+ statusListId: string
40
+ value?: string
41
+ statusListIndex: number
42
+ credentialHash?: string
43
+ credentialId?: string
44
+ correlationId?: string
45
+ },
46
+ 'statusList' | 'statusListId'
47
+ >
@@ -0,0 +1,82 @@
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
+ })
@@ -1,19 +0,0 @@
1
- import { IIssuer, JwtDecodedVerifiableCredential, StatusListCredentialIdMode, StatusListDriverType, StatusListIndexingDirection, StatusListType, StatusPurpose2021, W3CVerifiableCredential } from '@sphereon/ssi-types';
2
- import { ProofFormat } from '@veramo/core';
3
- import { BaseEntity } from 'typeorm';
4
- import { StatusListEntryEntity } from './StatusList2021EntryEntity';
5
- export declare class StatusListEntity extends BaseEntity {
6
- id: string;
7
- correlationId: string;
8
- length: number;
9
- issuer: string | IIssuer;
10
- type: StatusListType;
11
- driverType: StatusListDriverType;
12
- credentialIdMode: StatusListCredentialIdMode;
13
- proofFormat: ProofFormat;
14
- indexingDirection: StatusListIndexingDirection;
15
- statusPurpose: StatusPurpose2021;
16
- statusListCredential?: W3CVerifiableCredential | JwtDecodedVerifiableCredential;
17
- statusListEntries: StatusListEntryEntity[];
18
- }
19
- //# sourceMappingURL=StatusList2021Entity.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StatusList2021Entity.d.ts","sourceRoot":"","sources":["../../../src/entities/statusList2021/StatusList2021Entity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,8BAA8B,EAC9B,0BAA0B,EAC1B,oBAAoB,EACpB,2BAA2B,EAC3B,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAoD,MAAM,SAAS,CAAA;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,qBAEa,gBAAiB,SAAQ,UAAU;IAE9C,EAAE,EAAG,MAAM,CAAA;IAGX,aAAa,EAAG,MAAM,CAAA;IAGtB,MAAM,EAAG,MAAM,CAAA;IAsBf,MAAM,EAAG,MAAM,GAAG,OAAO,CAAA;IAGzB,IAAI,EAAG,cAAc,CAAA;IAGrB,UAAU,EAAG,oBAAoB,CAAA;IAQjC,gBAAgB,EAAG,0BAA0B,CAAA;IAG7C,WAAW,EAAG,WAAW,CAAA;IAGzB,iBAAiB,EAAG,2BAA2B,CAAA;IAG/C,aAAa,EAAG,iBAAiB,CAAA;IAsBjC,oBAAoB,CAAC,EAAE,uBAAuB,GAAG,8BAA8B,CAAA;IAG/E,iBAAiB,EAAG,qBAAqB,EAAE,CAAA;CAC5C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"StatusList2021Entity.js","sourceRoot":"","sources":["../../../src/entities/statusList2021/StatusList2021Entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAS4B;AAE5B,qCAAsF;AACtF,2EAAmE;AAI5D,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,oBAAU;CA+E/C,CAAA;AA/EY,4CAAgB;AAE3B;IADC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,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AI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;YAC9B,CAAC;SACF;KACF,CAAC;;8DAC6E;AAG/E;IADC,IAAA,mBAAS,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iDAAqB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC;;2DAC7B;2BA9EhC,gBAAgB;IAF5B,IAAA,gBAAM,EAAC,YAAY,CAAC;IACpB,IAAA,gBAAM,EAAC,kBAAkB,EAAE,CAAC,eAAe,CAAC,CAAC;GACjC,gBAAgB,CA+E5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"StatusList2021EntryEntity.d.ts","sourceRoot":"","sources":["../../../src/entities/statusList2021/StatusList2021EntryEntity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAA4C,MAAM,SAAS,CAAA;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,qBAGa,qBAAsB,SAAQ,UAAU;IAGnD,UAAU,EAAG,gBAAgB,CAAA;IAI7B,eAAe,EAAG,MAAM,CAAA;IAGxB,YAAY,CAAC,EAAE,MAAM,CAAA;IAGrB,cAAc,CAAC,EAAE,MAAM,CAAA;IAGvB,aAAa,CAAC,EAAE,MAAM,CAAA;IAGtB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"StatusList2021EntryEntity.js","sourceRoot":"","sources":["../../../src/entities/statusList2021/StatusList2021EntryEntity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA0C;AAC1C,qCAA8E;AAC9E,8CAA0D;AAC1D,iEAAyD;AAKlD,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,oBAAU;CAoBpD,CAAA;AApBY,sDAAqB;AAGhC;IAFC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IACxD,IAAA,mBAAS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