@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.
- package/dist/index.cjs +199 -182
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -42
- package/dist/index.d.ts +92 -42
- package/dist/index.js +209 -192
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/statusList.store.test.ts +1 -0
- package/src/entities/statusList/BitstringStatusListEntryEntity.ts +8 -30
- package/src/entities/statusList/StatusList2021EntryEntity.ts +2 -1
- package/src/entities/statusList/StatusListEntities.ts +7 -0
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +23 -24
- package/src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts +49 -6
- package/src/statusList/IStatusListStore.ts +14 -11
- package/src/statusList/StatusListStore.ts +69 -33
- package/src/types/index.ts +0 -1
- package/src/types/statusList/IAbstractStatusListStore.ts +54 -4
- package/src/types/statusList/statusList.ts +40 -2
- package/src/utils/statusList/MappingUtils.ts +49 -46
- package/src/types/statusList/bitstringTypes.ts +0 -7
|
@@ -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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
}
|