@sphereon/ssi-sdk.data-store 0.38.0 → 0.38.1-next.3
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 +220 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +220 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/digitalCredential.store.test.ts +26 -0
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +3 -0
- package/src/migrations/generic/19-AddCredentialStatusFields.ts +66 -0
- package/src/migrations/generic/index.ts +6 -1
- package/src/migrations/postgres/1780000000001-AddCredentialStatusFields.ts +30 -0
- package/src/migrations/sqlite/1780000000002-AddCredentialStatusFields.ts +137 -0
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1935,6 +1935,7 @@ var DigitalCredentialEntity = class extends BaseEntity11 {
|
|
|
1935
1935
|
validFrom;
|
|
1936
1936
|
verifiedAt;
|
|
1937
1937
|
revokedAt;
|
|
1938
|
+
statusLastCheckedAt;
|
|
1938
1939
|
};
|
|
1939
1940
|
_ts_decorate18([
|
|
1940
1941
|
PrimaryGeneratedColumn13("uuid"),
|
|
@@ -2169,6 +2170,14 @@ _ts_decorate18([
|
|
|
2169
2170
|
}),
|
|
2170
2171
|
_ts_metadata17("design:type", typeof Date === "undefined" ? Object : Date)
|
|
2171
2172
|
], DigitalCredentialEntity.prototype, "revokedAt", void 0);
|
|
2173
|
+
_ts_decorate18([
|
|
2174
|
+
Column15({
|
|
2175
|
+
name: "status_last_checked_at",
|
|
2176
|
+
nullable: true,
|
|
2177
|
+
type: typeOrmDateTime10()
|
|
2178
|
+
}),
|
|
2179
|
+
_ts_metadata17("design:type", typeof Date === "undefined" ? Object : Date)
|
|
2180
|
+
], DigitalCredentialEntity.prototype, "statusLastCheckedAt", void 0);
|
|
2172
2181
|
DigitalCredentialEntity = _ts_decorate18([
|
|
2173
2182
|
Entity13("DigitalCredential")
|
|
2174
2183
|
], DigitalCredentialEntity);
|
|
@@ -11153,6 +11162,215 @@ var AddCredentialDesigns1773657426000 = class {
|
|
|
11153
11162
|
}
|
|
11154
11163
|
};
|
|
11155
11164
|
|
|
11165
|
+
// src/migrations/generic/19-AddCredentialStatusFields.ts
|
|
11166
|
+
import Debug32 from "debug";
|
|
11167
|
+
|
|
11168
|
+
// src/migrations/postgres/1780000000001-AddCredentialStatusFields.ts
|
|
11169
|
+
var AddCredentialStatusFields1780000000001 = class {
|
|
11170
|
+
static {
|
|
11171
|
+
__name(this, "AddCredentialStatusFields1780000000001");
|
|
11172
|
+
}
|
|
11173
|
+
name = "AddCredentialStatusFields1780000000001";
|
|
11174
|
+
async up(queryRunner) {
|
|
11175
|
+
await queryRunner.query(`ALTER TABLE "DigitalCredential" ADD COLUMN "status_last_checked_at" TIMESTAMP`);
|
|
11176
|
+
await queryRunner.query(`CREATE TYPE "digital_credential_state_type_v2" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED')`);
|
|
11177
|
+
await queryRunner.query(`ALTER TABLE "DigitalCredential" ALTER COLUMN "verified_state" TYPE "digital_credential_state_type_v2" USING "verified_state"::text::"digital_credential_state_type_v2"`);
|
|
11178
|
+
await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
|
|
11179
|
+
await queryRunner.query(`ALTER TYPE "digital_credential_state_type_v2" RENAME TO "digital_credential_state_type"`);
|
|
11180
|
+
}
|
|
11181
|
+
async down(queryRunner) {
|
|
11182
|
+
await queryRunner.query(`UPDATE "DigitalCredential" SET "verified_state" = NULL WHERE "verified_state" = 'SUSPENDED'`);
|
|
11183
|
+
await queryRunner.query(`CREATE TYPE "digital_credential_state_type_old" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
|
|
11184
|
+
await queryRunner.query(`ALTER TABLE "DigitalCredential" ALTER COLUMN "verified_state" TYPE "digital_credential_state_type_old" USING "verified_state"::text::"digital_credential_state_type_old"`);
|
|
11185
|
+
await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
|
|
11186
|
+
await queryRunner.query(`ALTER TYPE "digital_credential_state_type_old" RENAME TO "digital_credential_state_type"`);
|
|
11187
|
+
await queryRunner.query(`ALTER TABLE "DigitalCredential" DROP COLUMN "status_last_checked_at"`);
|
|
11188
|
+
}
|
|
11189
|
+
};
|
|
11190
|
+
|
|
11191
|
+
// src/migrations/sqlite/1780000000002-AddCredentialStatusFields.ts
|
|
11192
|
+
var AddCredentialStatusFields1780000000002 = class {
|
|
11193
|
+
static {
|
|
11194
|
+
__name(this, "AddCredentialStatusFields1780000000002");
|
|
11195
|
+
}
|
|
11196
|
+
name = "AddCredentialStatusFields1780000000002";
|
|
11197
|
+
async up(queryRunner) {
|
|
11198
|
+
await queryRunner.query(`
|
|
11199
|
+
CREATE TABLE "DigitalCredential_new" (
|
|
11200
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
11201
|
+
"parent_id" text,
|
|
11202
|
+
"document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
|
|
11203
|
+
"regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
|
|
11204
|
+
"document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
|
|
11205
|
+
"credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
|
|
11206
|
+
"raw_document" text NOT NULL,
|
|
11207
|
+
"uniform_document" text NOT NULL,
|
|
11208
|
+
"credential_id" text,
|
|
11209
|
+
"hash" text NOT NULL,
|
|
11210
|
+
"kms_key_ref" text,
|
|
11211
|
+
"identifier_method" text,
|
|
11212
|
+
"issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
|
|
11213
|
+
"subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
11214
|
+
"issuer_correlation_id" text NOT NULL,
|
|
11215
|
+
"subject_correlation_id" text,
|
|
11216
|
+
"issuer_signed" boolean,
|
|
11217
|
+
"rp_correlation_id" text,
|
|
11218
|
+
"rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
11219
|
+
"verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED') ),
|
|
11220
|
+
"tenant_id" text,
|
|
11221
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
11222
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
11223
|
+
"presented_at" datetime,
|
|
11224
|
+
"valid_from" datetime,
|
|
11225
|
+
"valid_until" datetime,
|
|
11226
|
+
"verified_at" datetime,
|
|
11227
|
+
"revoked_at" datetime,
|
|
11228
|
+
"linked_vp_id" text,
|
|
11229
|
+
"linked_vp_from" datetime,
|
|
11230
|
+
"linked_vp_until" datetime,
|
|
11231
|
+
"status_last_checked_at" datetime,
|
|
11232
|
+
UNIQUE ("hash", "credential_role")
|
|
11233
|
+
)
|
|
11234
|
+
`);
|
|
11235
|
+
await queryRunner.query(`
|
|
11236
|
+
INSERT INTO "DigitalCredential_new" (
|
|
11237
|
+
"id","parent_id","document_type","regulation_type","document_format","credential_role",
|
|
11238
|
+
"raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
|
|
11239
|
+
"issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
|
|
11240
|
+
"issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
|
|
11241
|
+
"created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
|
|
11242
|
+
"linked_vp_id","linked_vp_from","linked_vp_until"
|
|
11243
|
+
)
|
|
11244
|
+
SELECT
|
|
11245
|
+
"id","parent_id","document_type","regulation_type","document_format","credential_role",
|
|
11246
|
+
"raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
|
|
11247
|
+
"issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
|
|
11248
|
+
"issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
|
|
11249
|
+
"created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
|
|
11250
|
+
"linked_vp_id","linked_vp_from","linked_vp_until"
|
|
11251
|
+
FROM "DigitalCredential"
|
|
11252
|
+
`);
|
|
11253
|
+
await queryRunner.query(`DROP TABLE "DigitalCredential"`);
|
|
11254
|
+
await queryRunner.query(`ALTER TABLE "DigitalCredential_new" RENAME TO "DigitalCredential"`);
|
|
11255
|
+
}
|
|
11256
|
+
async down(queryRunner) {
|
|
11257
|
+
await queryRunner.query(`UPDATE "DigitalCredential" SET "verified_state" = NULL WHERE "verified_state" = 'SUSPENDED'`);
|
|
11258
|
+
await queryRunner.query(`
|
|
11259
|
+
CREATE TABLE "DigitalCredential_old" (
|
|
11260
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
11261
|
+
"parent_id" text,
|
|
11262
|
+
"document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
|
|
11263
|
+
"regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
|
|
11264
|
+
"document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
|
|
11265
|
+
"credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
|
|
11266
|
+
"raw_document" text NOT NULL,
|
|
11267
|
+
"uniform_document" text NOT NULL,
|
|
11268
|
+
"credential_id" text,
|
|
11269
|
+
"hash" text NOT NULL,
|
|
11270
|
+
"kms_key_ref" text,
|
|
11271
|
+
"identifier_method" text,
|
|
11272
|
+
"issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
|
|
11273
|
+
"subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
11274
|
+
"issuer_correlation_id" text NOT NULL,
|
|
11275
|
+
"subject_correlation_id" text,
|
|
11276
|
+
"issuer_signed" boolean,
|
|
11277
|
+
"rp_correlation_id" text,
|
|
11278
|
+
"rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
11279
|
+
"verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
|
|
11280
|
+
"tenant_id" text,
|
|
11281
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
11282
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
11283
|
+
"presented_at" datetime,
|
|
11284
|
+
"valid_from" datetime,
|
|
11285
|
+
"valid_until" datetime,
|
|
11286
|
+
"verified_at" datetime,
|
|
11287
|
+
"revoked_at" datetime,
|
|
11288
|
+
"linked_vp_id" text,
|
|
11289
|
+
"linked_vp_from" datetime,
|
|
11290
|
+
"linked_vp_until" datetime,
|
|
11291
|
+
UNIQUE ("hash", "credential_role")
|
|
11292
|
+
)
|
|
11293
|
+
`);
|
|
11294
|
+
await queryRunner.query(`
|
|
11295
|
+
INSERT INTO "DigitalCredential_old" (
|
|
11296
|
+
"id","parent_id","document_type","regulation_type","document_format","credential_role",
|
|
11297
|
+
"raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
|
|
11298
|
+
"issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
|
|
11299
|
+
"issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
|
|
11300
|
+
"created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
|
|
11301
|
+
"linked_vp_id","linked_vp_from","linked_vp_until"
|
|
11302
|
+
)
|
|
11303
|
+
SELECT
|
|
11304
|
+
"id","parent_id","document_type","regulation_type","document_format","credential_role",
|
|
11305
|
+
"raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
|
|
11306
|
+
"issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
|
|
11307
|
+
"issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
|
|
11308
|
+
"created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
|
|
11309
|
+
"linked_vp_id","linked_vp_from","linked_vp_until"
|
|
11310
|
+
FROM "DigitalCredential"
|
|
11311
|
+
`);
|
|
11312
|
+
await queryRunner.query(`DROP TABLE "DigitalCredential"`);
|
|
11313
|
+
await queryRunner.query(`ALTER TABLE "DigitalCredential_old" RENAME TO "DigitalCredential"`);
|
|
11314
|
+
}
|
|
11315
|
+
};
|
|
11316
|
+
|
|
11317
|
+
// src/migrations/generic/19-AddCredentialStatusFields.ts
|
|
11318
|
+
var debug32 = Debug32("sphereon:ssi-sdk:migrations");
|
|
11319
|
+
var AddCredentialStatusFields1780000000000 = class {
|
|
11320
|
+
static {
|
|
11321
|
+
__name(this, "AddCredentialStatusFields1780000000000");
|
|
11322
|
+
}
|
|
11323
|
+
name = "AddCredentialStatusFields1780000000000";
|
|
11324
|
+
async up(queryRunner) {
|
|
11325
|
+
debug32("migration: adding credential status fields to DigitalCredential table");
|
|
11326
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
11327
|
+
switch (dbType) {
|
|
11328
|
+
case "postgres": {
|
|
11329
|
+
debug32("using postgres migration file for AddCredentialStatusFields");
|
|
11330
|
+
const mig = new AddCredentialStatusFields1780000000001();
|
|
11331
|
+
await mig.up(queryRunner);
|
|
11332
|
+
debug32("Postgres migration statements for AddCredentialStatusFields executed");
|
|
11333
|
+
return;
|
|
11334
|
+
}
|
|
11335
|
+
case "sqlite":
|
|
11336
|
+
case "expo":
|
|
11337
|
+
case "react-native": {
|
|
11338
|
+
debug32("using sqlite/react-native migration file for AddCredentialStatusFields");
|
|
11339
|
+
const mig = new AddCredentialStatusFields1780000000002();
|
|
11340
|
+
await mig.up(queryRunner);
|
|
11341
|
+
debug32("SQLite migration statements for AddCredentialStatusFields executed");
|
|
11342
|
+
return;
|
|
11343
|
+
}
|
|
11344
|
+
default:
|
|
11345
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for AddCredentialStatusFields. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
11346
|
+
}
|
|
11347
|
+
}
|
|
11348
|
+
async down(queryRunner) {
|
|
11349
|
+
debug32("migration: reverting credential status fields from DigitalCredential table");
|
|
11350
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
11351
|
+
switch (dbType) {
|
|
11352
|
+
case "postgres": {
|
|
11353
|
+
debug32("using postgres migration file for AddCredentialStatusFields");
|
|
11354
|
+
const mig = new AddCredentialStatusFields1780000000001();
|
|
11355
|
+
await mig.down(queryRunner);
|
|
11356
|
+
debug32("Postgres migration statements for AddCredentialStatusFields reverted");
|
|
11357
|
+
return;
|
|
11358
|
+
}
|
|
11359
|
+
case "sqlite":
|
|
11360
|
+
case "expo":
|
|
11361
|
+
case "react-native": {
|
|
11362
|
+
debug32("using sqlite/react-native migration file for AddCredentialStatusFields");
|
|
11363
|
+
const mig = new AddCredentialStatusFields1780000000002();
|
|
11364
|
+
await mig.down(queryRunner);
|
|
11365
|
+
debug32("SQLite migration statements for AddCredentialStatusFields reverted");
|
|
11366
|
+
return;
|
|
11367
|
+
}
|
|
11368
|
+
default:
|
|
11369
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for AddCredentialStatusFields. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
11370
|
+
}
|
|
11371
|
+
}
|
|
11372
|
+
};
|
|
11373
|
+
|
|
11156
11374
|
// src/migrations/generic/index.ts
|
|
11157
11375
|
var DataStoreContactMigrations = [
|
|
11158
11376
|
CreateContacts1659463079429,
|
|
@@ -11180,7 +11398,8 @@ var DataStoreEventLoggerMigrations = [
|
|
|
11180
11398
|
];
|
|
11181
11399
|
var DataStoreDigitalCredentialMigrations = [
|
|
11182
11400
|
CreateDigitalCredential1708525189000,
|
|
11183
|
-
AddLinkedVpFields1763387280000
|
|
11401
|
+
AddLinkedVpFields1763387280000,
|
|
11402
|
+
AddCredentialStatusFields1780000000000
|
|
11184
11403
|
];
|
|
11185
11404
|
var DataStoreMachineStateMigrations = [
|
|
11186
11405
|
CreateMachineStateStore1708098041262
|