@nmshd/transport 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/buildInformation.js +5 -5
  2. package/dist/core/CoreIdHelper.d.ts +1 -1
  3. package/dist/core/CoreIdHelper.js.map +1 -1
  4. package/dist/core/{DbCollectionNames.d.ts → DbCollectionName.d.ts} +2 -2
  5. package/dist/core/DbCollectionName.js +16 -0
  6. package/dist/core/DbCollectionName.js.map +1 -0
  7. package/dist/core/ICacheable.d.ts +1 -0
  8. package/dist/core/ICacheable.js +6 -2
  9. package/dist/core/ICacheable.js.map +1 -1
  10. package/dist/core/Transport.d.ts +1 -1
  11. package/dist/core/backbone/AuthClient.js.map +1 -1
  12. package/dist/core/backbone/RESTClient.js +1 -2
  13. package/dist/core/backbone/RESTClient.js.map +1 -1
  14. package/dist/modules/accounts/AccountController.js +2 -2
  15. package/dist/modules/accounts/AccountController.js.map +1 -1
  16. package/dist/modules/certificates/CertificateIssuer.js +2 -2
  17. package/dist/modules/certificates/CertificateIssuer.js.map +1 -1
  18. package/dist/modules/devices/DevicesController.js +2 -2
  19. package/dist/modules/devices/DevicesController.js.map +1 -1
  20. package/dist/modules/files/FileController.d.ts +6 -0
  21. package/dist/modules/files/FileController.js +22 -7
  22. package/dist/modules/files/FileController.js.map +1 -1
  23. package/dist/modules/messages/MessageController.d.ts +6 -1
  24. package/dist/modules/messages/MessageController.js +18 -5
  25. package/dist/modules/messages/MessageController.js.map +1 -1
  26. package/dist/modules/relationshipTemplates/RelationshipTemplateController.d.ts +6 -0
  27. package/dist/modules/relationshipTemplates/RelationshipTemplateController.js +22 -7
  28. package/dist/modules/relationshipTemplates/RelationshipTemplateController.js.map +1 -1
  29. package/dist/modules/relationships/RelationshipsController.d.ts +6 -0
  30. package/dist/modules/relationships/RelationshipsController.js +36 -18
  31. package/dist/modules/relationships/RelationshipsController.js.map +1 -1
  32. package/dist/modules/secrets/SecretController.js +2 -2
  33. package/dist/modules/secrets/SecretController.js.map +1 -1
  34. package/dist/modules/sync/DatawalletModificationsProcessor.d.ts +42 -9
  35. package/dist/modules/sync/DatawalletModificationsProcessor.js +66 -37
  36. package/dist/modules/sync/DatawalletModificationsProcessor.js.map +1 -1
  37. package/dist/modules/sync/SyncController.js +1 -1
  38. package/dist/modules/sync/SyncController.js.map +1 -1
  39. package/dist/modules/tokens/TokenController.d.ts +6 -0
  40. package/dist/modules/tokens/TokenController.js +22 -7
  41. package/dist/modules/tokens/TokenController.js.map +1 -1
  42. package/lib-web/nmshd.transport.js +411 -221
  43. package/lib-web/nmshd.transport.js.map +1 -1
  44. package/lib-web/nmshd.transport.min.js +1 -1
  45. package/lib-web/nmshd.transport.min.js.map +1 -1
  46. package/package.json +3 -3
  47. package/dist/core/DbCollectionNames.js +0 -16
  48. package/dist/core/DbCollectionNames.js.map +0 -1
@@ -15,11 +15,11 @@ exports.buildInformation = void 0;
15
15
  const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
16
16
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
17
17
  exports.buildInformation = {
18
- version: "1.0.2",
19
- build: "5",
20
- date: "2021-09-30T08:27:43+00:00",
21
- commit: "dbec0223dae9590e34133f0058f0ae4b88fe652c",
22
- dependencies: {"@js-soft/docdb-access-abstractions":"1.0.1","@js-soft/logging-abstractions":"1.0.0","@js-soft/simple-logger":"1.0.0","@js-soft/ts-utils":"1.0.1","axios":"^0.21.4","deep-equal":"^2.0.5","fast-json-patch":"^3.1.0","form-data":"^4.0.0","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^2.0.2","qs":"^6.10.1","reflect-metadata":"^0.1.13","ts-simple-nameof":"^1.3.1","uuid":"^8.3.2"},
18
+ version: "1.0.3",
19
+ build: "6",
20
+ date: "2021-10-04T12:56:05+00:00",
21
+ commit: "d976ae0870949b85d8b2c8c4ca728ba1c09d0353",
22
+ dependencies: {"@js-soft/docdb-access-abstractions":"1.0.1","@js-soft/logging-abstractions":"1.0.0","@js-soft/simple-logger":"1.0.0","@js-soft/ts-utils":"1.0.1","axios":"^0.22.0","deep-equal":"^2.0.5","fast-json-patch":"^3.1.0","form-data":"^4.0.0","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^2.0.2","qs":"^6.10.1","reflect-metadata":"^0.1.13","ts-simple-nameof":"^1.3.1","uuid":"^8.3.2"},
23
23
  libraries: {
24
24
  crypto: crypto_1.buildInformation,
25
25
  serval: ts_serval_1.buildInformation
@@ -546,29 +546,29 @@ exports.CoreUtil = CoreUtil;
546
546
 
547
547
  /***/ }),
548
548
 
549
- /***/ "./dist/core/DbCollectionNames.js":
550
- /*!****************************************!*\
551
- !*** ./dist/core/DbCollectionNames.js ***!
552
- \****************************************/
549
+ /***/ "./dist/core/DbCollectionName.js":
550
+ /*!***************************************!*\
551
+ !*** ./dist/core/DbCollectionName.js ***!
552
+ \***************************************/
553
553
  /***/ ((__unused_webpack_module, exports) => {
554
554
 
555
555
  "use strict";
556
556
 
557
557
  Object.defineProperty(exports, "__esModule", ({ value: true }));
558
- exports.DbCollectionNames = void 0;
559
- var DbCollectionNames;
560
- (function (DbCollectionNames) {
561
- DbCollectionNames["Files"] = "Files";
562
- DbCollectionNames["Tokens"] = "Tokens";
563
- DbCollectionNames["Relationships"] = "Relationships";
564
- DbCollectionNames["Templates"] = "Templates";
565
- DbCollectionNames["Messages"] = "Messages";
566
- DbCollectionNames["CertificatesIssued"] = "CertificatesIssued";
567
- DbCollectionNames["UnpushedDatawalletModifications"] = "UnpushedDatawalletModifications";
568
- DbCollectionNames["Devices"] = "Devices";
569
- DbCollectionNames["Secrets"] = "Secrets";
570
- })(DbCollectionNames = exports.DbCollectionNames || (exports.DbCollectionNames = {}));
571
- //# sourceMappingURL=DbCollectionNames.js.map
558
+ exports.DbCollectionName = void 0;
559
+ var DbCollectionName;
560
+ (function (DbCollectionName) {
561
+ DbCollectionName["Files"] = "Files";
562
+ DbCollectionName["Tokens"] = "Tokens";
563
+ DbCollectionName["Relationships"] = "Relationships";
564
+ DbCollectionName["RelationshipTemplates"] = "Templates";
565
+ DbCollectionName["Messages"] = "Messages";
566
+ DbCollectionName["CertificatesIssued"] = "CertificatesIssued";
567
+ DbCollectionName["UnpushedDatawalletModifications"] = "UnpushedDatawalletModifications";
568
+ DbCollectionName["Devices"] = "Devices";
569
+ DbCollectionName["Secrets"] = "Secrets";
570
+ })(DbCollectionName = exports.DbCollectionName || (exports.DbCollectionName = {}));
571
+ //# sourceMappingURL=DbCollectionName.js.map
572
572
 
573
573
  /***/ }),
574
574
 
@@ -588,8 +588,12 @@ function isCacheable(object) {
588
588
  if (!(object instanceof CoreSynchronizable_1.CoreSynchronizable)) {
589
589
  return false;
590
590
  }
591
- const hasCacheProperty = Object.prototype.hasOwnProperty.call(object.toJSON(), (0, ts_simple_nameof_1.nameof)((o) => o.cache));
592
- return hasCacheProperty;
591
+ if (typeof object !== "object") {
592
+ return false;
593
+ }
594
+ const hasCacheProperty = object.toJSON().hasOwnProperty((0, ts_simple_nameof_1.nameof)((o) => o.cache));
595
+ const hasSetCacheMethod = typeof object.setCache === "function";
596
+ return hasCacheProperty && hasSetCacheMethod;
593
597
  }
594
598
  exports.isCacheable = isCacheable;
595
599
  //# sourceMappingURL=ICacheable.js.map
@@ -1543,10 +1547,9 @@ class RESTClient {
1543
1547
  return response;
1544
1548
  });
1545
1549
  const logResponseTime = (response) => {
1546
- var _a;
1547
1550
  const requestStartTime = response.config.meta.startTime;
1548
1551
  // Backbone Call duration
1549
- const backboneResponseDuration = ((_a = response.headers) === null || _a === void 0 ? void 0 : _a["x-response-duration-ms"])
1552
+ const backboneResponseDuration = response.headers["x-response-duration-ms"]
1550
1553
  ? Number.parseInt(response.headers["x-response-duration-ms"])
1551
1554
  : undefined;
1552
1555
  const backboneMessage = `${response.config.method.toUpperCase()} ${response.request.path} (backbone call): ${backboneResponseDuration ? `${backboneResponseDuration}ms` : "unknown"}`;
@@ -2591,7 +2594,7 @@ const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
2591
2594
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
2592
2595
  const Authenticator_1 = __webpack_require__(/*! ../../core/backbone/Authenticator */ "./dist/core/backbone/Authenticator.js");
2593
2596
  const CoreCrypto_1 = __webpack_require__(/*! ../../core/CoreCrypto */ "./dist/core/CoreCrypto.js");
2594
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
2597
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
2595
2598
  const TransportLoggerFactory_1 = __webpack_require__(/*! ../../core/TransportLoggerFactory */ "./dist/core/TransportLoggerFactory.js");
2596
2599
  const util_1 = __webpack_require__(/*! ../../util */ "./dist/util/index.js");
2597
2600
  const CertificateController_1 = __webpack_require__(/*! ../certificates/CertificateController */ "./dist/modules/certificates/CertificateController.js");
@@ -2656,7 +2659,7 @@ class AccountController {
2656
2659
  // TODO: JSSNMSHDD-2487 (last login date)
2657
2660
  async init(deviceSharedSecret) {
2658
2661
  this.info = await this.db.getMap("AccountInfo");
2659
- this.unpushedDatawalletModifications = await this.db.getCollection(DbCollectionNames_1.DbCollectionNames.UnpushedDatawalletModifications);
2662
+ this.unpushedDatawalletModifications = await this.db.getCollection(DbCollectionName_1.DbCollectionName.UnpushedDatawalletModifications);
2660
2663
  this.deviceClient = new DeviceClient_1.DeviceClient(this.config);
2661
2664
  this.identityClient = new IdentityClient_1.IdentityClient(this.config);
2662
2665
  this._identity = new IdentityController_1.IdentityController(this);
@@ -3213,7 +3216,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
3213
3216
  exports.CertificateContentParam = exports.CertificateIssuer = void 0;
3214
3217
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
3215
3218
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
3216
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
3219
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
3217
3220
  const Certificate_1 = __webpack_require__(/*! ./data/Certificate */ "./dist/modules/certificates/data/Certificate.js");
3218
3221
  const CertificateContent_1 = __webpack_require__(/*! ./data/CertificateContent */ "./dist/modules/certificates/data/CertificateContent.js");
3219
3222
  /**
@@ -3227,7 +3230,7 @@ class CertificateIssuer extends core_1.TransportController {
3227
3230
  }
3228
3231
  async init() {
3229
3232
  await super.init();
3230
- this.certificatesIssued = await this.db.getCollection(DbCollectionNames_1.DbCollectionNames.CertificatesIssued);
3233
+ this.certificatesIssued = await this.db.getCollection(DbCollectionName_1.DbCollectionName.CertificatesIssued);
3231
3234
  return this;
3232
3235
  }
3233
3236
  async issueCertificate(value) {
@@ -4684,7 +4687,7 @@ DeviceSecretController.secretContext = "DEVICE01";
4684
4687
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4685
4688
  exports.DevicesController = void 0;
4686
4689
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
4687
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
4690
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
4688
4691
  const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
4689
4692
  const util_1 = __webpack_require__(/*! ../../util */ "./dist/util/index.js");
4690
4693
  const Challenge_1 = __webpack_require__(/*! ../challenges/data/Challenge */ "./dist/modules/challenges/data/Challenge.js");
@@ -4698,7 +4701,7 @@ class DevicesController extends TransportController_1.TransportController {
4698
4701
  async init() {
4699
4702
  await super.init();
4700
4703
  this.client = new DeviceAuthClient_1.DeviceAuthClient(this.config, this.parent.authenticator);
4701
- this.devices = await this.parent.getSynchronizedCollection(DbCollectionNames_1.DbCollectionNames.Devices);
4704
+ this.devices = await this.parent.getSynchronizedCollection(DbCollectionName_1.DbCollectionName.Devices);
4702
4705
  return this;
4703
4706
  }
4704
4707
  async get(id) {
@@ -5188,7 +5191,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
5188
5191
  exports.FileController = void 0;
5189
5192
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
5190
5193
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
5191
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
5194
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
5192
5195
  const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
5193
5196
  const FileClient_1 = __webpack_require__(/*! ./backbone/FileClient */ "./dist/modules/files/backbone/FileClient.js");
5194
5197
  const CachedFile_1 = __webpack_require__(/*! ./local/CachedFile */ "./dist/modules/files/local/CachedFile.js");
@@ -5203,7 +5206,7 @@ class FileController extends TransportController_1.TransportController {
5203
5206
  async init() {
5204
5207
  await super.init();
5205
5208
  this.client = new FileClient_1.FileClient(this.config, this.parent.authenticator);
5206
- this.files = await this.parent.getSynchronizedCollection(DbCollectionNames_1.DbCollectionNames.Files);
5209
+ this.files = await this.parent.getSynchronizedCollection(DbCollectionName_1.DbCollectionName.Files);
5207
5210
  return this;
5208
5211
  }
5209
5212
  async getFiles(query) {
@@ -5214,6 +5217,17 @@ class FileController extends TransportController_1.TransportController {
5214
5217
  const doc = await this.files.read(id.toString());
5215
5218
  return doc ? await File_1.File.from(doc) : undefined;
5216
5219
  }
5220
+ async fetchCaches(ids) {
5221
+ if (ids.length === 0)
5222
+ return [];
5223
+ const backboneFiles = await (await this.client.getFiles({ ids: ids.map((id) => id.id) })).value.collect();
5224
+ const decryptionPromises = backboneFiles.map(async (f) => {
5225
+ const fileDoc = await this.files.read(f.id);
5226
+ const file = await File_1.File.from(fileDoc);
5227
+ return { id: core_1.CoreId.from(f.id), cache: await this.decryptFile(f, file.secretKey) };
5228
+ });
5229
+ return await Promise.all(decryptionPromises);
5230
+ }
5217
5231
  async updateCache(ids) {
5218
5232
  const resultItems = (await this.client.getFiles({ ids })).value;
5219
5233
  const promises = [];
@@ -5237,17 +5251,21 @@ class FileController extends TransportController_1.TransportController {
5237
5251
  if (!response) {
5238
5252
  response = (await this.client.getFile(fileId)).value;
5239
5253
  }
5254
+ const cachedFile = await this.decryptFile(response, file.secretKey);
5255
+ file.setCache(cachedFile);
5256
+ // Update isOwn, as it is possible that the identity receives an attachment with an own File.
5257
+ file.isOwn = this.parent.identity.isMe(cachedFile.createdBy);
5258
+ }
5259
+ async decryptFile(response, secretKey) {
5240
5260
  const cipher = await crypto_1.CryptoCipher.fromBase64(response.encryptedProperties);
5241
- const plaintextMetadataBuffer = await core_1.CoreCrypto.decrypt(cipher, file.secretKey);
5261
+ const plaintextMetadataBuffer = await core_1.CoreCrypto.decrypt(cipher, secretKey);
5242
5262
  const plaintextMetadata = await FileMetadata_1.FileMetadata.deserialize(plaintextMetadataBuffer.toUtf8());
5243
5263
  if (!(plaintextMetadata instanceof FileMetadata_1.FileMetadata)) {
5244
- throw core_1.TransportErrors.files.invalidMetadata(fileId).logWith(this._log);
5264
+ throw core_1.TransportErrors.files.invalidMetadata(response.id).logWith(this._log);
5245
5265
  }
5246
5266
  // TODO: JSSNMSHDD-2486 (check signature)
5247
5267
  const cachedFile = await CachedFile_1.CachedFile.fromBackbone(response, plaintextMetadata);
5248
- file.setCache(cachedFile);
5249
- // Update isOwn, as it is possible that the identity receives an attachment with an own File.
5250
- file.isOwn = this.parent.identity.isMe(cachedFile.createdBy);
5268
+ return cachedFile;
5251
5269
  }
5252
5270
  async loadPeerFileByTruncated(truncated) {
5253
5271
  const reference = await FileReference_1.FileReference.fromTruncated(truncated);
@@ -6065,7 +6083,7 @@ exports.MessageController = void 0;
6065
6083
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
6066
6084
  const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
6067
6085
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
6068
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
6086
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
6069
6087
  const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
6070
6088
  const File_1 = __webpack_require__(/*! ../files/local/File */ "./dist/modules/files/local/File.js");
6071
6089
  const Relationship_1 = __webpack_require__(/*! ../relationships/local/Relationship */ "./dist/modules/relationships/local/Relationship.js");
@@ -6089,7 +6107,7 @@ class MessageController extends TransportController_1.TransportController {
6089
6107
  this.secrets = new RelationshipSecretController_1.RelationshipSecretController(this.parent);
6090
6108
  await this.secrets.init();
6091
6109
  this.client = new MessageClient_1.MessageClient(this.config, this.parent.authenticator);
6092
- this.messages = await this.parent.getSynchronizedCollection(DbCollectionNames_1.DbCollectionNames.Messages);
6110
+ this.messages = await this.parent.getSynchronizedCollection(DbCollectionName_1.DbCollectionName.Messages);
6093
6111
  return this;
6094
6112
  }
6095
6113
  async getMessages(query) {
@@ -6127,6 +6145,19 @@ class MessageController extends TransportController_1.TransportController {
6127
6145
  }
6128
6146
  return await Promise.all(promises);
6129
6147
  }
6148
+ async fetchCaches(ids) {
6149
+ if (ids.length === 0)
6150
+ return [];
6151
+ const backboneMessages = await (await this.client.getMessages({ ids: ids.map((id) => id.toString()) })).value.collect();
6152
+ const decryptionPromises = backboneMessages.map(async (m) => {
6153
+ const messageDoc = await this.messages.read(m.id);
6154
+ const message = await Message_1.Message.from(messageDoc);
6155
+ const envelope = await this.getEnvelopeFromBackboneGetMessagesResponse(m);
6156
+ const cachedMessage = (await this.decryptMessage(envelope, message.secretKey))[0];
6157
+ return { id: core_1.CoreId.from(m.id), cache: cachedMessage };
6158
+ });
6159
+ return await Promise.all(decryptionPromises);
6160
+ }
6130
6161
  async updateCacheOfExistingMessageInDb(id, response) {
6131
6162
  const messageDoc = await this.messages.read(id);
6132
6163
  if (!messageDoc) {
@@ -6143,14 +6174,14 @@ class MessageController extends TransportController_1.TransportController {
6143
6174
  response = (await this.client.getMessage(messageId)).value;
6144
6175
  }
6145
6176
  const envelope = await this.getEnvelopeFromBackboneGetMessagesResponse(response);
6146
- const [cachedMessage, messageKey] = await this.decryptSealedEnvelope(envelope, message.secretKey);
6177
+ const [cachedMessage, messageKey] = await this.decryptMessage(envelope, message.secretKey);
6147
6178
  message.secretKey = messageKey;
6148
6179
  message.setCache(cachedMessage);
6149
6180
  }
6150
6181
  async loadPeerMessage(id) {
6151
6182
  const response = (await this.client.getMessage(id.toString())).value;
6152
6183
  const envelope = await this.getEnvelopeFromBackboneGetMessagesResponse(response);
6153
- const [cachedMessage, messageKey, relationship] = await this.decryptSealedEnvelope(envelope);
6184
+ const [cachedMessage, messageKey, relationship] = await this.decryptMessage(envelope);
6154
6185
  if (!relationship) {
6155
6186
  throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, envelope.id.toString()).logWith(this._log);
6156
6187
  }
@@ -6331,7 +6362,7 @@ class MessageController extends TransportController_1.TransportController {
6331
6362
  }
6332
6363
  return [messagePlain, plaintextKey];
6333
6364
  }
6334
- async decryptSealedEnvelope(envelope, secretKey) {
6365
+ async decryptMessage(envelope, secretKey) {
6335
6366
  this.log.trace(`Decrypting MessageEnvelope with id ${envelope.id}...`);
6336
6367
  let plainMessage;
6337
6368
  let messageKey;
@@ -7002,7 +7033,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
7002
7033
  exports.RelationshipTemplateController = void 0;
7003
7034
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
7004
7035
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
7005
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
7036
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
7006
7037
  const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
7007
7038
  const RelationshipTemplateClient_1 = __webpack_require__(/*! ./backbone/RelationshipTemplateClient */ "./dist/modules/relationshipTemplates/backbone/RelationshipTemplateClient.js");
7008
7039
  const CachedRelationshipTemplate_1 = __webpack_require__(/*! ./local/CachedRelationshipTemplate */ "./dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js");
@@ -7018,7 +7049,7 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
7018
7049
  }
7019
7050
  async init() {
7020
7051
  await super.init();
7021
- this.templates = await this.parent.getSynchronizedCollection(DbCollectionNames_1.DbCollectionNames.Templates);
7052
+ this.templates = await this.parent.getSynchronizedCollection(DbCollectionName_1.DbCollectionName.RelationshipTemplates);
7022
7053
  return this;
7023
7054
  }
7024
7055
  async sendRelationshipTemplate(parameters) {
@@ -7081,6 +7112,17 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
7081
7112
  }
7082
7113
  return await Promise.all(promises);
7083
7114
  }
7115
+ async fetchCaches(ids) {
7116
+ if (ids.length === 0)
7117
+ return [];
7118
+ const backboneRelationships = await (await this.client.getRelationshipTemplates({ ids: ids.map((id) => id.id) })).value.collect();
7119
+ const decryptionPromises = backboneRelationships.map(async (t) => {
7120
+ const templateDoc = await this.templates.read(t.id);
7121
+ const template = await RelationshipTemplate_1.RelationshipTemplate.from(templateDoc);
7122
+ return { id: core_1.CoreId.from(t.id), cache: await this.decryptRelationshipTemplate(t, template.secretKey) };
7123
+ });
7124
+ return await Promise.all(decryptionPromises);
7125
+ }
7084
7126
  async updateCacheOfExistingTemplateInDb(id, response) {
7085
7127
  const templateDoc = await this.templates.read(id);
7086
7128
  if (!templateDoc) {
@@ -7092,12 +7134,18 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
7092
7134
  return template;
7093
7135
  }
7094
7136
  async updateCacheOfTemplate(template, response) {
7095
- var _a;
7096
7137
  if (!response) {
7097
7138
  response = (await this.client.getRelationshipTemplate(template.id.toString())).value;
7098
7139
  }
7140
+ const cachedTemplate = await this.decryptRelationshipTemplate(response, template.secretKey);
7141
+ template.setCache(cachedTemplate);
7142
+ // Update isOwn, as it is possible that the identity receives an own template.
7143
+ template.isOwn = this.parent.identity.isMe(cachedTemplate.createdBy);
7144
+ }
7145
+ async decryptRelationshipTemplate(response, secretKey) {
7146
+ var _a;
7099
7147
  const cipher = await crypto_1.CryptoCipher.fromBase64(response.content);
7100
- const signedTemplateBuffer = await this.secrets.decryptTemplate(cipher, template.secretKey);
7148
+ const signedTemplateBuffer = await this.secrets.decryptTemplate(cipher, secretKey);
7101
7149
  const signedTemplate = await RelationshipTemplateSigned_1.RelationshipTemplateSigned.deserialize(signedTemplateBuffer.toUtf8());
7102
7150
  const templateContent = await RelationshipTemplateContent_1.RelationshipTemplateContent.deserialize(signedTemplate.serializedTemplate);
7103
7151
  const templateSignatureValid = await this.secrets.verifyTemplate(crypto_1.CoreBuffer.fromUtf8(signedTemplate.serializedTemplate), signedTemplate.deviceSignature, templateContent.identity.publicKey);
@@ -7114,9 +7162,7 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
7114
7162
  maxNumberOfRelationships: (_a = response.maxNumberOfRelationships) !== null && _a !== void 0 ? _a : undefined,
7115
7163
  templateKey: templateContent.templateKey
7116
7164
  });
7117
- template.setCache(cachedTemplate);
7118
- // Update isOwn, as it is possible that the identity receives an own template.
7119
- template.isOwn = this.parent.identity.isMe(cachedTemplate.createdBy);
7165
+ return cachedTemplate;
7120
7166
  }
7121
7167
  async getRelationshipTemplate(id) {
7122
7168
  const templateDoc = await this.templates.read(id.toString());
@@ -7811,7 +7857,7 @@ const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
7811
7857
  const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
7812
7858
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
7813
7859
  const CoreUtil_1 = __webpack_require__(/*! ../../core/CoreUtil */ "./dist/core/CoreUtil.js");
7814
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
7860
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
7815
7861
  const TransportErrors_1 = __webpack_require__(/*! ../../core/TransportErrors */ "./dist/core/TransportErrors.js");
7816
7862
  const TransportIds_1 = __webpack_require__(/*! ../../core/TransportIds */ "./dist/core/TransportIds.js");
7817
7863
  const RelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js");
@@ -7838,7 +7884,7 @@ class RelationshipsController extends core_1.TransportController {
7838
7884
  async init() {
7839
7885
  await super.init();
7840
7886
  this.client = new RelationshipClient_1.RelationshipClient(this.config, this.parent.authenticator);
7841
- this.relationships = await this.parent.getSynchronizedCollection(DbCollectionNames_1.DbCollectionNames.Relationships);
7887
+ this.relationships = await this.parent.getSynchronizedCollection(DbCollectionName_1.DbCollectionName.Relationships);
7842
7888
  return this;
7843
7889
  }
7844
7890
  async getRelationships(query) {
@@ -7853,6 +7899,20 @@ class RelationshipsController extends core_1.TransportController {
7853
7899
  }
7854
7900
  return await Promise.all(promises);
7855
7901
  }
7902
+ async fetchCaches(ids) {
7903
+ if (ids.length === 0)
7904
+ return [];
7905
+ const backboneRelationships = await (await this.client.getRelationships({ ids: ids.map((id) => id.id) })).value.collect();
7906
+ const decryptionPromises = backboneRelationships.map(async (r) => {
7907
+ const relationshipDoc = await this.relationships.read(r.id);
7908
+ const relationship = await Relationship_1.Relationship.from(relationshipDoc);
7909
+ return {
7910
+ id: core_1.CoreId.from(r.id),
7911
+ cache: await this.decryptRelationship(r, relationship.relationshipSecretId)
7912
+ };
7913
+ });
7914
+ return await Promise.all(decryptionPromises);
7915
+ }
7856
7916
  async updateCacheOfExistingRelationshipInDb(id, response) {
7857
7917
  const relationshipDoc = await this.relationships.read(id);
7858
7918
  if (!relationshipDoc) {
@@ -7939,18 +7999,22 @@ class RelationshipsController extends core_1.TransportController {
7939
7999
  if (!response) {
7940
8000
  response = (await this.client.getRelationship(relationship.id.toString())).value;
7941
8001
  }
8002
+ const cachedRelationship = await this.decryptRelationship(response, relationship.relationshipSecretId);
8003
+ relationship.setCache(cachedRelationship);
8004
+ }
8005
+ async decryptRelationship(response, relationshipSecretId) {
7942
8006
  const templateId = core_1.CoreId.from(response.relationshipTemplateId);
7943
- this._log.trace(`Parsing relationship template ${templateId} for ${relationship.id}...`);
8007
+ this._log.trace(`Parsing relationship template ${templateId} for ${response.id}...`);
7944
8008
  const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId);
7945
8009
  if (!template) {
7946
8010
  throw TransportErrors_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString());
7947
8011
  }
7948
- this._log.trace(`Parsing relationship changes of ${relationship.id}...`);
8012
+ this._log.trace(`Parsing relationship changes of ${response.id}...`);
7949
8013
  const changesPromises = [];
7950
8014
  for (const change of response.changes) {
7951
8015
  switch (change.type) {
7952
8016
  case RelationshipChangeType_1.RelationshipChangeType.Creation:
7953
- changesPromises.push(this.parseCreationChange(change, relationship, templateId));
8017
+ changesPromises.push(this.parseCreationChange(change, relationshipSecretId, templateId));
7954
8018
  break;
7955
8019
  default:
7956
8020
  break;
@@ -7961,7 +8025,7 @@ class RelationshipsController extends core_1.TransportController {
7961
8025
  changes: changes,
7962
8026
  template: template
7963
8027
  });
7964
- relationship.setCache(cachedRelationship);
8028
+ return cachedRelationship;
7965
8029
  }
7966
8030
  async prepareRequest(relationshipSecretId, template, content) {
7967
8031
  if (!template.cache) {
@@ -8027,15 +8091,15 @@ class RelationshipsController extends core_1.TransportController {
8027
8091
  }
8028
8092
  return newRelationship;
8029
8093
  }
8030
- async parseCreationChange(change, relationship, templateId) {
8094
+ async parseCreationChange(change, relationshipSecretId, templateId) {
8031
8095
  if (change.type !== RelationshipChangeType_1.RelationshipChangeType.Creation) {
8032
8096
  throw TransportErrors_1.TransportErrors.relationships.wrongChangeType(change.type).logWith(this._log);
8033
8097
  }
8034
8098
  const promises = [];
8035
- promises.push(this.decryptCreationChangeRequest(change.request, relationship.relationshipSecretId, templateId));
8036
- const hasRelationshipSecret = await this.secrets.hasCryptoRelationshipSecrets(relationship.relationshipSecretId);
8099
+ promises.push(this.decryptCreationChangeRequest(change.request, relationshipSecretId, templateId));
8100
+ const hasRelationshipSecret = await this.secrets.hasCryptoRelationshipSecrets(relationshipSecretId);
8037
8101
  if (change.response && hasRelationshipSecret) {
8038
- promises.push(this.decryptCreationChangeResponse(change, relationship));
8102
+ promises.push(this.decryptCreationChangeResponse(change, relationshipSecretId));
8039
8103
  }
8040
8104
  const [requestContent, responseContent] = await Promise.all(promises);
8041
8105
  const creationChange = await RelationshipChange_1.RelationshipChange.fromBackbone(change, requestContent.content, responseContent === null || responseContent === void 0 ? void 0 : responseContent.content);
@@ -8065,7 +8129,7 @@ class RelationshipsController extends core_1.TransportController {
8065
8129
  }
8066
8130
  return requestContent;
8067
8131
  }
8068
- async decryptCreationChangeResponse(change, relationship) {
8132
+ async decryptCreationChangeResponse(change, relationshipSecretId) {
8069
8133
  if (!change.response) {
8070
8134
  throw TransportErrors_1.TransportErrors.relationships.changeResponseMissing(change.id).logWith(this._log);
8071
8135
  }
@@ -8080,28 +8144,28 @@ class RelationshipsController extends core_1.TransportController {
8080
8144
  let signedResponseBuffer;
8081
8145
  if (change.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Revoked) {
8082
8146
  if (isOwnChange) {
8083
- signedResponseBuffer = await this.secrets.decryptOwn(relationship.relationshipSecretId, cipher.cipher);
8147
+ signedResponseBuffer = await this.secrets.decryptOwn(relationshipSecretId, cipher.cipher);
8084
8148
  }
8085
8149
  else {
8086
- signedResponseBuffer = await this.secrets.decryptPeer(relationship.relationshipSecretId, cipher.cipher, true);
8150
+ signedResponseBuffer = await this.secrets.decryptPeer(relationshipSecretId, cipher.cipher, true);
8087
8151
  }
8088
8152
  }
8089
8153
  else {
8090
- signedResponseBuffer = await this.secrets.decryptRequest(relationship.relationshipSecretId, cipher.cipher);
8154
+ signedResponseBuffer = await this.secrets.decryptRequest(relationshipSecretId, cipher.cipher);
8091
8155
  }
8092
8156
  const signedResponse = await RelationshipCreationChangeResponseSigned_1.RelationshipCreationChangeResponseSigned.deserialize(signedResponseBuffer.toUtf8());
8093
8157
  let relationshipSignatureValid;
8094
8158
  if (isOwnChange) {
8095
- relationshipSignatureValid = await this.secrets.verifyOwn(relationship.relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
8159
+ relationshipSignatureValid = await this.secrets.verifyOwn(relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
8096
8160
  }
8097
8161
  else {
8098
- relationshipSignatureValid = await this.secrets.verifyPeer(relationship.relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
8162
+ relationshipSignatureValid = await this.secrets.verifyPeer(relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
8099
8163
  }
8100
8164
  if (!relationshipSignatureValid) {
8101
8165
  throw TransportErrors_1.TransportErrors.general.signatureNotValid("relationshipResponse").logWith(this._log);
8102
8166
  }
8103
8167
  const responseContent = await RelationshipCreationChangeResponseContent_1.RelationshipCreationChangeResponseContent.deserialize(signedResponse.serializedResponse);
8104
- if (responseContent.relationshipId.toString() !== relationship.id.toString()) {
8168
+ if (responseContent.relationshipId.toString() !== change.relationshipId.toString()) {
8105
8169
  throw TransportErrors_1.TransportErrors.relationships.responseContainsWrongRequestId().logWith(this._log);
8106
8170
  }
8107
8171
  return responseContent;
@@ -8128,7 +8192,7 @@ class RelationshipsController extends core_1.TransportController {
8128
8192
  }
8129
8193
  await this.secrets.convertSecrets(relationship.relationshipSecretId, cipher.publicResponseCrypto);
8130
8194
  }
8131
- const responseContent = await this.decryptCreationChangeResponse(change, relationship);
8195
+ const responseContent = await this.decryptCreationChangeResponse(change, relationship.relationshipSecretId);
8132
8196
  const response = await RelationshipChangeResponse_1.RelationshipChangeResponse.fromBackbone(change.response, responseContent.content);
8133
8197
  if (!relationship.cache) {
8134
8198
  throw TransportErrors_1.TransportErrors.general.cacheEmpty(Relationship_1.Relationship, relationship.id.toString());
@@ -9231,7 +9295,7 @@ exports.SecretController = exports.SecretBaseKeyType = void 0;
9231
9295
  const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
9232
9296
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
9233
9297
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
9234
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
9298
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
9235
9299
  const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
9236
9300
  const DeviceSecretController_1 = __webpack_require__(/*! ../devices/DeviceSecretController */ "./dist/modules/devices/DeviceSecretController.js");
9237
9301
  const SecretContainerCipher_1 = __webpack_require__(/*! ./data/SecretContainerCipher */ "./dist/modules/secrets/data/SecretContainerCipher.js");
@@ -9253,7 +9317,7 @@ class SecretController extends TransportController_1.TransportController {
9253
9317
  }
9254
9318
  async init() {
9255
9319
  await super.init();
9256
- this.secrets = await this.parent.getSynchronizedCollection(DbCollectionNames_1.DbCollectionNames.Secrets);
9320
+ this.secrets = await this.parent.getSynchronizedCollection(DbCollectionName_1.DbCollectionName.Secrets);
9257
9321
  const lastNonce = await this.parent.info.get(SecretController.secretNonceKey);
9258
9322
  if (lastNonce) {
9259
9323
  this.nonce = lastNonce;
@@ -9690,20 +9754,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9690
9754
  return (mod && mod.__esModule) ? mod : { "default": mod };
9691
9755
  };
9692
9756
  Object.defineProperty(exports, "__esModule", ({ value: true }));
9693
- exports.DatawalletModificationsProcessor = void 0;
9757
+ exports.CacheFetcher = exports.DatawalletModificationsProcessor = void 0;
9694
9758
  const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"));
9695
9759
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
9696
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
9760
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
9761
+ const File_1 = __webpack_require__(/*! ../files/local/File */ "./dist/modules/files/local/File.js");
9762
+ const Message_1 = __webpack_require__(/*! ../messages/local/Message */ "./dist/modules/messages/local/Message.js");
9763
+ const Relationship_1 = __webpack_require__(/*! ../relationships/local/Relationship */ "./dist/modules/relationships/local/Relationship.js");
9764
+ const RelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js");
9765
+ const Token_1 = __webpack_require__(/*! ../tokens/local/Token */ "./dist/modules/tokens/local/Token.js");
9697
9766
  const DatawalletModification_1 = __webpack_require__(/*! ./local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js");
9698
9767
  class DatawalletModificationsProcessor {
9699
- constructor(collectionProvider, modifications, fileCacheUpdater, messageCacheUpdater, relationshipTemplateCacheUpdater, relationshipCacheUpdater, tokenCacheUpdater) {
9768
+ constructor(cacheFetcher, collectionProvider, modifications) {
9769
+ this.cacheFetcher = cacheFetcher;
9700
9770
  this.collectionProvider = collectionProvider;
9701
9771
  this.modifications = modifications;
9702
- this.fileCacheUpdater = fileCacheUpdater;
9703
- this.messageCacheUpdater = messageCacheUpdater;
9704
- this.relationshipTemplateCacheUpdater = relationshipTemplateCacheUpdater;
9705
- this.relationshipCacheUpdater = relationshipCacheUpdater;
9706
- this.tokenCacheUpdater = tokenCacheUpdater;
9707
9772
  }
9708
9773
  async execute() {
9709
9774
  const modificationsGroupedByType = lodash_1.default.groupBy(this.modifications, (m) => m.type);
@@ -9759,42 +9824,70 @@ class DatawalletModificationsProcessor {
9759
9824
  }
9760
9825
  }
9761
9826
  async applyCacheChanges(cacheChanges) {
9827
+ var _a, _b, _c, _d, _e;
9762
9828
  if (!cacheChanges || cacheChanges.length === 0) {
9763
9829
  return;
9764
9830
  }
9765
9831
  const cacheChangesGroupedByCollection = lodash_1.default.groupBy(cacheChanges, (c) => c.collection);
9766
- const fillCachePromises = [];
9767
- for (const collectionName in cacheChangesGroupedByCollection) {
9768
- const modificationsInCollection = cacheChangesGroupedByCollection[collectionName];
9769
- switch (collectionName) {
9770
- case DbCollectionNames_1.DbCollectionNames.Files:
9771
- fillCachePromises.push(this.fileCacheUpdater.updateCache(modificationsInCollection.map((m) => m.objectIdentifier.toString())));
9772
- break;
9773
- case DbCollectionNames_1.DbCollectionNames.Messages:
9774
- fillCachePromises.push(this.messageCacheUpdater.updateCache(modificationsInCollection.map((m) => m.objectIdentifier.toString())));
9775
- break;
9776
- case DbCollectionNames_1.DbCollectionNames.Relationships:
9777
- // Relationship caches are filled afterwards. It requires the template caches to be filled.
9778
- break;
9779
- case DbCollectionNames_1.DbCollectionNames.Templates:
9780
- fillCachePromises.push(this.relationshipTemplateCacheUpdater.updateCache(modificationsInCollection.map((m) => m.objectIdentifier.toString())));
9781
- break;
9782
- case DbCollectionNames_1.DbCollectionNames.Tokens:
9783
- fillCachePromises.push(this.tokenCacheUpdater.updateCache(modificationsInCollection.map((m) => m.objectIdentifier.toString())));
9784
- break;
9785
- default:
9786
- throw new Error(`DB collection with name '${collectionName}' is not supported.'`);
9787
- }
9788
- }
9789
- await Promise.all(fillCachePromises);
9790
- const relationshipCacheUpdates = cacheChangesGroupedByCollection[DbCollectionNames_1.DbCollectionNames.Relationships];
9791
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
9792
- if (relationshipCacheUpdates) {
9793
- await this.relationshipCacheUpdater.updateCache(relationshipCacheUpdates.map((m) => m.objectIdentifier.toString()));
9794
- }
9832
+ const caches = await this.cacheFetcher.fetchCacheFor({
9833
+ files: ((_a = cacheChangesGroupedByCollection[DbCollectionName_1.DbCollectionName.Files]) !== null && _a !== void 0 ? _a : []).map((m) => m.objectIdentifier),
9834
+ messages: ((_b = cacheChangesGroupedByCollection[DbCollectionName_1.DbCollectionName.Messages]) !== null && _b !== void 0 ? _b : []).map((m) => m.objectIdentifier),
9835
+ relationshipTemplates: ((_c = cacheChangesGroupedByCollection[DbCollectionName_1.DbCollectionName.RelationshipTemplates]) !== null && _c !== void 0 ? _c : []).map((m) => m.objectIdentifier),
9836
+ tokens: ((_d = cacheChangesGroupedByCollection[DbCollectionName_1.DbCollectionName.Tokens]) !== null && _d !== void 0 ? _d : []).map((m) => m.objectIdentifier)
9837
+ });
9838
+ await this.save(caches.files, DbCollectionName_1.DbCollectionName.Files, File_1.File);
9839
+ await this.save(caches.messages, DbCollectionName_1.DbCollectionName.Messages, Message_1.Message);
9840
+ await this.save(caches.relationshipTemplates, DbCollectionName_1.DbCollectionName.RelationshipTemplates, RelationshipTemplate_1.RelationshipTemplate);
9841
+ await this.save(caches.tokens, DbCollectionName_1.DbCollectionName.Tokens, Token_1.Token);
9842
+ const relationshipCaches = await this.cacheFetcher.fetchCacheFor({
9843
+ relationships: ((_e = cacheChangesGroupedByCollection[DbCollectionName_1.DbCollectionName.Relationships]) !== null && _e !== void 0 ? _e : []).map((m) => m.objectIdentifier)
9844
+ });
9845
+ await this.save(relationshipCaches.relationships, DbCollectionName_1.DbCollectionName.Relationships, Relationship_1.Relationship);
9846
+ }
9847
+ async save(caches, collectionName, constructorOfT) {
9848
+ const collection = await this.collectionProvider.getCollection(collectionName);
9849
+ await Promise.all(caches.map(async (c) => {
9850
+ const itemDoc = await collection.read(c.id.toString());
9851
+ const item = await core_1.CoreSerializableAsync.fromT(itemDoc, constructorOfT);
9852
+ item.setCache(c.cache);
9853
+ await collection.update(itemDoc, item);
9854
+ }));
9795
9855
  }
9796
9856
  }
9797
9857
  exports.DatawalletModificationsProcessor = DatawalletModificationsProcessor;
9858
+ class CacheFetcher {
9859
+ constructor(fileController, messageController, relationshipTemplateController, relationshipController, tokenController) {
9860
+ this.fileController = fileController;
9861
+ this.messageController = messageController;
9862
+ this.relationshipTemplateController = relationshipTemplateController;
9863
+ this.relationshipController = relationshipController;
9864
+ this.tokenController = tokenController;
9865
+ }
9866
+ async fetchCacheFor(input) {
9867
+ const caches = await Promise.all([
9868
+ this.fetchCaches(this.fileController, input.files),
9869
+ this.fetchCaches(this.messageController, input.messages),
9870
+ this.fetchCaches(this.relationshipController, input.relationships),
9871
+ this.fetchCaches(this.relationshipTemplateController, input.relationshipTemplates),
9872
+ this.fetchCaches(this.tokenController, input.tokens)
9873
+ ]);
9874
+ const output = {
9875
+ files: caches[0],
9876
+ messages: caches[1],
9877
+ relationships: caches[2],
9878
+ relationshipTemplates: caches[3],
9879
+ tokens: caches[4]
9880
+ };
9881
+ return output;
9882
+ }
9883
+ async fetchCaches(controller, ids) {
9884
+ if (!ids)
9885
+ return [];
9886
+ const caches = await controller.fetchCaches(ids);
9887
+ return caches;
9888
+ }
9889
+ }
9890
+ exports.CacheFetcher = CacheFetcher;
9798
9891
  //# sourceMappingURL=DatawalletModificationsProcessor.js.map
9799
9892
 
9800
9893
  /***/ }),
@@ -9985,7 +10078,7 @@ class SyncController extends core_1.TransportController {
9985
10078
  }
9986
10079
  const incomingModifications = await this.decryptDatawalletModifications(encryptedIncomingModifications);
9987
10080
  this.log.trace(`${incomingModifications.length} incoming modifications found`);
9988
- const datawalletModificationsProcessor = new DatawalletModificationsProcessor_1.DatawalletModificationsProcessor(this._db, incomingModifications, this.parent.files, this.parent.messages, this.parent.relationshipTemplates, this.parent.relationships, this.parent.tokens);
10081
+ const datawalletModificationsProcessor = new DatawalletModificationsProcessor_1.DatawalletModificationsProcessor(new DatawalletModificationsProcessor_1.CacheFetcher(this.parent.files, this.parent.messages, this.parent.relationshipTemplates, this.parent.relationships, this.parent.tokens), this._db, incomingModifications);
9989
10082
  await datawalletModificationsProcessor.execute();
9990
10083
  this.log.trace(`${incomingModifications.length} incoming modifications executed`, incomingModifications);
9991
10084
  await this.updateLocalDatawalletModificationIndex(encryptedIncomingModifications.sort(descending)[0].index);
@@ -10492,7 +10585,7 @@ exports.TokenController = void 0;
10492
10585
  const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
10493
10586
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
10494
10587
  const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
10495
- const DbCollectionNames_1 = __webpack_require__(/*! ../../core/DbCollectionNames */ "./dist/core/DbCollectionNames.js");
10588
+ const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
10496
10589
  const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
10497
10590
  const TokenClient_1 = __webpack_require__(/*! ./backbone/TokenClient */ "./dist/modules/tokens/backbone/TokenClient.js");
10498
10591
  const CachedToken_1 = __webpack_require__(/*! ./local/CachedToken */ "./dist/modules/tokens/local/CachedToken.js");
@@ -10506,7 +10599,7 @@ class TokenController extends TransportController_1.TransportController {
10506
10599
  async init() {
10507
10600
  await super.init();
10508
10601
  this.client = new TokenClient_1.TokenClient(this.config, this.parent.authenticator);
10509
- this.tokens = await this.parent.getSynchronizedCollection(DbCollectionNames_1.DbCollectionNames.Tokens);
10602
+ this.tokens = await this.parent.getSynchronizedCollection(DbCollectionName_1.DbCollectionName.Tokens);
10510
10603
  return this;
10511
10604
  }
10512
10605
  async getTokens(query) {
@@ -10565,6 +10658,17 @@ class TokenController extends TransportController_1.TransportController {
10565
10658
  }
10566
10659
  return await Promise.all(promises);
10567
10660
  }
10661
+ async fetchCaches(ids) {
10662
+ if (ids.length === 0)
10663
+ return [];
10664
+ const backboneTokens = await (await this.client.getTokens({ ids: ids.map((id) => id.id) })).value.collect();
10665
+ const decryptionPromises = backboneTokens.map(async (t) => {
10666
+ const tokenDoc = await this.tokens.read(t.id);
10667
+ const token = await Token_1.Token.from(tokenDoc);
10668
+ return { id: core_1.CoreId.from(t), cache: await this.decryptToken(t, token.secretKey) };
10669
+ });
10670
+ return await Promise.all(decryptionPromises);
10671
+ }
10568
10672
  async updateCacheOfExistingTokenInDb(id, response) {
10569
10673
  const tokenDoc = await this.tokens.read(id);
10570
10674
  if (!tokenDoc) {
@@ -10580,11 +10684,17 @@ class TokenController extends TransportController_1.TransportController {
10580
10684
  if (!response) {
10581
10685
  response = (await this.client.getToken(tokenId)).value;
10582
10686
  }
10687
+ const cachedToken = await this.decryptToken(response, token.secretKey);
10688
+ token.setCache(cachedToken);
10689
+ // Update isOwn, as it is possible that the identity receives an own token
10690
+ token.isOwn = this.parent.identity.isMe(cachedToken.createdBy);
10691
+ }
10692
+ async decryptToken(response, secretKey) {
10583
10693
  const cipher = await crypto_1.CryptoCipher.fromBase64(response.content);
10584
- const plaintextTokenBuffer = await core_1.CoreCrypto.decrypt(cipher, token.secretKey);
10694
+ const plaintextTokenBuffer = await core_1.CoreCrypto.decrypt(cipher, secretKey);
10585
10695
  const plaintextTokenContent = await core_1.CoreSerializableAsync.deserializeUnknown(plaintextTokenBuffer.toUtf8());
10586
10696
  if (!(plaintextTokenContent instanceof ts_serval_1.SerializableAsync)) {
10587
- throw core_1.TransportErrors.tokens.invalidTokenContent(tokenId).logWith(this._log);
10697
+ throw core_1.TransportErrors.tokens.invalidTokenContent(response.id).logWith(this._log);
10588
10698
  }
10589
10699
  const cachedToken = await CachedToken_1.CachedToken.from({
10590
10700
  createdAt: core_1.CoreDate.from(response.createdAt),
@@ -10593,9 +10703,7 @@ class TokenController extends TransportController_1.TransportController {
10593
10703
  createdByDevice: core_1.CoreId.from(response.createdByDevice),
10594
10704
  content: plaintextTokenContent
10595
10705
  });
10596
- token.setCache(cachedToken);
10597
- // Update isOwn, as it is possible that the identity receives an own token
10598
- token.isOwn = this.parent.identity.isMe(cachedToken.createdBy);
10706
+ return cachedToken;
10599
10707
  }
10600
10708
  async loadPeerTokenByTruncated(truncated, ephemeral) {
10601
10709
  const reference = await TokenReference_1.TokenReference.fromTruncated(truncated);
@@ -12088,12 +12196,24 @@ var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_mod
12088
12196
  var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
12089
12197
  var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
12090
12198
  var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
12199
+ var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
12200
+ var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
12091
12201
 
12092
12202
  module.exports = function xhrAdapter(config) {
12093
12203
  return new Promise(function dispatchXhrRequest(resolve, reject) {
12094
12204
  var requestData = config.data;
12095
12205
  var requestHeaders = config.headers;
12096
12206
  var responseType = config.responseType;
12207
+ var onCanceled;
12208
+ function done() {
12209
+ if (config.cancelToken) {
12210
+ config.cancelToken.unsubscribe(onCanceled);
12211
+ }
12212
+
12213
+ if (config.signal) {
12214
+ config.signal.removeEventListener('abort', onCanceled);
12215
+ }
12216
+ }
12097
12217
 
12098
12218
  if (utils.isFormData(requestData)) {
12099
12219
  delete requestHeaders['Content-Type']; // Let the browser set it
@@ -12131,7 +12251,13 @@ module.exports = function xhrAdapter(config) {
12131
12251
  request: request
12132
12252
  };
12133
12253
 
12134
- settle(resolve, reject, response);
12254
+ settle(function _resolve(value) {
12255
+ resolve(value);
12256
+ done();
12257
+ }, function _reject(err) {
12258
+ reject(err);
12259
+ done();
12260
+ }, response);
12135
12261
 
12136
12262
  // Clean up request
12137
12263
  request = null;
@@ -12185,13 +12311,14 @@ module.exports = function xhrAdapter(config) {
12185
12311
  // Handle timeout
12186
12312
  request.ontimeout = function handleTimeout() {
12187
12313
  var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
12314
+ var transitional = config.transitional || defaults.transitional;
12188
12315
  if (config.timeoutErrorMessage) {
12189
12316
  timeoutErrorMessage = config.timeoutErrorMessage;
12190
12317
  }
12191
12318
  reject(createError(
12192
12319
  timeoutErrorMessage,
12193
12320
  config,
12194
- config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
12321
+ transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
12195
12322
  request));
12196
12323
 
12197
12324
  // Clean up request
@@ -12245,18 +12372,22 @@ module.exports = function xhrAdapter(config) {
12245
12372
  request.upload.addEventListener('progress', config.onUploadProgress);
12246
12373
  }
12247
12374
 
12248
- if (config.cancelToken) {
12375
+ if (config.cancelToken || config.signal) {
12249
12376
  // Handle cancellation
12250
- config.cancelToken.promise.then(function onCanceled(cancel) {
12377
+ // eslint-disable-next-line func-names
12378
+ onCanceled = function(cancel) {
12251
12379
  if (!request) {
12252
12380
  return;
12253
12381
  }
12254
-
12382
+ reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
12255
12383
  request.abort();
12256
- reject(cancel);
12257
- // Clean up request
12258
12384
  request = null;
12259
- });
12385
+ };
12386
+
12387
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
12388
+ if (config.signal) {
12389
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
12390
+ }
12260
12391
  }
12261
12392
 
12262
12393
  if (!requestData) {
@@ -12302,6 +12433,11 @@ function createInstance(defaultConfig) {
12302
12433
  // Copy context to instance
12303
12434
  utils.extend(instance, context);
12304
12435
 
12436
+ // Factory for creating new instances
12437
+ instance.create = function create(instanceConfig) {
12438
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
12439
+ };
12440
+
12305
12441
  return instance;
12306
12442
  }
12307
12443
 
@@ -12311,15 +12447,11 @@ var axios = createInstance(defaults);
12311
12447
  // Expose Axios class to allow class inheritance
12312
12448
  axios.Axios = Axios;
12313
12449
 
12314
- // Factory for creating new instances
12315
- axios.create = function create(instanceConfig) {
12316
- return createInstance(mergeConfig(axios.defaults, instanceConfig));
12317
- };
12318
-
12319
12450
  // Expose Cancel & CancelToken
12320
12451
  axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
12321
12452
  axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
12322
12453
  axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
12454
+ axios.VERSION = __webpack_require__(/*! ./env/data */ "./node_modules/axios/lib/env/data.js").version;
12323
12455
 
12324
12456
  // Expose all/spread
12325
12457
  axios.all = function all(promises) {
@@ -12391,11 +12523,42 @@ function CancelToken(executor) {
12391
12523
  }
12392
12524
 
12393
12525
  var resolvePromise;
12526
+
12394
12527
  this.promise = new Promise(function promiseExecutor(resolve) {
12395
12528
  resolvePromise = resolve;
12396
12529
  });
12397
12530
 
12398
12531
  var token = this;
12532
+
12533
+ // eslint-disable-next-line func-names
12534
+ this.promise.then(function(cancel) {
12535
+ if (!token._listeners) return;
12536
+
12537
+ var i;
12538
+ var l = token._listeners.length;
12539
+
12540
+ for (i = 0; i < l; i++) {
12541
+ token._listeners[i](cancel);
12542
+ }
12543
+ token._listeners = null;
12544
+ });
12545
+
12546
+ // eslint-disable-next-line func-names
12547
+ this.promise.then = function(onfulfilled) {
12548
+ var _resolve;
12549
+ // eslint-disable-next-line func-names
12550
+ var promise = new Promise(function(resolve) {
12551
+ token.subscribe(resolve);
12552
+ _resolve = resolve;
12553
+ }).then(onfulfilled);
12554
+
12555
+ promise.cancel = function reject() {
12556
+ token.unsubscribe(_resolve);
12557
+ };
12558
+
12559
+ return promise;
12560
+ };
12561
+
12399
12562
  executor(function cancel(message) {
12400
12563
  if (token.reason) {
12401
12564
  // Cancellation has already been requested
@@ -12416,6 +12579,37 @@ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
12416
12579
  }
12417
12580
  };
12418
12581
 
12582
+ /**
12583
+ * Subscribe to the cancel signal
12584
+ */
12585
+
12586
+ CancelToken.prototype.subscribe = function subscribe(listener) {
12587
+ if (this.reason) {
12588
+ listener(this.reason);
12589
+ return;
12590
+ }
12591
+
12592
+ if (this._listeners) {
12593
+ this._listeners.push(listener);
12594
+ } else {
12595
+ this._listeners = [listener];
12596
+ }
12597
+ };
12598
+
12599
+ /**
12600
+ * Unsubscribe from the cancel signal
12601
+ */
12602
+
12603
+ CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
12604
+ if (!this._listeners) {
12605
+ return;
12606
+ }
12607
+ var index = this._listeners.indexOf(listener);
12608
+ if (index !== -1) {
12609
+ this._listeners.splice(index, 1);
12610
+ }
12611
+ };
12612
+
12419
12613
  /**
12420
12614
  * Returns an object that contains a new `CancelToken` and a function that, when called,
12421
12615
  * cancels the `CancelToken`.
@@ -12512,9 +12706,9 @@ Axios.prototype.request = function request(config) {
12512
12706
 
12513
12707
  if (transitional !== undefined) {
12514
12708
  validator.assertOptions(transitional, {
12515
- silentJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
12516
- forcedJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
12517
- clarifyTimeoutError: validators.transitional(validators.boolean, '1.0.0')
12709
+ silentJSONParsing: validators.transitional(validators.boolean),
12710
+ forcedJSONParsing: validators.transitional(validators.boolean),
12711
+ clarifyTimeoutError: validators.transitional(validators.boolean)
12518
12712
  }, false);
12519
12713
  }
12520
12714
 
@@ -12749,6 +12943,7 @@ var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/util
12749
12943
  var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
12750
12944
  var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
12751
12945
  var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
12946
+ var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
12752
12947
 
12753
12948
  /**
12754
12949
  * Throws a `Cancel` if cancellation has been requested.
@@ -12757,6 +12952,10 @@ function throwIfCancellationRequested(config) {
12757
12952
  if (config.cancelToken) {
12758
12953
  config.cancelToken.throwIfRequested();
12759
12954
  }
12955
+
12956
+ if (config.signal && config.signal.aborted) {
12957
+ throw new Cancel('canceled');
12958
+ }
12760
12959
  }
12761
12960
 
12762
12961
  /**
@@ -12873,7 +13072,8 @@ module.exports = function enhanceError(error, config, code, request, response) {
12873
13072
  stack: this.stack,
12874
13073
  // Axios
12875
13074
  config: this.config,
12876
- code: this.code
13075
+ code: this.code,
13076
+ status: this.response && this.response.status ? this.response.status : null
12877
13077
  };
12878
13078
  };
12879
13079
  return error;
@@ -12906,17 +13106,6 @@ module.exports = function mergeConfig(config1, config2) {
12906
13106
  config2 = config2 || {};
12907
13107
  var config = {};
12908
13108
 
12909
- var valueFromConfig2Keys = ['url', 'method', 'data'];
12910
- var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
12911
- var defaultToConfig2Keys = [
12912
- 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
12913
- 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
12914
- 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
12915
- 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
12916
- 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
12917
- ];
12918
- var directMergeKeys = ['validateStatus'];
12919
-
12920
13109
  function getMergedValue(target, source) {
12921
13110
  if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
12922
13111
  return utils.merge(target, source);
@@ -12928,51 +13117,74 @@ module.exports = function mergeConfig(config1, config2) {
12928
13117
  return source;
12929
13118
  }
12930
13119
 
13120
+ // eslint-disable-next-line consistent-return
12931
13121
  function mergeDeepProperties(prop) {
12932
13122
  if (!utils.isUndefined(config2[prop])) {
12933
- config[prop] = getMergedValue(config1[prop], config2[prop]);
13123
+ return getMergedValue(config1[prop], config2[prop]);
12934
13124
  } else if (!utils.isUndefined(config1[prop])) {
12935
- config[prop] = getMergedValue(undefined, config1[prop]);
13125
+ return getMergedValue(undefined, config1[prop]);
12936
13126
  }
12937
13127
  }
12938
13128
 
12939
- utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
13129
+ // eslint-disable-next-line consistent-return
13130
+ function valueFromConfig2(prop) {
12940
13131
  if (!utils.isUndefined(config2[prop])) {
12941
- config[prop] = getMergedValue(undefined, config2[prop]);
13132
+ return getMergedValue(undefined, config2[prop]);
12942
13133
  }
12943
- });
12944
-
12945
- utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
13134
+ }
12946
13135
 
12947
- utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
13136
+ // eslint-disable-next-line consistent-return
13137
+ function defaultToConfig2(prop) {
12948
13138
  if (!utils.isUndefined(config2[prop])) {
12949
- config[prop] = getMergedValue(undefined, config2[prop]);
13139
+ return getMergedValue(undefined, config2[prop]);
12950
13140
  } else if (!utils.isUndefined(config1[prop])) {
12951
- config[prop] = getMergedValue(undefined, config1[prop]);
13141
+ return getMergedValue(undefined, config1[prop]);
12952
13142
  }
12953
- });
13143
+ }
12954
13144
 
12955
- utils.forEach(directMergeKeys, function merge(prop) {
13145
+ // eslint-disable-next-line consistent-return
13146
+ function mergeDirectKeys(prop) {
12956
13147
  if (prop in config2) {
12957
- config[prop] = getMergedValue(config1[prop], config2[prop]);
13148
+ return getMergedValue(config1[prop], config2[prop]);
12958
13149
  } else if (prop in config1) {
12959
- config[prop] = getMergedValue(undefined, config1[prop]);
12960
- }
12961
- });
12962
-
12963
- var axiosKeys = valueFromConfig2Keys
12964
- .concat(mergeDeepPropertiesKeys)
12965
- .concat(defaultToConfig2Keys)
12966
- .concat(directMergeKeys);
12967
-
12968
- var otherKeys = Object
12969
- .keys(config1)
12970
- .concat(Object.keys(config2))
12971
- .filter(function filterAxiosKeys(key) {
12972
- return axiosKeys.indexOf(key) === -1;
12973
- });
13150
+ return getMergedValue(undefined, config1[prop]);
13151
+ }
13152
+ }
13153
+
13154
+ var mergeMap = {
13155
+ 'url': valueFromConfig2,
13156
+ 'method': valueFromConfig2,
13157
+ 'data': valueFromConfig2,
13158
+ 'baseURL': defaultToConfig2,
13159
+ 'transformRequest': defaultToConfig2,
13160
+ 'transformResponse': defaultToConfig2,
13161
+ 'paramsSerializer': defaultToConfig2,
13162
+ 'timeout': defaultToConfig2,
13163
+ 'timeoutMessage': defaultToConfig2,
13164
+ 'withCredentials': defaultToConfig2,
13165
+ 'adapter': defaultToConfig2,
13166
+ 'responseType': defaultToConfig2,
13167
+ 'xsrfCookieName': defaultToConfig2,
13168
+ 'xsrfHeaderName': defaultToConfig2,
13169
+ 'onUploadProgress': defaultToConfig2,
13170
+ 'onDownloadProgress': defaultToConfig2,
13171
+ 'decompress': defaultToConfig2,
13172
+ 'maxContentLength': defaultToConfig2,
13173
+ 'maxBodyLength': defaultToConfig2,
13174
+ 'transport': defaultToConfig2,
13175
+ 'httpAgent': defaultToConfig2,
13176
+ 'httpsAgent': defaultToConfig2,
13177
+ 'cancelToken': defaultToConfig2,
13178
+ 'socketPath': defaultToConfig2,
13179
+ 'responseEncoding': defaultToConfig2,
13180
+ 'validateStatus': mergeDirectKeys
13181
+ };
12974
13182
 
12975
- utils.forEach(otherKeys, mergeDeepProperties);
13183
+ utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
13184
+ var merge = mergeMap[prop] || mergeDeepProperties;
13185
+ var configValue = merge(prop);
13186
+ (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
13187
+ });
12976
13188
 
12977
13189
  return config;
12978
13190
  };
@@ -13137,7 +13349,7 @@ var defaults = {
13137
13349
  }],
13138
13350
 
13139
13351
  transformResponse: [function transformResponse(data) {
13140
- var transitional = this.transitional;
13352
+ var transitional = this.transitional || defaults.transitional;
13141
13353
  var silentJSONParsing = transitional && transitional.silentJSONParsing;
13142
13354
  var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
13143
13355
  var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
@@ -13172,12 +13384,12 @@ var defaults = {
13172
13384
 
13173
13385
  validateStatus: function validateStatus(status) {
13174
13386
  return status >= 200 && status < 300;
13175
- }
13176
- };
13387
+ },
13177
13388
 
13178
- defaults.headers = {
13179
- common: {
13180
- 'Accept': 'application/json, text/plain, */*'
13389
+ headers: {
13390
+ common: {
13391
+ 'Accept': 'application/json, text/plain, */*'
13392
+ }
13181
13393
  }
13182
13394
  };
13183
13395
 
@@ -13192,6 +13404,18 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
13192
13404
  module.exports = defaults;
13193
13405
 
13194
13406
 
13407
+ /***/ }),
13408
+
13409
+ /***/ "./node_modules/axios/lib/env/data.js":
13410
+ /*!********************************************!*\
13411
+ !*** ./node_modules/axios/lib/env/data.js ***!
13412
+ \********************************************/
13413
+ /***/ ((module) => {
13414
+
13415
+ module.exports = {
13416
+ "version": "0.22.0"
13417
+ };
13418
+
13195
13419
  /***/ }),
13196
13420
 
13197
13421
  /***/ "./node_modules/axios/lib/helpers/bind.js":
@@ -13646,7 +13870,7 @@ module.exports = function spread(callback) {
13646
13870
  "use strict";
13647
13871
 
13648
13872
 
13649
- var pkg = __webpack_require__(/*! ./../../package.json */ "./node_modules/axios/package.json");
13873
+ var VERSION = __webpack_require__(/*! ../env/data */ "./node_modules/axios/lib/env/data.js").version;
13650
13874
 
13651
13875
  var validators = {};
13652
13876
 
@@ -13658,48 +13882,26 @@ var validators = {};
13658
13882
  });
13659
13883
 
13660
13884
  var deprecatedWarnings = {};
13661
- var currentVerArr = pkg.version.split('.');
13662
-
13663
- /**
13664
- * Compare package versions
13665
- * @param {string} version
13666
- * @param {string?} thanVersion
13667
- * @returns {boolean}
13668
- */
13669
- function isOlderVersion(version, thanVersion) {
13670
- var pkgVersionArr = thanVersion ? thanVersion.split('.') : currentVerArr;
13671
- var destVer = version.split('.');
13672
- for (var i = 0; i < 3; i++) {
13673
- if (pkgVersionArr[i] > destVer[i]) {
13674
- return true;
13675
- } else if (pkgVersionArr[i] < destVer[i]) {
13676
- return false;
13677
- }
13678
- }
13679
- return false;
13680
- }
13681
13885
 
13682
13886
  /**
13683
13887
  * Transitional option validator
13684
- * @param {function|boolean?} validator
13685
- * @param {string?} version
13686
- * @param {string} message
13888
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
13889
+ * @param {string?} version - deprecated version / removed since version
13890
+ * @param {string?} message - some message with additional info
13687
13891
  * @returns {function}
13688
13892
  */
13689
13893
  validators.transitional = function transitional(validator, version, message) {
13690
- var isDeprecated = version && isOlderVersion(version);
13691
-
13692
13894
  function formatMessage(opt, desc) {
13693
- return '[Axios v' + pkg.version + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
13895
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
13694
13896
  }
13695
13897
 
13696
13898
  // eslint-disable-next-line func-names
13697
13899
  return function(value, opt, opts) {
13698
13900
  if (validator === false) {
13699
- throw new Error(formatMessage(opt, ' has been removed in ' + version));
13901
+ throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
13700
13902
  }
13701
13903
 
13702
- if (isDeprecated && !deprecatedWarnings[opt]) {
13904
+ if (version && !deprecatedWarnings[opt]) {
13703
13905
  deprecatedWarnings[opt] = true;
13704
13906
  // eslint-disable-next-line no-console
13705
13907
  console.warn(
@@ -13745,7 +13947,6 @@ function assertOptions(options, schema, allowUnknown) {
13745
13947
  }
13746
13948
 
13747
13949
  module.exports = {
13748
- isOlderVersion: isOlderVersion,
13749
13950
  assertOptions: assertOptions,
13750
13951
  validators: validators
13751
13952
  };
@@ -54620,17 +54821,6 @@ var PatchError = /** @class */ (function (_super) {
54620
54821
 
54621
54822
 
54622
54823
 
54623
- /***/ }),
54624
-
54625
- /***/ "./node_modules/axios/package.json":
54626
- /*!*****************************************!*\
54627
- !*** ./node_modules/axios/package.json ***!
54628
- \*****************************************/
54629
- /***/ ((module) => {
54630
-
54631
- "use strict";
54632
- module.exports = JSON.parse('{"name":"axios","version":"0.21.4","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz","_integrity":"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==","_from":"axios@0.21.4"}');
54633
-
54634
54824
  /***/ })
54635
54825
 
54636
54826
  /******/ });