@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.78.280 → 0.34.1-feature.SSISDK.82.and.SSISDK.70.345

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
@@ -133,6 +133,7 @@ __export(index_exports, {
133
133
  naturalPersonEntityFrom: () => naturalPersonEntityFrom,
134
134
  naturalPersonFrom: () => naturalPersonFrom,
135
135
  nonPersistedDigitalCredentialEntityFromAddArgs: () => nonPersistedDigitalCredentialEntityFromAddArgs,
136
+ normalizeNullableFields: () => normalizeNullableFields,
136
137
  openIdConfigEntityFrom: () => openIdConfigEntityFrom,
137
138
  openIdConfigFrom: () => openIdConfigFrom,
138
139
  organizationEntityFrom: () => organizationEntityFrom,
@@ -144,6 +145,8 @@ __export(index_exports, {
144
145
  partyRelationshipFrom: () => partyRelationshipFrom,
145
146
  partyTypeEntityFrom: () => partyTypeEntityFrom,
146
147
  partyTypeFrom: () => partyTypeFrom,
148
+ persistedDigitalCredentialEntityFromStateArgs: () => persistedDigitalCredentialEntityFromStateArgs,
149
+ persistedDigitalCredentialEntityFromUpdateArgs: () => persistedDigitalCredentialEntityFromUpdateArgs,
147
150
  physicalAddressEntityFrom: () => physicalAddressEntityFrom,
148
151
  physicalAddressFrom: () => physicalAddressFrom,
149
152
  textAttributesEntityFrom: () => textAttributesEntityFrom
@@ -2071,6 +2074,8 @@ var DigitalCredentialEntity = class extends import_typeorm17.BaseEntity {
2071
2074
  rpCorrelationId;
2072
2075
  verifiedState;
2073
2076
  tenantId;
2077
+ linkedVpId;
2078
+ linkedVpFrom;
2074
2079
  createdAt;
2075
2080
  presentedAt;
2076
2081
  lastUpdatedAt;
@@ -2233,6 +2238,21 @@ _ts_decorate18([
2233
2238
  }),
2234
2239
  _ts_metadata17("design:type", String)
2235
2240
  ], DigitalCredentialEntity.prototype, "tenantId", void 0);
2241
+ _ts_decorate18([
2242
+ (0, import_typeorm17.Column)("text", {
2243
+ name: "linked_vp_id",
2244
+ nullable: true
2245
+ }),
2246
+ _ts_metadata17("design:type", String)
2247
+ ], DigitalCredentialEntity.prototype, "linkedVpId", void 0);
2248
+ _ts_decorate18([
2249
+ (0, import_typeorm17.CreateDateColumn)({
2250
+ name: "linked_vp_from",
2251
+ nullable: true,
2252
+ type: (0, import_ssi_sdk14.typeOrmDateTime)()
2253
+ }),
2254
+ _ts_metadata17("design:type", typeof Date === "undefined" ? Object : Date)
2255
+ ], DigitalCredentialEntity.prototype, "linkedVpFrom", void 0);
2236
2256
  _ts_decorate18([
2237
2257
  (0, import_typeorm17.CreateDateColumn)({
2238
2258
  name: "created_at",
@@ -5430,6 +5450,34 @@ var DigitalCredentialStore = class extends import_ssi_sdk26.AbstractDigitalCrede
5430
5450
  total
5431
5451
  };
5432
5452
  }, "getCredentials");
5453
+ updateCredential = /* @__PURE__ */ __name(async (args) => {
5454
+ const dcRepo = await this.getRepository();
5455
+ const whereClause = {};
5456
+ if ("id" in args) {
5457
+ whereClause.id = args.id;
5458
+ } else if ("hash" in args) {
5459
+ whereClause.hash = args.hash;
5460
+ } else {
5461
+ return Promise.reject(Error("No id or hash param is provided."));
5462
+ }
5463
+ const credential = await dcRepo.findOne({
5464
+ where: whereClause
5465
+ });
5466
+ if (!credential) {
5467
+ return Promise.reject(Error(`No credential found for args: ${JSON.stringify(whereClause)}`));
5468
+ }
5469
+ const updates = Object.fromEntries(Object.entries(args).filter(([key]) => key !== "id" && key !== "hash"));
5470
+ const entityToSave = persistedDigitalCredentialEntityFromUpdateArgs(credential, updates);
5471
+ const validationError = this.assertValidDigitalCredential(entityToSave);
5472
+ if (validationError) {
5473
+ return Promise.reject(validationError);
5474
+ }
5475
+ debug2("Updating credential", entityToSave);
5476
+ const updatedResult = await dcRepo.save(entityToSave, {
5477
+ transaction: true
5478
+ });
5479
+ return digitalCredentialFrom(updatedResult);
5480
+ }, "updateCredential");
5433
5481
  removeCredential = /* @__PURE__ */ __name(async (args) => {
5434
5482
  if (!args) {
5435
5483
  return false;
@@ -5500,20 +5548,9 @@ var DigitalCredentialStore = class extends import_ssi_sdk26.AbstractDigitalCrede
5500
5548
  if (!credential) {
5501
5549
  return Promise.reject(Error(`No credential found for args: ${JSON.stringify(whereClause)}`));
5502
5550
  }
5503
- const updatedCredential = {
5504
- ...credential,
5505
- ...args.verifiedState !== import_ssi_sdk26.CredentialStateType.REVOKED && {
5506
- verifiedAt: args.verifiedAt
5507
- },
5508
- ...args.verifiedState === import_ssi_sdk26.CredentialStateType.REVOKED && {
5509
- revokedAt: args.revokedAt
5510
- },
5511
- identifierMethod: credential.identifierMethod,
5512
- lastUpdatedAt: /* @__PURE__ */ new Date(),
5513
- verifiedState: args.verifiedState
5514
- };
5515
- debug2("Updating credential", credential);
5516
- const updatedResult = await credentialRepository.save(updatedCredential, {
5551
+ const entityToSave = persistedDigitalCredentialEntityFromStateArgs(credential, args);
5552
+ debug2("Updating credential state", entityToSave);
5553
+ const updatedResult = await credentialRepository.save(entityToSave, {
5517
5554
  transaction: true
5518
5555
  });
5519
5556
  return digitalCredentialFrom(updatedResult);
@@ -7560,6 +7597,7 @@ var CreateBitstringStatusListPG1741895823000 = class {
7560
7597
  await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`);
7561
7598
  await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "type" character varying NOT NULL DEFAULT 'StatusListEntryEntity'`);
7562
7599
  await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`);
7600
+ await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "bitsPerStatus" integer DEFAULT 1`);
7563
7601
  await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`);
7564
7602
  await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`);
7565
7603
  await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD CONSTRAINT "CHK_StatusListEntry_type" CHECK ("type" IN ('StatusListEntryEntity', 'bitstring'))`);
@@ -7897,32 +7935,148 @@ var CreateDcqlQueryItem1726617600000 = class {
7897
7935
  }
7898
7936
  };
7899
7937
 
7900
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7938
+ // src/migrations/generic/14-AddLinkedVpFields.ts
7901
7939
  var import_debug13 = __toESM(require("debug"), 1);
7940
+
7941
+ // src/migrations/postgres/1763387280001-AddLinkedVpFields.ts
7942
+ var AddLinkedVpFields1763387280001 = class {
7943
+ static {
7944
+ __name(this, "AddLinkedVpFields1763387280001");
7945
+ }
7946
+ name = "AddLinkedVpFields1763387280001";
7947
+ async up(queryRunner) {
7948
+ await queryRunner.query(`
7949
+ ALTER TABLE "DigitalCredential"
7950
+ ADD COLUMN "linked_vp_id" text
7951
+ `);
7952
+ await queryRunner.query(`
7953
+ ALTER TABLE "DigitalCredential"
7954
+ ADD COLUMN "linked_vp_from" TIMESTAMP
7955
+ `);
7956
+ }
7957
+ async down(queryRunner) {
7958
+ await queryRunner.query(`
7959
+ ALTER TABLE "DigitalCredential"
7960
+ DROP COLUMN "linked_vp_from"
7961
+ `);
7962
+ await queryRunner.query(`
7963
+ ALTER TABLE "DigitalCredential"
7964
+ DROP COLUMN "linked_vp_id"
7965
+ `);
7966
+ }
7967
+ };
7968
+
7969
+ // src/migrations/sqlite/1763387280002-AddLinkedVpFields.ts
7970
+ var AddLinkedVpFields1763387280002 = class {
7971
+ static {
7972
+ __name(this, "AddLinkedVpFields1763387280002");
7973
+ }
7974
+ name = "AddLinkedVpFields1763387280002";
7975
+ async up(queryRunner) {
7976
+ await queryRunner.query(`
7977
+ ALTER TABLE "DigitalCredential"
7978
+ ADD COLUMN "linked_vp_id" text
7979
+ `);
7980
+ await queryRunner.query(`
7981
+ ALTER TABLE "DigitalCredential"
7982
+ ADD COLUMN "linked_vp_from" datetime
7983
+ `);
7984
+ }
7985
+ async down(queryRunner) {
7986
+ await queryRunner.query(`
7987
+ ALTER TABLE "DigitalCredential"
7988
+ DROP COLUMN "linked_vp_from"
7989
+ `);
7990
+ await queryRunner.query(`
7991
+ ALTER TABLE "DigitalCredential"
7992
+ DROP COLUMN "linked_vp_id"
7993
+ `);
7994
+ }
7995
+ };
7996
+
7997
+ // src/migrations/generic/14-AddLinkedVpFields.ts
7902
7998
  var debug13 = (0, import_debug13.default)("sphereon:ssi-sdk:migrations");
7999
+ var AddLinkedVpFields1763387280000 = class {
8000
+ static {
8001
+ __name(this, "AddLinkedVpFields1763387280000");
8002
+ }
8003
+ name = "AddLinkedVpFields1763387280000";
8004
+ async up(queryRunner) {
8005
+ debug13("migration: adding linked VP fields to DigitalCredential table");
8006
+ const dbType = queryRunner.connection.driver.options.type;
8007
+ switch (dbType) {
8008
+ case "postgres": {
8009
+ debug13("using postgres migration file for AddLinkedVpFields");
8010
+ const mig = new AddLinkedVpFields1763387280001();
8011
+ await mig.up(queryRunner);
8012
+ debug13("Postgres migration statements for AddLinkedVpFields executed");
8013
+ return;
8014
+ }
8015
+ case "sqlite":
8016
+ case "expo":
8017
+ case "react-native": {
8018
+ debug13("using sqlite/react-native migration file for AddLinkedVpFields");
8019
+ const mig = new AddLinkedVpFields1763387280002();
8020
+ await mig.up(queryRunner);
8021
+ debug13("SQLite migration statements for AddLinkedVpFields executed");
8022
+ return;
8023
+ }
8024
+ default:
8025
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for AddLinkedVpFields. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8026
+ }
8027
+ }
8028
+ async down(queryRunner) {
8029
+ debug13("migration: reverting linked VP fields from DigitalCredential table");
8030
+ const dbType = queryRunner.connection.driver.options.type;
8031
+ switch (dbType) {
8032
+ case "postgres": {
8033
+ debug13("using postgres migration file for AddLinkedVpFields");
8034
+ const mig = new AddLinkedVpFields1763387280001();
8035
+ await mig.down(queryRunner);
8036
+ debug13("Postgres migration statements for AddLinkedVpFields reverted");
8037
+ return;
8038
+ }
8039
+ case "sqlite":
8040
+ case "expo":
8041
+ case "react-native": {
8042
+ debug13("using sqlite/react-native migration file for AddLinkedVpFields");
8043
+ const mig = new AddLinkedVpFields1763387280002();
8044
+ await mig.down(queryRunner);
8045
+ debug13("SQLite migration statements for AddLinkedVpFields reverted");
8046
+ return;
8047
+ }
8048
+ default:
8049
+ return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for AddLinkedVpFields. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8050
+ }
8051
+ }
8052
+ };
8053
+
8054
+ // src/migrations/generic/2-CreateIssuanceBranding.ts
8055
+ var import_debug14 = __toESM(require("debug"), 1);
8056
+ var debug14 = (0, import_debug14.default)("sphereon:ssi-sdk:migrations");
7903
8057
  var CreateIssuanceBranding1659463079429 = class {
7904
8058
  static {
7905
8059
  __name(this, "CreateIssuanceBranding1659463079429");
7906
8060
  }
7907
8061
  name = "CreateIssuanceBranding1659463079429";
7908
8062
  async up(queryRunner) {
7909
- debug13("migration: creating issuance branding tables");
8063
+ debug14("migration: creating issuance branding tables");
7910
8064
  const dbType = queryRunner.connection.driver.options.type;
7911
8065
  switch (dbType) {
7912
8066
  case "postgres": {
7913
- debug13("using postgres migration file");
8067
+ debug14("using postgres migration file");
7914
8068
  const mig = new CreateIssuanceBranding1685628974232();
7915
8069
  await mig.up(queryRunner);
7916
- debug13("Migration statements executed");
8070
+ debug14("Migration statements executed");
7917
8071
  return;
7918
8072
  }
7919
8073
  case "sqlite":
7920
8074
  case "expo":
7921
8075
  case "react-native": {
7922
- debug13("using sqlite/react-native migration file");
8076
+ debug14("using sqlite/react-native migration file");
7923
8077
  const mig = new CreateIssuanceBranding1685628973231();
7924
8078
  await mig.up(queryRunner);
7925
- debug13("Migration statements executed");
8079
+ debug14("Migration statements executed");
7926
8080
  return;
7927
8081
  }
7928
8082
  default:
@@ -7930,23 +8084,23 @@ var CreateIssuanceBranding1659463079429 = class {
7930
8084
  }
7931
8085
  }
7932
8086
  async down(queryRunner) {
7933
- debug13("migration: reverting issuance branding tables");
8087
+ debug14("migration: reverting issuance branding tables");
7934
8088
  const dbType = queryRunner.connection.driver.options.type;
7935
8089
  switch (dbType) {
7936
8090
  case "postgres": {
7937
- debug13("using postgres migration file");
8091
+ debug14("using postgres migration file");
7938
8092
  const mig = new CreateIssuanceBranding1685628974232();
7939
8093
  await mig.down(queryRunner);
7940
- debug13("Migration statements executed");
8094
+ debug14("Migration statements executed");
7941
8095
  return;
7942
8096
  }
7943
8097
  case "sqlite":
7944
8098
  case "expo":
7945
8099
  case "react-native": {
7946
- debug13("using sqlite/react-native migration file");
8100
+ debug14("using sqlite/react-native migration file");
7947
8101
  const mig = new CreateIssuanceBranding1685628973231();
7948
8102
  await mig.down(queryRunner);
7949
- debug13("Migration statements executed");
8103
+ debug14("Migration statements executed");
7950
8104
  return;
7951
8105
  }
7952
8106
  default:
@@ -7956,7 +8110,7 @@ var CreateIssuanceBranding1659463079429 = class {
7956
8110
  };
7957
8111
 
7958
8112
  // src/migrations/generic/3-CreateContacts.ts
7959
- var import_debug14 = __toESM(require("debug"), 1);
8113
+ var import_debug15 = __toESM(require("debug"), 1);
7960
8114
 
7961
8115
  // src/migrations/postgres/1690925872592-CreateContacts.ts
7962
8116
  var import_ssi_sdk33 = require("@sphereon/ssi-sdk.core");
@@ -8177,30 +8331,30 @@ var CreateContacts1690925872693 = class {
8177
8331
  };
8178
8332
 
8179
8333
  // src/migrations/generic/3-CreateContacts.ts
8180
- var debug14 = (0, import_debug14.default)("sphereon:ssi-sdk:migrations");
8334
+ var debug15 = (0, import_debug15.default)("sphereon:ssi-sdk:migrations");
8181
8335
  var CreateContacts1690925872318 = class {
8182
8336
  static {
8183
8337
  __name(this, "CreateContacts1690925872318");
8184
8338
  }
8185
8339
  name = "CreateContacts1690925872318";
8186
8340
  async up(queryRunner) {
8187
- debug14("migration: creating contacts tables");
8341
+ debug15("migration: creating contacts tables");
8188
8342
  const dbType = queryRunner.connection.driver.options.type;
8189
8343
  switch (dbType) {
8190
8344
  case "postgres": {
8191
- debug14("using postgres migration file");
8345
+ debug15("using postgres migration file");
8192
8346
  const mig = new CreateContacts1690925872592();
8193
8347
  await mig.up(queryRunner);
8194
- debug14("Migration statements executed");
8348
+ debug15("Migration statements executed");
8195
8349
  return;
8196
8350
  }
8197
8351
  case "sqlite":
8198
8352
  case "expo":
8199
8353
  case "react-native": {
8200
- debug14("using sqlite/react-native migration file");
8354
+ debug15("using sqlite/react-native migration file");
8201
8355
  const mig = new CreateContacts1690925872693();
8202
8356
  await mig.up(queryRunner);
8203
- debug14("Migration statements executed");
8357
+ debug15("Migration statements executed");
8204
8358
  return;
8205
8359
  }
8206
8360
  default:
@@ -8208,23 +8362,23 @@ var CreateContacts1690925872318 = class {
8208
8362
  }
8209
8363
  }
8210
8364
  async down(queryRunner) {
8211
- debug14("migration: reverting contacts tables");
8365
+ debug15("migration: reverting contacts tables");
8212
8366
  const dbType = queryRunner.connection.driver.options.type;
8213
8367
  switch (dbType) {
8214
8368
  case "postgres": {
8215
- debug14("using postgres migration file");
8369
+ debug15("using postgres migration file");
8216
8370
  const mig = new CreateContacts1690925872592();
8217
8371
  await mig.down(queryRunner);
8218
- debug14("Migration statements executed");
8372
+ debug15("Migration statements executed");
8219
8373
  return;
8220
8374
  }
8221
8375
  case "sqlite":
8222
8376
  case "expo":
8223
8377
  case "react-native": {
8224
- debug14("using sqlite/react-native migration file");
8378
+ debug15("using sqlite/react-native migration file");
8225
8379
  const mig = new CreateContacts1690925872693();
8226
8380
  await mig.down(queryRunner);
8227
- debug14("Migration statements executed");
8381
+ debug15("Migration statements executed");
8228
8382
  return;
8229
8383
  }
8230
8384
  default:
@@ -8234,7 +8388,7 @@ var CreateContacts1690925872318 = class {
8234
8388
  };
8235
8389
 
8236
8390
  // src/migrations/generic/4-CreateStatusList.ts
8237
- var import_debug15 = __toESM(require("debug"), 1);
8391
+ var import_debug16 = __toESM(require("debug"), 1);
8238
8392
 
8239
8393
  // src/migrations/postgres/1693866470001-CreateStatusList.ts
8240
8394
  var CreateStatusList1693866470001 = class {
@@ -8440,53 +8594,53 @@ var UpdateStatusList1737110469000 = class {
8440
8594
  };
8441
8595
 
8442
8596
  // src/migrations/generic/4-CreateStatusList.ts
8443
- var debug15 = (0, import_debug15.default)("sphereon:ssi-sdk:migrations");
8597
+ var debug16 = (0, import_debug16.default)("sphereon:ssi-sdk:migrations");
8444
8598
  var CreateStatusList1693866470000 = class {
8445
8599
  static {
8446
8600
  __name(this, "CreateStatusList1693866470000");
8447
8601
  }
8448
8602
  name = "CreateStatusList1693866470000";
8449
8603
  async up(queryRunner) {
8450
- debug15("migration: creating issuance branding tables");
8604
+ debug16("migration: creating issuance branding tables");
8451
8605
  const dbType = queryRunner.connection.driver.options.type;
8452
8606
  if (dbType === "postgres") {
8453
- debug15("using postgres migration files");
8607
+ debug16("using postgres migration files");
8454
8608
  const createMig = new CreateStatusList1693866470001();
8455
8609
  await createMig.up(queryRunner);
8456
8610
  const updateMig = new UpdateStatusList1737110469001();
8457
8611
  const up = await updateMig.up(queryRunner);
8458
- debug15("Migration statements executed");
8612
+ debug16("Migration statements executed");
8459
8613
  return up;
8460
8614
  } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8461
- debug15("using sqlite/react-native migration files");
8615
+ debug16("using sqlite/react-native migration files");
8462
8616
  const createMig = new CreateStatusList1693866470002();
8463
8617
  await createMig.up(queryRunner);
8464
8618
  const updateMig = new UpdateStatusList1737110469000();
8465
8619
  const up = await updateMig.up(queryRunner);
8466
- debug15("Migration statements executed");
8620
+ debug16("Migration statements executed");
8467
8621
  return up;
8468
8622
  } else {
8469
8623
  return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
8470
8624
  }
8471
8625
  }
8472
8626
  async down(queryRunner) {
8473
- debug15("migration: reverting issuance branding tables");
8627
+ debug16("migration: reverting issuance branding tables");
8474
8628
  const dbType = queryRunner.connection.driver.options.type;
8475
8629
  if (dbType === "postgres") {
8476
- debug15("using postgres migration files");
8630
+ debug16("using postgres migration files");
8477
8631
  const updateMig = new UpdateStatusList1737110469001();
8478
8632
  await updateMig.down(queryRunner);
8479
8633
  const createMig = new CreateStatusList1693866470001();
8480
8634
  const down = await createMig.down(queryRunner);
8481
- debug15("Migration statements executed");
8635
+ debug16("Migration statements executed");
8482
8636
  return down;
8483
8637
  } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8484
- debug15("using sqlite/react-native migration files");
8638
+ debug16("using sqlite/react-native migration files");
8485
8639
  const updateMig = new UpdateStatusList1737110469000();
8486
8640
  await updateMig.down(queryRunner);
8487
8641
  const createMig = new CreateStatusList1693866470002();
8488
8642
  const down = await createMig.down(queryRunner);
8489
- debug15("Migration statements executed");
8643
+ debug16("Migration statements executed");
8490
8644
  return down;
8491
8645
  } else {
8492
8646
  return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
@@ -8495,7 +8649,7 @@ var CreateStatusList1693866470000 = class {
8495
8649
  };
8496
8650
 
8497
8651
  // src/migrations/generic/5-CreateAuditEvents.ts
8498
- var import_debug16 = __toESM(require("debug"), 1);
8652
+ var import_debug17 = __toESM(require("debug"), 1);
8499
8653
 
8500
8654
  // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8501
8655
  var CreateAuditEvents1701634812183 = class {
@@ -8594,30 +8748,30 @@ var CreateAuditEvents1701634819487 = class {
8594
8748
  };
8595
8749
 
8596
8750
  // src/migrations/generic/5-CreateAuditEvents.ts
8597
- var debug16 = (0, import_debug16.default)("sphereon:ssi-sdk:migrations");
8751
+ var debug17 = (0, import_debug17.default)("sphereon:ssi-sdk:migrations");
8598
8752
  var CreateAuditEvents1701635835330 = class {
8599
8753
  static {
8600
8754
  __name(this, "CreateAuditEvents1701635835330");
8601
8755
  }
8602
8756
  name = "CreateAuditEvents1701635835330";
8603
8757
  async up(queryRunner) {
8604
- debug16("migration: creating audit events tables");
8758
+ debug17("migration: creating audit events tables");
8605
8759
  const dbType = queryRunner.connection.driver.options.type;
8606
8760
  switch (dbType) {
8607
8761
  case "postgres": {
8608
- debug16("using postgres migration file");
8762
+ debug17("using postgres migration file");
8609
8763
  const mig = new CreateAuditEvents1701634812183();
8610
8764
  await mig.up(queryRunner);
8611
- debug16("Migration statements executed");
8765
+ debug17("Migration statements executed");
8612
8766
  return;
8613
8767
  }
8614
8768
  case "sqlite":
8615
8769
  case "expo":
8616
8770
  case "react-native": {
8617
- debug16("using sqlite/react-native migration file");
8771
+ debug17("using sqlite/react-native migration file");
8618
8772
  const mig = new CreateAuditEvents1701634819487();
8619
8773
  await mig.up(queryRunner);
8620
- debug16("Migration statements executed");
8774
+ debug17("Migration statements executed");
8621
8775
  return;
8622
8776
  }
8623
8777
  default:
@@ -8625,23 +8779,23 @@ var CreateAuditEvents1701635835330 = class {
8625
8779
  }
8626
8780
  }
8627
8781
  async down(queryRunner) {
8628
- debug16("migration: reverting audit events tables");
8782
+ debug17("migration: reverting audit events tables");
8629
8783
  const dbType = queryRunner.connection.driver.options.type;
8630
8784
  switch (dbType) {
8631
8785
  case "postgres": {
8632
- debug16("using postgres migration file");
8786
+ debug17("using postgres migration file");
8633
8787
  const mig = new CreateAuditEvents1701634812183();
8634
8788
  await mig.down(queryRunner);
8635
- debug16("Migration statements executed");
8789
+ debug17("Migration statements executed");
8636
8790
  return;
8637
8791
  }
8638
8792
  case "sqlite":
8639
8793
  case "expo":
8640
8794
  case "react-native": {
8641
- debug16("using sqlite/react-native migration file");
8795
+ debug17("using sqlite/react-native migration file");
8642
8796
  const mig = new CreateAuditEvents1701634819487();
8643
8797
  await mig.down(queryRunner);
8644
- debug16("Migration statements executed");
8798
+ debug17("Migration statements executed");
8645
8799
  return;
8646
8800
  }
8647
8801
  default:
@@ -8651,7 +8805,7 @@ var CreateAuditEvents1701635835330 = class {
8651
8805
  };
8652
8806
 
8653
8807
  // src/migrations/generic/6-CreateDigitalCredential.ts
8654
- var import_debug17 = __toESM(require("debug"), 1);
8808
+ var import_debug18 = __toESM(require("debug"), 1);
8655
8809
 
8656
8810
  // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8657
8811
  var CreateDigitalCredential1708525189001 = class {
@@ -8759,30 +8913,30 @@ var CreateDigitalCredential1708525189002 = class {
8759
8913
  };
8760
8914
 
8761
8915
  // src/migrations/generic/6-CreateDigitalCredential.ts
8762
- var debug17 = (0, import_debug17.default)("sphereon:ssi-sdk:migrations");
8916
+ var debug18 = (0, import_debug18.default)("sphereon:ssi-sdk:migrations");
8763
8917
  var CreateDigitalCredential1708525189000 = class {
8764
8918
  static {
8765
8919
  __name(this, "CreateDigitalCredential1708525189000");
8766
8920
  }
8767
8921
  name = "CreateDigitalCredential1708525189000";
8768
8922
  async up(queryRunner) {
8769
- debug17("migration: creating DigitalCredential tables");
8923
+ debug18("migration: creating DigitalCredential tables");
8770
8924
  const dbType = queryRunner.connection.driver.options.type;
8771
8925
  switch (dbType) {
8772
8926
  case "postgres": {
8773
- debug17("using postgres migration file for DigitalCredential");
8927
+ debug18("using postgres migration file for DigitalCredential");
8774
8928
  const mig = new CreateDigitalCredential1708525189001();
8775
8929
  await mig.up(queryRunner);
8776
- debug17("Postgres Migration statements for DigitalCredential executed");
8930
+ debug18("Postgres Migration statements for DigitalCredential executed");
8777
8931
  return;
8778
8932
  }
8779
8933
  case "sqlite":
8780
8934
  case "expo":
8781
8935
  case "react-native": {
8782
- debug17("using sqlite/react-native migration file for DigitalCredential");
8936
+ debug18("using sqlite/react-native migration file for DigitalCredential");
8783
8937
  const mig = new CreateDigitalCredential1708525189002();
8784
8938
  await mig.up(queryRunner);
8785
- debug17("SQLite Migration statements for DigitalCredential executed");
8939
+ debug18("SQLite Migration statements for DigitalCredential executed");
8786
8940
  return;
8787
8941
  }
8788
8942
  default:
@@ -8790,23 +8944,23 @@ var CreateDigitalCredential1708525189000 = class {
8790
8944
  }
8791
8945
  }
8792
8946
  async down(queryRunner) {
8793
- debug17("migration: reverting DigitalCredential tables");
8947
+ debug18("migration: reverting DigitalCredential tables");
8794
8948
  const dbType = queryRunner.connection.driver.options.type;
8795
8949
  switch (dbType) {
8796
8950
  case "postgres": {
8797
- debug17("using postgres migration file for DigitalCredential");
8951
+ debug18("using postgres migration file for DigitalCredential");
8798
8952
  const mig = new CreateDigitalCredential1708525189001();
8799
8953
  await mig.down(queryRunner);
8800
- debug17("Postgres Migration statements for DigitalCredential reverted");
8954
+ debug18("Postgres Migration statements for DigitalCredential reverted");
8801
8955
  return;
8802
8956
  }
8803
8957
  case "sqlite":
8804
8958
  case "expo":
8805
8959
  case "react-native": {
8806
- debug17("using sqlite/react-native migration file for DigitalCredential");
8960
+ debug18("using sqlite/react-native migration file for DigitalCredential");
8807
8961
  const mig = new CreateDigitalCredential1708525189002();
8808
8962
  await mig.down(queryRunner);
8809
- debug17("SQLite Migration statements for DigitalCredential reverted");
8963
+ debug18("SQLite Migration statements for DigitalCredential reverted");
8810
8964
  return;
8811
8965
  }
8812
8966
  default:
@@ -8816,7 +8970,7 @@ var CreateDigitalCredential1708525189000 = class {
8816
8970
  };
8817
8971
 
8818
8972
  // src/migrations/generic/7-CreateMachineStateStore.ts
8819
- var import_debug18 = __toESM(require("debug"), 1);
8973
+ var import_debug19 = __toESM(require("debug"), 1);
8820
8974
 
8821
8975
  // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8822
8976
  var CreateMachineStateStore1708797018115 = class {
@@ -8878,30 +9032,30 @@ var CreateMachineStateStore1708796002272 = class {
8878
9032
  };
8879
9033
 
8880
9034
  // src/migrations/generic/7-CreateMachineStateStore.ts
8881
- var debug18 = (0, import_debug18.default)("sphereon:ssi-sdk:migrations");
9035
+ var debug19 = (0, import_debug19.default)("sphereon:ssi-sdk:migrations");
8882
9036
  var CreateMachineStateStore1708098041262 = class {
8883
9037
  static {
8884
9038
  __name(this, "CreateMachineStateStore1708098041262");
8885
9039
  }
8886
9040
  name = "CreateMachineStateStore1708098041262";
8887
9041
  async up(queryRunner) {
8888
- debug18("migration: creating machine state tables");
9042
+ debug19("migration: creating machine state tables");
8889
9043
  const dbType = queryRunner.connection.driver.options.type;
8890
9044
  switch (dbType) {
8891
9045
  case "postgres": {
8892
- debug18("using postgres migration file");
9046
+ debug19("using postgres migration file");
8893
9047
  const mig = new CreateMachineStateStore1708797018115();
8894
9048
  await mig.up(queryRunner);
8895
- debug18("Migration statements executed");
9049
+ debug19("Migration statements executed");
8896
9050
  return;
8897
9051
  }
8898
9052
  case "sqlite":
8899
9053
  case "expo":
8900
9054
  case "react-native": {
8901
- debug18("using sqlite/react-native migration file");
9055
+ debug19("using sqlite/react-native migration file");
8902
9056
  const mig = new CreateMachineStateStore1708796002272();
8903
9057
  await mig.up(queryRunner);
8904
- debug18("Migration statements executed");
9058
+ debug19("Migration statements executed");
8905
9059
  return;
8906
9060
  }
8907
9061
  default:
@@ -8909,23 +9063,23 @@ var CreateMachineStateStore1708098041262 = class {
8909
9063
  }
8910
9064
  }
8911
9065
  async down(queryRunner) {
8912
- debug18("migration: reverting machine state tables");
9066
+ debug19("migration: reverting machine state tables");
8913
9067
  const dbType = queryRunner.connection.driver.options.type;
8914
9068
  switch (dbType) {
8915
9069
  case "postgres": {
8916
- debug18("using postgres migration file");
9070
+ debug19("using postgres migration file");
8917
9071
  const mig = new CreateMachineStateStore1708797018115();
8918
9072
  await mig.down(queryRunner);
8919
- debug18("Migration statements executed");
9073
+ debug19("Migration statements executed");
8920
9074
  return;
8921
9075
  }
8922
9076
  case "sqlite":
8923
9077
  case "expo":
8924
9078
  case "react-native": {
8925
- debug18("using sqlite/react-native migration file");
9079
+ debug19("using sqlite/react-native migration file");
8926
9080
  const mig = new CreateMachineStateStore1708796002272();
8927
9081
  await mig.down(queryRunner);
8928
- debug18("Migration statements executed");
9082
+ debug19("Migration statements executed");
8929
9083
  return;
8930
9084
  }
8931
9085
  default:
@@ -8935,7 +9089,7 @@ var CreateMachineStateStore1708098041262 = class {
8935
9089
  };
8936
9090
 
8937
9091
  // src/migrations/generic/8-CreateContacts.ts
8938
- var import_debug19 = __toESM(require("debug"), 1);
9092
+ var import_debug20 = __toESM(require("debug"), 1);
8939
9093
 
8940
9094
  // src/migrations/postgres/1710438363001-CreateContacts.ts
8941
9095
  var CreateContacts1710438363001 = class {
@@ -9049,30 +9203,30 @@ var CreateContacts1710438363002 = class {
9049
9203
  };
9050
9204
 
9051
9205
  // src/migrations/generic/8-CreateContacts.ts
9052
- var debug19 = (0, import_debug19.default)("sphereon:ssi-sdk:migrations");
9206
+ var debug20 = (0, import_debug20.default)("sphereon:ssi-sdk:migrations");
9053
9207
  var CreateContacts1708525189000 = class {
9054
9208
  static {
9055
9209
  __name(this, "CreateContacts1708525189000");
9056
9210
  }
9057
9211
  name = "CreateContacts1708525189000";
9058
9212
  async up(queryRunner) {
9059
- debug19("migration: updating contact tables");
9213
+ debug20("migration: updating contact tables");
9060
9214
  const dbType = queryRunner.connection.driver.options.type;
9061
9215
  switch (dbType) {
9062
9216
  case "postgres": {
9063
- debug19("using postgres migration file");
9217
+ debug20("using postgres migration file");
9064
9218
  const mig = new CreateContacts1710438363001();
9065
9219
  await mig.up(queryRunner);
9066
- debug19("Migration statements executed");
9220
+ debug20("Migration statements executed");
9067
9221
  return;
9068
9222
  }
9069
9223
  case "sqlite":
9070
9224
  case "expo":
9071
9225
  case "react-native": {
9072
- debug19("using sqlite/react-native migration file");
9226
+ debug20("using sqlite/react-native migration file");
9073
9227
  const mig = new CreateContacts1710438363002();
9074
9228
  await mig.up(queryRunner);
9075
- debug19("Migration statements executed");
9229
+ debug20("Migration statements executed");
9076
9230
  return;
9077
9231
  }
9078
9232
  default:
@@ -9080,23 +9234,23 @@ var CreateContacts1708525189000 = class {
9080
9234
  }
9081
9235
  }
9082
9236
  async down(queryRunner) {
9083
- debug19("migration: reverting machine state tables");
9237
+ debug20("migration: reverting machine state tables");
9084
9238
  const dbType = queryRunner.connection.driver.options.type;
9085
9239
  switch (dbType) {
9086
9240
  case "postgres": {
9087
- debug19("using postgres migration file");
9241
+ debug20("using postgres migration file");
9088
9242
  const mig = new CreateContacts1710438363001();
9089
9243
  await mig.down(queryRunner);
9090
- debug19("Migration statements executed");
9244
+ debug20("Migration statements executed");
9091
9245
  return;
9092
9246
  }
9093
9247
  case "sqlite":
9094
9248
  case "expo":
9095
9249
  case "react-native": {
9096
- debug19("using sqlite/react-native migration file");
9250
+ debug20("using sqlite/react-native migration file");
9097
9251
  const mig = new CreateContacts1710438363002();
9098
9252
  await mig.down(queryRunner);
9099
- debug19("Migration statements executed");
9253
+ debug20("Migration statements executed");
9100
9254
  return;
9101
9255
  }
9102
9256
  default:
@@ -9106,7 +9260,7 @@ var CreateContacts1708525189000 = class {
9106
9260
  };
9107
9261
 
9108
9262
  // src/migrations/generic/9-CreateContacts.ts
9109
- var import_debug20 = __toESM(require("debug"), 1);
9263
+ var import_debug21 = __toESM(require("debug"), 1);
9110
9264
 
9111
9265
  // src/migrations/postgres/1715761125001-CreateContacts.ts
9112
9266
  var CreateContacts1715761125001 = class {
@@ -9218,30 +9372,30 @@ var CreateContacts1715761125002 = class {
9218
9372
  };
9219
9373
 
9220
9374
  // src/migrations/generic/9-CreateContacts.ts
9221
- var debug20 = (0, import_debug20.default)("sphereon:ssi-sdk:migrations");
9375
+ var debug21 = (0, import_debug21.default)("sphereon:ssi-sdk:migrations");
9222
9376
  var CreateContacts1715761125000 = class {
9223
9377
  static {
9224
9378
  __name(this, "CreateContacts1715761125000");
9225
9379
  }
9226
9380
  name = "CreateContacts1715761125000";
9227
9381
  async up(queryRunner) {
9228
- debug20("migration: updating contact tables");
9382
+ debug21("migration: updating contact tables");
9229
9383
  const dbType = queryRunner.connection.driver.options.type;
9230
9384
  switch (dbType) {
9231
9385
  case "postgres": {
9232
- debug20("using postgres migration file");
9386
+ debug21("using postgres migration file");
9233
9387
  const mig = new CreateContacts1715761125001();
9234
9388
  await mig.up(queryRunner);
9235
- debug20("Migration statements executed");
9389
+ debug21("Migration statements executed");
9236
9390
  return;
9237
9391
  }
9238
9392
  case "sqlite":
9239
9393
  case "expo":
9240
9394
  case "react-native": {
9241
- debug20("using sqlite/react-native migration file");
9395
+ debug21("using sqlite/react-native migration file");
9242
9396
  const mig = new CreateContacts1715761125002();
9243
9397
  await mig.up(queryRunner);
9244
- debug20("Migration statements executed");
9398
+ debug21("Migration statements executed");
9245
9399
  return;
9246
9400
  }
9247
9401
  default:
@@ -9249,23 +9403,23 @@ var CreateContacts1715761125000 = class {
9249
9403
  }
9250
9404
  }
9251
9405
  async down(queryRunner) {
9252
- debug20("migration: reverting machine state tables");
9406
+ debug21("migration: reverting machine state tables");
9253
9407
  const dbType = queryRunner.connection.driver.options.type;
9254
9408
  switch (dbType) {
9255
9409
  case "postgres": {
9256
- debug20("using postgres migration file");
9410
+ debug21("using postgres migration file");
9257
9411
  const mig = new CreateContacts1715761125001();
9258
9412
  await mig.down(queryRunner);
9259
- debug20("Migration statements executed");
9413
+ debug21("Migration statements executed");
9260
9414
  return;
9261
9415
  }
9262
9416
  case "sqlite":
9263
9417
  case "expo":
9264
9418
  case "react-native": {
9265
- debug20("using sqlite/react-native migration file");
9419
+ debug21("using sqlite/react-native migration file");
9266
9420
  const mig = new CreateContacts1715761125002();
9267
9421
  await mig.down(queryRunner);
9268
- debug20("Migration statements executed");
9422
+ debug21("Migration statements executed");
9269
9423
  return;
9270
9424
  }
9271
9425
  default:
@@ -9294,7 +9448,8 @@ var DataStoreEventLoggerMigrations = [
9294
9448
  CreateAuditEvents1701635835330
9295
9449
  ];
9296
9450
  var DataStoreDigitalCredentialMigrations = [
9297
- CreateDigitalCredential1708525189000
9451
+ CreateDigitalCredential1708525189000,
9452
+ AddLinkedVpFields1763387280000
9298
9453
  ];
9299
9454
  var DataStoreMachineStateMigrations = [
9300
9455
  CreateMachineStateStore1708098041262
@@ -9366,6 +9521,18 @@ function determineCredentialDocumentFormat(documentFormat) {
9366
9521
  }
9367
9522
  }
9368
9523
  __name(determineCredentialDocumentFormat, "determineCredentialDocumentFormat");
9524
+ function normalizeNullableFields(obj, nullableKeys) {
9525
+ const normalized = {
9526
+ ...obj
9527
+ };
9528
+ for (const key of nullableKeys) {
9529
+ if (normalized[key] === void 0) {
9530
+ normalized[key] = null;
9531
+ }
9532
+ }
9533
+ return normalized;
9534
+ }
9535
+ __name(normalizeNullableFields, "normalizeNullableFields");
9369
9536
  function getValidUntil(uniformDocument) {
9370
9537
  if ("expirationDate" in uniformDocument && uniformDocument.expirationDate) {
9371
9538
  return new Date(uniformDocument.expirationDate);
@@ -9428,6 +9595,33 @@ var nonPersistedDigitalCredentialEntityFromAddArgs = /* @__PURE__ */ __name((add
9428
9595
  lastUpdatedAt: /* @__PURE__ */ new Date()
9429
9596
  };
9430
9597
  }, "nonPersistedDigitalCredentialEntityFromAddArgs");
9598
+ var persistedDigitalCredentialEntityFromUpdateArgs = /* @__PURE__ */ __name((existingCredential, updates) => {
9599
+ const entity = new DigitalCredentialEntity();
9600
+ Object.assign(entity, existingCredential);
9601
+ const normalizedUpdates = normalizeNullableFields(updates, [
9602
+ "linkedVpId",
9603
+ "linkedVpFrom"
9604
+ ]);
9605
+ Object.assign(entity, normalizedUpdates);
9606
+ entity.id = existingCredential.id;
9607
+ entity.hash = existingCredential.hash;
9608
+ entity.createdAt = existingCredential.createdAt;
9609
+ entity.lastUpdatedAt = /* @__PURE__ */ new Date();
9610
+ return entity;
9611
+ }, "persistedDigitalCredentialEntityFromUpdateArgs");
9612
+ var persistedDigitalCredentialEntityFromStateArgs = /* @__PURE__ */ __name((existingCredential, args) => {
9613
+ const entity = new DigitalCredentialEntity();
9614
+ Object.assign(entity, existingCredential);
9615
+ entity.verifiedState = args.verifiedState;
9616
+ entity.lastUpdatedAt = /* @__PURE__ */ new Date();
9617
+ if (args.verifiedState === import_ssi_sdk35.CredentialStateType.REVOKED && args.revokedAt) {
9618
+ entity.revokedAt = args.revokedAt;
9619
+ }
9620
+ if (args.verifiedState !== import_ssi_sdk35.CredentialStateType.REVOKED && args.verifiedAt) {
9621
+ entity.verifiedAt = args.verifiedAt;
9622
+ }
9623
+ return entity;
9624
+ }, "persistedDigitalCredentialEntityFromStateArgs");
9431
9625
  var digitalCredentialFrom = /* @__PURE__ */ __name((credentialEntity) => {
9432
9626
  const result = {
9433
9627
  ...credentialEntity