@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.17.bitstring.sl.2 → 0.34.1-feature.SSISDK.17.bitstring.sl.24
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/index.cjs +232 -217
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +94 -44
- package/dist/index.d.ts +94 -44
- package/dist/index.js +178 -163
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/statusList.entities.test.ts +4 -4
- package/src/__tests__/statusList.store.test.ts +2 -1
- package/src/entities/statusList/BitstringStatusListEntryEntity.ts +11 -34
- package/src/entities/statusList/StatusList2021EntryEntity.ts +2 -1
- package/src/entities/statusList/StatusListEntities.ts +14 -8
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +25 -26
- package/src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts +51 -9
- package/src/statusList/IStatusListStore.ts +14 -11
- package/src/statusList/StatusListStore.ts +69 -32
- package/src/types/statusList/IAbstractStatusListStore.ts +44 -4
- package/src/types/statusList/statusList.ts +41 -8
- package/src/utils/statusList/MappingUtils.ts +7 -3
|
@@ -3,9 +3,12 @@ import Debug from 'debug'
|
|
|
3
3
|
import { DataSource, In, type Repository } from 'typeorm'
|
|
4
4
|
import { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
|
|
5
5
|
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
6
|
-
import
|
|
6
|
+
import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
7
|
+
import {
|
|
7
8
|
IAddStatusListArgs,
|
|
8
9
|
IAddStatusListEntryArgs,
|
|
10
|
+
IBitstringStatusListEntity,
|
|
11
|
+
IBitstringStatusListEntryEntity,
|
|
9
12
|
IGetStatusListArgs,
|
|
10
13
|
IGetStatusListEntriesArgs,
|
|
11
14
|
IGetStatusListEntryByCredentialIdArgs,
|
|
@@ -41,11 +44,11 @@ export class StatusListStore implements IStatusListStore {
|
|
|
41
44
|
async availableStatusListEntries(args: IStatusListEntryAvailableArgs): Promise<number[]> {
|
|
42
45
|
const statusListIndex = Array.isArray(args.statusListIndex) ? args.statusListIndex : [args.statusListIndex]
|
|
43
46
|
const statusList = await this.getStatusList({ ...args, id: args.statusListId })
|
|
44
|
-
const repo = await this.getStatusListEntryRepo()
|
|
47
|
+
const repo = await this.getStatusListEntryRepo(statusList.type)
|
|
45
48
|
const results = (
|
|
46
49
|
await repo.find({
|
|
47
50
|
where: {
|
|
48
|
-
statusList,
|
|
51
|
+
statusListId: statusList.id,
|
|
49
52
|
statusListIndex: In(statusListIndex),
|
|
50
53
|
},
|
|
51
54
|
})
|
|
@@ -53,23 +56,33 @@ export class StatusListStore implements IStatusListStore {
|
|
|
53
56
|
return statusListIndex.filter((index) => !results.includes(index))
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
async addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity> {
|
|
57
|
-
|
|
59
|
+
async addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity> {
|
|
60
|
+
if (!args.statusListId) {
|
|
61
|
+
throw new Error('statusListId is required')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const statusList = await this.getStatusList({ id: args.statusListId })
|
|
65
|
+
const result = await (await this.getStatusListEntryRepo(statusList.type)).save(args)
|
|
66
|
+
return result as IStatusListEntryEntity | IBitstringStatusListEntryEntity
|
|
58
67
|
}
|
|
59
68
|
|
|
60
|
-
async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity> {
|
|
61
|
-
const statusListId = args.statusListId
|
|
69
|
+
async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity> {
|
|
70
|
+
const statusListId = args.statusListId
|
|
71
|
+
if (!statusListId) {
|
|
72
|
+
throw new Error('statusListId is required')
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const statusList = await this.getStatusList({ id: statusListId })
|
|
62
76
|
const result = await this.getStatusListEntryByIndex({ ...args, statusListId, errorOnNotFound: false })
|
|
63
77
|
const updatedEntry: Partial<IStatusListEntryEntity> = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
credentialId: args.credentialId,
|
|
78
|
+
...result,
|
|
79
|
+
...args,
|
|
80
|
+
statusListId,
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
const updStatusListId = result?.statusListId ?? statusListId
|
|
71
84
|
const updateResult = await (
|
|
72
|
-
await this.getStatusListEntryRepo()
|
|
85
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
73
86
|
).upsert(
|
|
74
87
|
{ ...(result ?? { statusListId: updStatusListId, statusListIndex: args.statusListIndex }), ...updatedEntry },
|
|
75
88
|
{ conflictPaths: ['statusList', 'statusListIndex'] },
|
|
@@ -79,7 +92,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
79
92
|
...args,
|
|
80
93
|
statusListId: updStatusListId,
|
|
81
94
|
errorOnNotFound: true,
|
|
82
|
-
}))
|
|
95
|
+
}))!
|
|
83
96
|
}
|
|
84
97
|
|
|
85
98
|
async getStatusListEntryByIndex({
|
|
@@ -88,7 +101,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
88
101
|
statusListIndex,
|
|
89
102
|
entryCorrelationId,
|
|
90
103
|
errorOnNotFound,
|
|
91
|
-
}: IGetStatusListEntryByIndexArgs): Promise<StatusListEntryEntity | undefined> {
|
|
104
|
+
}: IGetStatusListEntryByIndexArgs): Promise<StatusListEntryEntity | BitstringStatusListEntryEntity | undefined> {
|
|
92
105
|
if (!statusListId && !statusListCorrelationId) {
|
|
93
106
|
throw Error(`Cannot get statusList entry without either a statusList id or statusListCorrelationId`)
|
|
94
107
|
}
|
|
@@ -97,8 +110,12 @@ export class StatusListStore implements IStatusListStore {
|
|
|
97
110
|
throw Error(`Cannot get statusList entry without either a statusListIndex or entryCorrelationId`)
|
|
98
111
|
}
|
|
99
112
|
|
|
113
|
+
const statusList = statusListId
|
|
114
|
+
? await this.getStatusList({ id: statusListId })
|
|
115
|
+
: await this.getStatusList({ correlationId: statusListCorrelationId })
|
|
116
|
+
|
|
100
117
|
const result = await (
|
|
101
|
-
await this.getStatusListEntryRepo()
|
|
118
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
102
119
|
).findOne({
|
|
103
120
|
where: {
|
|
104
121
|
...(statusListId && { statusListId }),
|
|
@@ -118,7 +135,9 @@ export class StatusListStore implements IStatusListStore {
|
|
|
118
135
|
return result ?? undefined
|
|
119
136
|
}
|
|
120
137
|
|
|
121
|
-
async getStatusListEntryByCredentialId(
|
|
138
|
+
async getStatusListEntryByCredentialId(
|
|
139
|
+
args: IGetStatusListEntryByCredentialIdArgs,
|
|
140
|
+
): Promise<StatusListEntryEntity | BitstringStatusListEntryEntity | undefined> {
|
|
122
141
|
const credentialId = args.credentialId
|
|
123
142
|
if (!credentialId) {
|
|
124
143
|
throw Error('Can only get a credential by credentialId when a credentialId is supplied')
|
|
@@ -132,8 +151,8 @@ export class StatusListStore implements IStatusListStore {
|
|
|
132
151
|
...(args.entryCorrelationId && { correlationId: args.entryCorrelationId }),
|
|
133
152
|
credentialId,
|
|
134
153
|
}
|
|
135
|
-
console.log(`Entries: ${JSON.stringify(await (await this.getStatusListEntryRepo()).find(), null, 2)}`)
|
|
136
|
-
const result = await (await this.getStatusListEntryRepo()).findOne({ where })
|
|
154
|
+
console.log(`Entries: ${JSON.stringify(await (await this.getStatusListEntryRepo(statusList.type)).find(), null, 2)}`)
|
|
155
|
+
const result = await (await this.getStatusListEntryRepo(statusList.type)).findOne({ where })
|
|
137
156
|
|
|
138
157
|
if (!result && args.errorOnNotFound) {
|
|
139
158
|
throw Error(`Could not find status list credential id ${credentialId} for status list id ${statusList.id}`)
|
|
@@ -149,8 +168,12 @@ export class StatusListStore implements IStatusListStore {
|
|
|
149
168
|
error = true
|
|
150
169
|
}
|
|
151
170
|
if (!error) {
|
|
171
|
+
const statusList = await this.getStatusList({
|
|
172
|
+
id: args.statusListId,
|
|
173
|
+
correlationId: args.statusListCorrelationId,
|
|
174
|
+
})
|
|
152
175
|
const result = await (
|
|
153
|
-
await this.getStatusListEntryRepo()
|
|
176
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
154
177
|
).delete({
|
|
155
178
|
...(args.statusListId && { statusList: args.statusListId }),
|
|
156
179
|
...(args.entryCorrelationId && { correlationId: args.entryCorrelationId }),
|
|
@@ -171,8 +194,9 @@ export class StatusListStore implements IStatusListStore {
|
|
|
171
194
|
if (error) {
|
|
172
195
|
console.log(`Could not delete statusList ${args.statusListId} entry by index ${args.statusListIndex}`)
|
|
173
196
|
} else {
|
|
197
|
+
const statusList = await this.getStatusList({ id: args.statusListId })
|
|
174
198
|
const result = await (
|
|
175
|
-
await this.getStatusListEntryRepo()
|
|
199
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
176
200
|
).delete({
|
|
177
201
|
...(args.statusListId && { statusList: args.statusListId }),
|
|
178
202
|
...(args.entryCorrelationId && { correlationId: args.entryCorrelationId }),
|
|
@@ -183,12 +207,14 @@ export class StatusListStore implements IStatusListStore {
|
|
|
183
207
|
return !error
|
|
184
208
|
}
|
|
185
209
|
|
|
186
|
-
async getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
210
|
+
async getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<Array<IStatusListEntryEntity | IBitstringStatusListEntryEntity>> {
|
|
211
|
+
const statusList = await this.getStatusList({ id: args.statusListId })
|
|
212
|
+
const results = await (
|
|
213
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
214
|
+
).find({
|
|
215
|
+
where: { ...args?.filter, statusList: args.statusListId },
|
|
216
|
+
})
|
|
217
|
+
return results as Array<IStatusListEntryEntity | IBitstringStatusListEntryEntity>
|
|
192
218
|
}
|
|
193
219
|
|
|
194
220
|
private async getStatusListEntity(args: IGetStatusListArgs): Promise<StatusListEntity> {
|
|
@@ -208,7 +234,12 @@ export class StatusListStore implements IStatusListStore {
|
|
|
208
234
|
return result
|
|
209
235
|
}
|
|
210
236
|
|
|
211
|
-
async
|
|
237
|
+
async getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity | IBitstringStatusListEntity> {
|
|
238
|
+
const entity = await this.getStatusListEntity(args)
|
|
239
|
+
return statusListFrom(entity) as IStatusListEntity | IBitstringStatusListEntity
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async getStatusLists(args: IGetStatusListsArgs): Promise<Array<IStatusListEntity | IBitstringStatusListEntity>> {
|
|
212
243
|
const result = await (
|
|
213
244
|
await this.getStatusListRepo()
|
|
214
245
|
).find({
|
|
@@ -219,7 +250,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
219
250
|
return []
|
|
220
251
|
}
|
|
221
252
|
|
|
222
|
-
return result.map((entity) => statusListFrom(entity))
|
|
253
|
+
return result.map((entity) => statusListFrom(entity) as IStatusListEntity | IBitstringStatusListEntity)
|
|
223
254
|
}
|
|
224
255
|
|
|
225
256
|
async addStatusList(args: IAddStatusListArgs): Promise<IStatusListEntity> {
|
|
@@ -240,7 +271,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
240
271
|
return statusListFrom(createdResult)
|
|
241
272
|
}
|
|
242
273
|
|
|
243
|
-
async updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity> {
|
|
274
|
+
async updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity | IBitstringStatusListEntity> {
|
|
244
275
|
const result = await this.getStatusList(args)
|
|
245
276
|
debug('Updating status list', result)
|
|
246
277
|
const entity = statusListEntityFrom(args)
|
|
@@ -251,7 +282,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
251
282
|
async removeStatusList(args: IRemoveStatusListArgs): Promise<boolean> {
|
|
252
283
|
const result = await this.getStatusListEntity(args)
|
|
253
284
|
|
|
254
|
-
await (await this.getStatusListEntryRepo()).delete({ statusListId: result.id })
|
|
285
|
+
await (await this.getStatusListEntryRepo(result.type)).delete({ statusListId: result.id })
|
|
255
286
|
const deletedEntity = await (await this.getStatusListRepo()).remove(result)
|
|
256
287
|
|
|
257
288
|
return Boolean(deletedEntity)
|
|
@@ -275,7 +306,13 @@ export class StatusListStore implements IStatusListStore {
|
|
|
275
306
|
}
|
|
276
307
|
}
|
|
277
308
|
|
|
278
|
-
async getStatusListEntryRepo(): Promise<Repository<StatusListEntryEntity>> {
|
|
279
|
-
|
|
309
|
+
async getStatusListEntryRepo(type?: StatusListType): Promise<Repository<StatusListEntryEntity | BitstringStatusListEntryEntity>> {
|
|
310
|
+
const dataSource = await this.getDS()
|
|
311
|
+
switch (type) {
|
|
312
|
+
case StatusListType.BitstringStatusList:
|
|
313
|
+
return dataSource.getRepository(BitstringStatusListEntryEntity)
|
|
314
|
+
default:
|
|
315
|
+
return dataSource.getRepository(StatusListEntryEntity)
|
|
316
|
+
}
|
|
280
317
|
}
|
|
281
318
|
}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { FindOptionsWhere } from 'typeorm'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BitstringStatusPurpose,
|
|
4
|
+
IBitstringStatusListEntryEntity,
|
|
5
|
+
IOAuthStatusListEntity,
|
|
6
|
+
IStatusList2021Entity,
|
|
7
|
+
IStatusListEntryEntity,
|
|
8
|
+
} from './statusList'
|
|
9
|
+
import {
|
|
10
|
+
CredentialProofFormat,
|
|
11
|
+
IIssuer,
|
|
12
|
+
StatusListCredential,
|
|
13
|
+
StatusListCredentialIdMode,
|
|
14
|
+
StatusListDriverType,
|
|
15
|
+
StatusListIndexingDirection,
|
|
16
|
+
StatusListType,
|
|
17
|
+
StatusPurpose2021,
|
|
18
|
+
} from '@sphereon/ssi-types'
|
|
3
19
|
|
|
4
20
|
export type FindStatusListArgs = FindOptionsWhere<IStatusList2021Entity | IOAuthStatusListEntity>[]
|
|
5
21
|
export type FindStatusListEntryArgs = FindOptionsWhere<IStatusListEntryEntity>[] | FindOptionsWhere<IStatusListEntryEntity>
|
|
@@ -30,7 +46,7 @@ export interface IGetStatusListEntriesArgs {
|
|
|
30
46
|
filter?: FindStatusListEntryArgs
|
|
31
47
|
}
|
|
32
48
|
|
|
33
|
-
export type IAddStatusListEntryArgs = IStatusListEntryEntity
|
|
49
|
+
export type IAddStatusListEntryArgs = IStatusListEntryEntity | IBitstringStatusListEntryEntity
|
|
34
50
|
|
|
35
51
|
export interface IGetStatusListArgs {
|
|
36
52
|
id?: string
|
|
@@ -43,6 +59,30 @@ export interface IGetStatusListsArgs {
|
|
|
43
59
|
filter?: FindStatusListArgs
|
|
44
60
|
}
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
interface IBaseStatusListArgs {
|
|
63
|
+
id: string
|
|
64
|
+
correlationId: string
|
|
65
|
+
driverType: StatusListDriverType
|
|
66
|
+
credentialIdMode: StatusListCredentialIdMode
|
|
67
|
+
length: number
|
|
68
|
+
issuer: string | IIssuer
|
|
69
|
+
type: StatusListType
|
|
70
|
+
proofFormat: CredentialProofFormat
|
|
71
|
+
statusListCredential?: StatusListCredential
|
|
72
|
+
bitsPerStatus?: number
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Then extend for specific types when needed
|
|
76
|
+
export type IAddStatusListArgs =
|
|
77
|
+
| (IBaseStatusListArgs & { type: StatusListType.StatusList2021; indexingDirection: StatusListIndexingDirection; statusPurpose: StatusPurpose2021 })
|
|
78
|
+
| (IBaseStatusListArgs & { type: StatusListType.OAuthStatusList; bitsPerStatus: number; expiresAt?: Date })
|
|
79
|
+
| (IBaseStatusListArgs & {
|
|
80
|
+
type: StatusListType.BitstringStatusList
|
|
81
|
+
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
|
|
82
|
+
bitsPerStatus?: number
|
|
83
|
+
validFrom?: Date
|
|
84
|
+
validUntil?: Date
|
|
85
|
+
ttl?: number
|
|
86
|
+
})
|
|
47
87
|
|
|
48
|
-
export type IUpdateStatusListIndexArgs =
|
|
88
|
+
export type IUpdateStatusListIndexArgs = IAddStatusListArgs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BitstringStatusPurpose,
|
|
3
2
|
type CredentialProofFormat,
|
|
3
|
+
type ICredentialStatus,
|
|
4
4
|
IIssuer,
|
|
5
5
|
RequireOneOf,
|
|
6
6
|
StatusListCredential,
|
|
@@ -12,12 +12,6 @@ import {
|
|
|
12
12
|
} from '@sphereon/ssi-types'
|
|
13
13
|
import { StatusListEntity } from '../../entities/statusList/StatusListEntities'
|
|
14
14
|
|
|
15
|
-
export type BitstringStatus = {
|
|
16
|
-
status: string
|
|
17
|
-
message?: string
|
|
18
|
-
[x: string]: any
|
|
19
|
-
}
|
|
20
|
-
|
|
21
15
|
export interface IStatusListEntity {
|
|
22
16
|
id: string
|
|
23
17
|
correlationId: string
|
|
@@ -28,6 +22,7 @@ export interface IStatusListEntity {
|
|
|
28
22
|
type: StatusListType
|
|
29
23
|
proofFormat: CredentialProofFormat
|
|
30
24
|
statusListCredential?: StatusListCredential
|
|
25
|
+
bitsPerStatus?: number
|
|
31
26
|
}
|
|
32
27
|
|
|
33
28
|
export interface IStatusList2021Entity extends IStatusListEntity {
|
|
@@ -42,7 +37,7 @@ export interface IOAuthStatusListEntity extends IStatusListEntity {
|
|
|
42
37
|
|
|
43
38
|
export interface IBitstringStatusListEntity extends IStatusListEntity {
|
|
44
39
|
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
|
|
45
|
-
|
|
40
|
+
bitsPerStatus?: number
|
|
46
41
|
validFrom?: Date
|
|
47
42
|
validUntil?: Date
|
|
48
43
|
ttl?: number
|
|
@@ -60,3 +55,41 @@ export type IStatusListEntryEntity = RequireOneOf<
|
|
|
60
55
|
},
|
|
61
56
|
'statusList' | 'statusListId'
|
|
62
57
|
>
|
|
58
|
+
|
|
59
|
+
export type BitstringStatusPurpose = 'revocation' | 'suspension' | 'refresh' | 'message' | string // From vc-bitstring-status-lists without pulling in the whole dep for just this one type
|
|
60
|
+
|
|
61
|
+
export type BitstringStatusMessage = {
|
|
62
|
+
status: string
|
|
63
|
+
message?: string
|
|
64
|
+
[x: string]: any
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface BitstringStatusListEntryCredentialStatus extends ICredentialStatus {
|
|
68
|
+
type: 'BitstringStatusListEntry'
|
|
69
|
+
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
|
|
70
|
+
statusListIndex: string
|
|
71
|
+
statusListCredential: string
|
|
72
|
+
bitsPerStatus?: number
|
|
73
|
+
statusMessage?: Array<BitstringStatusMessage>
|
|
74
|
+
statusReference?: string | string[]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type BitstringStatusListArgs = {
|
|
78
|
+
statusPurpose: BitstringStatusPurpose
|
|
79
|
+
bitsPerStatus: number
|
|
80
|
+
ttl?: number
|
|
81
|
+
validFrom?: Date
|
|
82
|
+
validUntil?: Date
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface IBitstringStatusListEntryEntity {
|
|
86
|
+
statusListId: string
|
|
87
|
+
statusListIndex: number
|
|
88
|
+
credentialId?: string
|
|
89
|
+
credentialHash?: string
|
|
90
|
+
entryCorrelationId?: string
|
|
91
|
+
statusPurpose: string
|
|
92
|
+
bitsPerStatus?: number
|
|
93
|
+
statusMessage?: Array<BitstringStatusMessage>
|
|
94
|
+
statusReference?: string | string[]
|
|
95
|
+
}
|
|
@@ -40,8 +40,12 @@ export const statusListEntityFrom = (args: IStatusListEntity): StatusListEntity
|
|
|
40
40
|
if (args.type === StatusListType.BitstringStatusList) {
|
|
41
41
|
const entity = new BitstringStatusListEntity()
|
|
42
42
|
const bitstringsl = args as IBitstringStatusListEntity
|
|
43
|
+
if (!bitstringsl.bitsPerStatus) {
|
|
44
|
+
throw Error('bitsPerStatus must be set for BitstringStatusList')
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
entity.statusPurpose = bitstringsl.statusPurpose
|
|
44
|
-
entity.
|
|
48
|
+
entity.bitsPerStatus = bitstringsl.bitsPerStatus
|
|
45
49
|
entity.validFrom = bitstringsl.validFrom
|
|
46
50
|
entity.validUntil = bitstringsl.validUntil
|
|
47
51
|
entity.ttl = bitstringsl.ttl
|
|
@@ -57,7 +61,7 @@ export const statusListEntityFrom = (args: IStatusListEntity): StatusListEntity
|
|
|
57
61
|
throw new Error(`Invalid status list type ${args.type}`)
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
|
|
64
|
+
export const statusListFrom = (entity: StatusListEntity): IStatusListEntity | IBitstringStatusListEntity => {
|
|
61
65
|
if (entity instanceof StatusList2021Entity) {
|
|
62
66
|
const result: IStatusList2021Entity = {
|
|
63
67
|
...getBaseFields(entity),
|
|
@@ -83,7 +87,7 @@ export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
|
|
|
83
87
|
...getBaseFields(entity),
|
|
84
88
|
type: StatusListType.BitstringStatusList,
|
|
85
89
|
statusPurpose: entity.statusPurpose,
|
|
86
|
-
|
|
90
|
+
bitsPerStatus: entity.bitsPerStatus,
|
|
87
91
|
validFrom: entity.validFrom,
|
|
88
92
|
validUntil: entity.validUntil,
|
|
89
93
|
ttl: entity.ttl,
|