@sphereon/ssi-sdk.data-store 0.34.0 → 0.34.1-feature.SSISDK.17.bitstring.sl.2

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.
@@ -1,16 +1,23 @@
1
1
  import {
2
+ BitstringStatusPurpose,
3
+ type CredentialProofFormat,
2
4
  IIssuer,
5
+ RequireOneOf,
3
6
  StatusListCredential,
4
7
  StatusListCredentialIdMode,
5
8
  StatusListDriverType,
6
9
  StatusListIndexingDirection,
7
10
  StatusListType,
8
11
  StatusPurpose2021,
9
- type CredentialProofFormat,
10
- RequireOneOf,
11
12
  } from '@sphereon/ssi-types'
12
13
  import { StatusListEntity } from '../../entities/statusList/StatusListEntities'
13
14
 
15
+ export type BitstringStatus = {
16
+ status: string
17
+ message?: string
18
+ [x: string]: any
19
+ }
20
+
14
21
  export interface IStatusListEntity {
15
22
  id: string
16
23
  correlationId: string
@@ -33,6 +40,14 @@ export interface IOAuthStatusListEntity extends IStatusListEntity {
33
40
  expiresAt?: Date
34
41
  }
35
42
 
43
+ export interface IBitstringStatusListEntity extends IStatusListEntity {
44
+ statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
45
+ statusSize?: number
46
+ validFrom?: Date
47
+ validUntil?: Date
48
+ ttl?: number
49
+ }
50
+
36
51
  export type IStatusListEntryEntity = RequireOneOf<
37
52
  {
38
53
  statusList: StatusListEntity
@@ -1,5 +1,10 @@
1
- import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntity } from '../../types'
2
- import { OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../../entities/statusList/StatusListEntities'
1
+ import { IBitstringStatusListEntity, IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntity } from '../../types'
2
+ import {
3
+ BitstringStatusListEntity,
4
+ OAuthStatusListEntity,
5
+ StatusList2021Entity,
6
+ StatusListEntity,
7
+ } from '../../entities/statusList/StatusListEntities'
3
8
  import { StatusListType } from '@sphereon/ssi-types'
4
9
  import { replaceNullWithUndefined } from '../FormattingUtils'
5
10
 
@@ -32,6 +37,23 @@ export const statusListEntityFrom = (args: IStatusListEntity): StatusListEntity
32
37
  return entity
33
38
  }
34
39
 
40
+ if (args.type === StatusListType.BitstringStatusList) {
41
+ const entity = new BitstringStatusListEntity()
42
+ const bitstringsl = args as IBitstringStatusListEntity
43
+ entity.statusPurpose = bitstringsl.statusPurpose
44
+ entity.statusSize = bitstringsl.statusSize
45
+ entity.validFrom = bitstringsl.validFrom
46
+ entity.validUntil = bitstringsl.validUntil
47
+ entity.ttl = bitstringsl.ttl
48
+ setBaseFields(entity, args)
49
+ Object.defineProperty(entity, 'type', {
50
+ value: StatusListType.BitstringStatusList,
51
+ enumerable: true,
52
+ configurable: true,
53
+ })
54
+ return entity
55
+ }
56
+
35
57
  throw new Error(`Invalid status list type ${args.type}`)
36
58
  }
37
59
 
@@ -56,6 +78,18 @@ export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
56
78
  return replaceNullWithUndefined(result)
57
79
  }
58
80
 
81
+ if (entity instanceof BitstringStatusListEntity) {
82
+ const result: IBitstringStatusListEntity = {
83
+ ...getBaseFields(entity),
84
+ type: StatusListType.BitstringStatusList,
85
+ statusPurpose: entity.statusPurpose,
86
+ statusSize: entity.statusSize,
87
+ validFrom: entity.validFrom,
88
+ validUntil: entity.validUntil,
89
+ ttl: entity.ttl,
90
+ }
91
+ return replaceNullWithUndefined(result)
92
+ }
59
93
  throw new Error(`Invalid status list type ${typeof entity}`)
60
94
  }
61
95