@sphereon/ssi-sdk.data-store 0.36.1-next.11 → 0.36.1-next.113

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.js CHANGED
@@ -1922,6 +1922,9 @@ var DigitalCredentialEntity = class extends BaseEntity11 {
1922
1922
  rpCorrelationId;
1923
1923
  verifiedState;
1924
1924
  tenantId;
1925
+ linkedVpId;
1926
+ linkedVpFrom;
1927
+ linkedVpUntil;
1925
1928
  createdAt;
1926
1929
  presentedAt;
1927
1930
  lastUpdatedAt;
@@ -2084,6 +2087,29 @@ _ts_decorate18([
2084
2087
  }),
2085
2088
  _ts_metadata17("design:type", String)
2086
2089
  ], DigitalCredentialEntity.prototype, "tenantId", void 0);
2090
+ _ts_decorate18([
2091
+ Column15("text", {
2092
+ name: "linked_vp_id",
2093
+ nullable: true
2094
+ }),
2095
+ _ts_metadata17("design:type", String)
2096
+ ], DigitalCredentialEntity.prototype, "linkedVpId", void 0);
2097
+ _ts_decorate18([
2098
+ Column15({
2099
+ name: "linked_vp_from",
2100
+ nullable: true,
2101
+ type: typeOrmDateTime10()
2102
+ }),
2103
+ _ts_metadata17("design:type", typeof Date === "undefined" ? Object : Date)
2104
+ ], DigitalCredentialEntity.prototype, "linkedVpFrom", void 0);
2105
+ _ts_decorate18([
2106
+ Column15({
2107
+ name: "linked_vp_until",
2108
+ nullable: true,
2109
+ type: typeOrmDateTime10()
2110
+ }),
2111
+ _ts_metadata17("design:type", typeof Date === "undefined" ? Object : Date)
2112
+ ], DigitalCredentialEntity.prototype, "linkedVpUntil", void 0);
2087
2113
  _ts_decorate18([
2088
2114
  CreateDateColumn8({
2089
2115
  name: "created_at",
@@ -5217,6 +5243,7 @@ var ContactStore = class extends AbstractContactStore {
5217
5243
  import { AbstractDigitalCredentialStore, CredentialStateType as CredentialStateType2 } from "@sphereon/ssi-sdk.data-store-types";
5218
5244
  import { CredentialRole as CredentialRole2 } from "@sphereon/ssi-types";
5219
5245
  import Debug2 from "debug";
5246
+ import { LessThanOrEqual } from "typeorm";
5220
5247
 
5221
5248
  // src/utils/SortingUtils.ts
5222
5249
  var parseAndValidateOrderOptions = /* @__PURE__ */ __name((order) => {
@@ -5270,8 +5297,25 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
5270
5297
  const { filter = {}, offset, limit, order = "createdAt.asc" } = args ?? {};
5271
5298
  const sortOptions = order && typeof order === "string" ? parseAndValidateOrderOptions(order) : order;
5272
5299
  const dcRepo = await this.getRepository();
5300
+ const processLinkedVpUntil = /* @__PURE__ */ __name((filterItem) => {
5301
+ const processed = {
5302
+ ...filterItem
5303
+ };
5304
+ if (filterItem.linkedVpUntil) {
5305
+ processed.linkedVpUntil = LessThanOrEqual(filterItem.linkedVpUntil);
5306
+ }
5307
+ return processed;
5308
+ }, "processLinkedVpUntil");
5309
+ let whereClause;
5310
+ if (Array.isArray(filter) && filter.length > 0) {
5311
+ whereClause = filter.map(processLinkedVpUntil);
5312
+ } else if (Object.keys(filter).length > 0) {
5313
+ whereClause = processLinkedVpUntil(filter);
5314
+ } else {
5315
+ whereClause = filter;
5316
+ }
5273
5317
  const [result, total] = await dcRepo.findAndCount({
5274
- where: filter,
5318
+ where: whereClause,
5275
5319
  skip: offset,
5276
5320
  take: limit,
5277
5321
  order: sortOptions
@@ -5281,6 +5325,34 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
5281
5325
  total
5282
5326
  };
5283
5327
  }, "getCredentials");
5328
+ updateCredential = /* @__PURE__ */ __name(async (args) => {
5329
+ const dcRepo = await this.getRepository();
5330
+ const whereClause = {};
5331
+ if ("id" in args) {
5332
+ whereClause.id = args.id;
5333
+ } else if ("hash" in args) {
5334
+ whereClause.hash = args.hash;
5335
+ } else {
5336
+ return Promise.reject(Error("No id or hash param is provided."));
5337
+ }
5338
+ const credential = await dcRepo.findOne({
5339
+ where: whereClause
5340
+ });
5341
+ if (!credential) {
5342
+ return Promise.reject(Error(`No credential found for args: ${JSON.stringify(whereClause)}`));
5343
+ }
5344
+ const updates = Object.fromEntries(Object.entries(args).filter(([key]) => key !== "id" && key !== "hash"));
5345
+ const entityToSave = persistedDigitalCredentialEntityFromUpdateArgs(credential, updates);
5346
+ const validationError = this.assertValidDigitalCredential(entityToSave);
5347
+ if (validationError) {
5348
+ return Promise.reject(validationError);
5349
+ }
5350
+ debug2("Updating credential", entityToSave);
5351
+ const updatedResult = await dcRepo.save(entityToSave, {
5352
+ transaction: true
5353
+ });
5354
+ return digitalCredentialFrom(updatedResult);
5355
+ }, "updateCredential");
5284
5356
  removeCredential = /* @__PURE__ */ __name(async (args) => {
5285
5357
  if (!args) {
5286
5358
  return false;
@@ -5351,20 +5423,9 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
5351
5423
  if (!credential) {
5352
5424
  return Promise.reject(Error(`No credential found for args: ${JSON.stringify(whereClause)}`));
5353
5425
  }
5354
- const updatedCredential = {
5355
- ...credential,
5356
- ...args.verifiedState !== CredentialStateType2.REVOKED && {
5357
- verifiedAt: args.verifiedAt
5358
- },
5359
- ...args.verifiedState === CredentialStateType2.REVOKED && {
5360
- revokedAt: args.revokedAt
5361
- },
5362
- identifierMethod: credential.identifierMethod,
5363
- lastUpdatedAt: /* @__PURE__ */ new Date(),
5364
- verifiedState: args.verifiedState
5365
- };
5366
- debug2("Updating credential", credential);
5367
- const updatedResult = await credentialRepository.save(updatedCredential, {
5426
+ const entityToSave = persistedDigitalCredentialEntityFromStateArgs(credential, args);
5427
+ debug2("Updating credential state", entityToSave);
5428
+ const updatedResult = await credentialRepository.save(entityToSave, {
5368
5429
  transaction: true
5369
5430
  });
5370
5431
  return digitalCredentialFrom(updatedResult);
@@ -7749,32 +7810,164 @@ var CreateDcqlQueryItem1726617600000 = class {
7749
7810
  }
7750
7811
  };
7751
7812
 
7752
- // src/migrations/generic/2-CreateIssuanceBranding.ts
7813
+ // src/migrations/generic/14-AddLinkedVpFields.ts
7753
7814
  import Debug13 from "debug";
7815
+
7816
+ // src/migrations/postgres/1763387280001-AddLinkedVpFields.ts
7817
+ var AddLinkedVpFields1763387280001 = class {
7818
+ static {
7819
+ __name(this, "AddLinkedVpFields1763387280001");
7820
+ }
7821
+ name = "AddLinkedVpFields1763387280001";
7822
+ async up(queryRunner) {
7823
+ await queryRunner.query(`
7824
+ ALTER TABLE "DigitalCredential"
7825
+ ADD COLUMN "linked_vp_id" text
7826
+ `);
7827
+ await queryRunner.query(`
7828
+ ALTER TABLE "DigitalCredential"
7829
+ ADD COLUMN "linked_vp_from" TIMESTAMP
7830
+ `);
7831
+ await queryRunner.query(`
7832
+ ALTER TABLE "DigitalCredential"
7833
+ ADD COLUMN "linked_vp_until" TIMESTAMP
7834
+ `);
7835
+ }
7836
+ async down(queryRunner) {
7837
+ await queryRunner.query(`
7838
+ ALTER TABLE "DigitalCredential"
7839
+ DROP COLUMN "linked_vp_until"
7840
+ `);
7841
+ await queryRunner.query(`
7842
+ ALTER TABLE "DigitalCredential"
7843
+ DROP COLUMN "linked_vp_from"
7844
+ `);
7845
+ await queryRunner.query(`
7846
+ ALTER TABLE "DigitalCredential"
7847
+ DROP COLUMN "linked_vp_id"
7848
+ `);
7849
+ }
7850
+ };
7851
+
7852
+ // src/migrations/sqlite/1763387280002-AddLinkedVpFields.ts
7853
+ var AddLinkedVpFields1763387280002 = class {
7854
+ static {
7855
+ __name(this, "AddLinkedVpFields1763387280002");
7856
+ }
7857
+ name = "AddLinkedVpFields1763387280002";
7858
+ async up(queryRunner) {
7859
+ await queryRunner.query(`
7860
+ ALTER TABLE "DigitalCredential"
7861
+ ADD COLUMN "linked_vp_id" text
7862
+ `);
7863
+ await queryRunner.query(`
7864
+ ALTER TABLE "DigitalCredential"
7865
+ ADD COLUMN "linked_vp_from" datetime
7866
+ `);
7867
+ await queryRunner.query(`
7868
+ ALTER TABLE "DigitalCredential"
7869
+ ADD COLUMN "linked_vp_until" datetime
7870
+ `);
7871
+ }
7872
+ async down(queryRunner) {
7873
+ await queryRunner.query(`
7874
+ ALTER TABLE "DigitalCredential"
7875
+ DROP COLUMN "linked_vp_from"
7876
+ `);
7877
+ await queryRunner.query(`
7878
+ ALTER TABLE "DigitalCredential"
7879
+ DROP COLUMN "linked_vp_until"
7880
+ `);
7881
+ await queryRunner.query(`
7882
+ ALTER TABLE "DigitalCredential"
7883
+ DROP COLUMN "linked_vp_id"
7884
+ `);
7885
+ }
7886
+ };
7887
+
7888
+ // src/migrations/generic/14-AddLinkedVpFields.ts
7754
7889
  var debug13 = Debug13("sphereon:ssi-sdk:migrations");
7890
+ var AddLinkedVpFields1763387280000 = class {
7891
+ static {
7892
+ __name(this, "AddLinkedVpFields1763387280000");
7893
+ }
7894
+ name = "AddLinkedVpFields1763387280000";
7895
+ async up(queryRunner) {
7896
+ debug13("migration: adding linked VP fields to DigitalCredential table");
7897
+ const dbType = queryRunner.connection.driver.options.type;
7898
+ switch (dbType) {
7899
+ case "postgres": {
7900
+ debug13("using postgres migration file for AddLinkedVpFields");
7901
+ const mig = new AddLinkedVpFields1763387280001();
7902
+ await mig.up(queryRunner);
7903
+ debug13("Postgres migration statements for AddLinkedVpFields executed");
7904
+ return;
7905
+ }
7906
+ case "sqlite":
7907
+ case "expo":
7908
+ case "react-native": {
7909
+ debug13("using sqlite/react-native migration file for AddLinkedVpFields");
7910
+ const mig = new AddLinkedVpFields1763387280002();
7911
+ await mig.up(queryRunner);
7912
+ debug13("SQLite migration statements for AddLinkedVpFields executed");
7913
+ return;
7914
+ }
7915
+ default:
7916
+ 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`);
7917
+ }
7918
+ }
7919
+ async down(queryRunner) {
7920
+ debug13("migration: reverting linked VP fields from DigitalCredential table");
7921
+ const dbType = queryRunner.connection.driver.options.type;
7922
+ switch (dbType) {
7923
+ case "postgres": {
7924
+ debug13("using postgres migration file for AddLinkedVpFields");
7925
+ const mig = new AddLinkedVpFields1763387280001();
7926
+ await mig.down(queryRunner);
7927
+ debug13("Postgres migration statements for AddLinkedVpFields reverted");
7928
+ return;
7929
+ }
7930
+ case "sqlite":
7931
+ case "expo":
7932
+ case "react-native": {
7933
+ debug13("using sqlite/react-native migration file for AddLinkedVpFields");
7934
+ const mig = new AddLinkedVpFields1763387280002();
7935
+ await mig.down(queryRunner);
7936
+ debug13("SQLite migration statements for AddLinkedVpFields reverted");
7937
+ return;
7938
+ }
7939
+ default:
7940
+ 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`);
7941
+ }
7942
+ }
7943
+ };
7944
+
7945
+ // src/migrations/generic/2-CreateIssuanceBranding.ts
7946
+ import Debug14 from "debug";
7947
+ var debug14 = Debug14("sphereon:ssi-sdk:migrations");
7755
7948
  var CreateIssuanceBranding1659463079429 = class {
7756
7949
  static {
7757
7950
  __name(this, "CreateIssuanceBranding1659463079429");
7758
7951
  }
7759
7952
  name = "CreateIssuanceBranding1659463079429";
7760
7953
  async up(queryRunner) {
7761
- debug13("migration: creating issuance branding tables");
7954
+ debug14("migration: creating issuance branding tables");
7762
7955
  const dbType = queryRunner.connection.driver.options.type;
7763
7956
  switch (dbType) {
7764
7957
  case "postgres": {
7765
- debug13("using postgres migration file");
7958
+ debug14("using postgres migration file");
7766
7959
  const mig = new CreateIssuanceBranding1685628974232();
7767
7960
  await mig.up(queryRunner);
7768
- debug13("Migration statements executed");
7961
+ debug14("Migration statements executed");
7769
7962
  return;
7770
7963
  }
7771
7964
  case "sqlite":
7772
7965
  case "expo":
7773
7966
  case "react-native": {
7774
- debug13("using sqlite/react-native migration file");
7967
+ debug14("using sqlite/react-native migration file");
7775
7968
  const mig = new CreateIssuanceBranding1685628973231();
7776
7969
  await mig.up(queryRunner);
7777
- debug13("Migration statements executed");
7970
+ debug14("Migration statements executed");
7778
7971
  return;
7779
7972
  }
7780
7973
  default:
@@ -7782,23 +7975,23 @@ var CreateIssuanceBranding1659463079429 = class {
7782
7975
  }
7783
7976
  }
7784
7977
  async down(queryRunner) {
7785
- debug13("migration: reverting issuance branding tables");
7978
+ debug14("migration: reverting issuance branding tables");
7786
7979
  const dbType = queryRunner.connection.driver.options.type;
7787
7980
  switch (dbType) {
7788
7981
  case "postgres": {
7789
- debug13("using postgres migration file");
7982
+ debug14("using postgres migration file");
7790
7983
  const mig = new CreateIssuanceBranding1685628974232();
7791
7984
  await mig.down(queryRunner);
7792
- debug13("Migration statements executed");
7985
+ debug14("Migration statements executed");
7793
7986
  return;
7794
7987
  }
7795
7988
  case "sqlite":
7796
7989
  case "expo":
7797
7990
  case "react-native": {
7798
- debug13("using sqlite/react-native migration file");
7991
+ debug14("using sqlite/react-native migration file");
7799
7992
  const mig = new CreateIssuanceBranding1685628973231();
7800
7993
  await mig.down(queryRunner);
7801
- debug13("Migration statements executed");
7994
+ debug14("Migration statements executed");
7802
7995
  return;
7803
7996
  }
7804
7997
  default:
@@ -7808,7 +8001,7 @@ var CreateIssuanceBranding1659463079429 = class {
7808
8001
  };
7809
8002
 
7810
8003
  // src/migrations/generic/3-CreateContacts.ts
7811
- import Debug14 from "debug";
8004
+ import Debug15 from "debug";
7812
8005
 
7813
8006
  // src/migrations/postgres/1690925872592-CreateContacts.ts
7814
8007
  import { enablePostgresUuidExtension as enablePostgresUuidExtension3 } from "@sphereon/ssi-sdk.core";
@@ -8029,30 +8222,30 @@ var CreateContacts1690925872693 = class {
8029
8222
  };
8030
8223
 
8031
8224
  // src/migrations/generic/3-CreateContacts.ts
8032
- var debug14 = Debug14("sphereon:ssi-sdk:migrations");
8225
+ var debug15 = Debug15("sphereon:ssi-sdk:migrations");
8033
8226
  var CreateContacts1690925872318 = class {
8034
8227
  static {
8035
8228
  __name(this, "CreateContacts1690925872318");
8036
8229
  }
8037
8230
  name = "CreateContacts1690925872318";
8038
8231
  async up(queryRunner) {
8039
- debug14("migration: creating contacts tables");
8232
+ debug15("migration: creating contacts tables");
8040
8233
  const dbType = queryRunner.connection.driver.options.type;
8041
8234
  switch (dbType) {
8042
8235
  case "postgres": {
8043
- debug14("using postgres migration file");
8236
+ debug15("using postgres migration file");
8044
8237
  const mig = new CreateContacts1690925872592();
8045
8238
  await mig.up(queryRunner);
8046
- debug14("Migration statements executed");
8239
+ debug15("Migration statements executed");
8047
8240
  return;
8048
8241
  }
8049
8242
  case "sqlite":
8050
8243
  case "expo":
8051
8244
  case "react-native": {
8052
- debug14("using sqlite/react-native migration file");
8245
+ debug15("using sqlite/react-native migration file");
8053
8246
  const mig = new CreateContacts1690925872693();
8054
8247
  await mig.up(queryRunner);
8055
- debug14("Migration statements executed");
8248
+ debug15("Migration statements executed");
8056
8249
  return;
8057
8250
  }
8058
8251
  default:
@@ -8060,23 +8253,23 @@ var CreateContacts1690925872318 = class {
8060
8253
  }
8061
8254
  }
8062
8255
  async down(queryRunner) {
8063
- debug14("migration: reverting contacts tables");
8256
+ debug15("migration: reverting contacts tables");
8064
8257
  const dbType = queryRunner.connection.driver.options.type;
8065
8258
  switch (dbType) {
8066
8259
  case "postgres": {
8067
- debug14("using postgres migration file");
8260
+ debug15("using postgres migration file");
8068
8261
  const mig = new CreateContacts1690925872592();
8069
8262
  await mig.down(queryRunner);
8070
- debug14("Migration statements executed");
8263
+ debug15("Migration statements executed");
8071
8264
  return;
8072
8265
  }
8073
8266
  case "sqlite":
8074
8267
  case "expo":
8075
8268
  case "react-native": {
8076
- debug14("using sqlite/react-native migration file");
8269
+ debug15("using sqlite/react-native migration file");
8077
8270
  const mig = new CreateContacts1690925872693();
8078
8271
  await mig.down(queryRunner);
8079
- debug14("Migration statements executed");
8272
+ debug15("Migration statements executed");
8080
8273
  return;
8081
8274
  }
8082
8275
  default:
@@ -8086,7 +8279,7 @@ var CreateContacts1690925872318 = class {
8086
8279
  };
8087
8280
 
8088
8281
  // src/migrations/generic/4-CreateStatusList.ts
8089
- import Debug15 from "debug";
8282
+ import Debug16 from "debug";
8090
8283
 
8091
8284
  // src/migrations/postgres/1693866470001-CreateStatusList.ts
8092
8285
  var CreateStatusList1693866470001 = class {
@@ -8292,53 +8485,53 @@ var UpdateStatusList1737110469000 = class {
8292
8485
  };
8293
8486
 
8294
8487
  // src/migrations/generic/4-CreateStatusList.ts
8295
- var debug15 = Debug15("sphereon:ssi-sdk:migrations");
8488
+ var debug16 = Debug16("sphereon:ssi-sdk:migrations");
8296
8489
  var CreateStatusList1693866470000 = class {
8297
8490
  static {
8298
8491
  __name(this, "CreateStatusList1693866470000");
8299
8492
  }
8300
8493
  name = "CreateStatusList1693866470000";
8301
8494
  async up(queryRunner) {
8302
- debug15("migration: creating issuance branding tables");
8495
+ debug16("migration: creating issuance branding tables");
8303
8496
  const dbType = queryRunner.connection.driver.options.type;
8304
8497
  if (dbType === "postgres") {
8305
- debug15("using postgres migration files");
8498
+ debug16("using postgres migration files");
8306
8499
  const createMig = new CreateStatusList1693866470001();
8307
8500
  await createMig.up(queryRunner);
8308
8501
  const updateMig = new UpdateStatusList1737110469001();
8309
8502
  const up = await updateMig.up(queryRunner);
8310
- debug15("Migration statements executed");
8503
+ debug16("Migration statements executed");
8311
8504
  return up;
8312
8505
  } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8313
- debug15("using sqlite/react-native migration files");
8506
+ debug16("using sqlite/react-native migration files");
8314
8507
  const createMig = new CreateStatusList1693866470002();
8315
8508
  await createMig.up(queryRunner);
8316
8509
  const updateMig = new UpdateStatusList1737110469000();
8317
8510
  const up = await updateMig.up(queryRunner);
8318
- debug15("Migration statements executed");
8511
+ debug16("Migration statements executed");
8319
8512
  return up;
8320
8513
  } else {
8321
8514
  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`);
8322
8515
  }
8323
8516
  }
8324
8517
  async down(queryRunner) {
8325
- debug15("migration: reverting issuance branding tables");
8518
+ debug16("migration: reverting issuance branding tables");
8326
8519
  const dbType = queryRunner.connection.driver.options.type;
8327
8520
  if (dbType === "postgres") {
8328
- debug15("using postgres migration files");
8521
+ debug16("using postgres migration files");
8329
8522
  const updateMig = new UpdateStatusList1737110469001();
8330
8523
  await updateMig.down(queryRunner);
8331
8524
  const createMig = new CreateStatusList1693866470001();
8332
8525
  const down = await createMig.down(queryRunner);
8333
- debug15("Migration statements executed");
8526
+ debug16("Migration statements executed");
8334
8527
  return down;
8335
8528
  } else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
8336
- debug15("using sqlite/react-native migration files");
8529
+ debug16("using sqlite/react-native migration files");
8337
8530
  const updateMig = new UpdateStatusList1737110469000();
8338
8531
  await updateMig.down(queryRunner);
8339
8532
  const createMig = new CreateStatusList1693866470002();
8340
8533
  const down = await createMig.down(queryRunner);
8341
- debug15("Migration statements executed");
8534
+ debug16("Migration statements executed");
8342
8535
  return down;
8343
8536
  } else {
8344
8537
  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`);
@@ -8347,7 +8540,7 @@ var CreateStatusList1693866470000 = class {
8347
8540
  };
8348
8541
 
8349
8542
  // src/migrations/generic/5-CreateAuditEvents.ts
8350
- import Debug16 from "debug";
8543
+ import Debug17 from "debug";
8351
8544
 
8352
8545
  // src/migrations/postgres/1701634812183-CreateAuditEvents.ts
8353
8546
  var CreateAuditEvents1701634812183 = class {
@@ -8446,30 +8639,30 @@ var CreateAuditEvents1701634819487 = class {
8446
8639
  };
8447
8640
 
8448
8641
  // src/migrations/generic/5-CreateAuditEvents.ts
8449
- var debug16 = Debug16("sphereon:ssi-sdk:migrations");
8642
+ var debug17 = Debug17("sphereon:ssi-sdk:migrations");
8450
8643
  var CreateAuditEvents1701635835330 = class {
8451
8644
  static {
8452
8645
  __name(this, "CreateAuditEvents1701635835330");
8453
8646
  }
8454
8647
  name = "CreateAuditEvents1701635835330";
8455
8648
  async up(queryRunner) {
8456
- debug16("migration: creating audit events tables");
8649
+ debug17("migration: creating audit events tables");
8457
8650
  const dbType = queryRunner.connection.driver.options.type;
8458
8651
  switch (dbType) {
8459
8652
  case "postgres": {
8460
- debug16("using postgres migration file");
8653
+ debug17("using postgres migration file");
8461
8654
  const mig = new CreateAuditEvents1701634812183();
8462
8655
  await mig.up(queryRunner);
8463
- debug16("Migration statements executed");
8656
+ debug17("Migration statements executed");
8464
8657
  return;
8465
8658
  }
8466
8659
  case "sqlite":
8467
8660
  case "expo":
8468
8661
  case "react-native": {
8469
- debug16("using sqlite/react-native migration file");
8662
+ debug17("using sqlite/react-native migration file");
8470
8663
  const mig = new CreateAuditEvents1701634819487();
8471
8664
  await mig.up(queryRunner);
8472
- debug16("Migration statements executed");
8665
+ debug17("Migration statements executed");
8473
8666
  return;
8474
8667
  }
8475
8668
  default:
@@ -8477,23 +8670,23 @@ var CreateAuditEvents1701635835330 = class {
8477
8670
  }
8478
8671
  }
8479
8672
  async down(queryRunner) {
8480
- debug16("migration: reverting audit events tables");
8673
+ debug17("migration: reverting audit events tables");
8481
8674
  const dbType = queryRunner.connection.driver.options.type;
8482
8675
  switch (dbType) {
8483
8676
  case "postgres": {
8484
- debug16("using postgres migration file");
8677
+ debug17("using postgres migration file");
8485
8678
  const mig = new CreateAuditEvents1701634812183();
8486
8679
  await mig.down(queryRunner);
8487
- debug16("Migration statements executed");
8680
+ debug17("Migration statements executed");
8488
8681
  return;
8489
8682
  }
8490
8683
  case "sqlite":
8491
8684
  case "expo":
8492
8685
  case "react-native": {
8493
- debug16("using sqlite/react-native migration file");
8686
+ debug17("using sqlite/react-native migration file");
8494
8687
  const mig = new CreateAuditEvents1701634819487();
8495
8688
  await mig.down(queryRunner);
8496
- debug16("Migration statements executed");
8689
+ debug17("Migration statements executed");
8497
8690
  return;
8498
8691
  }
8499
8692
  default:
@@ -8503,7 +8696,7 @@ var CreateAuditEvents1701635835330 = class {
8503
8696
  };
8504
8697
 
8505
8698
  // src/migrations/generic/6-CreateDigitalCredential.ts
8506
- import Debug17 from "debug";
8699
+ import Debug18 from "debug";
8507
8700
 
8508
8701
  // src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
8509
8702
  var CreateDigitalCredential1708525189001 = class {
@@ -8611,30 +8804,30 @@ var CreateDigitalCredential1708525189002 = class {
8611
8804
  };
8612
8805
 
8613
8806
  // src/migrations/generic/6-CreateDigitalCredential.ts
8614
- var debug17 = Debug17("sphereon:ssi-sdk:migrations");
8807
+ var debug18 = Debug18("sphereon:ssi-sdk:migrations");
8615
8808
  var CreateDigitalCredential1708525189000 = class {
8616
8809
  static {
8617
8810
  __name(this, "CreateDigitalCredential1708525189000");
8618
8811
  }
8619
8812
  name = "CreateDigitalCredential1708525189000";
8620
8813
  async up(queryRunner) {
8621
- debug17("migration: creating DigitalCredential tables");
8814
+ debug18("migration: creating DigitalCredential tables");
8622
8815
  const dbType = queryRunner.connection.driver.options.type;
8623
8816
  switch (dbType) {
8624
8817
  case "postgres": {
8625
- debug17("using postgres migration file for DigitalCredential");
8818
+ debug18("using postgres migration file for DigitalCredential");
8626
8819
  const mig = new CreateDigitalCredential1708525189001();
8627
8820
  await mig.up(queryRunner);
8628
- debug17("Postgres Migration statements for DigitalCredential executed");
8821
+ debug18("Postgres Migration statements for DigitalCredential executed");
8629
8822
  return;
8630
8823
  }
8631
8824
  case "sqlite":
8632
8825
  case "expo":
8633
8826
  case "react-native": {
8634
- debug17("using sqlite/react-native migration file for DigitalCredential");
8827
+ debug18("using sqlite/react-native migration file for DigitalCredential");
8635
8828
  const mig = new CreateDigitalCredential1708525189002();
8636
8829
  await mig.up(queryRunner);
8637
- debug17("SQLite Migration statements for DigitalCredential executed");
8830
+ debug18("SQLite Migration statements for DigitalCredential executed");
8638
8831
  return;
8639
8832
  }
8640
8833
  default:
@@ -8642,23 +8835,23 @@ var CreateDigitalCredential1708525189000 = class {
8642
8835
  }
8643
8836
  }
8644
8837
  async down(queryRunner) {
8645
- debug17("migration: reverting DigitalCredential tables");
8838
+ debug18("migration: reverting DigitalCredential tables");
8646
8839
  const dbType = queryRunner.connection.driver.options.type;
8647
8840
  switch (dbType) {
8648
8841
  case "postgres": {
8649
- debug17("using postgres migration file for DigitalCredential");
8842
+ debug18("using postgres migration file for DigitalCredential");
8650
8843
  const mig = new CreateDigitalCredential1708525189001();
8651
8844
  await mig.down(queryRunner);
8652
- debug17("Postgres Migration statements for DigitalCredential reverted");
8845
+ debug18("Postgres Migration statements for DigitalCredential reverted");
8653
8846
  return;
8654
8847
  }
8655
8848
  case "sqlite":
8656
8849
  case "expo":
8657
8850
  case "react-native": {
8658
- debug17("using sqlite/react-native migration file for DigitalCredential");
8851
+ debug18("using sqlite/react-native migration file for DigitalCredential");
8659
8852
  const mig = new CreateDigitalCredential1708525189002();
8660
8853
  await mig.down(queryRunner);
8661
- debug17("SQLite Migration statements for DigitalCredential reverted");
8854
+ debug18("SQLite Migration statements for DigitalCredential reverted");
8662
8855
  return;
8663
8856
  }
8664
8857
  default:
@@ -8668,7 +8861,7 @@ var CreateDigitalCredential1708525189000 = class {
8668
8861
  };
8669
8862
 
8670
8863
  // src/migrations/generic/7-CreateMachineStateStore.ts
8671
- import Debug18 from "debug";
8864
+ import Debug19 from "debug";
8672
8865
 
8673
8866
  // src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
8674
8867
  var CreateMachineStateStore1708797018115 = class {
@@ -8730,30 +8923,30 @@ var CreateMachineStateStore1708796002272 = class {
8730
8923
  };
8731
8924
 
8732
8925
  // src/migrations/generic/7-CreateMachineStateStore.ts
8733
- var debug18 = Debug18("sphereon:ssi-sdk:migrations");
8926
+ var debug19 = Debug19("sphereon:ssi-sdk:migrations");
8734
8927
  var CreateMachineStateStore1708098041262 = class {
8735
8928
  static {
8736
8929
  __name(this, "CreateMachineStateStore1708098041262");
8737
8930
  }
8738
8931
  name = "CreateMachineStateStore1708098041262";
8739
8932
  async up(queryRunner) {
8740
- debug18("migration: creating machine state tables");
8933
+ debug19("migration: creating machine state tables");
8741
8934
  const dbType = queryRunner.connection.driver.options.type;
8742
8935
  switch (dbType) {
8743
8936
  case "postgres": {
8744
- debug18("using postgres migration file");
8937
+ debug19("using postgres migration file");
8745
8938
  const mig = new CreateMachineStateStore1708797018115();
8746
8939
  await mig.up(queryRunner);
8747
- debug18("Migration statements executed");
8940
+ debug19("Migration statements executed");
8748
8941
  return;
8749
8942
  }
8750
8943
  case "sqlite":
8751
8944
  case "expo":
8752
8945
  case "react-native": {
8753
- debug18("using sqlite/react-native migration file");
8946
+ debug19("using sqlite/react-native migration file");
8754
8947
  const mig = new CreateMachineStateStore1708796002272();
8755
8948
  await mig.up(queryRunner);
8756
- debug18("Migration statements executed");
8949
+ debug19("Migration statements executed");
8757
8950
  return;
8758
8951
  }
8759
8952
  default:
@@ -8761,23 +8954,23 @@ var CreateMachineStateStore1708098041262 = class {
8761
8954
  }
8762
8955
  }
8763
8956
  async down(queryRunner) {
8764
- debug18("migration: reverting machine state tables");
8957
+ debug19("migration: reverting machine state tables");
8765
8958
  const dbType = queryRunner.connection.driver.options.type;
8766
8959
  switch (dbType) {
8767
8960
  case "postgres": {
8768
- debug18("using postgres migration file");
8961
+ debug19("using postgres migration file");
8769
8962
  const mig = new CreateMachineStateStore1708797018115();
8770
8963
  await mig.down(queryRunner);
8771
- debug18("Migration statements executed");
8964
+ debug19("Migration statements executed");
8772
8965
  return;
8773
8966
  }
8774
8967
  case "sqlite":
8775
8968
  case "expo":
8776
8969
  case "react-native": {
8777
- debug18("using sqlite/react-native migration file");
8970
+ debug19("using sqlite/react-native migration file");
8778
8971
  const mig = new CreateMachineStateStore1708796002272();
8779
8972
  await mig.down(queryRunner);
8780
- debug18("Migration statements executed");
8973
+ debug19("Migration statements executed");
8781
8974
  return;
8782
8975
  }
8783
8976
  default:
@@ -8787,7 +8980,7 @@ var CreateMachineStateStore1708098041262 = class {
8787
8980
  };
8788
8981
 
8789
8982
  // src/migrations/generic/8-CreateContacts.ts
8790
- import Debug19 from "debug";
8983
+ import Debug20 from "debug";
8791
8984
 
8792
8985
  // src/migrations/postgres/1710438363001-CreateContacts.ts
8793
8986
  var CreateContacts1710438363001 = class {
@@ -8901,30 +9094,30 @@ var CreateContacts1710438363002 = class {
8901
9094
  };
8902
9095
 
8903
9096
  // src/migrations/generic/8-CreateContacts.ts
8904
- var debug19 = Debug19("sphereon:ssi-sdk:migrations");
9097
+ var debug20 = Debug20("sphereon:ssi-sdk:migrations");
8905
9098
  var CreateContacts1708525189000 = class {
8906
9099
  static {
8907
9100
  __name(this, "CreateContacts1708525189000");
8908
9101
  }
8909
9102
  name = "CreateContacts1708525189000";
8910
9103
  async up(queryRunner) {
8911
- debug19("migration: updating contact tables");
9104
+ debug20("migration: updating contact tables");
8912
9105
  const dbType = queryRunner.connection.driver.options.type;
8913
9106
  switch (dbType) {
8914
9107
  case "postgres": {
8915
- debug19("using postgres migration file");
9108
+ debug20("using postgres migration file");
8916
9109
  const mig = new CreateContacts1710438363001();
8917
9110
  await mig.up(queryRunner);
8918
- debug19("Migration statements executed");
9111
+ debug20("Migration statements executed");
8919
9112
  return;
8920
9113
  }
8921
9114
  case "sqlite":
8922
9115
  case "expo":
8923
9116
  case "react-native": {
8924
- debug19("using sqlite/react-native migration file");
9117
+ debug20("using sqlite/react-native migration file");
8925
9118
  const mig = new CreateContacts1710438363002();
8926
9119
  await mig.up(queryRunner);
8927
- debug19("Migration statements executed");
9120
+ debug20("Migration statements executed");
8928
9121
  return;
8929
9122
  }
8930
9123
  default:
@@ -8932,23 +9125,23 @@ var CreateContacts1708525189000 = class {
8932
9125
  }
8933
9126
  }
8934
9127
  async down(queryRunner) {
8935
- debug19("migration: reverting machine state tables");
9128
+ debug20("migration: reverting machine state tables");
8936
9129
  const dbType = queryRunner.connection.driver.options.type;
8937
9130
  switch (dbType) {
8938
9131
  case "postgres": {
8939
- debug19("using postgres migration file");
9132
+ debug20("using postgres migration file");
8940
9133
  const mig = new CreateContacts1710438363001();
8941
9134
  await mig.down(queryRunner);
8942
- debug19("Migration statements executed");
9135
+ debug20("Migration statements executed");
8943
9136
  return;
8944
9137
  }
8945
9138
  case "sqlite":
8946
9139
  case "expo":
8947
9140
  case "react-native": {
8948
- debug19("using sqlite/react-native migration file");
9141
+ debug20("using sqlite/react-native migration file");
8949
9142
  const mig = new CreateContacts1710438363002();
8950
9143
  await mig.down(queryRunner);
8951
- debug19("Migration statements executed");
9144
+ debug20("Migration statements executed");
8952
9145
  return;
8953
9146
  }
8954
9147
  default:
@@ -8958,7 +9151,7 @@ var CreateContacts1708525189000 = class {
8958
9151
  };
8959
9152
 
8960
9153
  // src/migrations/generic/9-CreateContacts.ts
8961
- import Debug20 from "debug";
9154
+ import Debug21 from "debug";
8962
9155
 
8963
9156
  // src/migrations/postgres/1715761125001-CreateContacts.ts
8964
9157
  var CreateContacts1715761125001 = class {
@@ -9070,30 +9263,30 @@ var CreateContacts1715761125002 = class {
9070
9263
  };
9071
9264
 
9072
9265
  // src/migrations/generic/9-CreateContacts.ts
9073
- var debug20 = Debug20("sphereon:ssi-sdk:migrations");
9266
+ var debug21 = Debug21("sphereon:ssi-sdk:migrations");
9074
9267
  var CreateContacts1715761125000 = class {
9075
9268
  static {
9076
9269
  __name(this, "CreateContacts1715761125000");
9077
9270
  }
9078
9271
  name = "CreateContacts1715761125000";
9079
9272
  async up(queryRunner) {
9080
- debug20("migration: updating contact tables");
9273
+ debug21("migration: updating contact tables");
9081
9274
  const dbType = queryRunner.connection.driver.options.type;
9082
9275
  switch (dbType) {
9083
9276
  case "postgres": {
9084
- debug20("using postgres migration file");
9277
+ debug21("using postgres migration file");
9085
9278
  const mig = new CreateContacts1715761125001();
9086
9279
  await mig.up(queryRunner);
9087
- debug20("Migration statements executed");
9280
+ debug21("Migration statements executed");
9088
9281
  return;
9089
9282
  }
9090
9283
  case "sqlite":
9091
9284
  case "expo":
9092
9285
  case "react-native": {
9093
- debug20("using sqlite/react-native migration file");
9286
+ debug21("using sqlite/react-native migration file");
9094
9287
  const mig = new CreateContacts1715761125002();
9095
9288
  await mig.up(queryRunner);
9096
- debug20("Migration statements executed");
9289
+ debug21("Migration statements executed");
9097
9290
  return;
9098
9291
  }
9099
9292
  default:
@@ -9101,23 +9294,23 @@ var CreateContacts1715761125000 = class {
9101
9294
  }
9102
9295
  }
9103
9296
  async down(queryRunner) {
9104
- debug20("migration: reverting machine state tables");
9297
+ debug21("migration: reverting machine state tables");
9105
9298
  const dbType = queryRunner.connection.driver.options.type;
9106
9299
  switch (dbType) {
9107
9300
  case "postgres": {
9108
- debug20("using postgres migration file");
9301
+ debug21("using postgres migration file");
9109
9302
  const mig = new CreateContacts1715761125001();
9110
9303
  await mig.down(queryRunner);
9111
- debug20("Migration statements executed");
9304
+ debug21("Migration statements executed");
9112
9305
  return;
9113
9306
  }
9114
9307
  case "sqlite":
9115
9308
  case "expo":
9116
9309
  case "react-native": {
9117
- debug20("using sqlite/react-native migration file");
9310
+ debug21("using sqlite/react-native migration file");
9118
9311
  const mig = new CreateContacts1715761125002();
9119
9312
  await mig.down(queryRunner);
9120
- debug20("Migration statements executed");
9313
+ debug21("Migration statements executed");
9121
9314
  return;
9122
9315
  }
9123
9316
  default:
@@ -9146,7 +9339,8 @@ var DataStoreEventLoggerMigrations = [
9146
9339
  CreateAuditEvents1701635835330
9147
9340
  ];
9148
9341
  var DataStoreDigitalCredentialMigrations = [
9149
- CreateDigitalCredential1708525189000
9342
+ CreateDigitalCredential1708525189000,
9343
+ AddLinkedVpFields1763387280000
9150
9344
  ];
9151
9345
  var DataStoreMachineStateMigrations = [
9152
9346
  CreateMachineStateStore1708098041262
@@ -9167,7 +9361,7 @@ var DataStoreMigrations = [
9167
9361
 
9168
9362
  // src/utils/digitalCredential/MappingUtils.ts
9169
9363
  import { defaultHasher } from "@sphereon/ssi-sdk.core";
9170
- import { CredentialDocumentFormat as CredentialDocumentFormat2, DocumentType as DocumentType2, RegulationType as RegulationType2 } from "@sphereon/ssi-sdk.data-store-types";
9364
+ import { CredentialDocumentFormat as CredentialDocumentFormat2, CredentialStateType as CredentialStateType3, DocumentType as DocumentType2, RegulationType as RegulationType2 } from "@sphereon/ssi-sdk.data-store-types";
9171
9365
  import { CredentialMapper, DocumentFormat, ObjectUtils } from "@sphereon/ssi-types";
9172
9366
  import { computeEntryHash } from "@veramo/utils";
9173
9367
  function determineDocumentType(raw) {
@@ -9218,6 +9412,18 @@ function determineCredentialDocumentFormat(documentFormat) {
9218
9412
  }
9219
9413
  }
9220
9414
  __name(determineCredentialDocumentFormat, "determineCredentialDocumentFormat");
9415
+ function normalizeNullableFields(obj, nullableKeys) {
9416
+ const normalized = {
9417
+ ...obj
9418
+ };
9419
+ for (const key of nullableKeys) {
9420
+ if (normalized[key] === void 0) {
9421
+ normalized[key] = null;
9422
+ }
9423
+ }
9424
+ return normalized;
9425
+ }
9426
+ __name(normalizeNullableFields, "normalizeNullableFields");
9221
9427
  function getValidUntil(uniformDocument) {
9222
9428
  if ("expirationDate" in uniformDocument && uniformDocument.expirationDate) {
9223
9429
  return new Date(uniformDocument.expirationDate);
@@ -9280,6 +9486,34 @@ var nonPersistedDigitalCredentialEntityFromAddArgs = /* @__PURE__ */ __name((add
9280
9486
  lastUpdatedAt: /* @__PURE__ */ new Date()
9281
9487
  };
9282
9488
  }, "nonPersistedDigitalCredentialEntityFromAddArgs");
9489
+ var persistedDigitalCredentialEntityFromUpdateArgs = /* @__PURE__ */ __name((existingCredential, updates) => {
9490
+ const entity = new DigitalCredentialEntity();
9491
+ Object.assign(entity, existingCredential);
9492
+ const normalizedUpdates = normalizeNullableFields(updates, [
9493
+ "linkedVpId",
9494
+ "linkedVpFrom",
9495
+ "linkedVpUntil"
9496
+ ]);
9497
+ Object.assign(entity, normalizedUpdates);
9498
+ entity.id = existingCredential.id;
9499
+ entity.hash = existingCredential.hash;
9500
+ entity.createdAt = existingCredential.createdAt;
9501
+ entity.lastUpdatedAt = /* @__PURE__ */ new Date();
9502
+ return entity;
9503
+ }, "persistedDigitalCredentialEntityFromUpdateArgs");
9504
+ var persistedDigitalCredentialEntityFromStateArgs = /* @__PURE__ */ __name((existingCredential, args) => {
9505
+ const entity = new DigitalCredentialEntity();
9506
+ Object.assign(entity, existingCredential);
9507
+ entity.verifiedState = args.verifiedState;
9508
+ entity.lastUpdatedAt = /* @__PURE__ */ new Date();
9509
+ if (args.verifiedState === CredentialStateType3.REVOKED && args.revokedAt) {
9510
+ entity.revokedAt = args.revokedAt;
9511
+ }
9512
+ if (args.verifiedState !== CredentialStateType3.REVOKED && args.verifiedAt) {
9513
+ entity.verifiedAt = args.verifiedAt;
9514
+ }
9515
+ return entity;
9516
+ }, "persistedDigitalCredentialEntityFromStateArgs");
9283
9517
  var digitalCredentialFrom = /* @__PURE__ */ __name((credentialEntity) => {
9284
9518
  const result = {
9285
9519
  ...credentialEntity
@@ -9456,6 +9690,7 @@ export {
9456
9690
  naturalPersonEntityFrom,
9457
9691
  naturalPersonFrom,
9458
9692
  nonPersistedDigitalCredentialEntityFromAddArgs,
9693
+ normalizeNullableFields,
9459
9694
  openIdConfigEntityFrom,
9460
9695
  openIdConfigFrom,
9461
9696
  organizationEntityFrom,
@@ -9467,6 +9702,8 @@ export {
9467
9702
  partyRelationshipFrom,
9468
9703
  partyTypeEntityFrom,
9469
9704
  partyTypeFrom,
9705
+ persistedDigitalCredentialEntityFromStateArgs,
9706
+ persistedDigitalCredentialEntityFromUpdateArgs,
9470
9707
  physicalAddressEntityFrom,
9471
9708
  physicalAddressFrom,
9472
9709
  textAttributesEntityFrom