@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.17.bitstring.sl.9 → 0.34.1-feature.merge.crypto.extensions.modules.33

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,21 @@
1
1
  import { FindOptionsWhere } from 'typeorm'
2
- import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntity, IStatusListEntryEntity } from './statusList'
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,40 @@ export interface IGetStatusListsArgs {
43
59
  filter?: FindStatusListArgs
44
60
  }
45
61
 
46
- export type IAddStatusListArgs = IStatusListEntity
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
+ export type IStatusList2021Args = IBaseStatusListArgs & {
76
+ type: StatusListType.StatusList2021
77
+ indexingDirection: StatusListIndexingDirection
78
+ statusPurpose: StatusPurpose2021
79
+ }
80
+
81
+ export type IOAuthStatusListArgs = IBaseStatusListArgs & {
82
+ type: StatusListType.OAuthStatusList
83
+ bitsPerStatus: number
84
+ expiresAt?: Date
85
+ }
86
+
87
+ export type IBitstringStatusListArgs = IBaseStatusListArgs & {
88
+ type: StatusListType.BitstringStatusList
89
+ statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
90
+ bitsPerStatus?: number
91
+ validFrom?: Date
92
+ validUntil?: Date
93
+ ttl?: number
94
+ }
95
+
96
+ export type IAddStatusListArgs = IStatusList2021Args | IOAuthStatusListArgs | IBitstringStatusListArgs
47
97
 
48
- export type IUpdateStatusListIndexArgs = IStatusListEntity
98
+ export type IUpdateStatusListIndexArgs = IAddStatusListArgs
@@ -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
- }