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

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.data-store",
3
- "version": "0.34.1-feature.SSISDK.17.bitstring.sl.10+f36e76fe",
3
+ "version": "0.34.1-feature.SSISDK.17.bitstring.sl.13+61bcf6d3",
4
4
  "source": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -30,9 +30,9 @@
30
30
  "@sphereon/pex": "5.0.0-unstable.28",
31
31
  "@sphereon/ssi-sdk-ext.did-utils": "0.29.0",
32
32
  "@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.0",
33
- "@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.17.bitstring.sl.10+f36e76fe",
34
- "@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.17.bitstring.sl.10+f36e76fe",
35
- "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.10+f36e76fe",
33
+ "@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.17.bitstring.sl.13+61bcf6d3",
34
+ "@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.17.bitstring.sl.13+61bcf6d3",
35
+ "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.13+61bcf6d3",
36
36
  "@veramo/core": "4.2.0",
37
37
  "@veramo/utils": "4.2.0",
38
38
  "blakejs": "^1.2.1",
@@ -65,5 +65,5 @@
65
65
  "PostgreSQL",
66
66
  "Contact Store"
67
67
  ],
68
- "gitHead": "f36e76fe5f4eb4e7303ddbe275e867144762b17c"
68
+ "gitHead": "61bcf6d37bcb3d77036b5415d72853c3ba3f9273"
69
69
  }
@@ -2,6 +2,8 @@ import { StatusListEntryEntity } from '../entities/statusList/StatusList2021Entr
2
2
  import type {
3
3
  IAddStatusListArgs,
4
4
  IAddStatusListEntryArgs,
5
+ IBitstringStatusListEntity,
6
+ IBitstringStatusListEntryEntity,
5
7
  IGetStatusListArgs,
6
8
  IGetStatusListEntriesArgs,
7
9
  IGetStatusListEntryByCredentialIdArgs,
@@ -15,21 +17,21 @@ import { IStatusListEntity, IStatusListEntryEntity } from '../types'
15
17
  import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
16
18
 
17
19
  export interface IStatusListStore {
18
- getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity>
20
+ getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity | IBitstringStatusListEntity>
19
21
 
20
- getStatusLists(args: IGetStatusListsArgs): Promise<Array<IStatusListEntity>>
22
+ getStatusLists(args: IGetStatusListsArgs): Promise<Array<IStatusListEntity | IBitstringStatusListEntity>>
21
23
 
22
24
  removeStatusList(args: IRemoveStatusListArgs): Promise<boolean>
23
25
 
24
- addStatusList(args: IAddStatusListArgs): Promise<IStatusListEntity>
26
+ addStatusList(args: IAddStatusListArgs): Promise<IStatusListEntity | IBitstringStatusListEntity>
25
27
 
26
- updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity>
28
+ updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity | IBitstringStatusListEntity>
27
29
 
28
30
  availableStatusListEntries(args: IStatusListEntryAvailableArgs): Promise<number[]>
29
31
 
30
- addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity>
32
+ addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity>
31
33
 
32
- updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity>
34
+ updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity>
33
35
 
34
36
  getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<StatusListEntryEntity | BitstringStatusListEntryEntity | undefined>
35
37
 
@@ -41,7 +43,5 @@ export interface IStatusListStore {
41
43
 
42
44
  removeStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<boolean>
43
45
 
44
- getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<IStatusListEntryEntity[]>
45
-
46
- getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity>
46
+ getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<Array<IStatusListEntryEntity | IBitstringStatusListEntryEntity>>
47
47
  }
@@ -4,9 +4,11 @@ import { DataSource, In, type Repository } from 'typeorm'
4
4
  import { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
5
5
  import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
6
6
  import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
7
- import type {
7
+ import {
8
8
  IAddStatusListArgs,
9
9
  IAddStatusListEntryArgs,
10
+ IBitstringStatusListEntity,
11
+ IBitstringStatusListEntryEntity,
10
12
  IGetStatusListArgs,
11
13
  IGetStatusListEntriesArgs,
12
14
  IGetStatusListEntryByCredentialIdArgs,
@@ -54,20 +56,28 @@ export class StatusListStore implements IStatusListStore {
54
56
  return statusListIndex.filter((index) => !results.includes(index))
55
57
  }
56
58
 
57
- async addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity> {
59
+ async addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity> {
60
+ if (!args.statusListId) {
61
+ throw new Error('statusListId is required')
62
+ }
63
+
58
64
  const statusList = await this.getStatusList({ id: args.statusListId })
59
- return (await this.getStatusListEntryRepo(statusList.type)).save(args)
65
+ const result = await (await this.getStatusListEntryRepo(statusList.type)).save(args)
66
+ return result as IStatusListEntryEntity | IBitstringStatusListEntryEntity
60
67
  }
61
68
 
62
- async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity> {
63
- const statusListId = args.statusListId ?? args.statusList?.id
69
+ async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity> {
70
+ const statusListId = args.statusListId
71
+ if (!statusListId) {
72
+ throw new Error('statusListId is required')
73
+ }
74
+
64
75
  const statusList = await this.getStatusList({ id: statusListId })
65
76
  const result = await this.getStatusListEntryByIndex({ ...args, statusListId, errorOnNotFound: false })
66
77
  const updatedEntry: Partial<IStatusListEntryEntity> = {
67
- value: args.value,
68
- correlationId: args.correlationId,
69
- credentialHash: args.credentialHash,
70
- credentialId: args.credentialId,
78
+ ...result,
79
+ ...args,
80
+ statusListId,
71
81
  }
72
82
 
73
83
  const updStatusListId = result?.statusListId ?? statusListId
@@ -82,7 +92,7 @@ export class StatusListStore implements IStatusListStore {
82
92
  ...args,
83
93
  statusListId: updStatusListId,
84
94
  errorOnNotFound: true,
85
- })) as IStatusListEntryEntity
95
+ }))!
86
96
  }
87
97
 
88
98
  async getStatusListEntryByIndex({
@@ -197,13 +207,14 @@ export class StatusListStore implements IStatusListStore {
197
207
  return !error
198
208
  }
199
209
 
200
- async getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<StatusListEntryEntity[]> {
210
+ async getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<Array<IStatusListEntryEntity | IBitstringStatusListEntryEntity>> {
201
211
  const statusList = await this.getStatusList({ id: args.statusListId })
202
- return (await this.getStatusListEntryRepo(statusList.type)).find({ where: { ...args?.filter, statusList: args.statusListId } })
203
- }
204
-
205
- async getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity> {
206
- return statusListFrom(await this.getStatusListEntity(args))
212
+ const results = await (
213
+ await this.getStatusListEntryRepo(statusList.type)
214
+ ).find({
215
+ where: { ...args?.filter, statusList: args.statusListId },
216
+ })
217
+ return results as Array<IStatusListEntryEntity | IBitstringStatusListEntryEntity>
207
218
  }
208
219
 
209
220
  private async getStatusListEntity(args: IGetStatusListArgs): Promise<StatusListEntity> {
@@ -223,7 +234,12 @@ export class StatusListStore implements IStatusListStore {
223
234
  return result
224
235
  }
225
236
 
226
- async getStatusLists(args: IGetStatusListsArgs): Promise<Array<IStatusListEntity>> {
237
+ async getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity | IBitstringStatusListEntity> {
238
+ const entity = await this.getStatusListEntity(args)
239
+ return statusListFrom(entity) as IStatusListEntity | IBitstringStatusListEntity
240
+ }
241
+
242
+ async getStatusLists(args: IGetStatusListsArgs): Promise<Array<IStatusListEntity | IBitstringStatusListEntity>> {
227
243
  const result = await (
228
244
  await this.getStatusListRepo()
229
245
  ).find({
@@ -234,7 +250,7 @@ export class StatusListStore implements IStatusListStore {
234
250
  return []
235
251
  }
236
252
 
237
- return result.map((entity) => statusListFrom(entity))
253
+ return result.map((entity) => statusListFrom(entity) as IStatusListEntity | IBitstringStatusListEntity)
238
254
  }
239
255
 
240
256
  async addStatusList(args: IAddStatusListArgs): Promise<IStatusListEntity> {
@@ -255,7 +271,7 @@ export class StatusListStore implements IStatusListStore {
255
271
  return statusListFrom(createdResult)
256
272
  }
257
273
 
258
- async updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity> {
274
+ async updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity | IBitstringStatusListEntity> {
259
275
  const result = await this.getStatusList(args)
260
276
  debug('Updating status list', result)
261
277
  const entity = statusListEntityFrom(args)
@@ -1,5 +1,16 @@
1
1
  import { FindOptionsWhere } from 'typeorm'
2
- import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntity, IStatusListEntryEntity } from './statusList'
2
+ import { IBitstringStatusListEntryEntity, IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntryEntity } from './statusList'
3
+ import {
4
+ CredentialProofFormat,
5
+ IIssuer,
6
+ StatusListCredential,
7
+ StatusListCredentialIdMode,
8
+ StatusListDriverType,
9
+ StatusListIndexingDirection,
10
+ StatusListType,
11
+ StatusPurpose2021,
12
+ } from '@sphereon/ssi-types'
13
+ import { BitstringStatusPurpose } from './bitstringTypes'
3
14
 
4
15
  export type FindStatusListArgs = FindOptionsWhere<IStatusList2021Entity | IOAuthStatusListEntity>[]
5
16
  export type FindStatusListEntryArgs = FindOptionsWhere<IStatusListEntryEntity>[] | FindOptionsWhere<IStatusListEntryEntity>
@@ -30,7 +41,7 @@ export interface IGetStatusListEntriesArgs {
30
41
  filter?: FindStatusListEntryArgs
31
42
  }
32
43
 
33
- export type IAddStatusListEntryArgs = IStatusListEntryEntity
44
+ export type IAddStatusListEntryArgs = IStatusListEntryEntity | IBitstringStatusListEntryEntity
34
45
 
35
46
  export interface IGetStatusListArgs {
36
47
  id?: string
@@ -43,6 +54,30 @@ export interface IGetStatusListsArgs {
43
54
  filter?: FindStatusListArgs
44
55
  }
45
56
 
46
- export type IAddStatusListArgs = IStatusListEntity
57
+ interface IBaseStatusListArgs {
58
+ id: string
59
+ correlationId: string
60
+ driverType: StatusListDriverType
61
+ credentialIdMode: StatusListCredentialIdMode
62
+ length: number
63
+ issuer: string | IIssuer
64
+ type: StatusListType
65
+ proofFormat: CredentialProofFormat
66
+ statusListCredential?: StatusListCredential
67
+ bitsPerStatus?: number
68
+ }
69
+
70
+ // Then extend for specific types when needed
71
+ export type IAddStatusListArgs =
72
+ | (IBaseStatusListArgs & { type: StatusListType.StatusList2021; indexingDirection: StatusListIndexingDirection; statusPurpose: StatusPurpose2021 })
73
+ | (IBaseStatusListArgs & { type: StatusListType.OAuthStatusList; bitsPerStatus: number; expiresAt?: Date })
74
+ | (IBaseStatusListArgs & {
75
+ type: StatusListType.BitstringStatusList
76
+ statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
77
+ bitsPerStatus?: number
78
+ validFrom?: Date
79
+ validUntil?: Date
80
+ ttl?: number
81
+ })
47
82
 
48
- export type IUpdateStatusListIndexArgs = IStatusListEntity
83
+ export type IUpdateStatusListIndexArgs = IAddStatusListArgs
@@ -10,7 +10,7 @@ import {
10
10
  StatusPurpose2021,
11
11
  } from '@sphereon/ssi-types'
12
12
  import { StatusListEntity } from '../../entities/statusList/StatusListEntities'
13
- import { BitstringStatusPurpose } from './bitstringTypes'
13
+ import { BitstringStatus, BitstringStatusPurpose } from './bitstringTypes'
14
14
 
15
15
  export interface IStatusListEntity {
16
16
  id: string
@@ -43,6 +43,18 @@ export interface IBitstringStatusListEntity extends IStatusListEntity {
43
43
  ttl?: number
44
44
  }
45
45
 
46
+ export interface IBitstringStatusListEntryEntity {
47
+ statusListId: string
48
+ statusListIndex: number
49
+ credentialId?: string
50
+ credentialHash?: string
51
+ entryCorrelationId?: string
52
+ statusPurpose: string
53
+ bitsPerStatus?: number
54
+ statusMessage?: Array<BitstringStatus>
55
+ statusReference?: string | string[]
56
+ }
57
+
46
58
  export type IStatusListEntryEntity = RequireOneOf<
47
59
  {
48
60
  statusList: StatusListEntity
@@ -52,7 +64,6 @@ export type IStatusListEntryEntity = RequireOneOf<
52
64
  credentialHash?: string
53
65
  credentialId?: string
54
66
  correlationId?: string
55
- bitsPerStatus?: number
56
67
  },
57
68
  'statusList' | 'statusListId'
58
69
  >
@@ -61,7 +61,7 @@ export const statusListEntityFrom = (args: IStatusListEntity): StatusListEntity
61
61
  throw new Error(`Invalid status list type ${args.type}`)
62
62
  }
63
63
 
64
- export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
64
+ export const statusListFrom = (entity: StatusListEntity): IStatusListEntity | IBitstringStatusListEntity => {
65
65
  if (entity instanceof StatusList2021Entity) {
66
66
  const result: IStatusList2021Entity = {
67
67
  ...getBaseFields(entity),