@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 CHANGED
@@ -2101,6 +2101,7 @@ var DigitalCredentialEntity = class extends import_typeorm17.BaseEntity {
2101
2101
  validFrom;
2102
2102
  verifiedAt;
2103
2103
  revokedAt;
2104
+ statusLastCheckedAt;
2104
2105
  };
2105
2106
  _ts_decorate18([
2106
2107
  (0, import_typeorm17.PrimaryGeneratedColumn)("uuid"),
@@ -2335,6 +2336,14 @@ _ts_decorate18([
2335
2336
  }),
2336
2337
  _ts_metadata17("design:type", typeof Date === "undefined" ? Object : Date)
2337
2338
  ], DigitalCredentialEntity.prototype, "revokedAt", void 0);
2339
+ _ts_decorate18([
2340
+ (0, import_typeorm17.Column)({
2341
+ name: "status_last_checked_at",
2342
+ nullable: true,
2343
+ type: (0, import_ssi_sdk14.typeOrmDateTime)()
2344
+ }),
2345
+ _ts_metadata17("design:type", typeof Date === "undefined" ? Object : Date)
2346
+ ], DigitalCredentialEntity.prototype, "statusLastCheckedAt", void 0);
2338
2347
  DigitalCredentialEntity = _ts_decorate18([
2339
2348
  (0, import_typeorm17.Entity)("DigitalCredential")
2340
2349
  ], DigitalCredentialEntity);
@@ -11319,6 +11328,215 @@ var AddCredentialDesigns1773657426000 = class {
11319
11328
  }
11320
11329
  };
11321
11330
 
11331
+ // src/migrations/generic/19-AddCredentialStatusFields.ts
11332
+ var import_debug32 = __toESM(require("debug"), 1);
11333
+
11334
+ // src/migrations/postgres/1780000000001-AddCredentialStatusFields.ts
11335
+ var AddCredentialStatusFields1780000000001 = class {
11336
+ static {
11337
+ __name(this, "AddCredentialStatusFields1780000000001");
11338
+ }
11339
+ name = "AddCredentialStatusFields1780000000001";
11340
+ async up(queryRunner) {
11341
+ await queryRunner.query(`ALTER TABLE "DigitalCredential" ADD COLUMN "status_last_checked_at" TIMESTAMP`);
11342
+ await queryRunner.query(`CREATE TYPE "digital_credential_state_type_v2" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED')`);
11343
+ 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"`);
11344
+ await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
11345
+ await queryRunner.query(`ALTER TYPE "digital_credential_state_type_v2" RENAME TO "digital_credential_state_type"`);
11346
+ }
11347
+ async down(queryRunner) {
11348
+ await queryRunner.query(`UPDATE "DigitalCredential" SET "verified_state" = NULL WHERE "verified_state" = 'SUSPENDED'`);
11349
+ await queryRunner.query(`CREATE TYPE "digital_credential_state_type_old" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
11350
+ 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"`);
11351
+ await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
11352
+ await queryRunner.query(`ALTER TYPE "digital_credential_state_type_old" RENAME TO "digital_credential_state_type"`);
11353
+ await queryRunner.query(`ALTER TABLE "DigitalCredential" DROP COLUMN "status_last_checked_at"`);
11354
+ }
11355
+ };
11356
+
11357
+ // src/migrations/sqlite/1780000000002-AddCredentialStatusFields.ts
11358
+ var AddCredentialStatusFields1780000000002 = class {
11359
+ static {
11360
+ __name(this, "AddCredentialStatusFields1780000000002");
11361
+ }
11362
+ name = "AddCredentialStatusFields1780000000002";
11363
+ async up(queryRunner) {
11364
+ await queryRunner.query(`
11365
+ CREATE TABLE "DigitalCredential_new" (
11366
+ "id" varchar PRIMARY KEY NOT NULL,
11367
+ "parent_id" text,
11368
+ "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
11369
+ "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
11370
+ "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
11371
+ "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
11372
+ "raw_document" text NOT NULL,
11373
+ "uniform_document" text NOT NULL,
11374
+ "credential_id" text,
11375
+ "hash" text NOT NULL,
11376
+ "kms_key_ref" text,
11377
+ "identifier_method" text,
11378
+ "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
11379
+ "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
11380
+ "issuer_correlation_id" text NOT NULL,
11381
+ "subject_correlation_id" text,
11382
+ "issuer_signed" boolean,
11383
+ "rp_correlation_id" text,
11384
+ "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
11385
+ "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED') ),
11386
+ "tenant_id" text,
11387
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
11388
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
11389
+ "presented_at" datetime,
11390
+ "valid_from" datetime,
11391
+ "valid_until" datetime,
11392
+ "verified_at" datetime,
11393
+ "revoked_at" datetime,
11394
+ "linked_vp_id" text,
11395
+ "linked_vp_from" datetime,
11396
+ "linked_vp_until" datetime,
11397
+ "status_last_checked_at" datetime,
11398
+ UNIQUE ("hash", "credential_role")
11399
+ )
11400
+ `);
11401
+ await queryRunner.query(`
11402
+ INSERT INTO "DigitalCredential_new" (
11403
+ "id","parent_id","document_type","regulation_type","document_format","credential_role",
11404
+ "raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
11405
+ "issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
11406
+ "issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
11407
+ "created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
11408
+ "linked_vp_id","linked_vp_from","linked_vp_until"
11409
+ )
11410
+ SELECT
11411
+ "id","parent_id","document_type","regulation_type","document_format","credential_role",
11412
+ "raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
11413
+ "issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
11414
+ "issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
11415
+ "created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
11416
+ "linked_vp_id","linked_vp_from","linked_vp_until"
11417
+ FROM "DigitalCredential"
11418
+ `);
11419
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
11420
+ await queryRunner.query(`ALTER TABLE "DigitalCredential_new" RENAME TO "DigitalCredential"`);
11421
+ }
11422
+ async down(queryRunner) {
11423
+ await queryRunner.query(`UPDATE "DigitalCredential" SET "verified_state" = NULL WHERE "verified_state" = 'SUSPENDED'`);
11424
+ await queryRunner.query(`
11425
+ CREATE TABLE "DigitalCredential_old" (
11426
+ "id" varchar PRIMARY KEY NOT NULL,
11427
+ "parent_id" text,
11428
+ "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
11429
+ "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
11430
+ "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
11431
+ "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
11432
+ "raw_document" text NOT NULL,
11433
+ "uniform_document" text NOT NULL,
11434
+ "credential_id" text,
11435
+ "hash" text NOT NULL,
11436
+ "kms_key_ref" text,
11437
+ "identifier_method" text,
11438
+ "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
11439
+ "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
11440
+ "issuer_correlation_id" text NOT NULL,
11441
+ "subject_correlation_id" text,
11442
+ "issuer_signed" boolean,
11443
+ "rp_correlation_id" text,
11444
+ "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
11445
+ "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
11446
+ "tenant_id" text,
11447
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
11448
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
11449
+ "presented_at" datetime,
11450
+ "valid_from" datetime,
11451
+ "valid_until" datetime,
11452
+ "verified_at" datetime,
11453
+ "revoked_at" datetime,
11454
+ "linked_vp_id" text,
11455
+ "linked_vp_from" datetime,
11456
+ "linked_vp_until" datetime,
11457
+ UNIQUE ("hash", "credential_role")
11458
+ )
11459
+ `);
11460
+ await queryRunner.query(`
11461
+ INSERT INTO "DigitalCredential_old" (
11462
+ "id","parent_id","document_type","regulation_type","document_format","credential_role",
11463
+ "raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
11464
+ "issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
11465
+ "issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
11466
+ "created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
11467
+ "linked_vp_id","linked_vp_from","linked_vp_until"
11468
+ )
11469
+ SELECT
11470
+ "id","parent_id","document_type","regulation_type","document_format","credential_role",
11471
+ "raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
11472
+ "issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
11473
+ "issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
11474
+ "created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
11475
+ "linked_vp_id","linked_vp_from","linked_vp_until"
11476
+ FROM "DigitalCredential"
11477
+ `);
11478
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
11479
+ await queryRunner.query(`ALTER TABLE "DigitalCredential_old" RENAME TO "DigitalCredential"`);
11480
+ }
11481
+ };
11482
+
11483
+ // src/migrations/generic/19-AddCredentialStatusFields.ts
11484
+ var debug32 = (0, import_debug32.default)("sphereon:ssi-sdk:migrations");
11485
+ var AddCredentialStatusFields1780000000000 = class {
11486
+ static {
11487
+ __name(this, "AddCredentialStatusFields1780000000000");
11488
+ }
11489
+ name = "AddCredentialStatusFields1780000000000";
11490
+ async up(queryRunner) {
11491
+ debug32("migration: adding credential status fields to DigitalCredential table");
11492
+ const dbType = queryRunner.connection.driver.options.type;
11493
+ switch (dbType) {
11494
+ case "postgres": {
11495
+ debug32("using postgres migration file for AddCredentialStatusFields");
11496
+ const mig = new AddCredentialStatusFields1780000000001();
11497
+ await mig.up(queryRunner);
11498
+ debug32("Postgres migration statements for AddCredentialStatusFields executed");
11499
+ return;
11500
+ }
11501
+ case "sqlite":
11502
+ case "expo":
11503
+ case "react-native": {
11504
+ debug32("using sqlite/react-native migration file for AddCredentialStatusFields");
11505
+ const mig = new AddCredentialStatusFields1780000000002();
11506
+ await mig.up(queryRunner);
11507
+ debug32("SQLite migration statements for AddCredentialStatusFields executed");
11508
+ return;
11509
+ }
11510
+ default:
11511
+ 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`);
11512
+ }
11513
+ }
11514
+ async down(queryRunner) {
11515
+ debug32("migration: reverting credential status fields from DigitalCredential table");
11516
+ const dbType = queryRunner.connection.driver.options.type;
11517
+ switch (dbType) {
11518
+ case "postgres": {
11519
+ debug32("using postgres migration file for AddCredentialStatusFields");
11520
+ const mig = new AddCredentialStatusFields1780000000001();
11521
+ await mig.down(queryRunner);
11522
+ debug32("Postgres migration statements for AddCredentialStatusFields reverted");
11523
+ return;
11524
+ }
11525
+ case "sqlite":
11526
+ case "expo":
11527
+ case "react-native": {
11528
+ debug32("using sqlite/react-native migration file for AddCredentialStatusFields");
11529
+ const mig = new AddCredentialStatusFields1780000000002();
11530
+ await mig.down(queryRunner);
11531
+ debug32("SQLite migration statements for AddCredentialStatusFields reverted");
11532
+ return;
11533
+ }
11534
+ default:
11535
+ 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`);
11536
+ }
11537
+ }
11538
+ };
11539
+
11322
11540
  // src/migrations/generic/index.ts
11323
11541
  var DataStoreContactMigrations = [
11324
11542
  CreateContacts1659463079429,
@@ -11346,7 +11564,8 @@ var DataStoreEventLoggerMigrations = [
11346
11564
  ];
11347
11565
  var DataStoreDigitalCredentialMigrations = [
11348
11566
  CreateDigitalCredential1708525189000,
11349
- AddLinkedVpFields1763387280000
11567
+ AddLinkedVpFields1763387280000,
11568
+ AddCredentialStatusFields1780000000000
11350
11569
  ];
11351
11570
  var DataStoreMachineStateMigrations = [
11352
11571
  CreateMachineStateStore1708098041262