@sphereon/ssi-sdk.data-store 0.32.1-feature.VDX.341.57 → 0.32.1-feature.new.develop.273
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/entities/oid4vcState/Oid4vcStateEntity.d.ts +13 -0
- package/dist/entities/oid4vcState/Oid4vcStateEntity.d.ts.map +1 -0
- package/dist/entities/oid4vcState/Oid4vcStateEntity.js +57 -0
- package/dist/entities/oid4vcState/Oid4vcStateEntity.js.map +1 -0
- package/dist/entities/{statusList2021 → statusList}/StatusList2021EntryEntity.d.ts +4 -3
- package/dist/entities/statusList/StatusList2021EntryEntity.d.ts.map +1 -0
- package/dist/entities/{statusList2021 → statusList}/StatusList2021EntryEntity.js +11 -6
- package/dist/entities/statusList/StatusList2021EntryEntity.js.map +1 -0
- package/dist/entities/statusList/StatusListEntities.d.ts +23 -0
- package/dist/entities/statusList/StatusListEntities.d.ts.map +1 -0
- package/dist/entities/{statusList2021/StatusList2021Entity.js → statusList/StatusListEntities.js} +45 -16
- package/dist/entities/statusList/StatusListEntities.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/4-CreateStatusList.d.ts.map +1 -1
- package/dist/migrations/generic/4-CreateStatusList.js +22 -12
- package/dist/migrations/generic/4-CreateStatusList.js.map +1 -1
- package/dist/migrations/postgres/1693866470001-CreateStatusList.d.ts.map +1 -1
- package/dist/migrations/postgres/1693866470001-CreateStatusList.js +40 -7
- package/dist/migrations/postgres/1693866470001-CreateStatusList.js.map +1 -1
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.d.ts +7 -0
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.d.ts.map +1 -0
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.js +39 -0
- package/dist/migrations/postgres/1737110469001-UpdateStatusList.js.map +1 -0
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts.map +1 -1
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js +45 -5
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js.map +1 -1
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.d.ts +7 -0
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.d.ts.map +1 -0
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.js +96 -0
- package/dist/migrations/sqlite/1737110469000-UpdateStatusList.js.map +1 -0
- package/dist/statusList/IStatusListStore.d.ts +2 -2
- package/dist/statusList/IStatusListStore.d.ts.map +1 -1
- package/dist/statusList/StatusListStore.d.ts +9 -8
- package/dist/statusList/StatusListStore.d.ts.map +1 -1
- package/dist/statusList/StatusListStore.js +72 -42
- package/dist/statusList/StatusListStore.js.map +1 -1
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.d.ts +2 -2
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.d.ts.map +1 -1
- package/dist/types/statusList/IAbstractStatusListStore.d.ts +5 -4
- package/dist/types/statusList/IAbstractStatusListStore.d.ts.map +1 -1
- package/dist/types/statusList/statusList.d.ts +13 -7
- package/dist/types/statusList/statusList.d.ts.map +1 -1
- package/dist/utils/statusList/MappingUtils.d.ts +5 -0
- package/dist/utils/statusList/MappingUtils.d.ts.map +1 -0
- package/dist/utils/statusList/MappingUtils.js +69 -0
- package/dist/utils/statusList/MappingUtils.js.map +1 -0
- package/package.json +7 -7
- package/src/__tests__/statusList.entities.test.ts +216 -0
- package/src/__tests__/statusList.store.test.ts +232 -0
- package/src/entities/oid4vcState/Oid4vcStateEntity.ts +32 -0
- package/src/entities/{statusList2021 → statusList}/StatusList2021EntryEntity.ts +10 -6
- package/src/entities/{statusList2021/StatusList2021Entity.ts → statusList/StatusListEntities.ts} +38 -18
- package/src/index.ts +8 -3
- package/src/migrations/generic/4-CreateStatusList.ts +22 -12
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +42 -9
- package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +25 -0
- package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +45 -5
- package/src/migrations/sqlite/1737110469000-UpdateStatusList.ts +94 -0
- package/src/statusList/IStatusListStore.ts +2 -2
- package/src/statusList/StatusListStore.ts +94 -51
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +2 -2
- package/src/types/statusList/IAbstractStatusListStore.ts +5 -4
- package/src/types/statusList/statusList.ts +24 -16
- package/src/utils/statusList/MappingUtils.ts +82 -0
- package/dist/entities/statusList2021/StatusList2021Entity.d.ts +0 -19
- package/dist/entities/statusList2021/StatusList2021Entity.d.ts.map +0 -1
- package/dist/entities/statusList2021/StatusList2021Entity.js.map +0 -1
- package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts.map +0 -1
- package/dist/entities/statusList2021/StatusList2021EntryEntity.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAbstractStatusListStore.d.ts","sourceRoot":"","sources":["../../../src/types/statusList/IAbstractStatusListStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"IAbstractStatusListStore.d.ts","sourceRoot":"","sources":["../../../src/types/statusList/IAbstractStatusListStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAEvH,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,qBAAqB,GAAG,sBAAsB,CAAC,EAAE,CAAA;AACnG,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,EAAE,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,CAAA;AAE3H,MAAM,WAAW,6BAA6B;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CACnC;AAED,MAAM,WAAW,8BAA8B;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,WAAW,qCAAqC;IACpD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AACD,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,uBAAuB,CAAA;CACjC;AAED,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,CAAA;AAE5D,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAA;AAEtD,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,kBAAkB,CAAA;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,CAAA;AAElD,MAAM,MAAM,0BAA0B,GAAG,iBAAiB,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IIssuer,
|
|
2
|
-
import {
|
|
3
|
-
import { StatusListEntity } from '../../entities/statusList2021/StatusList2021Entity';
|
|
1
|
+
import { IIssuer, StatusListCredential, StatusListCredentialIdMode, StatusListDriverType, StatusListIndexingDirection, StatusListType, StatusPurpose2021, ProofFormat, RequireOneOf } from '@sphereon/ssi-types';
|
|
2
|
+
import { StatusListEntity } from '../../entities/statusList/StatusListEntities';
|
|
4
3
|
export interface IStatusListEntity {
|
|
5
4
|
id: string;
|
|
6
5
|
correlationId: string;
|
|
@@ -10,16 +9,23 @@ export interface IStatusListEntity {
|
|
|
10
9
|
issuer: string | IIssuer;
|
|
11
10
|
type: StatusListType;
|
|
12
11
|
proofFormat: ProofFormat;
|
|
12
|
+
statusListCredential?: StatusListCredential;
|
|
13
|
+
}
|
|
14
|
+
export interface IStatusList2021Entity extends IStatusListEntity {
|
|
13
15
|
indexingDirection: StatusListIndexingDirection;
|
|
14
16
|
statusPurpose: StatusPurpose2021;
|
|
15
|
-
statusListCredential?: OriginalVerifiableCredential;
|
|
16
17
|
}
|
|
17
|
-
export interface
|
|
18
|
-
|
|
18
|
+
export interface IOAuthStatusListEntity extends IStatusListEntity {
|
|
19
|
+
bitsPerStatus: number;
|
|
20
|
+
expiresAt?: Date;
|
|
21
|
+
}
|
|
22
|
+
export type IStatusListEntryEntity = RequireOneOf<{
|
|
23
|
+
statusList: StatusListEntity;
|
|
24
|
+
statusListId: string;
|
|
19
25
|
value?: string;
|
|
20
26
|
statusListIndex: number;
|
|
21
27
|
credentialHash?: string;
|
|
22
28
|
credentialId?: string;
|
|
23
29
|
correlationId?: string;
|
|
24
|
-
}
|
|
30
|
+
}, 'statusList' | 'statusListId'>;
|
|
25
31
|
//# sourceMappingURL=statusList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statusList.d.ts","sourceRoot":"","sources":["../../../src/types/statusList/statusList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,
|
|
1
|
+
{"version":3,"file":"statusList.d.ts","sourceRoot":"","sources":["../../../src/types/statusList/statusList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,2BAA2B,EAC3B,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,YAAY,EACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAE/E,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,oBAAoB,CAAA;IAChC,gBAAgB,EAAE,0BAA0B,CAAA;IAC5C,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IACxB,IAAI,EAAE,cAAc,CAAA;IACpB,WAAW,EAAE,WAAW,CAAA;IACxB,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;CAC5C;AAED,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,iBAAiB,EAAE,2BAA2B,CAAA;IAC9C,aAAa,EAAE,iBAAiB,CAAA;CACjC;AAED,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,IAAI,CAAA;CACjB;AAED,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAC/C;IACE,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,EACD,YAAY,GAAG,cAAc,CAC9B,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IStatusListEntity } from '../../types';
|
|
2
|
+
import { StatusListEntity } from '../../entities/statusList/StatusListEntities';
|
|
3
|
+
export declare const statusListEntityFrom: (args: IStatusListEntity) => StatusListEntity;
|
|
4
|
+
export declare const statusListFrom: (entity: StatusListEntity) => IStatusListEntity;
|
|
5
|
+
//# sourceMappingURL=MappingUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MappingUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/statusList/MappingUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiD,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC9F,OAAO,EAA+C,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAI5H,eAAO,MAAM,oBAAoB,SAAU,iBAAiB,KAAG,gBA8B9D,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,gBAAgB,KAAG,iBAsBzD,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.statusListFrom = exports.statusListEntityFrom = void 0;
|
|
4
|
+
const StatusListEntities_1 = require("../../entities/statusList/StatusListEntities");
|
|
5
|
+
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
6
|
+
const FormattingUtils_1 = require("../FormattingUtils");
|
|
7
|
+
const statusListEntityFrom = (args) => {
|
|
8
|
+
if (args.type === ssi_types_1.StatusListType.StatusList2021) {
|
|
9
|
+
const entity = new StatusListEntities_1.StatusList2021Entity();
|
|
10
|
+
const sl2021 = args;
|
|
11
|
+
entity.indexingDirection = sl2021.indexingDirection;
|
|
12
|
+
entity.statusPurpose = sl2021.statusPurpose;
|
|
13
|
+
setBaseFields(entity, args);
|
|
14
|
+
Object.defineProperty(entity, 'type', {
|
|
15
|
+
value: ssi_types_1.StatusListType.StatusList2021,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
});
|
|
19
|
+
return entity;
|
|
20
|
+
}
|
|
21
|
+
if (args.type === ssi_types_1.StatusListType.OAuthStatusList) {
|
|
22
|
+
const entity = new StatusListEntities_1.OAuthStatusListEntity();
|
|
23
|
+
const oauthSl = args;
|
|
24
|
+
entity.bitsPerStatus = oauthSl.bitsPerStatus;
|
|
25
|
+
entity.expiresAt = oauthSl.expiresAt;
|
|
26
|
+
setBaseFields(entity, args);
|
|
27
|
+
Object.defineProperty(entity, 'type', {
|
|
28
|
+
value: ssi_types_1.StatusListType.OAuthStatusList,
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
});
|
|
32
|
+
return entity;
|
|
33
|
+
}
|
|
34
|
+
throw new Error(`Invalid status list type ${args.type}`);
|
|
35
|
+
};
|
|
36
|
+
exports.statusListEntityFrom = statusListEntityFrom;
|
|
37
|
+
const statusListFrom = (entity) => {
|
|
38
|
+
if (entity instanceof StatusListEntities_1.StatusList2021Entity) {
|
|
39
|
+
const result = Object.assign(Object.assign({}, getBaseFields(entity)), { type: ssi_types_1.StatusListType.StatusList2021, indexingDirection: entity.indexingDirection, statusPurpose: entity.statusPurpose });
|
|
40
|
+
return (0, FormattingUtils_1.replaceNullWithUndefined)(result);
|
|
41
|
+
}
|
|
42
|
+
if (entity instanceof StatusListEntities_1.OAuthStatusListEntity) {
|
|
43
|
+
const result = Object.assign(Object.assign({}, getBaseFields(entity)), { type: ssi_types_1.StatusListType.OAuthStatusList, bitsPerStatus: entity.bitsPerStatus, expiresAt: entity.expiresAt });
|
|
44
|
+
return (0, FormattingUtils_1.replaceNullWithUndefined)(result);
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`Invalid status list type ${typeof entity}`);
|
|
47
|
+
};
|
|
48
|
+
exports.statusListFrom = statusListFrom;
|
|
49
|
+
const setBaseFields = (entity, args) => {
|
|
50
|
+
entity.id = args.id;
|
|
51
|
+
entity.correlationId = args.correlationId;
|
|
52
|
+
entity.length = args.length;
|
|
53
|
+
entity.issuer = args.issuer;
|
|
54
|
+
entity.driverType = args.driverType;
|
|
55
|
+
entity.credentialIdMode = args.credentialIdMode;
|
|
56
|
+
entity.proofFormat = args.proofFormat;
|
|
57
|
+
entity.statusListCredential = args.statusListCredential;
|
|
58
|
+
};
|
|
59
|
+
const getBaseFields = (entity) => ({
|
|
60
|
+
id: entity.id,
|
|
61
|
+
correlationId: entity.correlationId,
|
|
62
|
+
length: entity.length,
|
|
63
|
+
issuer: entity.issuer,
|
|
64
|
+
driverType: entity.driverType,
|
|
65
|
+
credentialIdMode: entity.credentialIdMode,
|
|
66
|
+
proofFormat: entity.proofFormat,
|
|
67
|
+
statusListCredential: entity.statusListCredential,
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=MappingUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MappingUtils.js","sourceRoot":"","sources":["../../../src/utils/statusList/MappingUtils.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.data-store",
|
|
3
|
-
"version": "0.32.1-feature.
|
|
3
|
+
"version": "0.32.1-feature.new.develop.273+79f7bcde",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
18
18
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
19
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.27.
|
|
20
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.
|
|
21
|
-
"@sphereon/ssi-sdk.agent-config": "0.32.1-feature.
|
|
22
|
-
"@sphereon/ssi-sdk.core": "0.32.1-feature.
|
|
23
|
-
"@sphereon/ssi-types": "0.32.1-feature.
|
|
19
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.27.1-next.21",
|
|
20
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.1-next.21",
|
|
21
|
+
"@sphereon/ssi-sdk.agent-config": "0.32.1-feature.new.develop.273+79f7bcde",
|
|
22
|
+
"@sphereon/ssi-sdk.core": "0.32.1-feature.new.develop.273+79f7bcde",
|
|
23
|
+
"@sphereon/ssi-types": "0.32.1-feature.new.develop.273+79f7bcde",
|
|
24
24
|
"@veramo/core": "4.2.0",
|
|
25
25
|
"@veramo/utils": "4.2.0",
|
|
26
26
|
"blakejs": "^1.2.1",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"Contact Store"
|
|
55
55
|
],
|
|
56
56
|
"nx": {},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "79f7bcdece5b9890c6243a402f36160bf205e482"
|
|
58
58
|
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { DataSource } from 'typeorm'
|
|
2
|
+
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
+
import { DataStoreStatusListEntities, StatusListEntryEntity } from '../index'
|
|
4
|
+
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
|
+
import { OAuthStatusListEntity, StatusList2021Entity } from '../entities/statusList/StatusListEntities'
|
|
6
|
+
import { IIssuer, StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types'
|
|
7
|
+
|
|
8
|
+
describe('Status list entities tests', () => {
|
|
9
|
+
let dbConnection: DataSource
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
DataSources.singleInstance().defaultDbType = 'sqlite'
|
|
13
|
+
dbConnection = await new DataSource({
|
|
14
|
+
type: 'sqlite',
|
|
15
|
+
database: ':memory:',
|
|
16
|
+
migrationsRun: false,
|
|
17
|
+
migrations: DataStoreStatusListMigrations,
|
|
18
|
+
synchronize: false,
|
|
19
|
+
entities: [...DataStoreStatusListEntities],
|
|
20
|
+
}).initialize()
|
|
21
|
+
await dbConnection.runMigrations()
|
|
22
|
+
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
afterEach(async () => {
|
|
26
|
+
await dbConnection.destroy()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should save status list to database', async () => {
|
|
30
|
+
const statusList = new StatusList2021Entity()
|
|
31
|
+
statusList.id = 'test-list-1'
|
|
32
|
+
statusList.correlationId = 'correlation-1'
|
|
33
|
+
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
34
|
+
statusList.length = 100000
|
|
35
|
+
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
36
|
+
statusList.proofFormat = 'jwt'
|
|
37
|
+
statusList.statusPurpose = 'revocation'
|
|
38
|
+
statusList.indexingDirection = 'rightToLeft'
|
|
39
|
+
statusList.issuer = 'did:example:123'
|
|
40
|
+
|
|
41
|
+
const fromDb = await dbConnection.getRepository(StatusList2021Entity).save(statusList)
|
|
42
|
+
expect(fromDb).toBeDefined()
|
|
43
|
+
expect(fromDb.id).toEqual(statusList.id)
|
|
44
|
+
expect(fromDb.correlationId).toEqual(statusList.correlationId)
|
|
45
|
+
expect(fromDb.length).toEqual(statusList.length)
|
|
46
|
+
expect(fromDb.credentialIdMode).toEqual(statusList.credentialIdMode)
|
|
47
|
+
expect(fromDb.statusPurpose).toEqual(statusList.statusPurpose)
|
|
48
|
+
expect(fromDb.indexingDirection).toEqual(statusList.indexingDirection)
|
|
49
|
+
expect(fromDb.issuer).toEqual(statusList.issuer)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('should save status list entry to database', async () => {
|
|
53
|
+
const statusList = new StatusList2021Entity()
|
|
54
|
+
statusList.id = 'test-list-1'
|
|
55
|
+
statusList.correlationId = 'correlation-1'
|
|
56
|
+
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
57
|
+
statusList.length = 100000
|
|
58
|
+
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
59
|
+
statusList.proofFormat = 'jwt'
|
|
60
|
+
statusList.statusPurpose = 'revocation'
|
|
61
|
+
statusList.indexingDirection = 'rightToLeft'
|
|
62
|
+
statusList.issuer = 'did:example:123'
|
|
63
|
+
|
|
64
|
+
await dbConnection.getRepository(StatusList2021Entity).save(statusList)
|
|
65
|
+
|
|
66
|
+
const entry = new StatusListEntryEntity()
|
|
67
|
+
entry.statusList = statusList
|
|
68
|
+
entry.statusListIndex = 1
|
|
69
|
+
entry.credentialId = 'credential-1'
|
|
70
|
+
entry.credentialHash = 'hash-1'
|
|
71
|
+
entry.statusList.correlationId = 'correlation-1'
|
|
72
|
+
entry.value = '1'
|
|
73
|
+
|
|
74
|
+
const fromDb = await dbConnection.getRepository(StatusListEntryEntity).save(entry)
|
|
75
|
+
expect(fromDb).toBeDefined()
|
|
76
|
+
expect(fromDb.statusListIndex).toEqual(entry.statusListIndex)
|
|
77
|
+
expect(fromDb.credentialId).toEqual(entry.credentialId)
|
|
78
|
+
expect(fromDb.credentialHash).toEqual(entry.credentialHash)
|
|
79
|
+
expect(fromDb.statusList.correlationId).toEqual(entry.statusList.correlationId)
|
|
80
|
+
expect(fromDb.value).toEqual(entry.value)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('should handle complex issuer object', async () => {
|
|
84
|
+
const statusList = new StatusList2021Entity()
|
|
85
|
+
statusList.id = 'test-list-1'
|
|
86
|
+
statusList.correlationId = 'correlation-1'
|
|
87
|
+
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
88
|
+
statusList.length = 100000
|
|
89
|
+
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
90
|
+
statusList.proofFormat = 'jwt'
|
|
91
|
+
statusList.statusPurpose = 'revocation'
|
|
92
|
+
statusList.indexingDirection = 'rightToLeft'
|
|
93
|
+
statusList.issuer = { id: 'did:example:123', name: 'Test Issuer' }
|
|
94
|
+
|
|
95
|
+
const fromDb = await dbConnection.getRepository(StatusList2021Entity).save(statusList)
|
|
96
|
+
expect(fromDb).toBeDefined()
|
|
97
|
+
expect(fromDb.issuer).toEqual(statusList.issuer)
|
|
98
|
+
expect(typeof fromDb.issuer).toEqual('object')
|
|
99
|
+
expect((fromDb.issuer as IIssuer).id).toEqual('did:example:123')
|
|
100
|
+
expect((fromDb.issuer as IIssuer).name).toEqual('Test Issuer')
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('should save OAuth status list to database', async () => {
|
|
104
|
+
const statusList = new OAuthStatusListEntity()
|
|
105
|
+
statusList.id = 'oauth-list-1'
|
|
106
|
+
statusList.correlationId = 'correlation-oauth-1'
|
|
107
|
+
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
108
|
+
statusList.length = 100000
|
|
109
|
+
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
110
|
+
statusList.proofFormat = 'jwt'
|
|
111
|
+
statusList.bitsPerStatus = 1
|
|
112
|
+
statusList.expiresAt = new Date('2025-01-01T00:00:00Z')
|
|
113
|
+
statusList.issuer = 'did:example:123'
|
|
114
|
+
|
|
115
|
+
const fromDb = await dbConnection.getRepository(OAuthStatusListEntity).save(statusList)
|
|
116
|
+
expect(fromDb).toBeDefined()
|
|
117
|
+
expect(fromDb.id).toEqual(statusList.id)
|
|
118
|
+
expect(fromDb.correlationId).toEqual(statusList.correlationId)
|
|
119
|
+
expect(fromDb.length).toEqual(statusList.length)
|
|
120
|
+
expect(fromDb.credentialIdMode).toEqual(statusList.credentialIdMode)
|
|
121
|
+
expect(fromDb.bitsPerStatus).toEqual(statusList.bitsPerStatus)
|
|
122
|
+
expect(fromDb.expiresAt).toEqual(statusList.expiresAt)
|
|
123
|
+
expect(fromDb.issuer).toEqual(statusList.issuer)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('should handle both status list types having entries', async () => {
|
|
127
|
+
const statusList2021 = new StatusList2021Entity()
|
|
128
|
+
statusList2021.id = 'test-list-1'
|
|
129
|
+
statusList2021.correlationId = 'correlation-1'
|
|
130
|
+
statusList2021.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
131
|
+
statusList2021.length = 100000
|
|
132
|
+
statusList2021.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
133
|
+
statusList2021.proofFormat = 'jwt'
|
|
134
|
+
statusList2021.statusPurpose = 'revocation'
|
|
135
|
+
statusList2021.indexingDirection = 'rightToLeft'
|
|
136
|
+
statusList2021.issuer = 'did:example:123'
|
|
137
|
+
await dbConnection.getRepository(StatusList2021Entity).save(statusList2021)
|
|
138
|
+
|
|
139
|
+
const oauthStatusList = new OAuthStatusListEntity()
|
|
140
|
+
oauthStatusList.id = 'oauth-list-1'
|
|
141
|
+
oauthStatusList.correlationId = 'correlation-oauth-1'
|
|
142
|
+
oauthStatusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
143
|
+
oauthStatusList.length = 100000
|
|
144
|
+
oauthStatusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
145
|
+
oauthStatusList.proofFormat = 'jwt'
|
|
146
|
+
oauthStatusList.bitsPerStatus = 1
|
|
147
|
+
oauthStatusList.issuer = 'did:example:456'
|
|
148
|
+
await dbConnection.getRepository(OAuthStatusListEntity).save(oauthStatusList)
|
|
149
|
+
|
|
150
|
+
const entry2021 = new StatusListEntryEntity()
|
|
151
|
+
entry2021.statusList = statusList2021
|
|
152
|
+
entry2021.statusListIndex = 1
|
|
153
|
+
entry2021.credentialId = 'credential-1'
|
|
154
|
+
entry2021.credentialHash = 'hash-1'
|
|
155
|
+
entry2021.value = '1'
|
|
156
|
+
await dbConnection.getRepository(StatusListEntryEntity).save(entry2021)
|
|
157
|
+
|
|
158
|
+
const entryOAuth = new StatusListEntryEntity()
|
|
159
|
+
entryOAuth.statusList = oauthStatusList
|
|
160
|
+
entryOAuth.statusListIndex = 1
|
|
161
|
+
entryOAuth.credentialId = 'credential-2'
|
|
162
|
+
entryOAuth.credentialHash = 'hash-2'
|
|
163
|
+
entryOAuth.value = '1'
|
|
164
|
+
await dbConnection.getRepository(StatusListEntryEntity).save(entryOAuth)
|
|
165
|
+
|
|
166
|
+
const found2021Entry = await dbConnection.getRepository(StatusListEntryEntity).findOne({
|
|
167
|
+
where: { statusList: { id: statusList2021.id }, statusListIndex: 1 },
|
|
168
|
+
relations: { statusList: true },
|
|
169
|
+
})
|
|
170
|
+
const foundOAuthEntry = await dbConnection.getRepository(StatusListEntryEntity).findOne({
|
|
171
|
+
where: { statusList: { id: oauthStatusList.id }, statusListIndex: 1 },
|
|
172
|
+
relations: { statusList: true },
|
|
173
|
+
})
|
|
174
|
+
expect(found2021Entry).toBeTruthy()
|
|
175
|
+
expect(found2021Entry?.credentialId).toEqual('credential-1')
|
|
176
|
+
expect(foundOAuthEntry).toBeTruthy()
|
|
177
|
+
expect(foundOAuthEntry?.credentialId).toEqual('credential-2')
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
it('should cascade delete entries when status list is deleted', async () => {
|
|
181
|
+
const statusList = new StatusList2021Entity()
|
|
182
|
+
statusList.id = 'test-list-1'
|
|
183
|
+
statusList.correlationId = 'correlation-1'
|
|
184
|
+
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
185
|
+
statusList.length = 100000
|
|
186
|
+
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
187
|
+
statusList.proofFormat = 'jwt'
|
|
188
|
+
statusList.statusPurpose = 'revocation'
|
|
189
|
+
statusList.indexingDirection = 'rightToLeft'
|
|
190
|
+
statusList.issuer = 'did:example:123'
|
|
191
|
+
|
|
192
|
+
const savedStatusList = await dbConnection.getRepository(StatusList2021Entity).save(statusList)
|
|
193
|
+
|
|
194
|
+
const entry = new StatusListEntryEntity()
|
|
195
|
+
entry.statusList = statusList
|
|
196
|
+
entry.statusListIndex = 1
|
|
197
|
+
entry.credentialId = 'credential-1'
|
|
198
|
+
entry.credentialHash = 'hash-1'
|
|
199
|
+
entry.statusList.correlationId = 'correlation-1'
|
|
200
|
+
entry.value = '1'
|
|
201
|
+
|
|
202
|
+
await dbConnection.getRepository(StatusListEntryEntity).save(entry)
|
|
203
|
+
|
|
204
|
+
// First delete entry, otherwise constraint fails
|
|
205
|
+
await dbConnection.getRepository(StatusListEntryEntity).delete({ statusListId: savedStatusList.id })
|
|
206
|
+
await dbConnection.getRepository(StatusList2021Entity).remove(savedStatusList)
|
|
207
|
+
|
|
208
|
+
const foundEntry = await dbConnection.getRepository(StatusListEntryEntity).findOne({
|
|
209
|
+
where: {
|
|
210
|
+
statusList: statusList.id,
|
|
211
|
+
statusListIndex: entry.statusListIndex,
|
|
212
|
+
},
|
|
213
|
+
})
|
|
214
|
+
expect(foundEntry).toBeNull()
|
|
215
|
+
})
|
|
216
|
+
})
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { DataSource } from 'typeorm'
|
|
2
|
+
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
+
import { DataStoreStatusListEntities } from '../index'
|
|
4
|
+
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
|
+
import { StatusListStore } from '../statusList/StatusListStore'
|
|
6
|
+
import { IStatusList2021Entity, IStatusListEntryEntity, IOAuthStatusListEntity } from '../types'
|
|
7
|
+
import { StatusListCredentialIdMode, StatusListDriverType, StatusListType } from '@sphereon/ssi-types'
|
|
8
|
+
|
|
9
|
+
describe('Status list store tests', () => {
|
|
10
|
+
let dbConnection: DataSource
|
|
11
|
+
let statusListStore: StatusListStore
|
|
12
|
+
|
|
13
|
+
beforeEach(async () => {
|
|
14
|
+
DataSources.singleInstance().defaultDbType = 'sqlite'
|
|
15
|
+
dbConnection = await new DataSource({
|
|
16
|
+
type: 'sqlite',
|
|
17
|
+
database: ':memory:',
|
|
18
|
+
migrationsRun: false,
|
|
19
|
+
migrations: DataStoreStatusListMigrations,
|
|
20
|
+
synchronize: false,
|
|
21
|
+
entities: DataStoreStatusListEntities,
|
|
22
|
+
}).initialize()
|
|
23
|
+
await dbConnection.runMigrations()
|
|
24
|
+
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
25
|
+
statusListStore = new StatusListStore(dbConnection)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
afterEach(async () => {
|
|
29
|
+
await dbConnection.destroy()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('should store status list', async () => {
|
|
33
|
+
const statusList: IStatusList2021Entity = {
|
|
34
|
+
id: 'test-list-1',
|
|
35
|
+
correlationId: 'correlation-1',
|
|
36
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
37
|
+
length: 100000,
|
|
38
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
39
|
+
type: StatusListType.StatusList2021,
|
|
40
|
+
proofFormat: 'jwt',
|
|
41
|
+
statusPurpose: 'revocation',
|
|
42
|
+
indexingDirection: 'rightToLeft',
|
|
43
|
+
issuer: 'did:example:123',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const result = await statusListStore.addStatusList(statusList)
|
|
47
|
+
expect(result).toBeDefined()
|
|
48
|
+
expect(result.id).toEqual(statusList.id)
|
|
49
|
+
expect(result.correlationId).toEqual(statusList.correlationId)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('should store status list entry', async () => {
|
|
53
|
+
const statusList: IStatusList2021Entity = {
|
|
54
|
+
id: 'test-list-1',
|
|
55
|
+
correlationId: 'correlation-1',
|
|
56
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
57
|
+
length: 100000,
|
|
58
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
59
|
+
type: StatusListType.StatusList2021,
|
|
60
|
+
proofFormat: 'jwt',
|
|
61
|
+
statusPurpose: 'revocation',
|
|
62
|
+
indexingDirection: 'rightToLeft',
|
|
63
|
+
issuer: 'did:example:123',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
await statusListStore.addStatusList(statusList)
|
|
67
|
+
|
|
68
|
+
const entry: IStatusListEntryEntity = {
|
|
69
|
+
statusListId: statusList.id,
|
|
70
|
+
statusListIndex: 1,
|
|
71
|
+
credentialId: 'credential-1',
|
|
72
|
+
credentialHash: 'hash-1',
|
|
73
|
+
correlationId: 'correlation-1',
|
|
74
|
+
value: '1',
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const result = await statusListStore.addStatusListEntry(entry)
|
|
78
|
+
expect(result).toBeDefined()
|
|
79
|
+
expect(result.statusListIndex).toEqual(entry.statusListIndex)
|
|
80
|
+
expect(result.credentialId).toEqual(entry.credentialId)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('should store OAuth status list', async () => {
|
|
84
|
+
const statusList: IOAuthStatusListEntity = {
|
|
85
|
+
id: 'oauth-list-1',
|
|
86
|
+
correlationId: 'correlation-oauth-1',
|
|
87
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
88
|
+
length: 100000,
|
|
89
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
90
|
+
type: StatusListType.OAuthStatusList,
|
|
91
|
+
proofFormat: 'jwt',
|
|
92
|
+
bitsPerStatus: 1,
|
|
93
|
+
expiresAt: new Date('2025-01-01T00:00:00Z'),
|
|
94
|
+
issuer: 'did:example:123',
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const result = (await statusListStore.addStatusList(statusList)) as IOAuthStatusListEntity
|
|
98
|
+
expect(result).toBeDefined()
|
|
99
|
+
expect(result.id).toEqual(statusList.id)
|
|
100
|
+
expect(result.correlationId).toEqual(statusList.correlationId)
|
|
101
|
+
expect(result.bitsPerStatus).toEqual(statusList.bitsPerStatus)
|
|
102
|
+
expect(result.expiresAt).toEqual(statusList.expiresAt)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('should store and retrieve both types of status lists', async () => {
|
|
106
|
+
const statusList2021: IStatusList2021Entity = {
|
|
107
|
+
id: 'test-list-1',
|
|
108
|
+
correlationId: 'correlation-1',
|
|
109
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
110
|
+
length: 100000,
|
|
111
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
112
|
+
type: StatusListType.StatusList2021,
|
|
113
|
+
proofFormat: 'jwt',
|
|
114
|
+
statusPurpose: 'revocation',
|
|
115
|
+
indexingDirection: 'rightToLeft',
|
|
116
|
+
issuer: 'did:example:123',
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const oauthStatusList: IOAuthStatusListEntity = {
|
|
120
|
+
id: 'oauth-list-1',
|
|
121
|
+
correlationId: 'correlation-oauth-1',
|
|
122
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
123
|
+
length: 100000,
|
|
124
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
125
|
+
type: StatusListType.OAuthStatusList,
|
|
126
|
+
proofFormat: 'jwt',
|
|
127
|
+
bitsPerStatus: 1,
|
|
128
|
+
issuer: 'did:example:456',
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
await statusListStore.addStatusList(statusList2021)
|
|
132
|
+
await statusListStore.addStatusList(oauthStatusList)
|
|
133
|
+
|
|
134
|
+
const found2021 = (await statusListStore.getStatusList({ id: statusList2021.id })) as IStatusList2021Entity
|
|
135
|
+
const foundOAuth = (await statusListStore.getStatusList({ id: oauthStatusList.id })) as IOAuthStatusListEntity
|
|
136
|
+
|
|
137
|
+
expect(found2021.type).toEqual(StatusListType.StatusList2021)
|
|
138
|
+
expect(found2021.statusPurpose).toEqual('revocation')
|
|
139
|
+
expect(foundOAuth.type).toEqual(StatusListType.OAuthStatusList)
|
|
140
|
+
expect((foundOAuth as IOAuthStatusListEntity).bitsPerStatus).toEqual(1)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('should get status list by id', async () => {
|
|
144
|
+
const statusList: IStatusList2021Entity = {
|
|
145
|
+
id: 'test-list-1',
|
|
146
|
+
correlationId: 'correlation-1',
|
|
147
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
148
|
+
length: 100000,
|
|
149
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
150
|
+
type: StatusListType.StatusList2021,
|
|
151
|
+
proofFormat: 'jwt',
|
|
152
|
+
statusPurpose: 'revocation',
|
|
153
|
+
indexingDirection: 'rightToLeft',
|
|
154
|
+
issuer: 'did:example:123',
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
await statusListStore.addStatusList(statusList)
|
|
158
|
+
|
|
159
|
+
const result = await statusListStore.getStatusList({ id: statusList.id })
|
|
160
|
+
expect(result).toBeDefined()
|
|
161
|
+
expect(result.id).toEqual(statusList.id)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('should get status lists with filter', async () => {
|
|
165
|
+
const statusList1: IStatusList2021Entity = {
|
|
166
|
+
id: 'test-list-1',
|
|
167
|
+
correlationId: 'correlation-1',
|
|
168
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
169
|
+
length: 100000,
|
|
170
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
171
|
+
type: StatusListType.StatusList2021,
|
|
172
|
+
proofFormat: 'jwt',
|
|
173
|
+
statusPurpose: 'revocation',
|
|
174
|
+
indexingDirection: 'rightToLeft',
|
|
175
|
+
issuer: 'did:example:123',
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const statusList2: IStatusList2021Entity = {
|
|
179
|
+
id: 'test-list-2',
|
|
180
|
+
correlationId: 'correlation-2',
|
|
181
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
182
|
+
length: 100000,
|
|
183
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
184
|
+
type: StatusListType.StatusList2021,
|
|
185
|
+
proofFormat: 'jwt',
|
|
186
|
+
statusPurpose: 'suspension',
|
|
187
|
+
indexingDirection: 'rightToLeft',
|
|
188
|
+
issuer: 'did:example:456',
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
await statusListStore.addStatusList(statusList1)
|
|
192
|
+
await statusListStore.addStatusList(statusList2)
|
|
193
|
+
|
|
194
|
+
const result = await statusListStore.getStatusLists({
|
|
195
|
+
filter: [{ statusPurpose: 'revocation' }],
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
expect(result.length).toEqual(1)
|
|
199
|
+
expect(result[0].id).toEqual(statusList1.id)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
it('should delete status list', async () => {
|
|
203
|
+
const statusList: IStatusList2021Entity = {
|
|
204
|
+
id: 'test-list-1',
|
|
205
|
+
correlationId: 'correlation-1',
|
|
206
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
207
|
+
length: 100000,
|
|
208
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
209
|
+
type: StatusListType.StatusList2021,
|
|
210
|
+
proofFormat: 'jwt',
|
|
211
|
+
statusPurpose: 'revocation',
|
|
212
|
+
indexingDirection: 'rightToLeft',
|
|
213
|
+
issuer: 'did:example:123',
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
await statusListStore.addStatusList(statusList)
|
|
217
|
+
const entry: IStatusListEntryEntity = {
|
|
218
|
+
statusListId: statusList.id,
|
|
219
|
+
statusListIndex: 1,
|
|
220
|
+
credentialId: 'credential-1',
|
|
221
|
+
credentialHash: 'hash-1',
|
|
222
|
+
correlationId: 'correlation-1',
|
|
223
|
+
value: '1',
|
|
224
|
+
}
|
|
225
|
+
await statusListStore.addStatusListEntry(entry)
|
|
226
|
+
|
|
227
|
+
const result = await statusListStore.removeStatusList({ id: statusList.id })
|
|
228
|
+
expect(result).toEqual(true)
|
|
229
|
+
|
|
230
|
+
await expect(statusListStore.getStatusList({ id: statusList.id })).rejects.toThrow(`No status list found for id ${statusList.id}`)
|
|
231
|
+
})
|
|
232
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
+
import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
@Entity('Oid4vcStateEntity')
|
|
5
|
+
export class Oid4vcStateEntity<StateType> extends BaseEntity {
|
|
6
|
+
@PrimaryColumn({ name: 'id', type: 'varchar', nullable: false })
|
|
7
|
+
id!: string
|
|
8
|
+
|
|
9
|
+
@Column({ name: 'lookup_ids', type: 'array', nullable: true })
|
|
10
|
+
lookups?: Array<string>
|
|
11
|
+
|
|
12
|
+
@Column({ name: 'state_id', type: 'varchar', nullable: true })
|
|
13
|
+
stateId?: string
|
|
14
|
+
|
|
15
|
+
@Column({ name: 'correlation_id', type: 'varchar', nullable: true })
|
|
16
|
+
correlationId?: string
|
|
17
|
+
|
|
18
|
+
@Column({ name: 'state', type: 'json', nullable: false })
|
|
19
|
+
state!: StateType
|
|
20
|
+
|
|
21
|
+
@CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
|
|
22
|
+
createdAt!: Date
|
|
23
|
+
|
|
24
|
+
@UpdateDateColumn({ name: 'updated_at', nullable: false, type: typeOrmDateTime() })
|
|
25
|
+
updatedAt!: Date
|
|
26
|
+
|
|
27
|
+
@Column({ name: 'expires_at', nullable: true, type: typeOrmDateTime() })
|
|
28
|
+
expiresAt?: Date
|
|
29
|
+
|
|
30
|
+
@Column({ name: 'tenant_id', type: 'varchar', nullable: true })
|
|
31
|
+
tenantId?: string
|
|
32
|
+
}
|