@sphereon/ssi-sdk.data-store 0.39.0 → 0.40.0

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
@@ -11537,6 +11537,214 @@ var AddCredentialStatusFields1780000000000 = class {
11537
11537
  }
11538
11538
  };
11539
11539
 
11540
+ // src/migrations/generic/20-AddUntrustedCredentialState.ts
11541
+ var import_debug33 = __toESM(require("debug"), 1);
11542
+
11543
+ // src/migrations/postgres/1780000000011-AddUntrustedCredentialState.ts
11544
+ var AddUntrustedCredentialState1780000000011 = class {
11545
+ static {
11546
+ __name(this, "AddUntrustedCredentialState1780000000011");
11547
+ }
11548
+ name = "AddUntrustedCredentialState1780000000011";
11549
+ async up(queryRunner) {
11550
+ await queryRunner.query(`CREATE TYPE "digital_credential_state_type_v3" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED', 'UNTRUSTED')`);
11551
+ await queryRunner.query(`ALTER TABLE "DigitalCredential" ALTER COLUMN "verified_state" TYPE "digital_credential_state_type_v3" USING "verified_state"::text::"digital_credential_state_type_v3"`);
11552
+ await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
11553
+ await queryRunner.query(`ALTER TYPE "digital_credential_state_type_v3" RENAME TO "digital_credential_state_type"`);
11554
+ }
11555
+ async down(queryRunner) {
11556
+ await queryRunner.query(`UPDATE "DigitalCredential" SET "verified_state" = NULL WHERE "verified_state" = 'UNTRUSTED'`);
11557
+ await queryRunner.query(`CREATE TYPE "digital_credential_state_type_old" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED')`);
11558
+ 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"`);
11559
+ await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
11560
+ await queryRunner.query(`ALTER TYPE "digital_credential_state_type_old" RENAME TO "digital_credential_state_type"`);
11561
+ }
11562
+ };
11563
+
11564
+ // src/migrations/sqlite/1780000000012-AddUntrustedCredentialState.ts
11565
+ var AddUntrustedCredentialState1780000000012 = class {
11566
+ static {
11567
+ __name(this, "AddUntrustedCredentialState1780000000012");
11568
+ }
11569
+ name = "AddUntrustedCredentialState1780000000012";
11570
+ async up(queryRunner) {
11571
+ await queryRunner.query(`
11572
+ CREATE TABLE "DigitalCredential_new" (
11573
+ "id" varchar PRIMARY KEY NOT NULL,
11574
+ "parent_id" text,
11575
+ "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
11576
+ "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
11577
+ "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
11578
+ "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
11579
+ "raw_document" text NOT NULL,
11580
+ "uniform_document" text NOT NULL,
11581
+ "credential_id" text,
11582
+ "hash" text NOT NULL,
11583
+ "kms_key_ref" text,
11584
+ "identifier_method" text,
11585
+ "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
11586
+ "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
11587
+ "issuer_correlation_id" text NOT NULL,
11588
+ "subject_correlation_id" text,
11589
+ "issuer_signed" boolean,
11590
+ "rp_correlation_id" text,
11591
+ "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
11592
+ "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED', 'UNTRUSTED') ),
11593
+ "tenant_id" text,
11594
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
11595
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
11596
+ "presented_at" datetime,
11597
+ "valid_from" datetime,
11598
+ "valid_until" datetime,
11599
+ "verified_at" datetime,
11600
+ "revoked_at" datetime,
11601
+ "linked_vp_id" text,
11602
+ "linked_vp_from" datetime,
11603
+ "linked_vp_until" datetime,
11604
+ "status_last_checked_at" datetime,
11605
+ UNIQUE ("hash", "credential_role")
11606
+ )
11607
+ `);
11608
+ await queryRunner.query(`
11609
+ INSERT INTO "DigitalCredential_new" (
11610
+ "id","parent_id","document_type","regulation_type","document_format","credential_role",
11611
+ "raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
11612
+ "issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
11613
+ "issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
11614
+ "created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
11615
+ "linked_vp_id","linked_vp_from","linked_vp_until","status_last_checked_at"
11616
+ )
11617
+ SELECT
11618
+ "id","parent_id","document_type","regulation_type","document_format","credential_role",
11619
+ "raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
11620
+ "issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
11621
+ "issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
11622
+ "created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
11623
+ "linked_vp_id","linked_vp_from","linked_vp_until","status_last_checked_at"
11624
+ FROM "DigitalCredential"
11625
+ `);
11626
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
11627
+ await queryRunner.query(`ALTER TABLE "DigitalCredential_new" RENAME TO "DigitalCredential"`);
11628
+ }
11629
+ async down(queryRunner) {
11630
+ await queryRunner.query(`UPDATE "DigitalCredential" SET "verified_state" = NULL WHERE "verified_state" = 'UNTRUSTED'`);
11631
+ await queryRunner.query(`
11632
+ CREATE TABLE "DigitalCredential_old" (
11633
+ "id" varchar PRIMARY KEY NOT NULL,
11634
+ "parent_id" text,
11635
+ "document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
11636
+ "regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
11637
+ "document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
11638
+ "credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
11639
+ "raw_document" text NOT NULL,
11640
+ "uniform_document" text NOT NULL,
11641
+ "credential_id" text,
11642
+ "hash" text NOT NULL,
11643
+ "kms_key_ref" text,
11644
+ "identifier_method" text,
11645
+ "issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
11646
+ "subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
11647
+ "issuer_correlation_id" text NOT NULL,
11648
+ "subject_correlation_id" text,
11649
+ "issuer_signed" boolean,
11650
+ "rp_correlation_id" text,
11651
+ "rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
11652
+ "verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED') ),
11653
+ "tenant_id" text,
11654
+ "created_at" datetime NOT NULL DEFAULT (datetime('now')),
11655
+ "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
11656
+ "presented_at" datetime,
11657
+ "valid_from" datetime,
11658
+ "valid_until" datetime,
11659
+ "verified_at" datetime,
11660
+ "revoked_at" datetime,
11661
+ "linked_vp_id" text,
11662
+ "linked_vp_from" datetime,
11663
+ "linked_vp_until" datetime,
11664
+ "status_last_checked_at" datetime,
11665
+ UNIQUE ("hash", "credential_role")
11666
+ )
11667
+ `);
11668
+ await queryRunner.query(`
11669
+ INSERT INTO "DigitalCredential_old" (
11670
+ "id","parent_id","document_type","regulation_type","document_format","credential_role",
11671
+ "raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
11672
+ "issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
11673
+ "issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
11674
+ "created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
11675
+ "linked_vp_id","linked_vp_from","linked_vp_until","status_last_checked_at"
11676
+ )
11677
+ SELECT
11678
+ "id","parent_id","document_type","regulation_type","document_format","credential_role",
11679
+ "raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
11680
+ "issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
11681
+ "issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
11682
+ "created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
11683
+ "linked_vp_id","linked_vp_from","linked_vp_until","status_last_checked_at"
11684
+ FROM "DigitalCredential"
11685
+ `);
11686
+ await queryRunner.query(`DROP TABLE "DigitalCredential"`);
11687
+ await queryRunner.query(`ALTER TABLE "DigitalCredential_old" RENAME TO "DigitalCredential"`);
11688
+ }
11689
+ };
11690
+
11691
+ // src/migrations/generic/20-AddUntrustedCredentialState.ts
11692
+ var debug33 = (0, import_debug33.default)("sphereon:ssi-sdk:migrations");
11693
+ var AddUntrustedCredentialState1780000000010 = class {
11694
+ static {
11695
+ __name(this, "AddUntrustedCredentialState1780000000010");
11696
+ }
11697
+ name = "AddUntrustedCredentialState1780000000010";
11698
+ async up(queryRunner) {
11699
+ debug33("migration: widening DigitalCredential verified_state to include UNTRUSTED");
11700
+ const dbType = queryRunner.connection.driver.options.type;
11701
+ switch (dbType) {
11702
+ case "postgres": {
11703
+ debug33("using postgres migration file for AddUntrustedCredentialState");
11704
+ const mig = new AddUntrustedCredentialState1780000000011();
11705
+ await mig.up(queryRunner);
11706
+ debug33("Postgres migration statements for AddUntrustedCredentialState executed");
11707
+ return;
11708
+ }
11709
+ case "sqlite":
11710
+ case "expo":
11711
+ case "react-native": {
11712
+ debug33("using sqlite/react-native migration file for AddUntrustedCredentialState");
11713
+ const mig = new AddUntrustedCredentialState1780000000012();
11714
+ await mig.up(queryRunner);
11715
+ debug33("SQLite migration statements for AddUntrustedCredentialState executed");
11716
+ return;
11717
+ }
11718
+ default:
11719
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for AddUntrustedCredentialState. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
11720
+ }
11721
+ }
11722
+ async down(queryRunner) {
11723
+ debug33("migration: reverting DigitalCredential verified_state UNTRUSTED widening");
11724
+ const dbType = queryRunner.connection.driver.options.type;
11725
+ switch (dbType) {
11726
+ case "postgres": {
11727
+ debug33("using postgres migration file for AddUntrustedCredentialState");
11728
+ const mig = new AddUntrustedCredentialState1780000000011();
11729
+ await mig.down(queryRunner);
11730
+ debug33("Postgres migration statements for AddUntrustedCredentialState reverted");
11731
+ return;
11732
+ }
11733
+ case "sqlite":
11734
+ case "expo":
11735
+ case "react-native": {
11736
+ debug33("using sqlite/react-native migration file for AddUntrustedCredentialState");
11737
+ const mig = new AddUntrustedCredentialState1780000000012();
11738
+ await mig.down(queryRunner);
11739
+ debug33("SQLite migration statements for AddUntrustedCredentialState reverted");
11740
+ return;
11741
+ }
11742
+ default:
11743
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for AddUntrustedCredentialState. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
11744
+ }
11745
+ }
11746
+ };
11747
+
11540
11748
  // src/migrations/generic/index.ts
11541
11749
  var DataStoreContactMigrations = [
11542
11750
  CreateContacts1659463079429,
@@ -11565,7 +11773,8 @@ var DataStoreEventLoggerMigrations = [
11565
11773
  var DataStoreDigitalCredentialMigrations = [
11566
11774
  CreateDigitalCredential1708525189000,
11567
11775
  AddLinkedVpFields1763387280000,
11568
- AddCredentialStatusFields1780000000000
11776
+ AddCredentialStatusFields1780000000000,
11777
+ AddUntrustedCredentialState1780000000010
11569
11778
  ];
11570
11779
  var DataStoreMachineStateMigrations = [
11571
11780
  CreateMachineStateStore1708098041262