@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.17.bitstring.sl.9 → 0.34.1-next.29

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,5 +1,6 @@
1
1
  import {
2
2
  type CredentialProofFormat,
3
+ type ICredentialStatus,
3
4
  IIssuer,
4
5
  RequireOneOf,
5
6
  StatusListCredential,
@@ -10,7 +11,6 @@ import {
10
11
  StatusPurpose2021,
11
12
  } from '@sphereon/ssi-types'
12
13
  import { StatusListEntity } from '../../entities/statusList/StatusListEntities'
13
- import { BitstringStatusPurpose } from './bitstringTypes'
14
14
 
15
15
  export interface IStatusListEntity {
16
16
  id: string
@@ -36,7 +36,7 @@ export interface IOAuthStatusListEntity extends IStatusListEntity {
36
36
  }
37
37
 
38
38
  export interface IBitstringStatusListEntity extends IStatusListEntity {
39
- statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
39
+ statusPurpose: BitstringStatusPurpose | Array<BitstringStatusPurpose>
40
40
  bitsPerStatus?: number
41
41
  validFrom?: Date
42
42
  validUntil?: Date
@@ -55,3 +55,41 @@ export type IStatusListEntryEntity = RequireOneOf<
55
55
  },
56
56
  'statusList' | 'statusListId'
57
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 | Array<BitstringStatusPurpose>
70
+ statusListIndex: string
71
+ statusListCredential: string
72
+ bitsPerStatus?: number
73
+ statusMessage?: Array<BitstringStatusMessage>
74
+ statusReference?: string | Array<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 | Array<string>
95
+ }
@@ -9,59 +9,62 @@ import { StatusListType } from '@sphereon/ssi-types'
9
9
  import { replaceNullWithUndefined } from '../FormattingUtils'
10
10
 
11
11
  export const statusListEntityFrom = (args: IStatusListEntity): StatusListEntity => {
12
- if (args.type === StatusListType.StatusList2021) {
13
- const entity = new StatusList2021Entity()
14
- const sl2021 = args as IStatusList2021Entity
15
- entity.indexingDirection = sl2021.indexingDirection
16
- entity.statusPurpose = sl2021.statusPurpose
17
- setBaseFields(entity, args)
18
- Object.defineProperty(entity, 'type', {
19
- value: StatusListType.StatusList2021,
20
- enumerable: true,
21
- configurable: true,
22
- })
23
- return entity
24
- }
12
+ switch (args.type) {
13
+ case StatusListType.StatusList2021: {
14
+ const entity = new StatusList2021Entity()
15
+ const sl2021 = args as IStatusList2021Entity
16
+ entity.indexingDirection = sl2021.indexingDirection
17
+ entity.statusPurpose = sl2021.statusPurpose
18
+ setBaseFields(entity, args)
19
+ Object.defineProperty(entity, 'type', {
20
+ value: StatusListType.StatusList2021,
21
+ enumerable: true,
22
+ configurable: true,
23
+ })
24
+ return entity
25
+ }
25
26
 
26
- if (args.type === StatusListType.OAuthStatusList) {
27
- const entity = new OAuthStatusListEntity()
28
- const oauthSl = args as IOAuthStatusListEntity
29
- entity.bitsPerStatus = oauthSl.bitsPerStatus
30
- entity.expiresAt = oauthSl.expiresAt
31
- setBaseFields(entity, args)
32
- Object.defineProperty(entity, 'type', {
33
- value: StatusListType.OAuthStatusList,
34
- enumerable: true,
35
- configurable: true,
36
- })
37
- return entity
38
- }
27
+ case StatusListType.OAuthStatusList: {
28
+ const entity = new OAuthStatusListEntity()
29
+ const oauthSl = args as IOAuthStatusListEntity
30
+ entity.bitsPerStatus = oauthSl.bitsPerStatus
31
+ entity.expiresAt = oauthSl.expiresAt
32
+ setBaseFields(entity, args)
33
+ Object.defineProperty(entity, 'type', {
34
+ value: StatusListType.OAuthStatusList,
35
+ enumerable: true,
36
+ configurable: true,
37
+ })
38
+ return entity
39
+ }
40
+
41
+ case StatusListType.BitstringStatusList: {
42
+ const entity = new BitstringStatusListEntity()
43
+ const bitstringsl = args as IBitstringStatusListEntity
44
+ if (!bitstringsl.bitsPerStatus) {
45
+ throw Error('bitsPerStatus must be set for BitstringStatusList')
46
+ }
39
47
 
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')
48
+ entity.statusPurpose = bitstringsl.statusPurpose
49
+ entity.bitsPerStatus = bitstringsl.bitsPerStatus
50
+ entity.validFrom = bitstringsl.validFrom
51
+ entity.validUntil = bitstringsl.validUntil
52
+ entity.ttl = bitstringsl.ttl
53
+ setBaseFields(entity, args)
54
+ Object.defineProperty(entity, 'type', {
55
+ value: StatusListType.BitstringStatusList,
56
+ enumerable: true,
57
+ configurable: true,
58
+ })
59
+ return entity
45
60
  }
46
61
 
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
62
+ default:
63
+ throw new Error(`Invalid status list type ${args.type}`)
59
64
  }
60
-
61
- throw new Error(`Invalid status list type ${args.type}`)
62
65
  }
63
66
 
64
- export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
67
+ export const statusListFrom = (entity: StatusListEntity): IStatusListEntity | IBitstringStatusListEntity => {
65
68
  if (entity instanceof StatusList2021Entity) {
66
69
  const result: IStatusList2021Entity = {
67
70
  ...getBaseFields(entity),
@@ -1,7 +0,0 @@
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
- }