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

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.24+d486d9b6",
3
+ "version": "0.34.1-feature.SSISDK.17.bitstring.sl.26+45018dde",
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.1-next.3",
32
32
  "@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.1-next.3",
33
- "@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.17.bitstring.sl.24+d486d9b6",
34
- "@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.17.bitstring.sl.24+d486d9b6",
35
- "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.24+d486d9b6",
33
+ "@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.17.bitstring.sl.26+45018dde",
34
+ "@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.17.bitstring.sl.26+45018dde",
35
+ "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.26+45018dde",
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": "d486d9b69ca1a5c0df614642a2d1e158a60edee8"
68
+ "gitHead": "45018dde1cd6ea44529ec6fa68ba6877466f13bb"
69
69
  }
@@ -62,8 +62,7 @@ export class StatusListStore implements IStatusListStore {
62
62
  }
63
63
 
64
64
  const statusList = await this.getStatusList({ id: args.statusListId })
65
- const result = await (await this.getStatusListEntryRepo(statusList.type)).save(args)
66
- return result as IStatusListEntryEntity | IBitstringStatusListEntryEntity
65
+ return await (await this.getStatusListEntryRepo(statusList.type)).save(args)
67
66
  }
68
67
 
69
68
  async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity> {
@@ -87,7 +86,7 @@ export class StatusListStore implements IStatusListStore {
87
86
  { ...(result ?? { statusListId: updStatusListId, statusListIndex: args.statusListIndex }), ...updatedEntry },
88
87
  { conflictPaths: ['statusList', 'statusListIndex'] },
89
88
  )
90
- console.log(updateResult)
89
+ debug(updateResult)
91
90
  return (await this.getStatusListEntryByIndex({
92
91
  ...args,
93
92
  statusListId: updStatusListId,
@@ -151,7 +150,7 @@ export class StatusListStore implements IStatusListStore {
151
150
  ...(args.entryCorrelationId && { correlationId: args.entryCorrelationId }),
152
151
  credentialId,
153
152
  }
154
- console.log(`Entries: ${JSON.stringify(await (await this.getStatusListEntryRepo(statusList.type)).find(), null, 2)}`)
153
+ debug(`Entries: ${JSON.stringify(await (await this.getStatusListEntryRepo(statusList.type)).find(), null, 2)}`)
155
154
  const result = await (await this.getStatusListEntryRepo(statusList.type)).findOne({ where })
156
155
 
157
156
  if (!result && args.errorOnNotFound) {
@@ -192,7 +191,7 @@ export class StatusListStore implements IStatusListStore {
192
191
  error = true
193
192
  }
194
193
  if (error) {
195
- console.log(`Could not delete statusList ${args.statusListId} entry by index ${args.statusListIndex}`)
194
+ console.error(`Could not delete statusList ${args.statusListId} entry by index ${args.statusListIndex}`)
196
195
  } else {
197
196
  const statusList = await this.getStatusList({ id: args.statusListId })
198
197
  const result = await (
@@ -72,17 +72,27 @@ interface IBaseStatusListArgs {
72
72
  bitsPerStatus?: number
73
73
  }
74
74
 
75
- // Then extend for specific types when needed
76
- export type IAddStatusListArgs =
77
- | (IBaseStatusListArgs & { type: StatusListType.StatusList2021; indexingDirection: StatusListIndexingDirection; statusPurpose: StatusPurpose2021 })
78
- | (IBaseStatusListArgs & { type: StatusListType.OAuthStatusList; bitsPerStatus: number; expiresAt?: Date })
79
- | (IBaseStatusListArgs & {
80
- type: StatusListType.BitstringStatusList
81
- statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
82
- bitsPerStatus?: number
83
- validFrom?: Date
84
- validUntil?: Date
85
- ttl?: number
86
- })
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
87
97
 
88
98
  export type IUpdateStatusListIndexArgs = IAddStatusListArgs
@@ -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
@@ -66,12 +66,12 @@ export type BitstringStatusMessage = {
66
66
 
67
67
  export interface BitstringStatusListEntryCredentialStatus extends ICredentialStatus {
68
68
  type: 'BitstringStatusListEntry'
69
- statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
69
+ statusPurpose: BitstringStatusPurpose | Array<BitstringStatusPurpose>
70
70
  statusListIndex: string
71
71
  statusListCredential: string
72
72
  bitsPerStatus?: number
73
73
  statusMessage?: Array<BitstringStatusMessage>
74
- statusReference?: string | string[]
74
+ statusReference?: string | Array<string>
75
75
  }
76
76
 
77
77
  export type BitstringStatusListArgs = {
@@ -91,5 +91,5 @@ export interface IBitstringStatusListEntryEntity {
91
91
  statusPurpose: string
92
92
  bitsPerStatus?: number
93
93
  statusMessage?: Array<BitstringStatusMessage>
94
- statusReference?: string | string[]
94
+ statusReference?: string | Array<string>
95
95
  }
@@ -9,56 +9,59 @@ 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
67
  export const statusListFrom = (entity: StatusListEntity): IStatusListEntity | IBitstringStatusListEntity => {