@nmshd/transport 2.4.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/buildInformation.js +5 -5
  2. package/dist/core/CoreCrypto.js.map +1 -1
  3. package/dist/modules/accounts/AccountController.d.ts.map +1 -1
  4. package/dist/modules/accounts/AccountController.js +1 -2
  5. package/dist/modules/accounts/AccountController.js.map +1 -1
  6. package/dist/modules/certificates/CertificateIssuer.js.map +1 -1
  7. package/dist/modules/devices/DeviceController.js.map +1 -1
  8. package/dist/modules/devices/DeviceSecretController.d.ts +1 -1
  9. package/dist/modules/devices/DeviceSecretController.d.ts.map +1 -1
  10. package/dist/modules/devices/DeviceSecretController.js +6 -7
  11. package/dist/modules/devices/DeviceSecretController.js.map +1 -1
  12. package/dist/modules/devices/DevicesController.d.ts +1 -1
  13. package/dist/modules/devices/DevicesController.d.ts.map +1 -1
  14. package/dist/modules/devices/DevicesController.js +3 -3
  15. package/dist/modules/devices/DevicesController.js.map +1 -1
  16. package/dist/modules/devices/transmission/DeviceSharedSecret.d.ts +3 -1
  17. package/dist/modules/devices/transmission/DeviceSharedSecret.d.ts.map +1 -1
  18. package/dist/modules/devices/transmission/DeviceSharedSecret.js +5 -0
  19. package/dist/modules/devices/transmission/DeviceSharedSecret.js.map +1 -1
  20. package/dist/modules/files/FileController.d.ts.map +1 -1
  21. package/dist/modules/files/FileController.js.map +1 -1
  22. package/dist/modules/messages/MessageController.js.map +1 -1
  23. package/dist/modules/messages/transmission/MessageEnvelope.js.map +1 -1
  24. package/dist/modules/relationshipTemplates/RelationshipTemplateController.d.ts.map +1 -1
  25. package/dist/modules/relationshipTemplates/RelationshipTemplateController.js.map +1 -1
  26. package/dist/modules/relationships/RelationshipSecretController.d.ts +1 -1
  27. package/dist/modules/relationships/RelationshipSecretController.d.ts.map +1 -1
  28. package/dist/modules/relationships/RelationshipSecretController.js.map +1 -1
  29. package/dist/modules/relationships/RelationshipsController.d.ts +2 -2
  30. package/dist/modules/relationships/RelationshipsController.d.ts.map +1 -1
  31. package/dist/modules/relationships/RelationshipsController.js +1 -1
  32. package/dist/modules/relationships/RelationshipsController.js.map +1 -1
  33. package/dist/modules/secrets/SecretController.d.ts.map +1 -1
  34. package/dist/modules/secrets/SecretController.js +2 -3
  35. package/dist/modules/secrets/SecretController.js.map +1 -1
  36. package/dist/modules/tokens/TokenController.js.map +1 -1
  37. package/lib-web/nmshd.transport.js +71 -56
  38. package/lib-web/nmshd.transport.js.map +1 -1
  39. package/lib-web/nmshd.transport.min.js +1 -1
  40. package/lib-web/nmshd.transport.min.js.map +1 -1
  41. package/package.json +2 -2
@@ -29653,7 +29653,7 @@ var defaults = {
29653
29653
  charset: 'utf-8',
29654
29654
  charsetSentinel: false,
29655
29655
  comma: false,
29656
- decodeDotInKeys: true,
29656
+ decodeDotInKeys: false,
29657
29657
  decoder: utils.decode,
29658
29658
  delimiter: '&',
29659
29659
  depth: 5,
@@ -30422,6 +30422,10 @@ var decode = function (str, decoder, charset) {
30422
30422
  }
30423
30423
  };
30424
30424
 
30425
+ var limit = 1024;
30426
+
30427
+ /* eslint operator-linebreak: [2, "before"] */
30428
+
30425
30429
  var encode = function encode(str, defaultEncoder, charset, kind, format) {
30426
30430
  // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
30427
30431
  // It has been adapted here for stricter adherence to RFC 3986
@@ -30443,45 +30447,54 @@ var encode = function encode(str, defaultEncoder, charset, kind, format) {
30443
30447
  }
30444
30448
 
30445
30449
  var out = '';
30446
- for (var i = 0; i < string.length; ++i) {
30447
- var c = string.charCodeAt(i);
30448
-
30449
- if (
30450
- c === 0x2D // -
30451
- || c === 0x2E // .
30452
- || c === 0x5F // _
30453
- || c === 0x7E // ~
30454
- || (c >= 0x30 && c <= 0x39) // 0-9
30455
- || (c >= 0x41 && c <= 0x5A) // a-z
30456
- || (c >= 0x61 && c <= 0x7A) // A-Z
30457
- || (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
30458
- ) {
30459
- out += string.charAt(i);
30460
- continue;
30461
- }
30450
+ for (var j = 0; j < string.length; j += limit) {
30451
+ var segment = string.length >= limit ? string.slice(j, j + limit) : string;
30452
+ var arr = [];
30453
+
30454
+ for (var i = 0; i < segment.length; ++i) {
30455
+ var c = segment.charCodeAt(i);
30456
+ if (
30457
+ c === 0x2D // -
30458
+ || c === 0x2E // .
30459
+ || c === 0x5F // _
30460
+ || c === 0x7E // ~
30461
+ || (c >= 0x30 && c <= 0x39) // 0-9
30462
+ || (c >= 0x41 && c <= 0x5A) // a-z
30463
+ || (c >= 0x61 && c <= 0x7A) // A-Z
30464
+ || (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
30465
+ ) {
30466
+ arr[arr.length] = segment.charAt(i);
30467
+ continue;
30468
+ }
30462
30469
 
30463
- if (c < 0x80) {
30464
- out = out + hexTable[c];
30465
- continue;
30466
- }
30470
+ if (c < 0x80) {
30471
+ arr[arr.length] = hexTable[c];
30472
+ continue;
30473
+ }
30467
30474
 
30468
- if (c < 0x800) {
30469
- out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
30470
- continue;
30471
- }
30475
+ if (c < 0x800) {
30476
+ arr[arr.length] = hexTable[0xC0 | (c >> 6)]
30477
+ + hexTable[0x80 | (c & 0x3F)];
30478
+ continue;
30479
+ }
30472
30480
 
30473
- if (c < 0xD800 || c >= 0xE000) {
30474
- out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
30475
- continue;
30481
+ if (c < 0xD800 || c >= 0xE000) {
30482
+ arr[arr.length] = hexTable[0xE0 | (c >> 12)]
30483
+ + hexTable[0x80 | ((c >> 6) & 0x3F)]
30484
+ + hexTable[0x80 | (c & 0x3F)];
30485
+ continue;
30486
+ }
30487
+
30488
+ i += 1;
30489
+ c = 0x10000 + (((c & 0x3FF) << 10) | (segment.charCodeAt(i) & 0x3FF));
30490
+
30491
+ arr[arr.length] = hexTable[0xF0 | (c >> 18)]
30492
+ + hexTable[0x80 | ((c >> 12) & 0x3F)]
30493
+ + hexTable[0x80 | ((c >> 6) & 0x3F)]
30494
+ + hexTable[0x80 | (c & 0x3F)];
30476
30495
  }
30477
30496
 
30478
- i += 1;
30479
- c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
30480
- /* eslint operator-linebreak: [2, "before"] */
30481
- out += hexTable[0xF0 | (c >> 18)]
30482
- + hexTable[0x80 | ((c >> 12) & 0x3F)]
30483
- + hexTable[0x80 | ((c >> 6) & 0x3F)]
30484
- + hexTable[0x80 | (c & 0x3F)];
30497
+ out += arr.join('');
30485
30498
  }
30486
30499
 
30487
30500
  return out;
@@ -33561,11 +33574,11 @@ exports.buildInformation = void 0;
33561
33574
  const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
33562
33575
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
33563
33576
  exports.buildInformation = {
33564
- version: "2.4.1",
33565
- build: "64",
33566
- date: "2024-04-08T14:17:48+00:00",
33567
- commit: "2c9d6dbb7fd529de72e9693b07ad44c49073c795",
33568
- dependencies: {"@js-soft/docdb-access-abstractions":"1.0.4","@js-soft/logging-abstractions":"^1.0.1","@js-soft/simple-logger":"1.0.4","@js-soft/ts-utils":"^2.3.3","axios":"^1.6.8","fast-json-patch":"^3.1.1","form-data":"^4.0.0","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.4.4","qs":"^6.12.0","reflect-metadata":"^0.2.2","ts-simple-nameof":"^1.3.1","uuid":"^9.0.1"},
33577
+ version: "2.5.0",
33578
+ build: "71",
33579
+ date: "2024-04-16T13:33:56+00:00",
33580
+ commit: "56b83f1c831cf6621bddff38ce131bb500b78e7e",
33581
+ dependencies: {"@js-soft/docdb-access-abstractions":"1.0.4","@js-soft/logging-abstractions":"^1.0.1","@js-soft/simple-logger":"1.0.4","@js-soft/ts-utils":"^2.3.3","axios":"^1.6.8","fast-json-patch":"^3.1.1","form-data":"^4.0.0","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.4.4","qs":"^6.12.1","reflect-metadata":"^0.2.2","ts-simple-nameof":"^1.3.1","uuid":"^9.0.1"},
33569
33582
  libraries: {
33570
33583
  crypto: crypto_1.buildInformation,
33571
33584
  serval: ts_serval_1.buildInformation
@@ -36588,7 +36601,6 @@ class AccountController {
36588
36601
  createdAt: core_1.CoreDate.from(deviceResponse.createdAt),
36589
36602
  createdByDevice: deviceId,
36590
36603
  id: deviceId,
36591
- description: "",
36592
36604
  name: "Device 1",
36593
36605
  lastLoginAt: core_1.CoreDate.utc(),
36594
36606
  operatingSystem: deviceInfo.operatingSystem,
@@ -36632,7 +36644,7 @@ class AccountController {
36632
36644
  const device = Device_1.Device.from({
36633
36645
  id: deviceSharedSecret.id,
36634
36646
  name: deviceSharedSecret.name ? deviceSharedSecret.name : "",
36635
- description: deviceSharedSecret.description ? deviceSharedSecret.name : "",
36647
+ description: deviceSharedSecret.description,
36636
36648
  lastLoginAt: core_1.CoreDate.utc(),
36637
36649
  createdAt: deviceSharedSecret.createdAt,
36638
36650
  createdByDevice: deviceSharedSecret.createdByDevice,
@@ -38342,15 +38354,14 @@ class DeviceSecretController extends TransportController_1.TransportController {
38342
38354
  const encryptionKey = await core_1.CoreCrypto.deriveKeyFromBase(this.getBaseKey(), 1, DeviceSecretController.secretContext);
38343
38355
  const cipher = await core_1.CoreCrypto.encrypt(plainBuffer, encryptionKey);
38344
38356
  const date = core_1.CoreDate.utc();
38345
- const secretContainerInterface = {
38357
+ const container = SecretContainerCipher_1.SecretContainerCipher.from({
38346
38358
  cipher: cipher,
38347
38359
  createdAt: date,
38348
38360
  name: name,
38349
38361
  id: await TransportIds_1.TransportIds.secret.generate(),
38350
38362
  validFrom: date,
38351
38363
  active: true
38352
- };
38353
- const container = SecretContainerCipher_1.SecretContainerCipher.from(secretContainerInterface);
38364
+ });
38354
38365
  this.log.trace(`Created device secret id:${container.id} name:${container.name} on ${container.createdAt.toISOString()}.`);
38355
38366
  await this.secrets.set(name, container.toJSON());
38356
38367
  return container;
@@ -38379,14 +38390,13 @@ class DeviceSecretController extends TransportController_1.TransportController {
38379
38390
  }
38380
38391
  async deleteSecret(name) {
38381
38392
  const secretObj = await this.secrets.get(name);
38382
- if (!secretObj) {
38393
+ if (!secretObj)
38383
38394
  return false;
38384
- }
38385
38395
  await this.secrets.delete(name);
38386
38396
  this.log.trace(`Deleted device secret id:${secretObj.id} name:${secretObj.name} on ${core_1.CoreDate.utc().toISOString()}.`);
38387
38397
  return true;
38388
38398
  }
38389
- async createDeviceSharedSecret(device, deviceIndex, includeIdentityPrivateKey = false) {
38399
+ async createDeviceSharedSecret(device, deviceIndex, includeIdentityPrivateKey = false, profileName) {
38390
38400
  const synchronizationKey = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
38391
38401
  if (!synchronizationKey || !(synchronizationKey.secret instanceof crypto_1.CryptoSecretKey)) {
38392
38402
  throw core_1.CoreErrors.secrets.secretNotFound("SynchronizationKey");
@@ -38410,6 +38420,7 @@ class DeviceSecretController extends TransportController_1.TransportController {
38410
38420
  secretBaseKey: baseKey.secret,
38411
38421
  name: device.name,
38412
38422
  description: device.description,
38423
+ profileName,
38413
38424
  synchronizationKey: synchronizationKey.secret,
38414
38425
  identityPrivateKey: identityPrivateKey?.secret,
38415
38426
  username: device.username,
@@ -38458,7 +38469,7 @@ exports.DeviceSecretController = DeviceSecretController;
38458
38469
  __decorate([
38459
38470
  (0, ts_utils_1.log)(),
38460
38471
  __metadata("design:type", Function),
38461
- __metadata("design:paramtypes", [Device_1.Device, Number, Object]),
38472
+ __metadata("design:paramtypes", [Device_1.Device, Number, Object, String]),
38462
38473
  __metadata("design:returntype", Promise)
38463
38474
  ], DeviceSecretController.prototype, "createDeviceSharedSecret", null);
38464
38475
  __decorate([
@@ -38521,7 +38532,7 @@ class DevicesController extends TransportController_1.TransportController {
38521
38532
  async addExistingDevice(device) {
38522
38533
  await this.devices.create(device);
38523
38534
  }
38524
- async createDevice(name = "", description = "", isAdmin = false) {
38535
+ async createDevice(name = "", description, isAdmin = false) {
38525
38536
  const [signedChallenge, devicePwdDn] = await Promise.all([this.parent.challenges.createChallenge(Challenge_1.ChallengeType.Identity), util_1.PasswordGenerator.createStrongPassword(45, 50)]);
38526
38537
  this.log.trace("Device Creation Challenge signed. Creating device on backbone...");
38527
38538
  const response = (await this.client.createDevice({
@@ -38552,7 +38563,7 @@ class DevicesController extends TransportController_1.TransportController {
38552
38563
  await this.devices.create(device);
38553
38564
  return device;
38554
38565
  }
38555
- async getSharedSecret(id) {
38566
+ async getSharedSecret(id, profileName) {
38556
38567
  const deviceDoc = await this.devices.read(id.toString());
38557
38568
  if (!deviceDoc) {
38558
38569
  throw core_1.CoreErrors.general.recordNotFound(Device_1.Device, id.toString());
@@ -38563,7 +38574,7 @@ class DevicesController extends TransportController_1.TransportController {
38563
38574
  throw core_1.CoreErrors.device.alreadyOnboarded();
38564
38575
  }
38565
38576
  const isAdmin = device.isAdmin === true;
38566
- const secret = await this.parent.activeDevice.secrets.createDeviceSharedSecret(device, count, isAdmin);
38577
+ const secret = await this.parent.activeDevice.secrets.createDeviceSharedSecret(device, count, isAdmin, profileName);
38567
38578
  return secret;
38568
38579
  }
38569
38580
  async update(device) {
@@ -38956,6 +38967,11 @@ __decorate([
38956
38967
  (0, ts_serval_1.validate)({ nullable: true }),
38957
38968
  __metadata("design:type", String)
38958
38969
  ], DeviceSharedSecret.prototype, "description", void 0);
38970
+ __decorate([
38971
+ (0, ts_serval_1.serialize)(),
38972
+ (0, ts_serval_1.validate)({ nullable: true }),
38973
+ __metadata("design:type", String)
38974
+ ], DeviceSharedSecret.prototype, "profileName", void 0);
38959
38975
  __decorate([
38960
38976
  (0, ts_serval_1.serialize)(),
38961
38977
  (0, ts_serval_1.validate)(),
@@ -41872,11 +41888,11 @@ const RelationshipClient_1 = __webpack_require__(/*! ./backbone/RelationshipClie
41872
41888
  const CachedRelationship_1 = __webpack_require__(/*! ./local/CachedRelationship */ "./dist/modules/relationships/local/CachedRelationship.js");
41873
41889
  const Relationship_1 = __webpack_require__(/*! ./local/Relationship */ "./dist/modules/relationships/local/Relationship.js");
41874
41890
  const SendRelationshipParameters_1 = __webpack_require__(/*! ./local/SendRelationshipParameters */ "./dist/modules/relationships/local/SendRelationshipParameters.js");
41875
- const RelationshipStatus_1 = __webpack_require__(/*! ./transmission/RelationshipStatus */ "./dist/modules/relationships/transmission/RelationshipStatus.js");
41876
41891
  const RelationshipChange_1 = __webpack_require__(/*! ./transmission/changes/RelationshipChange */ "./dist/modules/relationships/transmission/changes/RelationshipChange.js");
41877
41892
  const RelationshipChangeResponse_1 = __webpack_require__(/*! ./transmission/changes/RelationshipChangeResponse */ "./dist/modules/relationships/transmission/changes/RelationshipChangeResponse.js");
41878
41893
  const RelationshipChangeStatus_1 = __webpack_require__(/*! ./transmission/changes/RelationshipChangeStatus */ "./dist/modules/relationships/transmission/changes/RelationshipChangeStatus.js");
41879
41894
  const RelationshipChangeType_1 = __webpack_require__(/*! ./transmission/changes/RelationshipChangeType */ "./dist/modules/relationships/transmission/changes/RelationshipChangeType.js");
41895
+ const RelationshipStatus_1 = __webpack_require__(/*! ./transmission/RelationshipStatus */ "./dist/modules/relationships/transmission/RelationshipStatus.js");
41880
41896
  const RelationshipCreationChangeRequestCipher_1 = __webpack_require__(/*! ./transmission/requests/RelationshipCreationChangeRequestCipher */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestCipher.js");
41881
41897
  const RelationshipCreationChangeRequestContentWrapper_1 = __webpack_require__(/*! ./transmission/requests/RelationshipCreationChangeRequestContentWrapper */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js");
41882
41898
  const RelationshipCreationChangeRequestSigned_1 = __webpack_require__(/*! ./transmission/requests/RelationshipCreationChangeRequestSigned */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestSigned.js");
@@ -43366,7 +43382,7 @@ class SecretController extends TransportController_1.TransportController {
43366
43382
  const encryptionKey = await core_1.CoreCrypto.deriveKeyFromBase(await this.getBaseKey(), nonce, SecretController.secretContext);
43367
43383
  const cipher = await core_1.CoreCrypto.encrypt(plainBuffer, encryptionKey);
43368
43384
  const createdAt = core_1.CoreDate.utc();
43369
- const secretContainerInterface = {
43385
+ const container = SecretContainerCipher_1.SecretContainerCipher.from({
43370
43386
  cipher: cipher,
43371
43387
  createdAt: createdAt,
43372
43388
  name: name,
@@ -43376,8 +43392,7 @@ class SecretController extends TransportController_1.TransportController {
43376
43392
  validFrom: createdAt,
43377
43393
  validTo: validTo,
43378
43394
  active: true
43379
- };
43380
- const container = SecretContainerCipher_1.SecretContainerCipher.from(secretContainerInterface);
43395
+ });
43381
43396
  this.log.trace(`Created secret id:${container.id} name:${container.name} on ${container.createdAt.toISOString()}.`);
43382
43397
  await this.secrets.create(container);
43383
43398
  return container;