@sphereon/ssi-sdk.data-store 0.38.1-next.3 → 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 +210 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +210 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/migrations/generic/20-AddUntrustedCredentialState.ts +66 -0
- package/src/migrations/generic/index.ts +2 -0
- package/src/migrations/postgres/1780000000011-AddUntrustedCredentialState.ts +28 -0
- package/src/migrations/sqlite/1780000000012-AddUntrustedCredentialState.ts +138 -0
package/dist/index.js
CHANGED
|
@@ -11371,6 +11371,214 @@ var AddCredentialStatusFields1780000000000 = class {
|
|
|
11371
11371
|
}
|
|
11372
11372
|
};
|
|
11373
11373
|
|
|
11374
|
+
// src/migrations/generic/20-AddUntrustedCredentialState.ts
|
|
11375
|
+
import Debug33 from "debug";
|
|
11376
|
+
|
|
11377
|
+
// src/migrations/postgres/1780000000011-AddUntrustedCredentialState.ts
|
|
11378
|
+
var AddUntrustedCredentialState1780000000011 = class {
|
|
11379
|
+
static {
|
|
11380
|
+
__name(this, "AddUntrustedCredentialState1780000000011");
|
|
11381
|
+
}
|
|
11382
|
+
name = "AddUntrustedCredentialState1780000000011";
|
|
11383
|
+
async up(queryRunner) {
|
|
11384
|
+
await queryRunner.query(`CREATE TYPE "digital_credential_state_type_v3" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED', 'UNTRUSTED')`);
|
|
11385
|
+
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"`);
|
|
11386
|
+
await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
|
|
11387
|
+
await queryRunner.query(`ALTER TYPE "digital_credential_state_type_v3" RENAME TO "digital_credential_state_type"`);
|
|
11388
|
+
}
|
|
11389
|
+
async down(queryRunner) {
|
|
11390
|
+
await queryRunner.query(`UPDATE "DigitalCredential" SET "verified_state" = NULL WHERE "verified_state" = 'UNTRUSTED'`);
|
|
11391
|
+
await queryRunner.query(`CREATE TYPE "digital_credential_state_type_old" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED')`);
|
|
11392
|
+
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"`);
|
|
11393
|
+
await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
|
|
11394
|
+
await queryRunner.query(`ALTER TYPE "digital_credential_state_type_old" RENAME TO "digital_credential_state_type"`);
|
|
11395
|
+
}
|
|
11396
|
+
};
|
|
11397
|
+
|
|
11398
|
+
// src/migrations/sqlite/1780000000012-AddUntrustedCredentialState.ts
|
|
11399
|
+
var AddUntrustedCredentialState1780000000012 = class {
|
|
11400
|
+
static {
|
|
11401
|
+
__name(this, "AddUntrustedCredentialState1780000000012");
|
|
11402
|
+
}
|
|
11403
|
+
name = "AddUntrustedCredentialState1780000000012";
|
|
11404
|
+
async up(queryRunner) {
|
|
11405
|
+
await queryRunner.query(`
|
|
11406
|
+
CREATE TABLE "DigitalCredential_new" (
|
|
11407
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
11408
|
+
"parent_id" text,
|
|
11409
|
+
"document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
|
|
11410
|
+
"regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
|
|
11411
|
+
"document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
|
|
11412
|
+
"credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
|
|
11413
|
+
"raw_document" text NOT NULL,
|
|
11414
|
+
"uniform_document" text NOT NULL,
|
|
11415
|
+
"credential_id" text,
|
|
11416
|
+
"hash" text NOT NULL,
|
|
11417
|
+
"kms_key_ref" text,
|
|
11418
|
+
"identifier_method" text,
|
|
11419
|
+
"issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
|
|
11420
|
+
"subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
11421
|
+
"issuer_correlation_id" text NOT NULL,
|
|
11422
|
+
"subject_correlation_id" text,
|
|
11423
|
+
"issuer_signed" boolean,
|
|
11424
|
+
"rp_correlation_id" text,
|
|
11425
|
+
"rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
11426
|
+
"verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED', 'UNTRUSTED') ),
|
|
11427
|
+
"tenant_id" text,
|
|
11428
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
11429
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
11430
|
+
"presented_at" datetime,
|
|
11431
|
+
"valid_from" datetime,
|
|
11432
|
+
"valid_until" datetime,
|
|
11433
|
+
"verified_at" datetime,
|
|
11434
|
+
"revoked_at" datetime,
|
|
11435
|
+
"linked_vp_id" text,
|
|
11436
|
+
"linked_vp_from" datetime,
|
|
11437
|
+
"linked_vp_until" datetime,
|
|
11438
|
+
"status_last_checked_at" datetime,
|
|
11439
|
+
UNIQUE ("hash", "credential_role")
|
|
11440
|
+
)
|
|
11441
|
+
`);
|
|
11442
|
+
await queryRunner.query(`
|
|
11443
|
+
INSERT INTO "DigitalCredential_new" (
|
|
11444
|
+
"id","parent_id","document_type","regulation_type","document_format","credential_role",
|
|
11445
|
+
"raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
|
|
11446
|
+
"issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
|
|
11447
|
+
"issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
|
|
11448
|
+
"created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
|
|
11449
|
+
"linked_vp_id","linked_vp_from","linked_vp_until","status_last_checked_at"
|
|
11450
|
+
)
|
|
11451
|
+
SELECT
|
|
11452
|
+
"id","parent_id","document_type","regulation_type","document_format","credential_role",
|
|
11453
|
+
"raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
|
|
11454
|
+
"issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
|
|
11455
|
+
"issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
|
|
11456
|
+
"created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
|
|
11457
|
+
"linked_vp_id","linked_vp_from","linked_vp_until","status_last_checked_at"
|
|
11458
|
+
FROM "DigitalCredential"
|
|
11459
|
+
`);
|
|
11460
|
+
await queryRunner.query(`DROP TABLE "DigitalCredential"`);
|
|
11461
|
+
await queryRunner.query(`ALTER TABLE "DigitalCredential_new" RENAME TO "DigitalCredential"`);
|
|
11462
|
+
}
|
|
11463
|
+
async down(queryRunner) {
|
|
11464
|
+
await queryRunner.query(`UPDATE "DigitalCredential" SET "verified_state" = NULL WHERE "verified_state" = 'UNTRUSTED'`);
|
|
11465
|
+
await queryRunner.query(`
|
|
11466
|
+
CREATE TABLE "DigitalCredential_old" (
|
|
11467
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
11468
|
+
"parent_id" text,
|
|
11469
|
+
"document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
|
|
11470
|
+
"regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
|
|
11471
|
+
"document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
|
|
11472
|
+
"credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
|
|
11473
|
+
"raw_document" text NOT NULL,
|
|
11474
|
+
"uniform_document" text NOT NULL,
|
|
11475
|
+
"credential_id" text,
|
|
11476
|
+
"hash" text NOT NULL,
|
|
11477
|
+
"kms_key_ref" text,
|
|
11478
|
+
"identifier_method" text,
|
|
11479
|
+
"issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
|
|
11480
|
+
"subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
11481
|
+
"issuer_correlation_id" text NOT NULL,
|
|
11482
|
+
"subject_correlation_id" text,
|
|
11483
|
+
"issuer_signed" boolean,
|
|
11484
|
+
"rp_correlation_id" text,
|
|
11485
|
+
"rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
11486
|
+
"verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED', 'SUSPENDED') ),
|
|
11487
|
+
"tenant_id" text,
|
|
11488
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
11489
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
11490
|
+
"presented_at" datetime,
|
|
11491
|
+
"valid_from" datetime,
|
|
11492
|
+
"valid_until" datetime,
|
|
11493
|
+
"verified_at" datetime,
|
|
11494
|
+
"revoked_at" datetime,
|
|
11495
|
+
"linked_vp_id" text,
|
|
11496
|
+
"linked_vp_from" datetime,
|
|
11497
|
+
"linked_vp_until" datetime,
|
|
11498
|
+
"status_last_checked_at" datetime,
|
|
11499
|
+
UNIQUE ("hash", "credential_role")
|
|
11500
|
+
)
|
|
11501
|
+
`);
|
|
11502
|
+
await queryRunner.query(`
|
|
11503
|
+
INSERT INTO "DigitalCredential_old" (
|
|
11504
|
+
"id","parent_id","document_type","regulation_type","document_format","credential_role",
|
|
11505
|
+
"raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
|
|
11506
|
+
"issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
|
|
11507
|
+
"issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
|
|
11508
|
+
"created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
|
|
11509
|
+
"linked_vp_id","linked_vp_from","linked_vp_until","status_last_checked_at"
|
|
11510
|
+
)
|
|
11511
|
+
SELECT
|
|
11512
|
+
"id","parent_id","document_type","regulation_type","document_format","credential_role",
|
|
11513
|
+
"raw_document","uniform_document","credential_id","hash","kms_key_ref","identifier_method",
|
|
11514
|
+
"issuer_correlation_type","subject_correlation_type","issuer_correlation_id","subject_correlation_id",
|
|
11515
|
+
"issuer_signed","rp_correlation_id","rp_correlation_type","verified_state","tenant_id",
|
|
11516
|
+
"created_at","last_updated_at","presented_at","valid_from","valid_until","verified_at","revoked_at",
|
|
11517
|
+
"linked_vp_id","linked_vp_from","linked_vp_until","status_last_checked_at"
|
|
11518
|
+
FROM "DigitalCredential"
|
|
11519
|
+
`);
|
|
11520
|
+
await queryRunner.query(`DROP TABLE "DigitalCredential"`);
|
|
11521
|
+
await queryRunner.query(`ALTER TABLE "DigitalCredential_old" RENAME TO "DigitalCredential"`);
|
|
11522
|
+
}
|
|
11523
|
+
};
|
|
11524
|
+
|
|
11525
|
+
// src/migrations/generic/20-AddUntrustedCredentialState.ts
|
|
11526
|
+
var debug33 = Debug33("sphereon:ssi-sdk:migrations");
|
|
11527
|
+
var AddUntrustedCredentialState1780000000010 = class {
|
|
11528
|
+
static {
|
|
11529
|
+
__name(this, "AddUntrustedCredentialState1780000000010");
|
|
11530
|
+
}
|
|
11531
|
+
name = "AddUntrustedCredentialState1780000000010";
|
|
11532
|
+
async up(queryRunner) {
|
|
11533
|
+
debug33("migration: widening DigitalCredential verified_state to include UNTRUSTED");
|
|
11534
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
11535
|
+
switch (dbType) {
|
|
11536
|
+
case "postgres": {
|
|
11537
|
+
debug33("using postgres migration file for AddUntrustedCredentialState");
|
|
11538
|
+
const mig = new AddUntrustedCredentialState1780000000011();
|
|
11539
|
+
await mig.up(queryRunner);
|
|
11540
|
+
debug33("Postgres migration statements for AddUntrustedCredentialState executed");
|
|
11541
|
+
return;
|
|
11542
|
+
}
|
|
11543
|
+
case "sqlite":
|
|
11544
|
+
case "expo":
|
|
11545
|
+
case "react-native": {
|
|
11546
|
+
debug33("using sqlite/react-native migration file for AddUntrustedCredentialState");
|
|
11547
|
+
const mig = new AddUntrustedCredentialState1780000000012();
|
|
11548
|
+
await mig.up(queryRunner);
|
|
11549
|
+
debug33("SQLite migration statements for AddUntrustedCredentialState executed");
|
|
11550
|
+
return;
|
|
11551
|
+
}
|
|
11552
|
+
default:
|
|
11553
|
+
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`);
|
|
11554
|
+
}
|
|
11555
|
+
}
|
|
11556
|
+
async down(queryRunner) {
|
|
11557
|
+
debug33("migration: reverting DigitalCredential verified_state UNTRUSTED widening");
|
|
11558
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
11559
|
+
switch (dbType) {
|
|
11560
|
+
case "postgres": {
|
|
11561
|
+
debug33("using postgres migration file for AddUntrustedCredentialState");
|
|
11562
|
+
const mig = new AddUntrustedCredentialState1780000000011();
|
|
11563
|
+
await mig.down(queryRunner);
|
|
11564
|
+
debug33("Postgres migration statements for AddUntrustedCredentialState reverted");
|
|
11565
|
+
return;
|
|
11566
|
+
}
|
|
11567
|
+
case "sqlite":
|
|
11568
|
+
case "expo":
|
|
11569
|
+
case "react-native": {
|
|
11570
|
+
debug33("using sqlite/react-native migration file for AddUntrustedCredentialState");
|
|
11571
|
+
const mig = new AddUntrustedCredentialState1780000000012();
|
|
11572
|
+
await mig.down(queryRunner);
|
|
11573
|
+
debug33("SQLite migration statements for AddUntrustedCredentialState reverted");
|
|
11574
|
+
return;
|
|
11575
|
+
}
|
|
11576
|
+
default:
|
|
11577
|
+
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`);
|
|
11578
|
+
}
|
|
11579
|
+
}
|
|
11580
|
+
};
|
|
11581
|
+
|
|
11374
11582
|
// src/migrations/generic/index.ts
|
|
11375
11583
|
var DataStoreContactMigrations = [
|
|
11376
11584
|
CreateContacts1659463079429,
|
|
@@ -11399,7 +11607,8 @@ var DataStoreEventLoggerMigrations = [
|
|
|
11399
11607
|
var DataStoreDigitalCredentialMigrations = [
|
|
11400
11608
|
CreateDigitalCredential1708525189000,
|
|
11401
11609
|
AddLinkedVpFields1763387280000,
|
|
11402
|
-
AddCredentialStatusFields1780000000000
|
|
11610
|
+
AddCredentialStatusFields1780000000000,
|
|
11611
|
+
AddUntrustedCredentialState1780000000010
|
|
11403
11612
|
];
|
|
11404
11613
|
var DataStoreMachineStateMigrations = [
|
|
11405
11614
|
CreateMachineStateStore1708098041262
|