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

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.
@@ -0,0 +1,7 @@
1
+ export type BitstringStatusPurpose = 'revocation' | 'suspension' | 'refresh' | 'message' | string // From vc-bitstring-status-lists without pulling in the whole dep for just this one type
2
+
3
+ export type BitstringStatus = {
4
+ status: string
5
+ message?: string
6
+ [x: string]: any
7
+ }
@@ -1,15 +1,16 @@
1
1
  import {
2
+ type CredentialProofFormat,
2
3
  IIssuer,
4
+ RequireOneOf,
3
5
  StatusListCredential,
4
6
  StatusListCredentialIdMode,
5
7
  StatusListDriverType,
6
8
  StatusListIndexingDirection,
7
9
  StatusListType,
8
10
  StatusPurpose2021,
9
- type CredentialProofFormat,
10
- RequireOneOf,
11
11
  } from '@sphereon/ssi-types'
12
12
  import { StatusListEntity } from '../../entities/statusList/StatusListEntities'
13
+ import { BitstringStatusPurpose } from './bitstringTypes'
13
14
 
14
15
  export interface IStatusListEntity {
15
16
  id: string
@@ -21,6 +22,7 @@ export interface IStatusListEntity {
21
22
  type: StatusListType
22
23
  proofFormat: CredentialProofFormat
23
24
  statusListCredential?: StatusListCredential
25
+ bitsPerStatus?: number
24
26
  }
25
27
 
26
28
  export interface IStatusList2021Entity extends IStatusListEntity {
@@ -33,6 +35,14 @@ export interface IOAuthStatusListEntity extends IStatusListEntity {
33
35
  expiresAt?: Date
34
36
  }
35
37
 
38
+ export interface IBitstringStatusListEntity extends IStatusListEntity {
39
+ statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
40
+ bitsPerStatus?: number
41
+ validFrom?: Date
42
+ validUntil?: Date
43
+ ttl?: number
44
+ }
45
+
36
46
  export type IStatusListEntryEntity = RequireOneOf<
37
47
  {
38
48
  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,27 @@ 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
+ if (!bitstringsl.bitsPerStatus) {
44
+ throw Error('bitsPerStatus must be set for BitstringStatusList')
45
+ }
46
+
47
+ entity.statusPurpose = bitstringsl.statusPurpose
48
+ entity.bitsPerStatus = bitstringsl.bitsPerStatus
49
+ entity.validFrom = bitstringsl.validFrom
50
+ entity.validUntil = bitstringsl.validUntil
51
+ entity.ttl = bitstringsl.ttl
52
+ setBaseFields(entity, args)
53
+ Object.defineProperty(entity, 'type', {
54
+ value: StatusListType.BitstringStatusList,
55
+ enumerable: true,
56
+ configurable: true,
57
+ })
58
+ return entity
59
+ }
60
+
35
61
  throw new Error(`Invalid status list type ${args.type}`)
36
62
  }
37
63
 
@@ -56,6 +82,18 @@ export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
56
82
  return replaceNullWithUndefined(result)
57
83
  }
58
84
 
85
+ if (entity instanceof BitstringStatusListEntity) {
86
+ const result: IBitstringStatusListEntity = {
87
+ ...getBaseFields(entity),
88
+ type: StatusListType.BitstringStatusList,
89
+ statusPurpose: entity.statusPurpose,
90
+ bitsPerStatus: entity.bitsPerStatus,
91
+ validFrom: entity.validFrom,
92
+ validUntil: entity.validUntil,
93
+ ttl: entity.ttl,
94
+ }
95
+ return replaceNullWithUndefined(result)
96
+ }
59
97
  throw new Error(`Invalid status list type ${typeof entity}`)
60
98
  }
61
99