@nmshd/transport 2.0.0-beta.6 → 2.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buildInformation.js +4 -4
- package/dist/core/CoreCrypto.js +5 -4
- package/dist/core/CoreCrypto.js.map +1 -1
- package/dist/core/{TransportErrors.d.ts → CoreErrors.d.ts} +1 -2
- package/dist/core/{TransportErrors.js → CoreErrors.js} +13 -16
- package/dist/core/CoreErrors.js.map +1 -0
- package/dist/core/CoreIdHelper.js +2 -1
- package/dist/core/CoreIdHelper.js.map +1 -1
- package/dist/core/CoreUtil.js +2 -1
- package/dist/core/CoreUtil.js.map +1 -1
- package/dist/core/Reference.js +3 -3
- package/dist/core/Reference.js.map +1 -1
- package/dist/core/Transport.js +7 -6
- package/dist/core/Transport.js.map +1 -1
- package/dist/core/TransportController.d.ts +1 -0
- package/dist/core/TransportController.js +5 -1
- package/dist/core/TransportController.js.map +1 -1
- package/dist/core/TransportError.d.ts +2 -0
- package/dist/core/TransportError.js +7 -0
- package/dist/core/TransportError.js.map +1 -0
- package/dist/core/TransportLoggerFactory.js +2 -1
- package/dist/core/TransportLoggerFactory.js.map +1 -1
- package/dist/core/backbone/ClientResult.js +5 -4
- package/dist/core/backbone/ClientResult.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/types/CoreDate.js +4 -3
- package/dist/core/types/CoreDate.js.map +1 -1
- package/dist/core/types/CoreId.js +2 -1
- package/dist/core/types/CoreId.js.map +1 -1
- package/dist/modules/accounts/AccountController.js +5 -7
- package/dist/modules/accounts/AccountController.js.map +1 -1
- package/dist/modules/accounts/IdentityController.js +1 -1
- package/dist/modules/accounts/IdentityController.js.map +1 -1
- package/dist/modules/accounts/IdentityUtil.js +1 -1
- package/dist/modules/accounts/IdentityUtil.js.map +1 -1
- package/dist/modules/accounts/data/Identity.d.ts +0 -18
- package/dist/modules/accounts/data/Identity.js +0 -33
- package/dist/modules/accounts/data/Identity.js.map +1 -1
- package/dist/modules/challenges/ChallengeController.js +4 -6
- package/dist/modules/challenges/ChallengeController.js.map +1 -1
- package/dist/modules/devices/DeviceController.js +8 -9
- package/dist/modules/devices/DeviceController.js.map +1 -1
- package/dist/modules/devices/DeviceSecretController.js +6 -7
- package/dist/modules/devices/DeviceSecretController.js.map +1 -1
- package/dist/modules/devices/DevicesController.js +3 -3
- package/dist/modules/devices/DevicesController.js.map +1 -1
- package/dist/modules/files/FileController.js +9 -19
- package/dist/modules/files/FileController.js.map +1 -1
- package/dist/modules/index.d.ts +4 -4
- package/dist/modules/index.js +4 -4
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/messages/MessageController.js +16 -16
- package/dist/modules/messages/MessageController.js.map +1 -1
- package/dist/modules/messages/transmission/{MessagePlain.d.ts → MessageContentWrapper.d.ts} +4 -4
- package/dist/modules/messages/transmission/{MessagePlain.js → MessageContentWrapper.js} +12 -12
- package/dist/modules/messages/transmission/MessageContentWrapper.js.map +1 -0
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js +7 -14
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js.map +1 -1
- package/dist/modules/relationshipTemplates/backbone/BackboneGetRelationshipTemplates.d.ts +0 -1
- package/dist/modules/relationshipTemplates/backbone/BackbonePostRelationshipTemplates.d.ts +0 -5
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.d.ts +0 -11
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js +1 -15
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js.map +1 -1
- package/dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.d.ts +0 -11
- package/dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js +2 -17
- package/dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js.map +1 -1
- package/dist/modules/relationshipTemplates/transmission/{RelationshipTemplateContent.d.ts → RelationshipTemplateContentWrapper.d.ts} +3 -3
- package/dist/modules/relationshipTemplates/transmission/{RelationshipTemplateContent.js → RelationshipTemplateContentWrapper.js} +10 -10
- package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js.map +1 -0
- package/dist/modules/relationships/RelationshipSecretController.js +14 -14
- package/dist/modules/relationships/RelationshipSecretController.js.map +1 -1
- package/dist/modules/relationships/RelationshipsController.js +32 -32
- package/dist/modules/relationships/RelationshipsController.js.map +1 -1
- package/dist/modules/relationships/local/Relationship.d.ts +1 -0
- package/dist/modules/relationships/local/Relationship.js +9 -9
- package/dist/modules/relationships/local/Relationship.js.map +1 -1
- package/dist/modules/relationships/transmission/requests/{RelationshipCreationChangeRequestContent.d.ts → RelationshipCreationChangeRequestContentWrapper.d.ts} +3 -3
- package/dist/modules/relationships/transmission/requests/{RelationshipCreationChangeRequestContent.js → RelationshipCreationChangeRequestContentWrapper.js} +10 -10
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js.map +1 -0
- package/dist/modules/relationships/transmission/responses/{RelationshipCreationChangeResponseContent.d.ts → RelationshipCreationChangeResponseContentWrapper.d.ts} +3 -3
- package/dist/modules/relationships/transmission/responses/{RelationshipCreationChangeResponseContent.js → RelationshipCreationChangeResponseContentWrapper.js} +9 -9
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js.map +1 -0
- package/dist/modules/secrets/SecretController.js +1 -2
- package/dist/modules/secrets/SecretController.js.map +1 -1
- package/dist/modules/sync/DatawalletModificationMapper.js +2 -2
- package/dist/modules/sync/DatawalletModificationMapper.js.map +1 -1
- package/dist/modules/sync/DatawalletModificationsProcessor.js +2 -2
- package/dist/modules/sync/DatawalletModificationsProcessor.js.map +1 -1
- package/dist/modules/sync/ExternalEventsProcessor.js +1 -1
- package/dist/modules/sync/ExternalEventsProcessor.js.map +1 -1
- package/dist/modules/sync/SyncController.js +10 -10
- package/dist/modules/sync/SyncController.js.map +1 -1
- package/dist/modules/tokens/AnonymousTokenController.js +1 -1
- package/dist/modules/tokens/AnonymousTokenController.js.map +1 -1
- package/dist/modules/tokens/TokenController.js +4 -5
- package/dist/modules/tokens/TokenController.js.map +1 -1
- package/dist/util/PasswordGenerator.js +2 -1
- package/dist/util/PasswordGenerator.js.map +1 -1
- package/dist/util/Random.js +8 -7
- package/dist/util/Random.js.map +1 -1
- package/lib-web/nmshd.transport.js +472 -530
- package/lib-web/nmshd.transport.js.map +1 -1
- package/lib-web/nmshd.transport.min.js +1 -1
- package/lib-web/nmshd.transport.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/core/TransportErrors.js.map +0 -1
- package/dist/modules/messages/transmission/MessagePlain.js.map +0 -1
- package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateContent.js.map +0 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContent.js.map +0 -1
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContent.js.map +0 -1
|
@@ -15,10 +15,10 @@ 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: "2.0.0-beta.
|
|
19
|
-
build: "
|
|
20
|
-
date: "2022-09-
|
|
21
|
-
commit: "
|
|
18
|
+
version: "2.0.0-beta.8",
|
|
19
|
+
build: "39",
|
|
20
|
+
date: "2022-09-29T06:39:51+00:00",
|
|
21
|
+
commit: "0f2238798e431a2714819655de1ab59674528345",
|
|
22
22
|
dependencies: {"@js-soft/docdb-access-abstractions":"1.0.1","@js-soft/logging-abstractions":"1.0.0","@js-soft/simple-logger":"1.0.2","@js-soft/ts-utils":"2.3.0","axios":"^0.27.2","deep-equal":"^2.0.5","fast-json-patch":"^3.1.1","form-data":"^4.0.0","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.0.4","qs":"^6.11.0","reflect-metadata":"^0.1.13","ts-simple-nameof":"^1.3.1","uuid":"^9.0.0"},
|
|
23
23
|
libraries: {
|
|
24
24
|
crypto: crypto_1.buildInformation,
|
|
@@ -40,7 +40,8 @@ exports.buildInformation = {
|
|
|
40
40
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
41
41
|
exports.CoreCrypto = void 0;
|
|
42
42
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
43
|
-
const
|
|
43
|
+
const PasswordGenerator_1 = __webpack_require__(/*! ../util/PasswordGenerator */ "./dist/util/PasswordGenerator.js");
|
|
44
|
+
const TransportError_1 = __webpack_require__(/*! ./TransportError */ "./dist/core/TransportError.js");
|
|
44
45
|
const TransportVersion_1 = __webpack_require__(/*! ./types/TransportVersion */ "./dist/core/types/TransportVersion.js");
|
|
45
46
|
class CoreCrypto {
|
|
46
47
|
/**
|
|
@@ -126,7 +127,7 @@ class CoreCrypto {
|
|
|
126
127
|
buffer = secret;
|
|
127
128
|
}
|
|
128
129
|
else {
|
|
129
|
-
throw new
|
|
130
|
+
throw new TransportError_1.TransportError("The secret type is invalid.");
|
|
130
131
|
}
|
|
131
132
|
return await crypto_1.CryptoDerivation.deriveKeyFromBase(buffer, keyId, context, keyAlgorithm);
|
|
132
133
|
}
|
|
@@ -235,10 +236,10 @@ class CoreCrypto {
|
|
|
235
236
|
return await crypto_1.CryptoRandom.bytes(size);
|
|
236
237
|
}
|
|
237
238
|
static async createAccountPassword() {
|
|
238
|
-
return await
|
|
239
|
+
return await PasswordGenerator_1.PasswordGenerator.createStrongPassword(100, 100);
|
|
239
240
|
}
|
|
240
241
|
static invalidVersion(version) {
|
|
241
|
-
return new
|
|
242
|
+
return new TransportError_1.TransportError(`The version ${version} is not supported.`);
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
245
|
exports.CoreCrypto = CoreCrypto;
|
|
@@ -319,6 +320,154 @@ exports.CoreError = CoreError;
|
|
|
319
320
|
|
|
320
321
|
/***/ }),
|
|
321
322
|
|
|
323
|
+
/***/ "./dist/core/CoreErrors.js":
|
|
324
|
+
/*!*********************************!*\
|
|
325
|
+
!*** ./dist/core/CoreErrors.js ***!
|
|
326
|
+
\*********************************/
|
|
327
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
328
|
+
|
|
329
|
+
"use strict";
|
|
330
|
+
|
|
331
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
332
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
333
|
+
};
|
|
334
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
335
|
+
exports.CoreErrors = void 0;
|
|
336
|
+
const json_stringify_safe_1 = __importDefault(__webpack_require__(/*! json-stringify-safe */ "./node_modules/json-stringify-safe/stringify.js"));
|
|
337
|
+
const CoreError_1 = __webpack_require__(/*! ./CoreError */ "./dist/core/CoreError.js");
|
|
338
|
+
class Relationships {
|
|
339
|
+
wrongChangeStatus(status) {
|
|
340
|
+
return new CoreError_1.CoreError("error.transport.relationships.wrongChangeStatus", `The relationship change has the wrong status (${status}) to run this operation`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
class Device {
|
|
344
|
+
alreadyOnboarded() {
|
|
345
|
+
return new CoreError_1.CoreError("error.transport.devices.alreadyOnboarded", "The device has already been onboarded.");
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
class Messages {
|
|
349
|
+
plaintextMismatch(ownAddress) {
|
|
350
|
+
return new CoreError_1.CoreError("error.transport.messages.plaintextMismatch", `The own address ${ownAddress} was not named as a recipient within the signed MessagePlaintext. A replay attack might be the cause of this.`);
|
|
351
|
+
}
|
|
352
|
+
signatureListMismatch(address) {
|
|
353
|
+
return new CoreError_1.CoreError("error.transport.messages.signatureListMismatch", `The signature list didn't contain an entry for address ${address}.`);
|
|
354
|
+
}
|
|
355
|
+
signatureNotValid() {
|
|
356
|
+
return new CoreError_1.CoreError("error.transport.messages.signatureNotValid", "The digital signature on this message for peer key is invalid. An impersonination attack might be the cause of this.");
|
|
357
|
+
}
|
|
358
|
+
ownAddressNotInList(messageId) {
|
|
359
|
+
return new CoreError_1.CoreError("error.transport.messages.ownAddressNotInList", `The recipients list of message ${messageId} didn't contain an entry for the own address. This message should not have been received.`);
|
|
360
|
+
}
|
|
361
|
+
noMatchingRelationship(senderAddress) {
|
|
362
|
+
return new CoreError_1.CoreError("error.transport.messages.noMatchingRelationship", `A relationship with sender ${senderAddress} does not exist.`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
class Secrets {
|
|
366
|
+
wrongSecretType(secretId) {
|
|
367
|
+
return new CoreError_1.CoreError("error.transport.secrets.wrongBaseKeyType", "Given Secret type is not supported!", {
|
|
368
|
+
secretId: secretId
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
secretNotFound(type) {
|
|
372
|
+
return new CoreError_1.CoreError("error.transport.secrets.secretNotFound", `secret "${type}" not found`);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
class Challenges {
|
|
376
|
+
challengeTypeRequiresRelationship() {
|
|
377
|
+
return new CoreError_1.CoreError("error.transport.challenges.challengeTypeRequiresRelationship", "The challenge type Relationship requires a relationship.");
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
class Datawallet {
|
|
381
|
+
encryptedPayloadIsNoCipher() {
|
|
382
|
+
return new CoreError_1.CoreError("error.transport.datawallet.encryptedPayloadIsNoCipher", "The given encrypted payload is no cipher.");
|
|
383
|
+
}
|
|
384
|
+
unsupportedModification(type, data) {
|
|
385
|
+
const errorCode = "error.transport.datawallet.unsupportedModification";
|
|
386
|
+
const formattedData = data ? (0, json_stringify_safe_1.default)(data) : "";
|
|
387
|
+
switch (type) {
|
|
388
|
+
case "unsupportedCacheChangedModificationCollection":
|
|
389
|
+
return new CoreError_1.CoreError(errorCode, `The following collections were received in CacheChanged datawallet modifications but are not supported by the current version of this library: ${formattedData}.`);
|
|
390
|
+
default:
|
|
391
|
+
throw new Error(`Given type '${type}' is not supported.`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
insufficientSupportedDatawalletVersion(supportedVersion, requiredVersion) {
|
|
395
|
+
return new CoreError_1.CoreError("error.transport.datawallet.insufficientSupportedDatawalletVersion", `The SupportedDatawalletVersion '${supportedVersion}' is too low. A minimum version of '${requiredVersion}' is required.`);
|
|
396
|
+
}
|
|
397
|
+
currentBiggerThanTarget(current, target) {
|
|
398
|
+
return new CoreError_1.CoreError("error.transport.datawallet.currentBiggerThanTarget", `The current datawallet version '${current}' is bigger than the target version '${target}'.`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
class Files {
|
|
402
|
+
plaintextHashMismatch() {
|
|
403
|
+
return new CoreError_1.CoreError("error.transport.files.plaintextHashMismatch", "The actual hash of the plaintext does not match the given plaintextHash. Something went wrong while encrypting/decrypting the file.");
|
|
404
|
+
}
|
|
405
|
+
cipherMismatch() {
|
|
406
|
+
return new CoreError_1.CoreError("error.transport.files.cipherMismatch", "The actual hash of the cipher does not match the given cipherHash. Something went wrong while storing/transmitting the file.");
|
|
407
|
+
}
|
|
408
|
+
invalidMetadata(id) {
|
|
409
|
+
return new CoreError_1.CoreError("error.transport.files.invalidMetadata", `The metadata of file id "${id}" is invalid.`);
|
|
410
|
+
}
|
|
411
|
+
fileContentUndefined() {
|
|
412
|
+
return new CoreError_1.CoreError("error.transport.files.fileContentUndefined", "The given file content is undefined.");
|
|
413
|
+
}
|
|
414
|
+
maxFileSizeExceeded(fileSize, platformMaxFileSize) {
|
|
415
|
+
return new CoreError_1.CoreError("error.transport.files.maxFileSizeExceeded", `The given file content size (${fileSize}) exceeds the max file size the backbone accepts (${platformMaxFileSize}).`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
class Tokens {
|
|
419
|
+
invalidTokenContent(id) {
|
|
420
|
+
return new CoreError_1.CoreError("error.transport.tokens.invalidTokenContent", `The content of token ${id} is not of type TokenContent`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
class General {
|
|
424
|
+
baseUrlNotSet() {
|
|
425
|
+
return new CoreError_1.CoreError("error.transport.general.baseUrlNotSet", "The baseUrl was not set.");
|
|
426
|
+
}
|
|
427
|
+
platformClientIdNotSet() {
|
|
428
|
+
return new CoreError_1.CoreError("error.transport.general.platformClientNotSet", "The platform clientSecret was not set.");
|
|
429
|
+
}
|
|
430
|
+
platformClientSecretNotSet() {
|
|
431
|
+
return new CoreError_1.CoreError("error.transport.general.platformClientNotSet", "The platform clientId was not set.");
|
|
432
|
+
}
|
|
433
|
+
platformClientInvalid() {
|
|
434
|
+
return new CoreError_1.CoreError("error.transport.general.platformClientInvalid", "The combination of platform clientId and clientSecret is invalid.");
|
|
435
|
+
}
|
|
436
|
+
incompatibleBackbone() {
|
|
437
|
+
return new CoreError_1.CoreError("error.transport.incompatibleBackbone", "The backbone sent an invalid payload.");
|
|
438
|
+
}
|
|
439
|
+
signatureNotValid(type) {
|
|
440
|
+
return new CoreError_1.CoreError("error.transport.signatureNotValid", `The ${type ? `${type}-` : ""}signature is not valid.`);
|
|
441
|
+
}
|
|
442
|
+
recordNotFound(entityName, entityId) {
|
|
443
|
+
return new CoreError_1.CoreError("error.transport.recordNotFound", `'${entityName instanceof Function ? entityName.name : entityName}' not found.`, entityId);
|
|
444
|
+
}
|
|
445
|
+
notSupported() {
|
|
446
|
+
return new CoreError_1.CoreError("error.transport.notSupported", "The method is not yet supported.");
|
|
447
|
+
}
|
|
448
|
+
realmLength() {
|
|
449
|
+
return new CoreError_1.CoreError("error.transport.identity.realmLength", "Realm must be of length 3.");
|
|
450
|
+
}
|
|
451
|
+
invalidTruncatedReference() {
|
|
452
|
+
return new CoreError_1.CoreError("error.transport.files.invalidTruncatedReference", "invalid truncated reference");
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
class CoreErrors {
|
|
456
|
+
}
|
|
457
|
+
exports.CoreErrors = CoreErrors;
|
|
458
|
+
CoreErrors.relationships = new Relationships();
|
|
459
|
+
CoreErrors.general = new General();
|
|
460
|
+
CoreErrors.messages = new Messages();
|
|
461
|
+
CoreErrors.secrets = new Secrets();
|
|
462
|
+
CoreErrors.device = new Device();
|
|
463
|
+
CoreErrors.files = new Files();
|
|
464
|
+
CoreErrors.challenges = new Challenges();
|
|
465
|
+
CoreErrors.datawallet = new Datawallet();
|
|
466
|
+
CoreErrors.tokens = new Tokens();
|
|
467
|
+
//# sourceMappingURL=CoreErrors.js.map
|
|
468
|
+
|
|
469
|
+
/***/ }),
|
|
470
|
+
|
|
322
471
|
/***/ "./dist/core/CoreIdHelper.js":
|
|
323
472
|
/*!***********************************!*\
|
|
324
473
|
!*** ./dist/core/CoreIdHelper.js ***!
|
|
@@ -330,6 +479,7 @@ exports.CoreError = CoreError;
|
|
|
330
479
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
331
480
|
exports.CoreIdHelper = void 0;
|
|
332
481
|
const Random_1 = __webpack_require__(/*! ../util/Random */ "./dist/util/Random.js");
|
|
482
|
+
const TransportError_1 = __webpack_require__(/*! ./TransportError */ "./dist/core/TransportError.js");
|
|
333
483
|
const CoreId_1 = __webpack_require__(/*! ./types/CoreId */ "./dist/core/types/CoreId.js");
|
|
334
484
|
class CoreIdHelper {
|
|
335
485
|
constructor(prefix, validateOnly = false) {
|
|
@@ -339,7 +489,7 @@ class CoreIdHelper {
|
|
|
339
489
|
}
|
|
340
490
|
async generate() {
|
|
341
491
|
if (this.validateOnly) {
|
|
342
|
-
throw new
|
|
492
|
+
throw new TransportError_1.TransportError("This CoreIdHelper is set up for validation only.");
|
|
343
493
|
}
|
|
344
494
|
return await CoreId_1.CoreId.generate(this.prefix);
|
|
345
495
|
}
|
|
@@ -504,6 +654,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
504
654
|
exports.CoreUtil = void 0;
|
|
505
655
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
506
656
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
657
|
+
const TransportError_1 = __webpack_require__(/*! ./TransportError */ "./dist/core/TransportError.js");
|
|
507
658
|
class CoreUtil {
|
|
508
659
|
static toBuffer(content, verbose = false) {
|
|
509
660
|
let buffer;
|
|
@@ -520,7 +671,7 @@ class CoreUtil {
|
|
|
520
671
|
buffer = new crypto_1.CoreBuffer(content);
|
|
521
672
|
}
|
|
522
673
|
else {
|
|
523
|
-
throw new
|
|
674
|
+
throw new TransportError_1.TransportError("The given content cannot be transformed to buffer.");
|
|
524
675
|
}
|
|
525
676
|
return buffer;
|
|
526
677
|
}
|
|
@@ -654,7 +805,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
654
805
|
exports.Reference = void 0;
|
|
655
806
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
656
807
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
657
|
-
const
|
|
808
|
+
const CoreErrors_1 = __webpack_require__(/*! ./CoreErrors */ "./dist/core/CoreErrors.js");
|
|
658
809
|
const CoreId_1 = __webpack_require__(/*! ./types/CoreId */ "./dist/core/types/CoreId.js");
|
|
659
810
|
class Reference extends ts_serval_1.Serializable {
|
|
660
811
|
truncate() {
|
|
@@ -665,7 +816,7 @@ class Reference extends ts_serval_1.Serializable {
|
|
|
665
816
|
const truncatedBuffer = crypto_1.CoreBuffer.fromBase64URL(value);
|
|
666
817
|
const splitted = truncatedBuffer.toUtf8().split("|");
|
|
667
818
|
if (splitted.length !== 3) {
|
|
668
|
-
throw
|
|
819
|
+
throw CoreErrors_1.CoreErrors.general.invalidTruncatedReference();
|
|
669
820
|
}
|
|
670
821
|
try {
|
|
671
822
|
const id = CoreId_1.CoreId.from(splitted[0]);
|
|
@@ -681,7 +832,7 @@ class Reference extends ts_serval_1.Serializable {
|
|
|
681
832
|
});
|
|
682
833
|
}
|
|
683
834
|
catch (e) {
|
|
684
|
-
throw
|
|
835
|
+
throw CoreErrors_1.CoreErrors.general.invalidTruncatedReference();
|
|
685
836
|
}
|
|
686
837
|
}
|
|
687
838
|
static validateId(value, helper) {
|
|
@@ -729,8 +880,9 @@ const simple_logger_1 = __webpack_require__(/*! @js-soft/simple-logger */ "./nod
|
|
|
729
880
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
730
881
|
const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"));
|
|
731
882
|
const Identity_1 = __webpack_require__(/*! ../modules/accounts/data/Identity */ "./dist/modules/accounts/data/Identity.js");
|
|
883
|
+
const CoreErrors_1 = __webpack_require__(/*! ./CoreErrors */ "./dist/core/CoreErrors.js");
|
|
732
884
|
const TransportContext_1 = __webpack_require__(/*! ./TransportContext */ "./dist/core/TransportContext.js");
|
|
733
|
-
const
|
|
885
|
+
const TransportError_1 = __webpack_require__(/*! ./TransportError */ "./dist/core/TransportError.js");
|
|
734
886
|
const TransportLoggerFactory_1 = __webpack_require__(/*! ./TransportLoggerFactory */ "./dist/core/TransportLoggerFactory.js");
|
|
735
887
|
let log;
|
|
736
888
|
class Transport {
|
|
@@ -741,19 +893,19 @@ class Transport {
|
|
|
741
893
|
TransportLoggerFactory_1.TransportLoggerFactory.init(loggerFactory);
|
|
742
894
|
log = TransportLoggerFactory_1.TransportLoggerFactory.getLogger(Transport);
|
|
743
895
|
if (!this._config.platformClientId) {
|
|
744
|
-
throw
|
|
896
|
+
throw CoreErrors_1.CoreErrors.general.platformClientIdNotSet().logWith(log);
|
|
745
897
|
}
|
|
746
898
|
if (!this._config.platformClientSecret) {
|
|
747
|
-
throw
|
|
899
|
+
throw CoreErrors_1.CoreErrors.general.platformClientSecretNotSet().logWith(log);
|
|
748
900
|
}
|
|
749
901
|
if (!this._config.baseUrl) {
|
|
750
|
-
throw
|
|
902
|
+
throw CoreErrors_1.CoreErrors.general.baseUrlNotSet().logWith(log);
|
|
751
903
|
}
|
|
752
904
|
if (this._config.supportedDatawalletVersion < 1) {
|
|
753
|
-
throw new
|
|
905
|
+
throw new TransportError_1.TransportError("The given identity version is invalid. The value must be 0 or higher.");
|
|
754
906
|
}
|
|
755
907
|
if (this._config.realm.length !== 3) {
|
|
756
|
-
throw
|
|
908
|
+
throw CoreErrors_1.CoreErrors.general.realmLength();
|
|
757
909
|
}
|
|
758
910
|
}
|
|
759
911
|
get config() {
|
|
@@ -849,6 +1001,7 @@ var TransportContext;
|
|
|
849
1001
|
|
|
850
1002
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
851
1003
|
exports.TransportController = exports.ControllerName = void 0;
|
|
1004
|
+
const TransportError_1 = __webpack_require__(/*! ./TransportError */ "./dist/core/TransportError.js");
|
|
852
1005
|
const TransportLoggerFactory_1 = __webpack_require__(/*! ./TransportLoggerFactory */ "./dist/core/TransportLoggerFactory.js");
|
|
853
1006
|
var ControllerName;
|
|
854
1007
|
(function (ControllerName) {
|
|
@@ -914,7 +1067,7 @@ class TransportController {
|
|
|
914
1067
|
}
|
|
915
1068
|
init(..._args) {
|
|
916
1069
|
if (this._initialized) {
|
|
917
|
-
throw new
|
|
1070
|
+
throw new TransportError_1.TransportError(`The controller ${this.controllerName} is already initialized.`);
|
|
918
1071
|
}
|
|
919
1072
|
this._initialized = true;
|
|
920
1073
|
return Promise.resolve(this);
|
|
@@ -922,160 +1075,29 @@ class TransportController {
|
|
|
922
1075
|
parseArray(values, type) {
|
|
923
1076
|
return values.map((v) => type.fromAny(v));
|
|
924
1077
|
}
|
|
1078
|
+
newCacheEmptyError(entityName, id) {
|
|
1079
|
+
return new TransportError_1.TransportError(`The cache of ${entityName instanceof Function ? entityName.name : entityName} with id "${id}" is empty.`);
|
|
1080
|
+
}
|
|
925
1081
|
}
|
|
926
1082
|
exports.TransportController = TransportController;
|
|
927
1083
|
//# sourceMappingURL=TransportController.js.map
|
|
928
1084
|
|
|
929
1085
|
/***/ }),
|
|
930
1086
|
|
|
931
|
-
/***/ "./dist/core/
|
|
932
|
-
|
|
933
|
-
!*** ./dist/core/
|
|
934
|
-
|
|
935
|
-
/***/ (
|
|
1087
|
+
/***/ "./dist/core/TransportError.js":
|
|
1088
|
+
/*!*************************************!*\
|
|
1089
|
+
!*** ./dist/core/TransportError.js ***!
|
|
1090
|
+
\*************************************/
|
|
1091
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
936
1092
|
|
|
937
1093
|
"use strict";
|
|
938
1094
|
|
|
939
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
940
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
941
|
-
};
|
|
942
1095
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
943
|
-
exports.
|
|
944
|
-
|
|
945
|
-
const CoreError_1 = __webpack_require__(/*! ./CoreError */ "./dist/core/CoreError.js");
|
|
946
|
-
class Relationships {
|
|
947
|
-
wrongChangeStatus(status) {
|
|
948
|
-
return new CoreError_1.CoreError("error.transport.relationships.wrongChangeStatus", `The relationship change has the wrong status (${status}) to run this operation`);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
class Device {
|
|
952
|
-
alreadyOnboarded() {
|
|
953
|
-
return new CoreError_1.CoreError("error.transport.devices.alreadyOnboarded", "The device has already been onboarded.");
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
class Messages {
|
|
957
|
-
plaintextMismatch(ownAddress) {
|
|
958
|
-
return new CoreError_1.CoreError("error.transport.messages.plaintextMismatch", `The own address ${ownAddress} was not named as a recipient within the signed MessagePlaintext. A replay attack might be the cause of this.`);
|
|
959
|
-
}
|
|
960
|
-
signatureListMismatch(address) {
|
|
961
|
-
return new CoreError_1.CoreError("error.transport.messages.signatureListMismatch", `The signature list didn't contain an entry for address ${address}.`);
|
|
962
|
-
}
|
|
963
|
-
signatureNotValid() {
|
|
964
|
-
return new CoreError_1.CoreError("error.transport.messages.signatureNotValid", "The digital signature on this message for peer key is invalid. An impersonination attack might be the cause of this.");
|
|
965
|
-
}
|
|
966
|
-
ownAddressNotInList(messageId) {
|
|
967
|
-
return new CoreError_1.CoreError("error.transport.messages.ownAddressNotInList", `The recipients list of message ${messageId} didn't contain an entry for the own address. This message should not have been received.`);
|
|
968
|
-
}
|
|
969
|
-
noMatchingRelationship(senderAddress) {
|
|
970
|
-
return new CoreError_1.CoreError("error.transport.messages.noMatchingRelationship", `A relationship with sender ${senderAddress} does not exist.`);
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
class Secrets {
|
|
974
|
-
wrongSecretType(secretId) {
|
|
975
|
-
return new CoreError_1.CoreError("error.transport.secrets.wrongBaseKeyType", "Given Secret type is not supported!", {
|
|
976
|
-
secretId: secretId
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
secretNotFound(type) {
|
|
980
|
-
return new CoreError_1.CoreError("error.transport.secrets.secretNotFound", `secret "${type}" not found`);
|
|
981
|
-
}
|
|
1096
|
+
exports.TransportError = void 0;
|
|
1097
|
+
class TransportError extends Error {
|
|
982
1098
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
return new CoreError_1.CoreError("error.transport.challenges.challengeTypeRequiresRelationship", "The challenge type Relationship requires a relationship.");
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
class Datawallet {
|
|
989
|
-
encryptedPayloadIsNoCipher() {
|
|
990
|
-
return new CoreError_1.CoreError("error.transport.datawallet.encryptedPayloadIsNoCipher", "The given encrypted payload is no cipher.");
|
|
991
|
-
}
|
|
992
|
-
unsupportedModification(type, data) {
|
|
993
|
-
const errorCode = "error.transport.datawallet.unsupportedModification";
|
|
994
|
-
const formattedData = data ? (0, json_stringify_safe_1.default)(data) : "";
|
|
995
|
-
switch (type) {
|
|
996
|
-
case "unsupportedCacheChangedModificationCollection":
|
|
997
|
-
return new CoreError_1.CoreError(errorCode, `The following collections were received in CacheChanged datawallet modifications but are not supported by the current version of this library: ${formattedData}.`);
|
|
998
|
-
default:
|
|
999
|
-
throw new Error(`Given type '${type}' is not supported.`);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
insufficientSupportedDatawalletVersion(supportedVersion, requiredVersion) {
|
|
1003
|
-
return new CoreError_1.CoreError("error.transport.datawallet.insufficientSupportedDatawalletVersion", `The SupportedDatawalletVersion '${supportedVersion}' is too low. A minimum version of '${requiredVersion}' is required.`);
|
|
1004
|
-
}
|
|
1005
|
-
currentBiggerThanTarget(current, target) {
|
|
1006
|
-
return new CoreError_1.CoreError("error.transport.datawallet.currentBiggerThanTarget", `The current datawallet version '${current}' is bigger than the target version '${target}'.`);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
class Files {
|
|
1010
|
-
plaintextHashMismatch() {
|
|
1011
|
-
return new CoreError_1.CoreError("error.transport.files.plaintextHashMismatch", "The actual hash of the plaintext does not match the given plaintextHash. Something went wrong while encrypting/decrypting the file.");
|
|
1012
|
-
}
|
|
1013
|
-
cipherMismatch() {
|
|
1014
|
-
return new CoreError_1.CoreError("error.transport.files.cipherMismatch", "The actual hash of the cipher does not match the given cipherHash. Something went wrong while storing/transmitting the file.");
|
|
1015
|
-
}
|
|
1016
|
-
invalidMetadata(id) {
|
|
1017
|
-
return new CoreError_1.CoreError("error.transport.files.invalidMetadata", `The metadata of file id "${id}" is invalid.`);
|
|
1018
|
-
}
|
|
1019
|
-
fileContentUndefined() {
|
|
1020
|
-
return new CoreError_1.CoreError("error.transport.files.fileContentUndefined", "The given file content is undefined.");
|
|
1021
|
-
}
|
|
1022
|
-
maxFileSizeExceeded(fileSize, platformMaxFileSize) {
|
|
1023
|
-
return new CoreError_1.CoreError("error.transport.files.maxFileSizeExceeded", `The given file content size (${fileSize}) exceeds the max file size the backbone accepts (${platformMaxFileSize}).`);
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
class Tokens {
|
|
1027
|
-
invalidTokenContent(id) {
|
|
1028
|
-
return new CoreError_1.CoreError("error.transport.tokens.invalidTokenContent", `The content of token ${id} is not of type TokenContent`);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
class General {
|
|
1032
|
-
baseUrlNotSet() {
|
|
1033
|
-
return new CoreError_1.CoreError("error.transport.general.baseUrlNotSet", "The baseUrl was not set.");
|
|
1034
|
-
}
|
|
1035
|
-
platformClientIdNotSet() {
|
|
1036
|
-
return new CoreError_1.CoreError("error.transport.general.platformClientNotSet", "The platform clientSecret was not set.");
|
|
1037
|
-
}
|
|
1038
|
-
platformClientSecretNotSet() {
|
|
1039
|
-
return new CoreError_1.CoreError("error.transport.general.platformClientNotSet", "The platform clientId was not set.");
|
|
1040
|
-
}
|
|
1041
|
-
platformClientInvalid() {
|
|
1042
|
-
return new CoreError_1.CoreError("error.transport.general.platformClientInvalid", "The combination of platform clientId and clientSecret is invalid.");
|
|
1043
|
-
}
|
|
1044
|
-
cacheEmpty(entityName, id) {
|
|
1045
|
-
return new Error(`The cache of ${entityName instanceof Function ? entityName.name : entityName} with id "${id}" is empty.`);
|
|
1046
|
-
}
|
|
1047
|
-
incompatibleBackbone() {
|
|
1048
|
-
return new CoreError_1.CoreError("error.transport.incompatibleBackbone", "The backbone sent an invalid payload.");
|
|
1049
|
-
}
|
|
1050
|
-
signatureNotValid(type) {
|
|
1051
|
-
return new CoreError_1.CoreError("error.transport.signatureNotValid", `The ${type ? `${type}-` : ""}signature is not valid.`);
|
|
1052
|
-
}
|
|
1053
|
-
recordNotFound(entityName, entityId) {
|
|
1054
|
-
return new CoreError_1.CoreError("error.transport.recordNotFound", `'${entityName instanceof Function ? entityName.name : entityName}' not found.`, entityId);
|
|
1055
|
-
}
|
|
1056
|
-
notSupported() {
|
|
1057
|
-
return new CoreError_1.CoreError("error.transport.notSupported", "The method is not yet supported.");
|
|
1058
|
-
}
|
|
1059
|
-
realmLength() {
|
|
1060
|
-
return new CoreError_1.CoreError("error.transport.identity.realmLength", "Realm must be of length 3.");
|
|
1061
|
-
}
|
|
1062
|
-
invalidTruncatedReference() {
|
|
1063
|
-
return new CoreError_1.CoreError("error.transport.files.invalidTruncatedReference", "invalid truncated reference");
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
class TransportErrors {
|
|
1067
|
-
}
|
|
1068
|
-
exports.TransportErrors = TransportErrors;
|
|
1069
|
-
TransportErrors.relationships = new Relationships();
|
|
1070
|
-
TransportErrors.general = new General();
|
|
1071
|
-
TransportErrors.messages = new Messages();
|
|
1072
|
-
TransportErrors.secrets = new Secrets();
|
|
1073
|
-
TransportErrors.device = new Device();
|
|
1074
|
-
TransportErrors.files = new Files();
|
|
1075
|
-
TransportErrors.challenges = new Challenges();
|
|
1076
|
-
TransportErrors.datawallet = new Datawallet();
|
|
1077
|
-
TransportErrors.tokens = new Tokens();
|
|
1078
|
-
//# sourceMappingURL=TransportErrors.js.map
|
|
1099
|
+
exports.TransportError = TransportError;
|
|
1100
|
+
//# sourceMappingURL=TransportError.js.map
|
|
1079
1101
|
|
|
1080
1102
|
/***/ }),
|
|
1081
1103
|
|
|
@@ -1106,19 +1128,20 @@ TransportIds.datawalletModification = new CoreIdHelper_1.CoreIdHelper("TRPDWM");
|
|
|
1106
1128
|
/*!*********************************************!*\
|
|
1107
1129
|
!*** ./dist/core/TransportLoggerFactory.js ***!
|
|
1108
1130
|
\*********************************************/
|
|
1109
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
1131
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1110
1132
|
|
|
1111
1133
|
"use strict";
|
|
1112
1134
|
|
|
1113
1135
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1114
1136
|
exports.TransportLoggerFactory = void 0;
|
|
1137
|
+
const TransportError_1 = __webpack_require__(/*! ./TransportError */ "./dist/core/TransportError.js");
|
|
1115
1138
|
class TransportLoggerFactory {
|
|
1116
1139
|
static init(instance) {
|
|
1117
1140
|
this.instance = instance;
|
|
1118
1141
|
}
|
|
1119
1142
|
static getLogger(name) {
|
|
1120
1143
|
if (!this.isInitialized()) {
|
|
1121
|
-
throw new
|
|
1144
|
+
throw new TransportError_1.TransportError("The logger factory is not yet initialized. Call TransportLoggerFactory.init() first.");
|
|
1122
1145
|
}
|
|
1123
1146
|
if (typeof name === "function") {
|
|
1124
1147
|
return this.instance.getLogger(`Transport.${name.name}`);
|
|
@@ -1298,17 +1321,18 @@ BackboneIds.device = new CoreIdHelper_1.CoreIdHelper("DVC", true);
|
|
|
1298
1321
|
|
|
1299
1322
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1300
1323
|
exports.ClientResult = void 0;
|
|
1324
|
+
const TransportError_1 = __webpack_require__(/*! ../TransportError */ "./dist/core/TransportError.js");
|
|
1301
1325
|
const CoreDate_1 = __webpack_require__(/*! ../types/CoreDate */ "./dist/core/types/CoreDate.js");
|
|
1302
1326
|
class ClientResult {
|
|
1303
1327
|
constructor(isSuccess, value, error, platformParameters) {
|
|
1304
1328
|
if (isSuccess && error) {
|
|
1305
|
-
throw new
|
|
1329
|
+
throw new TransportError_1.TransportError("InvalidOperation: A result cannot be successful and contain an error");
|
|
1306
1330
|
}
|
|
1307
1331
|
if (!isSuccess && !error) {
|
|
1308
|
-
throw new
|
|
1332
|
+
throw new TransportError_1.TransportError("InvalidOperation: A failing result needs to contain an error");
|
|
1309
1333
|
}
|
|
1310
1334
|
if (value !== undefined && !isSuccess) {
|
|
1311
|
-
throw new
|
|
1335
|
+
throw new TransportError_1.TransportError("InvalidOperation: A value is only useful in case of a success.");
|
|
1312
1336
|
}
|
|
1313
1337
|
this._value = value;
|
|
1314
1338
|
this._isSuccess = isSuccess;
|
|
@@ -1334,7 +1358,7 @@ class ClientResult {
|
|
|
1334
1358
|
}
|
|
1335
1359
|
get error() {
|
|
1336
1360
|
if (this._isSuccess) {
|
|
1337
|
-
throw new
|
|
1361
|
+
throw new TransportError_1.TransportError("Can't get the error of an succeeded result. Use 'value' instead.");
|
|
1338
1362
|
}
|
|
1339
1363
|
return this._error;
|
|
1340
1364
|
}
|
|
@@ -2116,6 +2140,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
2116
2140
|
__exportStar(__webpack_require__(/*! ./backbone */ "./dist/core/backbone/index.js"), exports);
|
|
2117
2141
|
__exportStar(__webpack_require__(/*! ./CoreCrypto */ "./dist/core/CoreCrypto.js"), exports);
|
|
2118
2142
|
__exportStar(__webpack_require__(/*! ./CoreError */ "./dist/core/CoreError.js"), exports);
|
|
2143
|
+
__exportStar(__webpack_require__(/*! ./CoreErrors */ "./dist/core/CoreErrors.js"), exports);
|
|
2119
2144
|
__exportStar(__webpack_require__(/*! ./CoreIdHelper */ "./dist/core/CoreIdHelper.js"), exports);
|
|
2120
2145
|
__exportStar(__webpack_require__(/*! ./CoreSerializable */ "./dist/core/CoreSerializable.js"), exports);
|
|
2121
2146
|
__exportStar(__webpack_require__(/*! ./CoreSerializableAsync */ "./dist/core/CoreSerializableAsync.js"), exports);
|
|
@@ -2127,7 +2152,7 @@ __exportStar(__webpack_require__(/*! ./Reference */ "./dist/core/Reference.js"),
|
|
|
2127
2152
|
__exportStar(__webpack_require__(/*! ./Transport */ "./dist/core/Transport.js"), exports);
|
|
2128
2153
|
__exportStar(__webpack_require__(/*! ./TransportContext */ "./dist/core/TransportContext.js"), exports);
|
|
2129
2154
|
__exportStar(__webpack_require__(/*! ./TransportController */ "./dist/core/TransportController.js"), exports);
|
|
2130
|
-
__exportStar(__webpack_require__(/*! ./
|
|
2155
|
+
__exportStar(__webpack_require__(/*! ./TransportError */ "./dist/core/TransportError.js"), exports);
|
|
2131
2156
|
__exportStar(__webpack_require__(/*! ./TransportIds */ "./dist/core/TransportIds.js"), exports);
|
|
2132
2157
|
__exportStar(__webpack_require__(/*! ./TransportLoggerFactory */ "./dist/core/TransportLoggerFactory.js"), exports);
|
|
2133
2158
|
__exportStar(__webpack_require__(/*! ./types */ "./dist/core/types/index.js"), exports);
|
|
@@ -2218,6 +2243,7 @@ exports.CoreDate = void 0;
|
|
|
2218
2243
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2219
2244
|
const luxon_1 = __webpack_require__(/*! luxon */ "./node_modules/luxon/build/node/luxon.js");
|
|
2220
2245
|
const CoreSerializable_1 = __webpack_require__(/*! ../CoreSerializable */ "./dist/core/CoreSerializable.js");
|
|
2246
|
+
const TransportError_1 = __webpack_require__(/*! ../TransportError */ "./dist/core/TransportError.js");
|
|
2221
2247
|
let CoreDate = CoreDate_1 = class CoreDate extends CoreSerializable_1.CoreSerializable {
|
|
2222
2248
|
constructor(dateTime = luxon_1.DateTime.utc()) {
|
|
2223
2249
|
super();
|
|
@@ -2330,12 +2356,12 @@ let CoreDate = CoreDate_1 = class CoreDate extends CoreSerializable_1.CoreSerial
|
|
|
2330
2356
|
}
|
|
2331
2357
|
static preFrom(value) {
|
|
2332
2358
|
if (typeof value === "undefined") {
|
|
2333
|
-
throw new
|
|
2359
|
+
throw new TransportError_1.TransportError("The provided object is undefined and cannot be deserialized.");
|
|
2334
2360
|
}
|
|
2335
2361
|
if (typeof value === "object") {
|
|
2336
2362
|
if (typeof value.date === "undefined") {
|
|
2337
2363
|
if (typeof value.toISOString !== "function") {
|
|
2338
|
-
throw new
|
|
2364
|
+
throw new TransportError_1.TransportError("The provided object doesn't have an 'toISOString' string method.");
|
|
2339
2365
|
}
|
|
2340
2366
|
const iso = value.toISOString();
|
|
2341
2367
|
return luxon_1.DateTime.fromISO(iso, { zone: "utc" });
|
|
@@ -2348,7 +2374,7 @@ let CoreDate = CoreDate_1 = class CoreDate extends CoreSerializable_1.CoreSerial
|
|
|
2348
2374
|
if (typeof value === "string") {
|
|
2349
2375
|
return luxon_1.DateTime.fromISO(value, { zone: "utc" }).toUTC();
|
|
2350
2376
|
}
|
|
2351
|
-
throw new
|
|
2377
|
+
throw new TransportError_1.TransportError("The provided object is invalid cannot be deserialized.");
|
|
2352
2378
|
}
|
|
2353
2379
|
static from(value) {
|
|
2354
2380
|
return this.fromAny(value);
|
|
@@ -2470,6 +2496,7 @@ exports.CoreId = void 0;
|
|
|
2470
2496
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2471
2497
|
const Random_1 = __webpack_require__(/*! ../../util/Random */ "./dist/util/Random.js");
|
|
2472
2498
|
const CoreSerializable_1 = __webpack_require__(/*! ../CoreSerializable */ "./dist/core/CoreSerializable.js");
|
|
2499
|
+
const TransportError_1 = __webpack_require__(/*! ../TransportError */ "./dist/core/TransportError.js");
|
|
2473
2500
|
/**
|
|
2474
2501
|
* A CoreId is any kind of identifier we have in the system.
|
|
2475
2502
|
*/
|
|
@@ -2482,7 +2509,7 @@ let CoreId = class CoreId extends CoreSerializable_1.CoreSerializable {
|
|
|
2482
2509
|
}
|
|
2483
2510
|
static async generate(prefix = "") {
|
|
2484
2511
|
if (prefix.length > 6) {
|
|
2485
|
-
throw new
|
|
2512
|
+
throw new TransportError_1.TransportError(`The prefix "${prefix}" is too long. It must not be longer than 6 characters.`);
|
|
2486
2513
|
}
|
|
2487
2514
|
const random = await Random_1.Random.string(20 - prefix.length, Random_1.RandomCharacterRange.Alphanumeric);
|
|
2488
2515
|
return this.from(prefix.toUpperCase() + random);
|
|
@@ -2843,7 +2870,7 @@ class AccountController {
|
|
|
2843
2870
|
}
|
|
2844
2871
|
get activeDevice() {
|
|
2845
2872
|
if (!this._activeDevice) {
|
|
2846
|
-
throw new
|
|
2873
|
+
throw new core_1.TransportError("The DeviceController is not initialized yet.");
|
|
2847
2874
|
}
|
|
2848
2875
|
return this._activeDevice;
|
|
2849
2876
|
}
|
|
@@ -2853,7 +2880,6 @@ class AccountController {
|
|
|
2853
2880
|
get identity() {
|
|
2854
2881
|
return this._identity;
|
|
2855
2882
|
}
|
|
2856
|
-
// TODO: JSSNMSHDD-2487 (last login date)
|
|
2857
2883
|
async init(deviceSharedSecret) {
|
|
2858
2884
|
this.info = await this.db.getMap("AccountInfo");
|
|
2859
2885
|
this.unpushedDatawalletModifications = await this.db.getCollection(DbCollectionName_1.DbCollectionName.UnpushedDatawalletModifications);
|
|
@@ -2888,7 +2914,7 @@ class AccountController {
|
|
|
2888
2914
|
else if (!deviceSharedSecret && availableIdentityDoc && availableDeviceDoc) {
|
|
2889
2915
|
// Login
|
|
2890
2916
|
if (!availableBaseKeyDoc) {
|
|
2891
|
-
throw core_1.
|
|
2917
|
+
throw core_1.CoreErrors.secrets.secretNotFound("BaseKey");
|
|
2892
2918
|
}
|
|
2893
2919
|
const [availableIdentity, availableDevice, availableBaseKey] = await Promise.all([
|
|
2894
2920
|
Identity_1.Identity.from(availableIdentityDoc),
|
|
@@ -2902,7 +2928,7 @@ class AccountController {
|
|
|
2902
2928
|
this.deviceAuthClient = new DeviceAuthClient_1.DeviceAuthClient(this.config, this.authenticator);
|
|
2903
2929
|
}
|
|
2904
2930
|
else {
|
|
2905
|
-
throw new
|
|
2931
|
+
throw new core_1.TransportError("The combination of deviceSharedSecret, existing identity or device is not allowed.");
|
|
2906
2932
|
}
|
|
2907
2933
|
this._log.trace(`Using device ${this.activeDevice.id} for identity ${this.identity.address}.`);
|
|
2908
2934
|
await this.initControllers();
|
|
@@ -2998,13 +3024,13 @@ class AccountController {
|
|
|
2998
3024
|
if (deviceResponseResult.isError) {
|
|
2999
3025
|
const error = deviceResponseResult.error;
|
|
3000
3026
|
if (error.code === "error.platform.unauthorized") {
|
|
3001
|
-
throw core_1.
|
|
3027
|
+
throw core_1.CoreErrors.general.platformClientInvalid();
|
|
3002
3028
|
}
|
|
3003
3029
|
}
|
|
3004
3030
|
const deviceResponse = deviceResponseResult.value;
|
|
3005
3031
|
this._log.trace(`Registered identity with address ${deviceResponse.address}, device id is ${deviceResponse.device.id}.`);
|
|
3006
3032
|
if (!localAddress.equals(deviceResponse.address)) {
|
|
3007
|
-
throw new
|
|
3033
|
+
throw new core_1.TransportError("The backbone address does not match the local address.");
|
|
3008
3034
|
}
|
|
3009
3035
|
const identity = Identity_1.Identity.from({
|
|
3010
3036
|
address: core_1.CoreAddress.from(deviceResponse.address),
|
|
@@ -3043,7 +3069,6 @@ class AccountController {
|
|
|
3043
3069
|
this.activeDevice.secrets.storeSecret(deviceKeypair.privateKey, DeviceSecretController_1.DeviceSecretType.DeviceSignature),
|
|
3044
3070
|
this.activeDevice.secrets.storeSecret(deviceCredentials, DeviceSecretController_1.DeviceSecretType.DeviceCredentials)
|
|
3045
3071
|
]);
|
|
3046
|
-
// TODO: JSSNMSHDD-2471 (Rollback on error)
|
|
3047
3072
|
return { identity, device };
|
|
3048
3073
|
}
|
|
3049
3074
|
async onboardDevice(deviceSharedSecret) {
|
|
@@ -3186,7 +3211,7 @@ class IdentityController extends core_1.TransportController {
|
|
|
3186
3211
|
async sign(content) {
|
|
3187
3212
|
const privateKeyContainer = await this.parent.activeDevice.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.IdentitySignature);
|
|
3188
3213
|
if (!privateKeyContainer || !(privateKeyContainer.secret instanceof crypto_1.CryptoSignaturePrivateKey)) {
|
|
3189
|
-
throw core_1.
|
|
3214
|
+
throw core_1.CoreErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.IdentitySignature);
|
|
3190
3215
|
}
|
|
3191
3216
|
const privateKey = privateKeyContainer.secret;
|
|
3192
3217
|
const signature = await core_1.CoreCrypto.sign(content, privateKey);
|
|
@@ -3230,7 +3255,7 @@ const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
|
3230
3255
|
class IdentityUtil {
|
|
3231
3256
|
static async createAddress(publicKey, realm) {
|
|
3232
3257
|
if (realm.length !== 3)
|
|
3233
|
-
throw core_1.
|
|
3258
|
+
throw core_1.CoreErrors.general.realmLength();
|
|
3234
3259
|
const sha512buffer = await crypto_1.CryptoHash.hash(publicKey.publicKey, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
3235
3260
|
const hash = await crypto_1.CryptoHash.hash(sha512buffer, 1 /* CryptoHashAlgorithm.SHA256 */);
|
|
3236
3261
|
const hashedPublicKey = new crypto_1.CoreBuffer(hash.buffer.slice(0, 20));
|
|
@@ -3328,7 +3353,6 @@ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-s
|
|
|
3328
3353
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
3329
3354
|
const CoreSerializable_1 = __webpack_require__(/*! ../../../core/CoreSerializable */ "./dist/core/CoreSerializable.js");
|
|
3330
3355
|
const CoreAddress_1 = __webpack_require__(/*! ../../../core/types/CoreAddress */ "./dist/core/types/CoreAddress.js");
|
|
3331
|
-
const CoreDate_1 = __webpack_require__(/*! ../../../core/types/CoreDate */ "./dist/core/types/CoreDate.js");
|
|
3332
3356
|
var Realm;
|
|
3333
3357
|
(function (Realm) {
|
|
3334
3358
|
Realm["Dev"] = "dev";
|
|
@@ -3336,14 +3360,6 @@ var Realm;
|
|
|
3336
3360
|
Realm["Prod"] = "id1";
|
|
3337
3361
|
})(Realm = exports.Realm || (exports.Realm = {}));
|
|
3338
3362
|
let Identity = class Identity extends CoreSerializable_1.CoreSerializable {
|
|
3339
|
-
static postFrom(value) {
|
|
3340
|
-
// TODO: Remove these default values once we're sure that nobody is accessing the deprecated properties anymore
|
|
3341
|
-
value.name = "";
|
|
3342
|
-
value.description = "";
|
|
3343
|
-
value.type = "unknown";
|
|
3344
|
-
value.createdAt = CoreDate_1.CoreDate.from("2020-01-01T00:00:00Z");
|
|
3345
|
-
return value;
|
|
3346
|
-
}
|
|
3347
3363
|
static from(value) {
|
|
3348
3364
|
return this.fromAny(value);
|
|
3349
3365
|
}
|
|
@@ -3363,30 +3379,6 @@ __decorate([
|
|
|
3363
3379
|
(0, ts_serval_1.serialize)(),
|
|
3364
3380
|
__metadata("design:type", String)
|
|
3365
3381
|
], Identity.prototype, "realm", void 0);
|
|
3366
|
-
__decorate([
|
|
3367
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3368
|
-
(0, ts_serval_1.serialize)(),
|
|
3369
|
-
__metadata("design:type", String)
|
|
3370
|
-
], Identity.prototype, "name", void 0);
|
|
3371
|
-
__decorate([
|
|
3372
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3373
|
-
(0, ts_serval_1.serialize)(),
|
|
3374
|
-
__metadata("design:type", String)
|
|
3375
|
-
], Identity.prototype, "description", void 0);
|
|
3376
|
-
__decorate([
|
|
3377
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3378
|
-
(0, ts_serval_1.serialize)(),
|
|
3379
|
-
__metadata("design:type", CoreDate_1.CoreDate
|
|
3380
|
-
/**
|
|
3381
|
-
* @deprecated
|
|
3382
|
-
*/
|
|
3383
|
-
)
|
|
3384
|
-
], Identity.prototype, "createdAt", void 0);
|
|
3385
|
-
__decorate([
|
|
3386
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3387
|
-
(0, ts_serval_1.serialize)(),
|
|
3388
|
-
__metadata("design:type", String)
|
|
3389
|
-
], Identity.prototype, "type", void 0);
|
|
3390
3382
|
Identity = __decorate([
|
|
3391
3383
|
(0, ts_serval_1.type)("Identity")
|
|
3392
3384
|
], Identity);
|
|
@@ -4304,7 +4296,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4304
4296
|
return { isValid: false };
|
|
4305
4297
|
const relationship = await this.parent.relationships.getActiveRelationshipToIdentity(challenge.createdBy);
|
|
4306
4298
|
if (!relationship) {
|
|
4307
|
-
throw core_1.
|
|
4299
|
+
throw core_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, challenge.createdBy.toString());
|
|
4308
4300
|
}
|
|
4309
4301
|
const challengeBuffer = crypto_1.CoreBuffer.fromUtf8(signedChallenge.challenge);
|
|
4310
4302
|
let isValid = false;
|
|
@@ -4313,7 +4305,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4313
4305
|
isValid = await this.parent.relationships.verifyIdentity(relationship, challengeBuffer, signedChallenge.signature);
|
|
4314
4306
|
break;
|
|
4315
4307
|
case Challenge_1.ChallengeType.Device:
|
|
4316
|
-
throw core_1.
|
|
4308
|
+
throw core_1.CoreErrors.general.notSupported();
|
|
4317
4309
|
case Challenge_1.ChallengeType.Relationship:
|
|
4318
4310
|
isValid = await this.parent.relationships.verify(relationship, challengeBuffer, signedChallenge.signature);
|
|
4319
4311
|
break;
|
|
@@ -4332,8 +4324,6 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4332
4324
|
if (backboneChallengeResponse.isError)
|
|
4333
4325
|
return { isValid: false };
|
|
4334
4326
|
if ((challenge.createdBy && backboneChallengeResponse.value.createdBy !== challenge.createdBy.toString()) ||
|
|
4335
|
-
// TODO: JSSNMSHDD-2472 (Reenable check once the backbone returns with same timestamp)
|
|
4336
|
-
// response.expiresAt !== challenge.expiresAt.toString() ||
|
|
4337
4327
|
backboneChallengeResponse.value.id !== challenge.id.toString()) {
|
|
4338
4328
|
return { isValid: false };
|
|
4339
4329
|
}
|
|
@@ -4357,7 +4347,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4357
4347
|
}
|
|
4358
4348
|
async createChallenge(type = Challenge_1.ChallengeType.Identity, relationship) {
|
|
4359
4349
|
if (type === Challenge_1.ChallengeType.Relationship && !relationship) {
|
|
4360
|
-
throw core_1.
|
|
4350
|
+
throw core_1.CoreErrors.challenges.challengeTypeRequiresRelationship();
|
|
4361
4351
|
}
|
|
4362
4352
|
const backboneResponse = (await this.authClient.createChallenge()).value;
|
|
4363
4353
|
const challenge = Challenge_1.Challenge.from({
|
|
@@ -4381,7 +4371,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4381
4371
|
break;
|
|
4382
4372
|
case Challenge_1.ChallengeType.Relationship:
|
|
4383
4373
|
if (!relationship) {
|
|
4384
|
-
throw core_1.
|
|
4374
|
+
throw core_1.CoreErrors.challenges.challengeTypeRequiresRelationship();
|
|
4385
4375
|
}
|
|
4386
4376
|
signature = await this.parent.relationships.sign(relationship, challengeBuffer);
|
|
4387
4377
|
break;
|
|
@@ -4638,7 +4628,7 @@ class DeviceController extends core_1.TransportController {
|
|
|
4638
4628
|
}
|
|
4639
4629
|
get device() {
|
|
4640
4630
|
if (!this._device)
|
|
4641
|
-
throw new
|
|
4631
|
+
throw new core_1.TransportError("The Device controller is not initialized.");
|
|
4642
4632
|
return this._device;
|
|
4643
4633
|
}
|
|
4644
4634
|
get deviceOrUndefined() {
|
|
@@ -4659,15 +4649,14 @@ class DeviceController extends core_1.TransportController {
|
|
|
4659
4649
|
try {
|
|
4660
4650
|
const credentialContainer = await this.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4661
4651
|
if (!credentialContainer) {
|
|
4662
|
-
throw new
|
|
4652
|
+
throw new core_1.TransportError("There was an error while accessing the device_credentials secret.");
|
|
4663
4653
|
}
|
|
4664
4654
|
const credentials = credentialContainer.secret;
|
|
4665
4655
|
credentials.password = newPassword;
|
|
4666
4656
|
await this.secrets.storeSecret(credentials, DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4667
4657
|
}
|
|
4668
4658
|
catch (e) {
|
|
4669
|
-
|
|
4670
|
-
this.log.warn(`We've changed the device password on the backboen but weren't able to store it to the database. The new password is '${newPassword}'.`);
|
|
4659
|
+
this.log.warn(`We've changed the device password on the backbone but weren't able to store it to the database. The new password is '${newPassword}'.`);
|
|
4671
4660
|
throw e;
|
|
4672
4661
|
}
|
|
4673
4662
|
}
|
|
@@ -4684,7 +4673,7 @@ class DeviceController extends core_1.TransportController {
|
|
|
4684
4673
|
async sign(content) {
|
|
4685
4674
|
const privateKeyContainer = await this.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.DeviceSignature);
|
|
4686
4675
|
if (!privateKeyContainer || !(privateKeyContainer.secret instanceof crypto_1.CryptoSignaturePrivateKey)) {
|
|
4687
|
-
throw core_1.
|
|
4676
|
+
throw core_1.CoreErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceSignature);
|
|
4688
4677
|
}
|
|
4689
4678
|
const privateKey = privateKeyContainer.secret;
|
|
4690
4679
|
const signature = await core_1.CoreCrypto.sign(content, privateKey);
|
|
@@ -4693,21 +4682,21 @@ class DeviceController extends core_1.TransportController {
|
|
|
4693
4682
|
}
|
|
4694
4683
|
async verify(content, signature) {
|
|
4695
4684
|
if (!this.publicKey) {
|
|
4696
|
-
throw new
|
|
4685
|
+
throw new core_1.TransportError("The device has no public key to verify a signature. This can happen if the device is not onboarded yet.");
|
|
4697
4686
|
}
|
|
4698
4687
|
return await core_1.CoreCrypto.verify(content, signature, this.publicKey);
|
|
4699
4688
|
}
|
|
4700
4689
|
async getCredentials() {
|
|
4701
4690
|
const credentialContainer = await this.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4702
4691
|
if (!credentialContainer) {
|
|
4703
|
-
throw core_1.
|
|
4692
|
+
throw core_1.CoreErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4704
4693
|
}
|
|
4705
4694
|
if (!(credentialContainer.secret instanceof DeviceSecretCredentials_1.DeviceSecretCredentials)) {
|
|
4706
|
-
throw core_1.
|
|
4695
|
+
throw core_1.CoreErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4707
4696
|
}
|
|
4708
4697
|
const credentials = credentialContainer.secret;
|
|
4709
4698
|
if (!credentials.username || !credentials.password) {
|
|
4710
|
-
throw core_1.
|
|
4699
|
+
throw core_1.CoreErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4711
4700
|
}
|
|
4712
4701
|
return {
|
|
4713
4702
|
username: credentials.username,
|
|
@@ -4851,17 +4840,17 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4851
4840
|
async createDeviceSharedSecret(device, deviceIndex, includeIdentityPrivateKey = false) {
|
|
4852
4841
|
const synchronizationKey = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4853
4842
|
if (!synchronizationKey || !(synchronizationKey.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4854
|
-
throw core_1.
|
|
4843
|
+
throw core_1.CoreErrors.secrets.secretNotFound("SynchronizationKey");
|
|
4855
4844
|
}
|
|
4856
4845
|
const baseKey = await this.loadSecret(DeviceSecretType.SharedSecretBaseKey);
|
|
4857
4846
|
if (!baseKey || !(baseKey.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4858
|
-
throw core_1.
|
|
4847
|
+
throw core_1.CoreErrors.secrets.secretNotFound("baseKey");
|
|
4859
4848
|
}
|
|
4860
4849
|
let identityPrivateKey;
|
|
4861
4850
|
if (includeIdentityPrivateKey) {
|
|
4862
4851
|
identityPrivateKey = await this.loadSecret(DeviceSecretType.IdentitySignature);
|
|
4863
4852
|
if (!identityPrivateKey || !(identityPrivateKey.secret instanceof crypto_1.CryptoSignaturePrivateKey)) {
|
|
4864
|
-
throw core_1.
|
|
4853
|
+
throw core_1.CoreErrors.secrets.secretNotFound("IdentityKey");
|
|
4865
4854
|
}
|
|
4866
4855
|
}
|
|
4867
4856
|
const deviceSharedSecret = DeviceSharedSecret_1.DeviceSharedSecret.from({
|
|
@@ -4878,7 +4867,6 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4878
4867
|
password: device.initialPassword,
|
|
4879
4868
|
identity: this.parent.identity.identity
|
|
4880
4869
|
});
|
|
4881
|
-
// TODO: JSSNMSHDD-2474 (Rollback on error)
|
|
4882
4870
|
return deviceSharedSecret;
|
|
4883
4871
|
}
|
|
4884
4872
|
async encryptDatawalletModificationPayload(event, index) {
|
|
@@ -4888,7 +4876,7 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4888
4876
|
const serializedEvent = crypto_1.CoreBuffer.fromUtf8(JSON.stringify(event.payload));
|
|
4889
4877
|
const privSync = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4890
4878
|
if (!privSync || !(privSync.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4891
|
-
throw core_1.
|
|
4879
|
+
throw core_1.CoreErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4892
4880
|
}
|
|
4893
4881
|
const encryptionKey = await core_1.CoreCrypto.deriveKeyFromBase(privSync.secret, index, "DataSync");
|
|
4894
4882
|
const cipher = await core_1.CoreCrypto.encrypt(serializedEvent, encryptionKey);
|
|
@@ -4902,7 +4890,7 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4902
4890
|
const payloadCipher = crypto_1.CryptoCipher.fromBase64(payloadCipherBase64);
|
|
4903
4891
|
const privSync = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4904
4892
|
if (!privSync || !(privSync.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4905
|
-
throw core_1.
|
|
4893
|
+
throw core_1.CoreErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4906
4894
|
}
|
|
4907
4895
|
const decryptionKey = await core_1.CoreCrypto.deriveKeyFromBase(privSync.secret, index, "DataSync");
|
|
4908
4896
|
const plaintext = await core_1.CoreCrypto.decrypt(payloadCipher, decryptionKey);
|
|
@@ -4912,7 +4900,7 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4912
4900
|
}
|
|
4913
4901
|
getBaseKey() {
|
|
4914
4902
|
if (!this.baseKey) {
|
|
4915
|
-
throw core_1.
|
|
4903
|
+
throw core_1.CoreErrors.general.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretType.SharedSecretBaseKey);
|
|
4916
4904
|
}
|
|
4917
4905
|
return this.baseKey;
|
|
4918
4906
|
}
|
|
@@ -5022,12 +5010,12 @@ class DevicesController extends TransportController_1.TransportController {
|
|
|
5022
5010
|
async getSharedSecret(id) {
|
|
5023
5011
|
const deviceDoc = await this.devices.read(id.toString());
|
|
5024
5012
|
if (!deviceDoc) {
|
|
5025
|
-
throw core_1.
|
|
5013
|
+
throw core_1.CoreErrors.general.recordNotFound(Device_1.Device, id.toString());
|
|
5026
5014
|
}
|
|
5027
5015
|
const count = await this.devices.count();
|
|
5028
5016
|
const device = Device_1.Device.from(deviceDoc);
|
|
5029
5017
|
if (!device.initialPassword || device.publicKey || device.lastLoginAt) {
|
|
5030
|
-
throw core_1.
|
|
5018
|
+
throw core_1.CoreErrors.device.alreadyOnboarded();
|
|
5031
5019
|
}
|
|
5032
5020
|
const isAdmin = device.isAdmin === true;
|
|
5033
5021
|
const secret = await this.parent.activeDevice.secrets.createDeviceSharedSecret(device, count, isAdmin);
|
|
@@ -5036,7 +5024,7 @@ class DevicesController extends TransportController_1.TransportController {
|
|
|
5036
5024
|
async update(device) {
|
|
5037
5025
|
const deviceDoc = await this.devices.read(device.id.toString());
|
|
5038
5026
|
if (!deviceDoc) {
|
|
5039
|
-
throw core_1.
|
|
5027
|
+
throw core_1.CoreErrors.general.recordNotFound(Device_1.Device, device.id.toString());
|
|
5040
5028
|
}
|
|
5041
5029
|
await this.devices.update(deviceDoc, device);
|
|
5042
5030
|
}
|
|
@@ -5509,7 +5497,6 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5509
5497
|
if (ids.length < 1) {
|
|
5510
5498
|
return [];
|
|
5511
5499
|
}
|
|
5512
|
-
// TODO: JSSNMSHDD-2820 (check for items that couldn't be fetched e.g. because it is expired)
|
|
5513
5500
|
const resultItems = (await this.client.getFiles({ ids })).value;
|
|
5514
5501
|
const promises = [];
|
|
5515
5502
|
for await (const resultItem of resultItems) {
|
|
@@ -5520,7 +5507,7 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5520
5507
|
async updateCacheOfExistingFileInDb(id, response) {
|
|
5521
5508
|
const fileDoc = await this.files.read(id);
|
|
5522
5509
|
if (!fileDoc) {
|
|
5523
|
-
throw core_1.
|
|
5510
|
+
throw core_1.CoreErrors.general.recordNotFound(File_1.File, id);
|
|
5524
5511
|
}
|
|
5525
5512
|
const file = File_1.File.from(fileDoc);
|
|
5526
5513
|
await this.updateCacheOfFile(file, response);
|
|
@@ -5542,9 +5529,8 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5542
5529
|
const plaintextMetadataBuffer = await core_1.CoreCrypto.decrypt(cipher, secretKey);
|
|
5543
5530
|
const plaintextMetadata = FileMetadata_1.FileMetadata.deserialize(plaintextMetadataBuffer.toUtf8());
|
|
5544
5531
|
if (!(plaintextMetadata instanceof FileMetadata_1.FileMetadata)) {
|
|
5545
|
-
throw core_1.
|
|
5532
|
+
throw core_1.CoreErrors.files.invalidMetadata(response.id);
|
|
5546
5533
|
}
|
|
5547
|
-
// TODO: JSSNMSHDD-2486 (check signature)
|
|
5548
5534
|
const cachedFile = CachedFile_1.CachedFile.fromBackbone(response, plaintextMetadata);
|
|
5549
5535
|
return cachedFile;
|
|
5550
5536
|
}
|
|
@@ -5575,7 +5561,7 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5575
5561
|
const id = idOrFile instanceof core_1.CoreId ? idOrFile.toString() : idOrFile.id.toString();
|
|
5576
5562
|
const fileDoc = await this.files.read(id);
|
|
5577
5563
|
if (!fileDoc) {
|
|
5578
|
-
throw core_1.
|
|
5564
|
+
throw core_1.CoreErrors.general.recordNotFound(File_1.File, id.toString());
|
|
5579
5565
|
}
|
|
5580
5566
|
const file = File_1.File.from(fileDoc);
|
|
5581
5567
|
file.setMetadata(metadata);
|
|
@@ -5587,7 +5573,7 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5587
5573
|
const content = input.buffer;
|
|
5588
5574
|
const fileSize = content.length;
|
|
5589
5575
|
if (fileSize > this.config.platformMaxUnencryptedFileSize) {
|
|
5590
|
-
throw core_1.
|
|
5576
|
+
throw core_1.CoreErrors.files.maxFileSizeExceeded(fileSize, this.config.platformMaxUnencryptedFileSize);
|
|
5591
5577
|
}
|
|
5592
5578
|
const plaintextHashBuffer = await crypto_1.CryptoHash.hash(content, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
5593
5579
|
const plaintextHash = core_1.CoreHash.from(plaintextHashBuffer.toBase64URL());
|
|
@@ -5650,30 +5636,22 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5650
5636
|
async downloadFileContent(idOrFile) {
|
|
5651
5637
|
const file = idOrFile instanceof File_1.File ? idOrFile : await this.getFile(idOrFile);
|
|
5652
5638
|
if (!file) {
|
|
5653
|
-
throw core_1.
|
|
5654
|
-
}
|
|
5655
|
-
if (!file.cache) {
|
|
5656
|
-
throw core_1.TransportErrors.general.cacheEmpty(File_1.File, file.id.toString());
|
|
5639
|
+
throw core_1.CoreErrors.general.recordNotFound(File_1.File, idOrFile.toString());
|
|
5657
5640
|
}
|
|
5641
|
+
if (!file.cache)
|
|
5642
|
+
throw this.newCacheEmptyError(File_1.File, file.id.toString());
|
|
5658
5643
|
const downloadResponse = (await this.client.downloadFile(file.id.toString())).value;
|
|
5659
5644
|
const buffer = crypto_1.CoreBuffer.fromObject(downloadResponse);
|
|
5660
5645
|
const hash = await crypto_1.CryptoHash.hash(buffer, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
5661
5646
|
const hashb64 = hash.toBase64URL();
|
|
5662
5647
|
if (hashb64 !== file.cache.cipherHash.hash) {
|
|
5663
|
-
throw core_1.
|
|
5664
|
-
}
|
|
5665
|
-
/*
|
|
5666
|
-
// TODO: JSSNMSHDD-2486 (verify owner signature)
|
|
5667
|
-
const valid = await Crypto.verify(parcel.cipher.cipher, parcel.ownerSignature, owner.signing)
|
|
5668
|
-
if (!valid) {
|
|
5669
|
-
throw CoreErrors.General.SignatureNotValid("file")
|
|
5648
|
+
throw core_1.CoreErrors.files.cipherMismatch();
|
|
5670
5649
|
}
|
|
5671
|
-
*/
|
|
5672
5650
|
const cipher = crypto_1.CryptoCipher.fromBase64(buffer.toBase64URL());
|
|
5673
5651
|
const decrypt = await core_1.CoreCrypto.decrypt(cipher, file.cache.cipherKey);
|
|
5674
5652
|
const plaintextHashesMatch = await file.cache.plaintextHash.verify(decrypt, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
5675
5653
|
if (!plaintextHashesMatch) {
|
|
5676
|
-
throw core_1.
|
|
5654
|
+
throw core_1.CoreErrors.files.plaintextHashMismatch();
|
|
5677
5655
|
}
|
|
5678
5656
|
return decrypt;
|
|
5679
5657
|
}
|
|
@@ -6272,9 +6250,9 @@ __exportStar(__webpack_require__(/*! ./messages/local/CachedMessage */ "./dist/m
|
|
|
6272
6250
|
__exportStar(__webpack_require__(/*! ./messages/local/Message */ "./dist/modules/messages/local/Message.js"), exports);
|
|
6273
6251
|
__exportStar(__webpack_require__(/*! ./messages/local/SendMessageParameters */ "./dist/modules/messages/local/SendMessageParameters.js"), exports);
|
|
6274
6252
|
__exportStar(__webpack_require__(/*! ./messages/MessageController */ "./dist/modules/messages/MessageController.js"), exports);
|
|
6253
|
+
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageContentWrapper */ "./dist/modules/messages/transmission/MessageContentWrapper.js"), exports);
|
|
6275
6254
|
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageEnvelope */ "./dist/modules/messages/transmission/MessageEnvelope.js"), exports);
|
|
6276
6255
|
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageEnvelopeRecipient */ "./dist/modules/messages/transmission/MessageEnvelopeRecipient.js"), exports);
|
|
6277
|
-
__exportStar(__webpack_require__(/*! ./messages/transmission/MessagePlain */ "./dist/modules/messages/transmission/MessagePlain.js"), exports);
|
|
6278
6256
|
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageSignature */ "./dist/modules/messages/transmission/MessageSignature.js"), exports);
|
|
6279
6257
|
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageSigned */ "./dist/modules/messages/transmission/MessageSigned.js"), exports);
|
|
6280
6258
|
__exportStar(__webpack_require__(/*! ./relationships/backbone/BackboneGetRelationships */ "./dist/modules/relationships/backbone/BackboneGetRelationships.js"), exports);
|
|
@@ -6293,10 +6271,10 @@ __exportStar(__webpack_require__(/*! ./relationships/transmission/changes/Relati
|
|
|
6293
6271
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/changes/RelationshipChangeType */ "./dist/modules/relationships/transmission/changes/RelationshipChangeType.js"), exports);
|
|
6294
6272
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/RelationshipStatus */ "./dist/modules/relationships/transmission/RelationshipStatus.js"), exports);
|
|
6295
6273
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/requests/RelationshipCreationChangeRequestCipher */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestCipher.js"), exports);
|
|
6296
|
-
__exportStar(__webpack_require__(/*! ./relationships/transmission/requests/
|
|
6274
|
+
__exportStar(__webpack_require__(/*! ./relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js"), exports);
|
|
6297
6275
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/requests/RelationshipCreationChangeRequestSigned */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestSigned.js"), exports);
|
|
6298
6276
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/responses/RelationshipCreationChangeResponseCipher */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseCipher.js"), exports);
|
|
6299
|
-
__exportStar(__webpack_require__(/*! ./relationships/transmission/responses/
|
|
6277
|
+
__exportStar(__webpack_require__(/*! ./relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js"), exports);
|
|
6300
6278
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/responses/RelationshipCreationChangeResponseSigned */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseSigned.js"), exports);
|
|
6301
6279
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/backbone/BackboneGetRelationshipTemplates */ "./dist/modules/relationshipTemplates/backbone/BackboneGetRelationshipTemplates.js"), exports);
|
|
6302
6280
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/backbone/BackbonePostRelationshipTemplates */ "./dist/modules/relationshipTemplates/backbone/BackbonePostRelationshipTemplates.js"), exports);
|
|
@@ -6305,7 +6283,7 @@ __exportStar(__webpack_require__(/*! ./relationshipTemplates/local/CachedRelatio
|
|
|
6305
6283
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js"), exports);
|
|
6306
6284
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/local/SendRelationshipTemplateParameters */ "./dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js"), exports);
|
|
6307
6285
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/RelationshipTemplateController */ "./dist/modules/relationshipTemplates/RelationshipTemplateController.js"), exports);
|
|
6308
|
-
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/
|
|
6286
|
+
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/RelationshipTemplateContentWrapper */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js"), exports);
|
|
6309
6287
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/RelationshipTemplatePublicKey */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.js"), exports);
|
|
6310
6288
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/RelationshipTemplateReference */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.js"), exports);
|
|
6311
6289
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/RelationshipTemplateSigned */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateSigned.js"), exports);
|
|
@@ -6377,9 +6355,9 @@ const MessageClient_1 = __webpack_require__(/*! ./backbone/MessageClient */ "./d
|
|
|
6377
6355
|
const CachedMessage_1 = __webpack_require__(/*! ./local/CachedMessage */ "./dist/modules/messages/local/CachedMessage.js");
|
|
6378
6356
|
const Message_1 = __webpack_require__(/*! ./local/Message */ "./dist/modules/messages/local/Message.js");
|
|
6379
6357
|
const SendMessageParameters_1 = __webpack_require__(/*! ./local/SendMessageParameters */ "./dist/modules/messages/local/SendMessageParameters.js");
|
|
6358
|
+
const MessageContentWrapper_1 = __webpack_require__(/*! ./transmission/MessageContentWrapper */ "./dist/modules/messages/transmission/MessageContentWrapper.js");
|
|
6380
6359
|
const MessageEnvelope_1 = __webpack_require__(/*! ./transmission/MessageEnvelope */ "./dist/modules/messages/transmission/MessageEnvelope.js");
|
|
6381
6360
|
const MessageEnvelopeRecipient_1 = __webpack_require__(/*! ./transmission/MessageEnvelopeRecipient */ "./dist/modules/messages/transmission/MessageEnvelopeRecipient.js");
|
|
6382
|
-
const MessagePlain_1 = __webpack_require__(/*! ./transmission/MessagePlain */ "./dist/modules/messages/transmission/MessagePlain.js");
|
|
6383
6361
|
const MessageSignature_1 = __webpack_require__(/*! ./transmission/MessageSignature */ "./dist/modules/messages/transmission/MessageSignature.js");
|
|
6384
6362
|
const MessageSigned_1 = __webpack_require__(/*! ./transmission/MessageSigned */ "./dist/modules/messages/transmission/MessageSigned.js");
|
|
6385
6363
|
class MessageController extends TransportController_1.TransportController {
|
|
@@ -6409,7 +6387,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6409
6387
|
async getMessagesByAddress(address) {
|
|
6410
6388
|
const relationship = await this.parent.relationships.getActiveRelationshipToIdentity(address);
|
|
6411
6389
|
if (!relationship) {
|
|
6412
|
-
throw core_1.
|
|
6390
|
+
throw core_1.CoreErrors.messages.noMatchingRelationship(address.toString());
|
|
6413
6391
|
}
|
|
6414
6392
|
return await this.getMessagesByRelationshipId(relationship.id);
|
|
6415
6393
|
}
|
|
@@ -6449,7 +6427,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6449
6427
|
async updateCacheOfExistingMessageInDb(id, response) {
|
|
6450
6428
|
const messageDoc = await this.messages.read(id);
|
|
6451
6429
|
if (!messageDoc) {
|
|
6452
|
-
throw core_1.
|
|
6430
|
+
throw core_1.CoreErrors.general.recordNotFound(Message_1.Message, id);
|
|
6453
6431
|
}
|
|
6454
6432
|
const message = Message_1.Message.from(messageDoc);
|
|
6455
6433
|
await this.updateCacheOfMessage(message, response);
|
|
@@ -6471,7 +6449,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6471
6449
|
const envelope = this.getEnvelopeFromBackboneGetMessagesResponse(response);
|
|
6472
6450
|
const [cachedMessage, messageKey, relationship] = await this.decryptMessage(envelope);
|
|
6473
6451
|
if (!relationship) {
|
|
6474
|
-
throw core_1.
|
|
6452
|
+
throw core_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, envelope.id.toString());
|
|
6475
6453
|
}
|
|
6476
6454
|
const message = Message_1.Message.from({
|
|
6477
6455
|
id: envelope.id,
|
|
@@ -6509,7 +6487,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6509
6487
|
const id = idOrMessage instanceof core_1.CoreId ? idOrMessage.toString() : idOrMessage.id.toString();
|
|
6510
6488
|
const messageDoc = await this.messages.read(id);
|
|
6511
6489
|
if (!messageDoc) {
|
|
6512
|
-
throw core_1.
|
|
6490
|
+
throw core_1.CoreErrors.general.recordNotFound(Message_1.Message, id.toString());
|
|
6513
6491
|
}
|
|
6514
6492
|
const message = Message_1.Message.from(messageDoc);
|
|
6515
6493
|
message.setMetadata(metadata);
|
|
@@ -6527,7 +6505,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6527
6505
|
for (const recipient of parameters.recipients) {
|
|
6528
6506
|
const relationship = await this.relationships.getActiveRelationshipToIdentity(core_1.CoreAddress.from(recipient));
|
|
6529
6507
|
if (!relationship) {
|
|
6530
|
-
throw core_1.
|
|
6508
|
+
throw core_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString());
|
|
6531
6509
|
}
|
|
6532
6510
|
const cipherForRecipient = await this.secrets.encrypt(relationship.relationshipSecretId, serializedSecret);
|
|
6533
6511
|
envelopeRecipients.push(MessageEnvelopeRecipient_1.MessageEnvelopeRecipient.from({
|
|
@@ -6543,7 +6521,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6543
6521
|
fileReferences.push(file.toFileReference());
|
|
6544
6522
|
publicAttachmentArray.push(file.id);
|
|
6545
6523
|
}
|
|
6546
|
-
const plaintext =
|
|
6524
|
+
const plaintext = MessageContentWrapper_1.MessageContentWrapper.from({
|
|
6547
6525
|
content: parameters.content,
|
|
6548
6526
|
recipients: addressArray,
|
|
6549
6527
|
createdAt: core_1.CoreDate.utc(),
|
|
@@ -6556,7 +6534,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6556
6534
|
for (const recipient of parameters.recipients) {
|
|
6557
6535
|
const relationship = await this.relationships.getActiveRelationshipToIdentity(core_1.CoreAddress.from(recipient));
|
|
6558
6536
|
if (!relationship) {
|
|
6559
|
-
throw core_1.
|
|
6537
|
+
throw core_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString());
|
|
6560
6538
|
}
|
|
6561
6539
|
const signature = await this.secrets.sign(relationship.relationshipSecretId, plaintextBuffer);
|
|
6562
6540
|
const messageSignature = MessageSignature_1.MessageSignature.from({
|
|
@@ -6613,14 +6591,14 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6613
6591
|
this.log.trace(`Decrypting own envelope with id ${envelope.id.toString()}...`);
|
|
6614
6592
|
const plaintextMessageBuffer = await core_1.CoreCrypto.decrypt(envelope.cipher, secretKey);
|
|
6615
6593
|
const signedMessage = MessageSigned_1.MessageSigned.deserialize(plaintextMessageBuffer.toUtf8());
|
|
6616
|
-
const messagePlain =
|
|
6594
|
+
const messagePlain = MessageContentWrapper_1.MessageContentWrapper.from(JSON.parse(signedMessage.message));
|
|
6617
6595
|
return messagePlain;
|
|
6618
6596
|
}
|
|
6619
6597
|
async decryptPeerEnvelope(envelope, relationship) {
|
|
6620
6598
|
var _a, _b;
|
|
6621
6599
|
const ownKeyCipher = (_a = envelope.recipients.find((r) => this.parent.identity.isMe(r.address))) === null || _a === void 0 ? void 0 : _a.encryptedKey;
|
|
6622
6600
|
if (!ownKeyCipher) {
|
|
6623
|
-
throw core_1.
|
|
6601
|
+
throw core_1.CoreErrors.messages.ownAddressNotInList(envelope.id.toString());
|
|
6624
6602
|
}
|
|
6625
6603
|
const plaintextKeyBuffer = await this.secrets.decryptPeer(relationship.relationshipSecretId, ownKeyCipher, true);
|
|
6626
6604
|
const plaintextKey = crypto_1.CryptoSecretKey.deserialize(plaintextKeyBuffer.toUtf8());
|
|
@@ -6628,16 +6606,16 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6628
6606
|
const signedMessage = MessageSigned_1.MessageSigned.deserialize(plaintextMessageBuffer.toUtf8());
|
|
6629
6607
|
const signature = (_b = signedMessage.signatures.find((s) => this.parent.identity.isMe(s.recipient))) === null || _b === void 0 ? void 0 : _b.signature;
|
|
6630
6608
|
if (!signature) {
|
|
6631
|
-
throw core_1.
|
|
6609
|
+
throw core_1.CoreErrors.messages.signatureListMismatch(envelope.id.toString());
|
|
6632
6610
|
}
|
|
6633
|
-
const messagePlain =
|
|
6611
|
+
const messagePlain = MessageContentWrapper_1.MessageContentWrapper.from(JSON.parse(signedMessage.message));
|
|
6634
6612
|
if (signedMessage.signatures.length !== messagePlain.recipients.length) {
|
|
6635
6613
|
this.log.debug(`Number of signatures does not match number of recipients from envelope ${envelope.id}.`);
|
|
6636
6614
|
}
|
|
6637
6615
|
const plainMessageBuffer = crypto_1.CoreBuffer.fromUtf8(signedMessage.message);
|
|
6638
6616
|
const validSignature = await this.secrets.verifyPeer(relationship.relationshipSecretId, plainMessageBuffer, signature);
|
|
6639
6617
|
if (!validSignature) {
|
|
6640
|
-
throw core_1.
|
|
6618
|
+
throw core_1.CoreErrors.messages.signatureNotValid();
|
|
6641
6619
|
}
|
|
6642
6620
|
if (messagePlain.recipients.length !== envelope.recipients.length) {
|
|
6643
6621
|
this.log.debug(`Number of signed recipients within the message does not match number of recipients from envelope ${envelope.id}.`);
|
|
@@ -6647,7 +6625,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6647
6625
|
}
|
|
6648
6626
|
const recipientFound = messagePlain.recipients.some((r) => this.parent.identity.isMe(r));
|
|
6649
6627
|
if (!recipientFound) {
|
|
6650
|
-
throw core_1.
|
|
6628
|
+
throw core_1.CoreErrors.messages.plaintextMismatch(envelope.id.toString());
|
|
6651
6629
|
}
|
|
6652
6630
|
return [messagePlain, plaintextKey];
|
|
6653
6631
|
}
|
|
@@ -6658,7 +6636,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6658
6636
|
let relationship;
|
|
6659
6637
|
if (this.parent.identity.isMe(envelope.createdBy)) {
|
|
6660
6638
|
if (!secretKey) {
|
|
6661
|
-
throw new
|
|
6639
|
+
throw new core_1.TransportError(`The own message (${envelope.id.toString()}) could not be decrypted, because no secret key was passed for it.`);
|
|
6662
6640
|
}
|
|
6663
6641
|
messageKey = secretKey;
|
|
6664
6642
|
plainMessage = await this.decryptOwnEnvelope(envelope, secretKey);
|
|
@@ -6666,7 +6644,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6666
6644
|
else {
|
|
6667
6645
|
relationship = await this.relationships.getActiveRelationshipToIdentity(envelope.createdBy);
|
|
6668
6646
|
if (!relationship) {
|
|
6669
|
-
throw core_1.
|
|
6647
|
+
throw core_1.CoreErrors.messages.noMatchingRelationship(envelope.createdBy.toString());
|
|
6670
6648
|
}
|
|
6671
6649
|
const [peerMessage, peerKey] = await this.decryptPeerEnvelope(envelope, relationship);
|
|
6672
6650
|
plainMessage = peerMessage;
|
|
@@ -7023,6 +7001,83 @@ exports.SendMessageParameters = SendMessageParameters;
|
|
|
7023
7001
|
|
|
7024
7002
|
/***/ }),
|
|
7025
7003
|
|
|
7004
|
+
/***/ "./dist/modules/messages/transmission/MessageContentWrapper.js":
|
|
7005
|
+
/*!*********************************************************************!*\
|
|
7006
|
+
!*** ./dist/modules/messages/transmission/MessageContentWrapper.js ***!
|
|
7007
|
+
\*********************************************************************/
|
|
7008
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7009
|
+
|
|
7010
|
+
"use strict";
|
|
7011
|
+
|
|
7012
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7013
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7014
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7015
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7016
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7017
|
+
};
|
|
7018
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
7019
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7020
|
+
};
|
|
7021
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7022
|
+
exports.MessageContentWrapper = void 0;
|
|
7023
|
+
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
7024
|
+
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
7025
|
+
const CoreAddress_1 = __webpack_require__(/*! ../../../core/types/CoreAddress */ "./dist/core/types/CoreAddress.js");
|
|
7026
|
+
const CoreDate_1 = __webpack_require__(/*! ../../../core/types/CoreDate */ "./dist/core/types/CoreDate.js");
|
|
7027
|
+
const FileReference_1 = __webpack_require__(/*! ../../files/transmission/FileReference */ "./dist/modules/files/transmission/FileReference.js");
|
|
7028
|
+
/**
|
|
7029
|
+
* MessageContentWrapper is a container for the actual message as [[IMessage]], its creationDate and
|
|
7030
|
+
* the list of recipients as [[IAddress]]. This container instance is then digitally signed
|
|
7031
|
+
* by the sender via an [[MessageSigned]] object.
|
|
7032
|
+
*
|
|
7033
|
+
* Insofar, the sender digitally signs the date of creation of this message (which could act as a
|
|
7034
|
+
* legal proof). Additionally, all recipients can - and must - check if they are addressed by
|
|
7035
|
+
* the sender. If a recipient is not in the signed list of recipients, the message needs to be
|
|
7036
|
+
* ignored (as the whole message could have been forwarded by bad party to a wrong recipient).
|
|
7037
|
+
*/
|
|
7038
|
+
let MessageContentWrapper = class MessageContentWrapper extends core_1.CoreSerializable {
|
|
7039
|
+
constructor() {
|
|
7040
|
+
super(...arguments);
|
|
7041
|
+
this.attachments = [];
|
|
7042
|
+
}
|
|
7043
|
+
static preFrom(value) {
|
|
7044
|
+
if (typeof value.attachments === "undefined") {
|
|
7045
|
+
value.attachments = [];
|
|
7046
|
+
}
|
|
7047
|
+
return value;
|
|
7048
|
+
}
|
|
7049
|
+
static from(value) {
|
|
7050
|
+
return this.fromAny(value);
|
|
7051
|
+
}
|
|
7052
|
+
};
|
|
7053
|
+
__decorate([
|
|
7054
|
+
(0, ts_serval_1.validate)(),
|
|
7055
|
+
(0, ts_serval_1.serialize)({ type: FileReference_1.FileReference }),
|
|
7056
|
+
__metadata("design:type", Array)
|
|
7057
|
+
], MessageContentWrapper.prototype, "attachments", void 0);
|
|
7058
|
+
__decorate([
|
|
7059
|
+
(0, ts_serval_1.validate)(),
|
|
7060
|
+
(0, ts_serval_1.serialize)(),
|
|
7061
|
+
__metadata("design:type", ts_serval_1.Serializable)
|
|
7062
|
+
], MessageContentWrapper.prototype, "content", void 0);
|
|
7063
|
+
__decorate([
|
|
7064
|
+
(0, ts_serval_1.validate)(),
|
|
7065
|
+
(0, ts_serval_1.serialize)(),
|
|
7066
|
+
__metadata("design:type", CoreDate_1.CoreDate)
|
|
7067
|
+
], MessageContentWrapper.prototype, "createdAt", void 0);
|
|
7068
|
+
__decorate([
|
|
7069
|
+
(0, ts_serval_1.validate)(),
|
|
7070
|
+
(0, ts_serval_1.serialize)({ type: CoreAddress_1.CoreAddress }),
|
|
7071
|
+
__metadata("design:type", Array)
|
|
7072
|
+
], MessageContentWrapper.prototype, "recipients", void 0);
|
|
7073
|
+
MessageContentWrapper = __decorate([
|
|
7074
|
+
(0, ts_serval_1.type)("MessageContentWrapper")
|
|
7075
|
+
], MessageContentWrapper);
|
|
7076
|
+
exports.MessageContentWrapper = MessageContentWrapper;
|
|
7077
|
+
//# sourceMappingURL=MessageContentWrapper.js.map
|
|
7078
|
+
|
|
7079
|
+
/***/ }),
|
|
7080
|
+
|
|
7026
7081
|
/***/ "./dist/modules/messages/transmission/MessageEnvelope.js":
|
|
7027
7082
|
/*!***************************************************************!*\
|
|
7028
7083
|
!*** ./dist/modules/messages/transmission/MessageEnvelope.js ***!
|
|
@@ -7169,83 +7224,6 @@ exports.MessageEnvelopeRecipient = MessageEnvelopeRecipient;
|
|
|
7169
7224
|
|
|
7170
7225
|
/***/ }),
|
|
7171
7226
|
|
|
7172
|
-
/***/ "./dist/modules/messages/transmission/MessagePlain.js":
|
|
7173
|
-
/*!************************************************************!*\
|
|
7174
|
-
!*** ./dist/modules/messages/transmission/MessagePlain.js ***!
|
|
7175
|
-
\************************************************************/
|
|
7176
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7177
|
-
|
|
7178
|
-
"use strict";
|
|
7179
|
-
|
|
7180
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7181
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7182
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7183
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7184
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7185
|
-
};
|
|
7186
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
7187
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7188
|
-
};
|
|
7189
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7190
|
-
exports.MessagePlain = void 0;
|
|
7191
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
7192
|
-
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
7193
|
-
const CoreAddress_1 = __webpack_require__(/*! ../../../core/types/CoreAddress */ "./dist/core/types/CoreAddress.js");
|
|
7194
|
-
const CoreDate_1 = __webpack_require__(/*! ../../../core/types/CoreDate */ "./dist/core/types/CoreDate.js");
|
|
7195
|
-
const FileReference_1 = __webpack_require__(/*! ../../files/transmission/FileReference */ "./dist/modules/files/transmission/FileReference.js");
|
|
7196
|
-
/**
|
|
7197
|
-
* MessagePlain is a container for the actual message as [[IMessage]], its creationDate and
|
|
7198
|
-
* the list of recipients as [[IAddress]]. This container instance is then digitally signed
|
|
7199
|
-
* by the sender via an [[MessageSigned]] object.
|
|
7200
|
-
*
|
|
7201
|
-
* Insofar, the sender digitally signs the date of creation of this message (which could act as a
|
|
7202
|
-
* legal proof). Additionally, all recipients can - and must - check if they are addressed by
|
|
7203
|
-
* the sender. If a recipient is not in the signed list of recipients, the message needs to be
|
|
7204
|
-
* ignored (as the whole message could have been forwarded by bad party to a wrong recipient).
|
|
7205
|
-
*/
|
|
7206
|
-
let MessagePlain = class MessagePlain extends core_1.CoreSerializable {
|
|
7207
|
-
constructor() {
|
|
7208
|
-
super(...arguments);
|
|
7209
|
-
this.attachments = [];
|
|
7210
|
-
}
|
|
7211
|
-
static preFrom(value) {
|
|
7212
|
-
if (typeof value.attachments === "undefined") {
|
|
7213
|
-
value.attachments = [];
|
|
7214
|
-
}
|
|
7215
|
-
return value;
|
|
7216
|
-
}
|
|
7217
|
-
static from(value) {
|
|
7218
|
-
return this.fromAny(value);
|
|
7219
|
-
}
|
|
7220
|
-
};
|
|
7221
|
-
__decorate([
|
|
7222
|
-
(0, ts_serval_1.validate)(),
|
|
7223
|
-
(0, ts_serval_1.serialize)({ type: FileReference_1.FileReference }),
|
|
7224
|
-
__metadata("design:type", Array)
|
|
7225
|
-
], MessagePlain.prototype, "attachments", void 0);
|
|
7226
|
-
__decorate([
|
|
7227
|
-
(0, ts_serval_1.validate)(),
|
|
7228
|
-
(0, ts_serval_1.serialize)(),
|
|
7229
|
-
__metadata("design:type", ts_serval_1.Serializable)
|
|
7230
|
-
], MessagePlain.prototype, "content", void 0);
|
|
7231
|
-
__decorate([
|
|
7232
|
-
(0, ts_serval_1.validate)(),
|
|
7233
|
-
(0, ts_serval_1.serialize)(),
|
|
7234
|
-
__metadata("design:type", CoreDate_1.CoreDate)
|
|
7235
|
-
], MessagePlain.prototype, "createdAt", void 0);
|
|
7236
|
-
__decorate([
|
|
7237
|
-
(0, ts_serval_1.validate)(),
|
|
7238
|
-
(0, ts_serval_1.serialize)({ type: CoreAddress_1.CoreAddress }),
|
|
7239
|
-
__metadata("design:type", Array)
|
|
7240
|
-
], MessagePlain.prototype, "recipients", void 0);
|
|
7241
|
-
MessagePlain = __decorate([
|
|
7242
|
-
(0, ts_serval_1.type)("MessagePlain")
|
|
7243
|
-
], MessagePlain);
|
|
7244
|
-
exports.MessagePlain = MessagePlain;
|
|
7245
|
-
//# sourceMappingURL=MessagePlain.js.map
|
|
7246
|
-
|
|
7247
|
-
/***/ }),
|
|
7248
|
-
|
|
7249
7227
|
/***/ "./dist/modules/messages/transmission/MessageSignature.js":
|
|
7250
7228
|
/*!****************************************************************!*\
|
|
7251
7229
|
!*** ./dist/modules/messages/transmission/MessageSignature.js ***!
|
|
@@ -7368,7 +7346,7 @@ const RelationshipTemplateClient_1 = __webpack_require__(/*! ./backbone/Relation
|
|
|
7368
7346
|
const CachedRelationshipTemplate_1 = __webpack_require__(/*! ./local/CachedRelationshipTemplate */ "./dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js");
|
|
7369
7347
|
const RelationshipTemplate_1 = __webpack_require__(/*! ./local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js");
|
|
7370
7348
|
const SendRelationshipTemplateParameters_1 = __webpack_require__(/*! ./local/SendRelationshipTemplateParameters */ "./dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js");
|
|
7371
|
-
const
|
|
7349
|
+
const RelationshipTemplateContentWrapper_1 = __webpack_require__(/*! ./transmission/RelationshipTemplateContentWrapper */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js");
|
|
7372
7350
|
const RelationshipTemplateReference_1 = __webpack_require__(/*! ./transmission/RelationshipTemplateReference */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.js");
|
|
7373
7351
|
const RelationshipTemplateSigned_1 = __webpack_require__(/*! ./transmission/RelationshipTemplateSigned */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateSigned.js");
|
|
7374
7352
|
class RelationshipTemplateController extends TransportController_1.TransportController {
|
|
@@ -7384,11 +7362,8 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7384
7362
|
}
|
|
7385
7363
|
async sendRelationshipTemplate(parameters) {
|
|
7386
7364
|
parameters = SendRelationshipTemplateParameters_1.SendRelationshipTemplateParameters.from(parameters);
|
|
7387
|
-
if (parameters.maxNumberOfRelationships) {
|
|
7388
|
-
this.log.warn("`maxNumberOfRelationships` is deprecated and will be removed in the future. Please use `maxNumberOfAllocations` instead.");
|
|
7389
|
-
}
|
|
7390
7365
|
const templateKey = await this.secrets.createTemplateKey();
|
|
7391
|
-
const templateContent =
|
|
7366
|
+
const templateContent = RelationshipTemplateContentWrapper_1.RelationshipTemplateContentWrapper.from({
|
|
7392
7367
|
content: parameters.content,
|
|
7393
7368
|
identity: this.parent.identity.identity,
|
|
7394
7369
|
templateKey: templateKey
|
|
@@ -7406,7 +7381,6 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7406
7381
|
const backboneResponse = (await this.client.createRelationshipTemplate({
|
|
7407
7382
|
expiresAt: parameters.expiresAt.toString(),
|
|
7408
7383
|
maxNumberOfAllocations: parameters.maxNumberOfAllocations,
|
|
7409
|
-
maxNumberOfRelationships: parameters.maxNumberOfRelationships,
|
|
7410
7384
|
content: cipher.toBase64()
|
|
7411
7385
|
})).value;
|
|
7412
7386
|
const templateCache = CachedRelationshipTemplate_1.CachedRelationshipTemplate.from({
|
|
@@ -7417,7 +7391,6 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7417
7391
|
expiresAt: parameters.expiresAt,
|
|
7418
7392
|
identity: this.parent.identity.identity,
|
|
7419
7393
|
maxNumberOfAllocations: parameters.maxNumberOfAllocations,
|
|
7420
|
-
maxNumberOfRelationships: parameters.maxNumberOfRelationships,
|
|
7421
7394
|
templateKey: templateKey
|
|
7422
7395
|
});
|
|
7423
7396
|
const template = RelationshipTemplate_1.RelationshipTemplate.from({
|
|
@@ -7442,7 +7415,6 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7442
7415
|
if (ids.length < 1) {
|
|
7443
7416
|
return [];
|
|
7444
7417
|
}
|
|
7445
|
-
// TODO: JSSNMSHDD-2820 (check for items that couldn't be fetched e.g. because it is expired)
|
|
7446
7418
|
const resultItems = (await this.client.getRelationshipTemplates({ ids })).value;
|
|
7447
7419
|
const promises = [];
|
|
7448
7420
|
for await (const resultItem of resultItems) {
|
|
@@ -7464,7 +7436,7 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7464
7436
|
async updateCacheOfExistingTemplateInDb(id, response) {
|
|
7465
7437
|
const templateDoc = await this.templates.read(id);
|
|
7466
7438
|
if (!templateDoc) {
|
|
7467
|
-
throw core_1.
|
|
7439
|
+
throw core_1.CoreErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id);
|
|
7468
7440
|
}
|
|
7469
7441
|
const template = RelationshipTemplate_1.RelationshipTemplate.from(templateDoc);
|
|
7470
7442
|
await this.updateCacheOfTemplate(template, response);
|
|
@@ -7481,14 +7453,14 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7481
7453
|
template.isOwn = this.parent.identity.isMe(cachedTemplate.createdBy);
|
|
7482
7454
|
}
|
|
7483
7455
|
async decryptRelationshipTemplate(response, secretKey) {
|
|
7484
|
-
var _a
|
|
7456
|
+
var _a;
|
|
7485
7457
|
const cipher = crypto_1.CryptoCipher.fromBase64(response.content);
|
|
7486
7458
|
const signedTemplateBuffer = await this.secrets.decryptTemplate(cipher, secretKey);
|
|
7487
7459
|
const signedTemplate = RelationshipTemplateSigned_1.RelationshipTemplateSigned.deserialize(signedTemplateBuffer.toUtf8());
|
|
7488
|
-
const templateContent =
|
|
7460
|
+
const templateContent = RelationshipTemplateContentWrapper_1.RelationshipTemplateContentWrapper.deserialize(signedTemplate.serializedTemplate);
|
|
7489
7461
|
const templateSignatureValid = await this.secrets.verifyTemplate(crypto_1.CoreBuffer.fromUtf8(signedTemplate.serializedTemplate), signedTemplate.deviceSignature, templateContent.identity.publicKey);
|
|
7490
7462
|
if (!templateSignatureValid) {
|
|
7491
|
-
throw core_1.
|
|
7463
|
+
throw core_1.CoreErrors.general.signatureNotValid("template");
|
|
7492
7464
|
}
|
|
7493
7465
|
const cachedTemplate = CachedRelationshipTemplate_1.CachedRelationshipTemplate.from({
|
|
7494
7466
|
content: templateContent.content,
|
|
@@ -7498,7 +7470,6 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7498
7470
|
expiresAt: response.expiresAt ? core_1.CoreDate.from(response.expiresAt) : undefined,
|
|
7499
7471
|
identity: templateContent.identity,
|
|
7500
7472
|
maxNumberOfAllocations: (_a = response.maxNumberOfAllocations) !== null && _a !== void 0 ? _a : undefined,
|
|
7501
|
-
maxNumberOfRelationships: (_b = response.maxNumberOfRelationships) !== null && _b !== void 0 ? _b : undefined,
|
|
7502
7473
|
templateKey: templateContent.templateKey
|
|
7503
7474
|
});
|
|
7504
7475
|
return cachedTemplate;
|
|
@@ -7514,7 +7485,7 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7514
7485
|
const id = idOrTemplate instanceof core_1.CoreId ? idOrTemplate.toString() : idOrTemplate.id.toString();
|
|
7515
7486
|
const templateDoc = await this.templates.read(id);
|
|
7516
7487
|
if (!templateDoc) {
|
|
7517
|
-
throw core_1.
|
|
7488
|
+
throw core_1.CoreErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id.toString());
|
|
7518
7489
|
}
|
|
7519
7490
|
const template = RelationshipTemplate_1.RelationshipTemplate.from(templateDoc);
|
|
7520
7491
|
template.setMetadata(metadata);
|
|
@@ -7643,7 +7614,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
7643
7614
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7644
7615
|
};
|
|
7645
7616
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7646
|
-
exports.validateMaxNumberOfAllocations = exports.
|
|
7617
|
+
exports.validateMaxNumberOfAllocations = exports.CachedRelationshipTemplate = void 0;
|
|
7647
7618
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
7648
7619
|
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
7649
7620
|
const CoreId_1 = __webpack_require__(/*! ../../../core/types/CoreId */ "./dist/core/types/CoreId.js");
|
|
@@ -7694,24 +7665,10 @@ __decorate([
|
|
|
7694
7665
|
(0, ts_serval_1.serialize)(),
|
|
7695
7666
|
__metadata("design:type", Number)
|
|
7696
7667
|
], CachedRelationshipTemplate.prototype, "maxNumberOfAllocations", void 0);
|
|
7697
|
-
__decorate([
|
|
7698
|
-
(0, ts_serval_1.validate)({ nullable: true, customValidator: validateMaxNumberOfRelationships }),
|
|
7699
|
-
(0, ts_serval_1.serialize)(),
|
|
7700
|
-
__metadata("design:type", Number)
|
|
7701
|
-
], CachedRelationshipTemplate.prototype, "maxNumberOfRelationships", void 0);
|
|
7702
7668
|
CachedRelationshipTemplate = __decorate([
|
|
7703
7669
|
(0, ts_serval_1.type)("CachedRelationshipTemplate")
|
|
7704
7670
|
], CachedRelationshipTemplate);
|
|
7705
7671
|
exports.CachedRelationshipTemplate = CachedRelationshipTemplate;
|
|
7706
|
-
function validateMaxNumberOfRelationships(value) {
|
|
7707
|
-
if (value === undefined)
|
|
7708
|
-
return;
|
|
7709
|
-
if (value <= 0) {
|
|
7710
|
-
return "maxNumberOfRelationships must be greater than 0";
|
|
7711
|
-
}
|
|
7712
|
-
return;
|
|
7713
|
-
}
|
|
7714
|
-
exports.validateMaxNumberOfRelationships = validateMaxNumberOfRelationships;
|
|
7715
7672
|
function validateMaxNumberOfAllocations(value) {
|
|
7716
7673
|
if (value === undefined)
|
|
7717
7674
|
return;
|
|
@@ -7841,22 +7798,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7841
7798
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
7842
7799
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7843
7800
|
};
|
|
7844
|
-
var SendRelationshipTemplateParameters_1;
|
|
7845
7801
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7846
7802
|
exports.SendRelationshipTemplateParameters = void 0;
|
|
7847
7803
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
7848
|
-
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
7849
7804
|
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
7850
7805
|
const CachedRelationshipTemplate_1 = __webpack_require__(/*! ./CachedRelationshipTemplate */ "./dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js");
|
|
7851
|
-
let SendRelationshipTemplateParameters =
|
|
7852
|
-
static postFrom(value) {
|
|
7853
|
-
if (!(value instanceof SendRelationshipTemplateParameters_1))
|
|
7854
|
-
throw new Error("this should never happen");
|
|
7855
|
-
if (value.maxNumberOfAllocations && value.maxNumberOfRelationships) {
|
|
7856
|
-
throw new ts_serval_1.ValidationError(SendRelationshipTemplateParameters_1.name, (0, ts_simple_nameof_1.nameof)((x) => x.maxNumberOfAllocations), `You cannot specify both ${(0, ts_simple_nameof_1.nameof)((x) => x.maxNumberOfAllocations)} and ${(0, ts_simple_nameof_1.nameof)((x) => x.maxNumberOfRelationships)}.`);
|
|
7857
|
-
}
|
|
7858
|
-
return value;
|
|
7859
|
-
}
|
|
7806
|
+
let SendRelationshipTemplateParameters = class SendRelationshipTemplateParameters extends core_1.CoreSerializable {
|
|
7860
7807
|
static from(value) {
|
|
7861
7808
|
return this.fromAny(value);
|
|
7862
7809
|
}
|
|
@@ -7876,12 +7823,7 @@ __decorate([
|
|
|
7876
7823
|
(0, ts_serval_1.serialize)(),
|
|
7877
7824
|
__metadata("design:type", Number)
|
|
7878
7825
|
], SendRelationshipTemplateParameters.prototype, "maxNumberOfAllocations", void 0);
|
|
7879
|
-
__decorate([
|
|
7880
|
-
(0, ts_serval_1.validate)({ nullable: true, customValidator: CachedRelationshipTemplate_1.validateMaxNumberOfRelationships }),
|
|
7881
|
-
(0, ts_serval_1.serialize)(),
|
|
7882
|
-
__metadata("design:type", Number)
|
|
7883
|
-
], SendRelationshipTemplateParameters.prototype, "maxNumberOfRelationships", void 0);
|
|
7884
|
-
SendRelationshipTemplateParameters = SendRelationshipTemplateParameters_1 = __decorate([
|
|
7826
|
+
SendRelationshipTemplateParameters = __decorate([
|
|
7885
7827
|
(0, ts_serval_1.type)("SendRelationshipTemplateParameters")
|
|
7886
7828
|
], SendRelationshipTemplateParameters);
|
|
7887
7829
|
exports.SendRelationshipTemplateParameters = SendRelationshipTemplateParameters;
|
|
@@ -7889,10 +7831,10 @@ exports.SendRelationshipTemplateParameters = SendRelationshipTemplateParameters;
|
|
|
7889
7831
|
|
|
7890
7832
|
/***/ }),
|
|
7891
7833
|
|
|
7892
|
-
/***/ "./dist/modules/relationshipTemplates/transmission/
|
|
7893
|
-
|
|
7894
|
-
!*** ./dist/modules/relationshipTemplates/transmission/
|
|
7895
|
-
|
|
7834
|
+
/***/ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js":
|
|
7835
|
+
/*!***********************************************************************************************!*\
|
|
7836
|
+
!*** ./dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js ***!
|
|
7837
|
+
\***********************************************************************************************/
|
|
7896
7838
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7897
7839
|
|
|
7898
7840
|
"use strict";
|
|
@@ -7907,12 +7849,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
7907
7849
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7908
7850
|
};
|
|
7909
7851
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7910
|
-
exports.
|
|
7852
|
+
exports.RelationshipTemplateContentWrapper = void 0;
|
|
7911
7853
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
7912
7854
|
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
7913
7855
|
const Identity_1 = __webpack_require__(/*! ../../accounts/data/Identity */ "./dist/modules/accounts/data/Identity.js");
|
|
7914
7856
|
const RelationshipTemplatePublicKey_1 = __webpack_require__(/*! ./RelationshipTemplatePublicKey */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.js");
|
|
7915
|
-
let
|
|
7857
|
+
let RelationshipTemplateContentWrapper = class RelationshipTemplateContentWrapper extends core_1.CoreSerializable {
|
|
7916
7858
|
static from(value) {
|
|
7917
7859
|
return this.fromAny(value);
|
|
7918
7860
|
}
|
|
@@ -7921,22 +7863,22 @@ __decorate([
|
|
|
7921
7863
|
(0, ts_serval_1.validate)(),
|
|
7922
7864
|
(0, ts_serval_1.serialize)(),
|
|
7923
7865
|
__metadata("design:type", Identity_1.Identity)
|
|
7924
|
-
],
|
|
7866
|
+
], RelationshipTemplateContentWrapper.prototype, "identity", void 0);
|
|
7925
7867
|
__decorate([
|
|
7926
7868
|
(0, ts_serval_1.validate)(),
|
|
7927
7869
|
(0, ts_serval_1.serialize)(),
|
|
7928
7870
|
__metadata("design:type", RelationshipTemplatePublicKey_1.RelationshipTemplatePublicKey)
|
|
7929
|
-
],
|
|
7871
|
+
], RelationshipTemplateContentWrapper.prototype, "templateKey", void 0);
|
|
7930
7872
|
__decorate([
|
|
7931
7873
|
(0, ts_serval_1.validate)(),
|
|
7932
7874
|
(0, ts_serval_1.serialize)(),
|
|
7933
7875
|
__metadata("design:type", ts_serval_1.Serializable)
|
|
7934
|
-
],
|
|
7935
|
-
|
|
7936
|
-
(0, ts_serval_1.type)("
|
|
7937
|
-
],
|
|
7938
|
-
exports.
|
|
7939
|
-
//# sourceMappingURL=
|
|
7876
|
+
], RelationshipTemplateContentWrapper.prototype, "content", void 0);
|
|
7877
|
+
RelationshipTemplateContentWrapper = __decorate([
|
|
7878
|
+
(0, ts_serval_1.type)("RelationshipTemplateContentWrapper")
|
|
7879
|
+
], RelationshipTemplateContentWrapper);
|
|
7880
|
+
exports.RelationshipTemplateContentWrapper = RelationshipTemplateContentWrapper;
|
|
7881
|
+
//# sourceMappingURL=RelationshipTemplateContentWrapper.js.map
|
|
7940
7882
|
|
|
7941
7883
|
/***/ }),
|
|
7942
7884
|
|
|
@@ -8104,8 +8046,8 @@ exports.RelationshipSecretController = void 0;
|
|
|
8104
8046
|
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
8105
8047
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
8106
8048
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
8049
|
+
const CoreErrors_1 = __webpack_require__(/*! ../../core/CoreErrors */ "./dist/core/CoreErrors.js");
|
|
8107
8050
|
const CoreUtil_1 = __webpack_require__(/*! ../../core/CoreUtil */ "./dist/core/CoreUtil.js");
|
|
8108
|
-
const TransportErrors_1 = __webpack_require__(/*! ../../core/TransportErrors */ "./dist/core/TransportErrors.js");
|
|
8109
8051
|
const TransportIds_1 = __webpack_require__(/*! ../../core/TransportIds */ "./dist/core/TransportIds.js");
|
|
8110
8052
|
const CachedRelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/CachedRelationshipTemplate */ "./dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js");
|
|
8111
8053
|
const RelationshipTemplatePublicKey_1 = __webpack_require__(/*! ../relationshipTemplates/transmission/RelationshipTemplatePublicKey */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.js");
|
|
@@ -8123,11 +8065,11 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8123
8065
|
}
|
|
8124
8066
|
const secretContainer = await this.loadActiveSecretByName(secretIdAsString);
|
|
8125
8067
|
if (!secretContainer) {
|
|
8126
|
-
throw
|
|
8068
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound("CryptoRelationshipRequestSecrets | CryptoRelationshipSecrets", secretIdAsString);
|
|
8127
8069
|
}
|
|
8128
8070
|
if (!(secretContainer.secret instanceof crypto_1.CryptoRelationshipRequestSecrets) &&
|
|
8129
8071
|
!(secretContainer.secret instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8130
|
-
throw
|
|
8072
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secretIdAsString);
|
|
8131
8073
|
}
|
|
8132
8074
|
const secret = secretContainer.secret;
|
|
8133
8075
|
this.cache.set(relationshipSecretId, secret);
|
|
@@ -8143,10 +8085,10 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8143
8085
|
const templateKeyId = template.templateKey.id.toString();
|
|
8144
8086
|
const exchangeKeypairContainer = await this.loadActiveSecretByName(templateKeyId);
|
|
8145
8087
|
if (!exchangeKeypairContainer) {
|
|
8146
|
-
throw
|
|
8088
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(crypto_1.CryptoExchangeKeypair, templateKeyId);
|
|
8147
8089
|
}
|
|
8148
8090
|
if (!(exchangeKeypairContainer.secret instanceof crypto_1.CryptoExchangeKeypair)) {
|
|
8149
|
-
throw
|
|
8091
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(templateKeyId);
|
|
8150
8092
|
}
|
|
8151
8093
|
const exchangeKeypair = exchangeKeypairContainer.secret;
|
|
8152
8094
|
const secrets = await crypto_1.CryptoRelationshipSecrets.fromRelationshipRequest(publicRequestCrypto, exchangeKeypair);
|
|
@@ -8156,10 +8098,10 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8156
8098
|
async getPublicResponse(relationshipSecretId) {
|
|
8157
8099
|
const secret = await this.loadActiveSecretByName(relationshipSecretId.toString());
|
|
8158
8100
|
if (!secret) {
|
|
8159
|
-
throw
|
|
8101
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(crypto_1.CryptoRelationshipSecrets, relationshipSecretId.toString());
|
|
8160
8102
|
}
|
|
8161
8103
|
if (!(secret.secret instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8162
|
-
throw
|
|
8104
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secret.id.toString());
|
|
8163
8105
|
}
|
|
8164
8106
|
const publicResponse = secret.secret.toPublicResponse();
|
|
8165
8107
|
return publicResponse;
|
|
@@ -8167,7 +8109,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8167
8109
|
async convertSecrets(relationshipSecretId, response) {
|
|
8168
8110
|
const request = await this.getSecret(relationshipSecretId);
|
|
8169
8111
|
if (request instanceof crypto_1.CryptoRelationshipSecrets) {
|
|
8170
|
-
throw
|
|
8112
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType();
|
|
8171
8113
|
}
|
|
8172
8114
|
const secrets = await crypto_1.CryptoRelationshipSecrets.fromRelationshipResponse(response, request);
|
|
8173
8115
|
const container = await this.succeedSecretWithName(secrets, relationshipSecretId.toString());
|
|
@@ -8192,7 +8134,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8192
8134
|
const buffer = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
8193
8135
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8194
8136
|
if (!(secrets instanceof crypto_1.CryptoRelationshipRequestSecrets)) {
|
|
8195
|
-
throw
|
|
8137
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
8196
8138
|
}
|
|
8197
8139
|
return await secrets.encryptRequest(buffer);
|
|
8198
8140
|
}
|
|
@@ -8200,14 +8142,14 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8200
8142
|
const buffer = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
8201
8143
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8202
8144
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8203
|
-
throw
|
|
8145
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
8204
8146
|
}
|
|
8205
8147
|
return await secrets.encrypt(buffer);
|
|
8206
8148
|
}
|
|
8207
8149
|
async decryptRequest(relationshipSecretId, cipher) {
|
|
8208
8150
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8209
8151
|
if (!(secrets instanceof crypto_1.CryptoRelationshipRequestSecrets) && !(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8210
|
-
throw
|
|
8152
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(relationshipSecretId.toString());
|
|
8211
8153
|
}
|
|
8212
8154
|
return await secrets.decryptRequest(cipher);
|
|
8213
8155
|
}
|
|
@@ -8224,7 +8166,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8224
8166
|
async decryptPeer(relationshipSecretId, cipher, omitCounterCheck = false) {
|
|
8225
8167
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8226
8168
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8227
|
-
throw
|
|
8169
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
8228
8170
|
}
|
|
8229
8171
|
return await secrets.decryptPeer(cipher, omitCounterCheck);
|
|
8230
8172
|
}
|
|
@@ -8235,7 +8177,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8235
8177
|
async decryptOwn(relationshipSecretId, cipher) {
|
|
8236
8178
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8237
8179
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8238
|
-
throw
|
|
8180
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
8239
8181
|
}
|
|
8240
8182
|
return await secrets.decryptOwn(cipher);
|
|
8241
8183
|
}
|
|
@@ -8253,7 +8195,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8253
8195
|
const bufferToVerify = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
8254
8196
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8255
8197
|
if (secrets instanceof crypto_1.CryptoRelationshipRequestSecrets) {
|
|
8256
|
-
throw
|
|
8198
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
8257
8199
|
}
|
|
8258
8200
|
const valid = await secrets.verifyPeer(bufferToVerify, signature);
|
|
8259
8201
|
return valid;
|
|
@@ -8351,9 +8293,9 @@ const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/
|
|
|
8351
8293
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
8352
8294
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
8353
8295
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
8296
|
+
const CoreErrors_1 = __webpack_require__(/*! ../../core/CoreErrors */ "./dist/core/CoreErrors.js");
|
|
8354
8297
|
const CoreUtil_1 = __webpack_require__(/*! ../../core/CoreUtil */ "./dist/core/CoreUtil.js");
|
|
8355
8298
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
8356
|
-
const TransportErrors_1 = __webpack_require__(/*! ../../core/TransportErrors */ "./dist/core/TransportErrors.js");
|
|
8357
8299
|
const TransportIds_1 = __webpack_require__(/*! ../../core/TransportIds */ "./dist/core/TransportIds.js");
|
|
8358
8300
|
const events_1 = __webpack_require__(/*! ../../events */ "./dist/events/index.js");
|
|
8359
8301
|
const RelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js");
|
|
@@ -8367,10 +8309,10 @@ const RelationshipChangeStatus_1 = __webpack_require__(/*! ./transmission/change
|
|
|
8367
8309
|
const RelationshipChangeType_1 = __webpack_require__(/*! ./transmission/changes/RelationshipChangeType */ "./dist/modules/relationships/transmission/changes/RelationshipChangeType.js");
|
|
8368
8310
|
const RelationshipStatus_1 = __webpack_require__(/*! ./transmission/RelationshipStatus */ "./dist/modules/relationships/transmission/RelationshipStatus.js");
|
|
8369
8311
|
const RelationshipCreationChangeRequestCipher_1 = __webpack_require__(/*! ./transmission/requests/RelationshipCreationChangeRequestCipher */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestCipher.js");
|
|
8370
|
-
const
|
|
8312
|
+
const RelationshipCreationChangeRequestContentWrapper_1 = __webpack_require__(/*! ./transmission/requests/RelationshipCreationChangeRequestContentWrapper */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js");
|
|
8371
8313
|
const RelationshipCreationChangeRequestSigned_1 = __webpack_require__(/*! ./transmission/requests/RelationshipCreationChangeRequestSigned */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestSigned.js");
|
|
8372
8314
|
const RelationshipCreationChangeResponseCipher_1 = __webpack_require__(/*! ./transmission/responses/RelationshipCreationChangeResponseCipher */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseCipher.js");
|
|
8373
|
-
const
|
|
8315
|
+
const RelationshipCreationChangeResponseContentWrapper_1 = __webpack_require__(/*! ./transmission/responses/RelationshipCreationChangeResponseContentWrapper */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js");
|
|
8374
8316
|
const RelationshipCreationChangeResponseSigned_1 = __webpack_require__(/*! ./transmission/responses/RelationshipCreationChangeResponseSigned */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseSigned.js");
|
|
8375
8317
|
class RelationshipsController extends core_1.TransportController {
|
|
8376
8318
|
constructor(parent, secrets) {
|
|
@@ -8415,7 +8357,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8415
8357
|
async updateCacheOfExistingRelationshipInDb(id, response) {
|
|
8416
8358
|
const relationshipDoc = await this.relationships.read(id);
|
|
8417
8359
|
if (!relationshipDoc)
|
|
8418
|
-
throw
|
|
8360
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, id);
|
|
8419
8361
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
8420
8362
|
await this.updateCacheOfRelationship(relationship, response);
|
|
8421
8363
|
await this.relationships.update(relationshipDoc, relationship);
|
|
@@ -8457,7 +8399,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8457
8399
|
parameters = SendRelationshipParameters_1.SendRelationshipParameters.from(parameters);
|
|
8458
8400
|
const template = parameters.template;
|
|
8459
8401
|
if (!template.cache) {
|
|
8460
|
-
throw
|
|
8402
|
+
throw this.newCacheEmptyError(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
8461
8403
|
}
|
|
8462
8404
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
8463
8405
|
const { requestCipher, requestContent } = await this.prepareRequest(secretId, template, parameters.content);
|
|
@@ -8474,7 +8416,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8474
8416
|
const id = idOrRelationship instanceof core_1.CoreId ? idOrRelationship.toString() : idOrRelationship.id.toString();
|
|
8475
8417
|
const relationshipDoc = await this.relationships.read(id);
|
|
8476
8418
|
if (!relationshipDoc)
|
|
8477
|
-
throw
|
|
8419
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, id.toString());
|
|
8478
8420
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
8479
8421
|
relationship.metadata = metadata;
|
|
8480
8422
|
relationship.metadataModifiedAt = core_1.CoreDate.utc();
|
|
@@ -8502,7 +8444,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8502
8444
|
this._log.trace(`Parsing relationship template ${templateId} for ${response.id}...`);
|
|
8503
8445
|
const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId);
|
|
8504
8446
|
if (!template) {
|
|
8505
|
-
throw
|
|
8447
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString());
|
|
8506
8448
|
}
|
|
8507
8449
|
this._log.trace(`Parsing relationship changes of ${response.id}...`);
|
|
8508
8450
|
const changesPromises = [];
|
|
@@ -8524,10 +8466,10 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8524
8466
|
}
|
|
8525
8467
|
async prepareRequest(relationshipSecretId, template, content) {
|
|
8526
8468
|
if (!template.cache) {
|
|
8527
|
-
throw
|
|
8469
|
+
throw this.newCacheEmptyError(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
8528
8470
|
}
|
|
8529
8471
|
const requestPublic = await this.secrets.createRequestorSecrets(template.cache, relationshipSecretId);
|
|
8530
|
-
const requestContent =
|
|
8472
|
+
const requestContent = RelationshipCreationChangeRequestContentWrapper_1.RelationshipCreationChangeRequestContentWrapper.from({
|
|
8531
8473
|
content: content,
|
|
8532
8474
|
identity: this.parent.identity.identity,
|
|
8533
8475
|
templateId: template.id
|
|
@@ -8560,9 +8502,9 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8560
8502
|
return await this.applyCreationChange(change);
|
|
8561
8503
|
case RelationshipChangeType_1.RelationshipChangeType.Termination:
|
|
8562
8504
|
case RelationshipChangeType_1.RelationshipChangeType.TerminationCancellation:
|
|
8563
|
-
throw
|
|
8505
|
+
throw CoreErrors_1.CoreErrors.general.notSupported();
|
|
8564
8506
|
default:
|
|
8565
|
-
throw
|
|
8507
|
+
throw CoreErrors_1.CoreErrors.general.incompatibleBackbone();
|
|
8566
8508
|
}
|
|
8567
8509
|
}
|
|
8568
8510
|
async applyCreationChange(change) {
|
|
@@ -8613,11 +8555,11 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8613
8555
|
relationshipSignatureValid = await this.secrets.verifyPeer(secretId, crypto_1.CoreBuffer.fromUtf8(signedRequest.serializedRequest), signedRequest.relationshipSignature);
|
|
8614
8556
|
}
|
|
8615
8557
|
if (!relationshipSignatureValid) {
|
|
8616
|
-
throw
|
|
8558
|
+
throw CoreErrors_1.CoreErrors.general.signatureNotValid("relationshipRequest");
|
|
8617
8559
|
}
|
|
8618
|
-
const requestContent =
|
|
8560
|
+
const requestContent = RelationshipCreationChangeRequestContentWrapper_1.RelationshipCreationChangeRequestContentWrapper.deserialize(signedRequest.serializedRequest);
|
|
8619
8561
|
if (!requestContent.templateId.equals(templateId)) {
|
|
8620
|
-
throw new
|
|
8562
|
+
throw new core_1.TransportError("The relationship request contains a wrong template id.");
|
|
8621
8563
|
}
|
|
8622
8564
|
return requestContent;
|
|
8623
8565
|
}
|
|
@@ -8652,11 +8594,11 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8652
8594
|
relationshipSignatureValid = await this.secrets.verifyPeer(relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
|
|
8653
8595
|
}
|
|
8654
8596
|
if (!relationshipSignatureValid) {
|
|
8655
|
-
throw
|
|
8597
|
+
throw CoreErrors_1.CoreErrors.general.signatureNotValid("relationshipResponse");
|
|
8656
8598
|
}
|
|
8657
|
-
const responseContent =
|
|
8599
|
+
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.deserialize(signedResponse.serializedResponse);
|
|
8658
8600
|
if (!responseContent.relationshipId.equals(change.relationshipId)) {
|
|
8659
|
-
throw new
|
|
8601
|
+
throw new core_1.TransportError("The relationship response contains a wrong relationship id.");
|
|
8660
8602
|
}
|
|
8661
8603
|
return responseContent;
|
|
8662
8604
|
}
|
|
@@ -8677,14 +8619,14 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8677
8619
|
const cipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.fromBase64(change.response.content);
|
|
8678
8620
|
if (change.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Revoked) {
|
|
8679
8621
|
if (!cipher.publicResponseCrypto) {
|
|
8680
|
-
throw new
|
|
8622
|
+
throw new core_1.TransportError("The response crypto is missing.");
|
|
8681
8623
|
}
|
|
8682
8624
|
await this.secrets.convertSecrets(relationship.relationshipSecretId, cipher.publicResponseCrypto);
|
|
8683
8625
|
}
|
|
8684
8626
|
const responseContent = await this.decryptCreationChangeResponse(change, relationship.relationshipSecretId);
|
|
8685
8627
|
const response = RelationshipChangeResponse_1.RelationshipChangeResponse.fromBackbone(change.response, responseContent.content);
|
|
8686
8628
|
if (!relationship.cache) {
|
|
8687
|
-
throw
|
|
8629
|
+
throw this.newCacheEmptyError(Relationship_1.Relationship, relationship.id.toString());
|
|
8688
8630
|
}
|
|
8689
8631
|
relationship.cache.changes[0].status = change.status;
|
|
8690
8632
|
switch (change.status) {
|
|
@@ -8698,7 +8640,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8698
8640
|
relationship.toRevoked(response);
|
|
8699
8641
|
break;
|
|
8700
8642
|
default:
|
|
8701
|
-
throw
|
|
8643
|
+
throw CoreErrors_1.CoreErrors.general.incompatibleBackbone();
|
|
8702
8644
|
}
|
|
8703
8645
|
await this.relationships.update(relationshipDoc, relationship);
|
|
8704
8646
|
return relationship;
|
|
@@ -8708,9 +8650,9 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8708
8650
|
const templateId = core_1.CoreId.from(backboneRelationship.relationshipTemplateId);
|
|
8709
8651
|
const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId);
|
|
8710
8652
|
if (!template)
|
|
8711
|
-
throw
|
|
8653
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString());
|
|
8712
8654
|
if (!template.cache)
|
|
8713
|
-
throw
|
|
8655
|
+
throw this.newCacheEmptyError(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
8714
8656
|
if (!change.request.content)
|
|
8715
8657
|
throw this.newEmptyOrInvalidContentError(change);
|
|
8716
8658
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
@@ -8725,21 +8667,21 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8725
8667
|
async completeChange(targetStatus, change, content) {
|
|
8726
8668
|
const relationshipDoc = await this.relationships.read(change.relationshipId.toString());
|
|
8727
8669
|
if (!relationshipDoc) {
|
|
8728
|
-
throw
|
|
8670
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, change.relationshipId.toString());
|
|
8729
8671
|
}
|
|
8730
8672
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
8731
8673
|
if (!relationship.cache) {
|
|
8732
8674
|
await this.updateCacheOfRelationship(relationship);
|
|
8733
8675
|
}
|
|
8734
8676
|
if (!relationship.cache) {
|
|
8735
|
-
throw
|
|
8677
|
+
throw this.newCacheEmptyError(Relationship_1.Relationship, relationship.id.toString());
|
|
8736
8678
|
}
|
|
8737
8679
|
const queriedChange = relationship.cache.changes.find((r) => r.id.toString() === change.id.toString());
|
|
8738
8680
|
if (!queriedChange) {
|
|
8739
|
-
throw
|
|
8681
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(RelationshipChange_1.RelationshipChange, change.id.toString());
|
|
8740
8682
|
}
|
|
8741
8683
|
if (queriedChange.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Pending) {
|
|
8742
|
-
throw
|
|
8684
|
+
throw CoreErrors_1.CoreErrors.relationships.wrongChangeStatus(queriedChange.status);
|
|
8743
8685
|
}
|
|
8744
8686
|
let encryptedContent;
|
|
8745
8687
|
if (content) {
|
|
@@ -8760,7 +8702,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8760
8702
|
backboneResponse = (await this.client.revokeRelationshipChange(relationship.id.toString(), change.id.toString(), encryptedContent)).value;
|
|
8761
8703
|
break;
|
|
8762
8704
|
default:
|
|
8763
|
-
throw new
|
|
8705
|
+
throw new core_1.TransportError("target change status not supported");
|
|
8764
8706
|
}
|
|
8765
8707
|
const backboneChange = backboneResponse.changes[backboneResponse.changes.length - 1];
|
|
8766
8708
|
queriedChange.response = RelationshipChangeResponse_1.RelationshipChangeResponse.fromBackbone(backboneResponse.changes[backboneResponse.changes.length - 1].response, content);
|
|
@@ -8771,7 +8713,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8771
8713
|
return relationship;
|
|
8772
8714
|
}
|
|
8773
8715
|
async encryptRevokeContent(relationship, content) {
|
|
8774
|
-
const responseContent =
|
|
8716
|
+
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.from({
|
|
8775
8717
|
relationshipId: relationship.id,
|
|
8776
8718
|
content: content
|
|
8777
8719
|
});
|
|
@@ -8794,7 +8736,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8794
8736
|
}
|
|
8795
8737
|
async encryptAcceptRejectContent(relationship, content) {
|
|
8796
8738
|
const publicResponseCrypto = await this.secrets.getPublicResponse(relationship.relationshipSecretId);
|
|
8797
|
-
const responseContent =
|
|
8739
|
+
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.from({
|
|
8798
8740
|
relationshipId: relationship.id,
|
|
8799
8741
|
content: content
|
|
8800
8742
|
});
|
|
@@ -8817,13 +8759,13 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8817
8759
|
return responseCipher.toBase64();
|
|
8818
8760
|
}
|
|
8819
8761
|
throwWrongChangeType(type) {
|
|
8820
|
-
throw new
|
|
8762
|
+
throw new core_1.TransportError(`The relationship change has the wrong type (${type}) to run this operation`);
|
|
8821
8763
|
}
|
|
8822
8764
|
newChangeResponseMissingError(changeId) {
|
|
8823
|
-
return new
|
|
8765
|
+
return new core_1.TransportError(`The response of the relationship change (${changeId}) is missing`);
|
|
8824
8766
|
}
|
|
8825
8767
|
newEmptyOrInvalidContentError(change) {
|
|
8826
|
-
return new
|
|
8768
|
+
return new core_1.TransportError(`The content property of the relationship change ${change === null || change === void 0 ? void 0 : change.id} is missing or invalid`);
|
|
8827
8769
|
}
|
|
8828
8770
|
}
|
|
8829
8771
|
__decorate([
|
|
@@ -9107,23 +9049,20 @@ let Relationship = Relationship_1 = class Relationship extends core_1.CoreSynchr
|
|
|
9107
9049
|
});
|
|
9108
9050
|
}
|
|
9109
9051
|
toActive(response) {
|
|
9110
|
-
if (!this.cache)
|
|
9111
|
-
throw
|
|
9112
|
-
}
|
|
9052
|
+
if (!this.cache)
|
|
9053
|
+
throw this.newCacheEmptyError();
|
|
9113
9054
|
this.cache.changes[0].response = response;
|
|
9114
9055
|
this.status = RelationshipStatus_1.RelationshipStatus.Active;
|
|
9115
9056
|
}
|
|
9116
9057
|
toRejected(response) {
|
|
9117
|
-
if (!this.cache)
|
|
9118
|
-
throw
|
|
9119
|
-
}
|
|
9058
|
+
if (!this.cache)
|
|
9059
|
+
throw this.newCacheEmptyError();
|
|
9120
9060
|
this.cache.changes[0].response = response;
|
|
9121
9061
|
this.status = RelationshipStatus_1.RelationshipStatus.Rejected;
|
|
9122
9062
|
}
|
|
9123
9063
|
toRevoked(response) {
|
|
9124
|
-
if (!this.cache)
|
|
9125
|
-
throw
|
|
9126
|
-
}
|
|
9064
|
+
if (!this.cache)
|
|
9065
|
+
throw this.newCacheEmptyError();
|
|
9127
9066
|
this.cache.changes[0].response = response;
|
|
9128
9067
|
this.status = RelationshipStatus_1.RelationshipStatus.Revoked;
|
|
9129
9068
|
}
|
|
@@ -9140,6 +9079,9 @@ let Relationship = Relationship_1 = class Relationship extends core_1.CoreSynchr
|
|
|
9140
9079
|
this.metadataModifiedAt = core_1.CoreDate.utc();
|
|
9141
9080
|
return this;
|
|
9142
9081
|
}
|
|
9082
|
+
newCacheEmptyError() {
|
|
9083
|
+
return new core_1.TransportError(`The cache of the Relationship with id "${this.id}" is empty.`);
|
|
9084
|
+
}
|
|
9143
9085
|
};
|
|
9144
9086
|
__decorate([
|
|
9145
9087
|
(0, ts_serval_1.validate)(),
|
|
@@ -9549,10 +9491,10 @@ exports.RelationshipCreationChangeRequestCipher = RelationshipCreationChangeRequ
|
|
|
9549
9491
|
|
|
9550
9492
|
/***/ }),
|
|
9551
9493
|
|
|
9552
|
-
/***/ "./dist/modules/relationships/transmission/requests/
|
|
9553
|
-
|
|
9554
|
-
!*** ./dist/modules/relationships/transmission/requests/
|
|
9555
|
-
|
|
9494
|
+
/***/ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js":
|
|
9495
|
+
/*!*************************************************************************************************************!*\
|
|
9496
|
+
!*** ./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js ***!
|
|
9497
|
+
\*************************************************************************************************************/
|
|
9556
9498
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
9557
9499
|
|
|
9558
9500
|
"use strict";
|
|
@@ -9567,11 +9509,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9567
9509
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9568
9510
|
};
|
|
9569
9511
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9570
|
-
exports.
|
|
9512
|
+
exports.RelationshipCreationChangeRequestContentWrapper = void 0;
|
|
9571
9513
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
9572
9514
|
const core_1 = __webpack_require__(/*! ../../../../core */ "./dist/core/index.js");
|
|
9573
9515
|
const Identity_1 = __webpack_require__(/*! ../../../accounts/data/Identity */ "./dist/modules/accounts/data/Identity.js");
|
|
9574
|
-
let
|
|
9516
|
+
let RelationshipCreationChangeRequestContentWrapper = class RelationshipCreationChangeRequestContentWrapper extends core_1.CoreSerializable {
|
|
9575
9517
|
static from(value) {
|
|
9576
9518
|
return this.fromAny(value);
|
|
9577
9519
|
}
|
|
@@ -9580,22 +9522,22 @@ __decorate([
|
|
|
9580
9522
|
(0, ts_serval_1.validate)(),
|
|
9581
9523
|
(0, ts_serval_1.serialize)(),
|
|
9582
9524
|
__metadata("design:type", Identity_1.Identity)
|
|
9583
|
-
],
|
|
9525
|
+
], RelationshipCreationChangeRequestContentWrapper.prototype, "identity", void 0);
|
|
9584
9526
|
__decorate([
|
|
9585
9527
|
(0, ts_serval_1.validate)(),
|
|
9586
9528
|
(0, ts_serval_1.serialize)(),
|
|
9587
9529
|
__metadata("design:type", ts_serval_1.Serializable)
|
|
9588
|
-
],
|
|
9530
|
+
], RelationshipCreationChangeRequestContentWrapper.prototype, "content", void 0);
|
|
9589
9531
|
__decorate([
|
|
9590
9532
|
(0, ts_serval_1.validate)(),
|
|
9591
9533
|
(0, ts_serval_1.serialize)(),
|
|
9592
9534
|
__metadata("design:type", core_1.CoreId)
|
|
9593
|
-
],
|
|
9594
|
-
|
|
9595
|
-
(0, ts_serval_1.type)("
|
|
9596
|
-
],
|
|
9597
|
-
exports.
|
|
9598
|
-
//# sourceMappingURL=
|
|
9535
|
+
], RelationshipCreationChangeRequestContentWrapper.prototype, "templateId", void 0);
|
|
9536
|
+
RelationshipCreationChangeRequestContentWrapper = __decorate([
|
|
9537
|
+
(0, ts_serval_1.type)("RelationshipCreationChangeRequestContentWrapper")
|
|
9538
|
+
], RelationshipCreationChangeRequestContentWrapper);
|
|
9539
|
+
exports.RelationshipCreationChangeRequestContentWrapper = RelationshipCreationChangeRequestContentWrapper;
|
|
9540
|
+
//# sourceMappingURL=RelationshipCreationChangeRequestContentWrapper.js.map
|
|
9599
9541
|
|
|
9600
9542
|
/***/ }),
|
|
9601
9543
|
|
|
@@ -9697,10 +9639,10 @@ exports.RelationshipCreationChangeResponseCipher = RelationshipCreationChangeRes
|
|
|
9697
9639
|
|
|
9698
9640
|
/***/ }),
|
|
9699
9641
|
|
|
9700
|
-
/***/ "./dist/modules/relationships/transmission/responses/
|
|
9701
|
-
|
|
9702
|
-
!*** ./dist/modules/relationships/transmission/responses/
|
|
9703
|
-
|
|
9642
|
+
/***/ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js":
|
|
9643
|
+
/*!***************************************************************************************************************!*\
|
|
9644
|
+
!*** ./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js ***!
|
|
9645
|
+
\***************************************************************************************************************/
|
|
9704
9646
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
9705
9647
|
|
|
9706
9648
|
"use strict";
|
|
@@ -9715,10 +9657,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9715
9657
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9716
9658
|
};
|
|
9717
9659
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9718
|
-
exports.
|
|
9660
|
+
exports.RelationshipCreationChangeResponseContentWrapper = void 0;
|
|
9719
9661
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
9720
9662
|
const core_1 = __webpack_require__(/*! ../../../../core */ "./dist/core/index.js");
|
|
9721
|
-
let
|
|
9663
|
+
let RelationshipCreationChangeResponseContentWrapper = class RelationshipCreationChangeResponseContentWrapper extends core_1.CoreSerializable {
|
|
9722
9664
|
static from(value) {
|
|
9723
9665
|
return this.fromAny(value);
|
|
9724
9666
|
}
|
|
@@ -9727,17 +9669,17 @@ __decorate([
|
|
|
9727
9669
|
(0, ts_serval_1.validate)(),
|
|
9728
9670
|
(0, ts_serval_1.serialize)(),
|
|
9729
9671
|
__metadata("design:type", ts_serval_1.Serializable)
|
|
9730
|
-
],
|
|
9672
|
+
], RelationshipCreationChangeResponseContentWrapper.prototype, "content", void 0);
|
|
9731
9673
|
__decorate([
|
|
9732
9674
|
(0, ts_serval_1.validate)(),
|
|
9733
9675
|
(0, ts_serval_1.serialize)(),
|
|
9734
9676
|
__metadata("design:type", core_1.CoreId)
|
|
9735
|
-
],
|
|
9736
|
-
|
|
9737
|
-
(0, ts_serval_1.type)("
|
|
9738
|
-
],
|
|
9739
|
-
exports.
|
|
9740
|
-
//# sourceMappingURL=
|
|
9677
|
+
], RelationshipCreationChangeResponseContentWrapper.prototype, "relationshipId", void 0);
|
|
9678
|
+
RelationshipCreationChangeResponseContentWrapper = __decorate([
|
|
9679
|
+
(0, ts_serval_1.type)("RelationshipCreationChangeResponseContentWrapper")
|
|
9680
|
+
], RelationshipCreationChangeResponseContentWrapper);
|
|
9681
|
+
exports.RelationshipCreationChangeResponseContentWrapper = RelationshipCreationChangeResponseContentWrapper;
|
|
9682
|
+
//# sourceMappingURL=RelationshipCreationChangeResponseContentWrapper.js.map
|
|
9741
9683
|
|
|
9742
9684
|
/***/ }),
|
|
9743
9685
|
|
|
@@ -9944,7 +9886,6 @@ class SecretController extends TransportController_1.TransportController {
|
|
|
9944
9886
|
async createExchangeKey(name = "", description = "", validTo) {
|
|
9945
9887
|
const exchangeKeypair = await core_1.CoreCrypto.generateExchangeKeypair();
|
|
9946
9888
|
const secretContainer = await this.storeSecret(exchangeKeypair, name, description, validTo);
|
|
9947
|
-
// TODO: JSSNMSHDD-2485 (wipe private key)
|
|
9948
9889
|
return [exchangeKeypair.publicKey, secretContainer];
|
|
9949
9890
|
}
|
|
9950
9891
|
async getBaseKey() {
|
|
@@ -9956,7 +9897,7 @@ class SecretController extends TransportController_1.TransportController {
|
|
|
9956
9897
|
this.baseKey = baseKey.secret;
|
|
9957
9898
|
}
|
|
9958
9899
|
else {
|
|
9959
|
-
throw core_1.
|
|
9900
|
+
throw core_1.CoreErrors.general.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretController_1.DeviceSecretType.SharedSecretBaseKey);
|
|
9960
9901
|
}
|
|
9961
9902
|
return this.baseKey;
|
|
9962
9903
|
}
|
|
@@ -10220,7 +10161,7 @@ class DatawalletModificationMapper {
|
|
|
10220
10161
|
type = DatawalletModification_1.DatawalletModificationType.CacheChanged;
|
|
10221
10162
|
break;
|
|
10222
10163
|
default:
|
|
10223
|
-
throw new
|
|
10164
|
+
throw new core_1.TransportError("Unsupported DatawalletModificationType '${backboneDatawalletModification.type}'");
|
|
10224
10165
|
}
|
|
10225
10166
|
let payloadCategory;
|
|
10226
10167
|
switch (backboneDatawalletModification.payloadCategory) {
|
|
@@ -10237,7 +10178,7 @@ class DatawalletModificationMapper {
|
|
|
10237
10178
|
payloadCategory = undefined;
|
|
10238
10179
|
break;
|
|
10239
10180
|
default:
|
|
10240
|
-
throw new
|
|
10181
|
+
throw new core_1.TransportError(`Unsupported DatawalletModificationCategory '${backboneDatawalletModification.payloadCategory}'`);
|
|
10241
10182
|
}
|
|
10242
10183
|
return DatawalletModification_1.DatawalletModification.from({
|
|
10243
10184
|
localId: await core_1.TransportIds.datawalletModification.generate(),
|
|
@@ -10374,7 +10315,7 @@ class DatawalletModificationsProcessor {
|
|
|
10374
10315
|
const targetCollection = await this.collectionProvider.getCollection(updateModification.collection);
|
|
10375
10316
|
const oldDoc = await targetCollection.read(updateModification.objectIdentifier.toString());
|
|
10376
10317
|
if (!oldDoc) {
|
|
10377
|
-
throw new
|
|
10318
|
+
throw new core_1.TransportError("Document to update was not found.");
|
|
10378
10319
|
}
|
|
10379
10320
|
const oldObject = core_1.CoreSerializable.fromUnknown(oldDoc);
|
|
10380
10321
|
const newObject = { ...oldObject.toJSON(), ...updateModification.payload };
|
|
@@ -10411,7 +10352,7 @@ class DatawalletModificationsProcessor {
|
|
|
10411
10352
|
const uniqueCollections = [...new Set(collections)];
|
|
10412
10353
|
const collectionsWithUncacheableItems = uniqueCollections.filter((c) => !this.collectionsWithCacheableItems.includes(c));
|
|
10413
10354
|
if (collectionsWithUncacheableItems.length > 0) {
|
|
10414
|
-
throw core_1.
|
|
10355
|
+
throw core_1.CoreErrors.datawallet.unsupportedModification("unsupportedCacheChangedModificationCollection", collectionsWithUncacheableItems);
|
|
10415
10356
|
}
|
|
10416
10357
|
}
|
|
10417
10358
|
groupCacheChangesByCollection(cacheChanges) {
|
|
@@ -10534,7 +10475,7 @@ class ExternalEventsProcessor {
|
|
|
10534
10475
|
await this.applyRelationshipChangeCompletedEvent(externalEvent);
|
|
10535
10476
|
break;
|
|
10536
10477
|
default:
|
|
10537
|
-
throw new
|
|
10478
|
+
throw new core_1.TransportError(`'${externalEvent.type}' is not a supported external event type.`);
|
|
10538
10479
|
}
|
|
10539
10480
|
this.results.push({
|
|
10540
10481
|
externalEventId: externalEvent.id
|
|
@@ -10757,7 +10698,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10757
10698
|
if (this.config.supportedDatawalletVersion < identityDatawalletVersion) {
|
|
10758
10699
|
// This means that the datawallet of the identity was upgraded by another device with a higher version.
|
|
10759
10700
|
// It is necesssary to update the current device.
|
|
10760
|
-
throw core_1.
|
|
10701
|
+
throw core_1.CoreErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion);
|
|
10761
10702
|
}
|
|
10762
10703
|
this.log.trace("Synchronization of Datawallet events started...");
|
|
10763
10704
|
try {
|
|
@@ -10769,7 +10710,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10769
10710
|
const outdatedErrorCode = "error.platform.validation.datawallet.insufficientSupportedDatawalletVersion";
|
|
10770
10711
|
if (!(e instanceof core_1.RequestError) || e.code !== outdatedErrorCode)
|
|
10771
10712
|
throw e;
|
|
10772
|
-
throw core_1.
|
|
10713
|
+
throw core_1.CoreErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion);
|
|
10773
10714
|
}
|
|
10774
10715
|
this.log.trace("Synchronization of Datawallet events ended...");
|
|
10775
10716
|
await this.checkDatawalletVersion(identityDatawalletVersion);
|
|
@@ -10777,7 +10718,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10777
10718
|
async checkDatawalletVersion(identityDatawalletVersion) {
|
|
10778
10719
|
var _a;
|
|
10779
10720
|
if (this.config.supportedDatawalletVersion < identityDatawalletVersion) {
|
|
10780
|
-
throw core_1.
|
|
10721
|
+
throw core_1.CoreErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion);
|
|
10781
10722
|
}
|
|
10782
10723
|
if (this.config.supportedDatawalletVersion > identityDatawalletVersion) {
|
|
10783
10724
|
await this.upgradeIdentityDatawalletVersion(identityDatawalletVersion, this.config.supportedDatawalletVersion);
|
|
@@ -10791,10 +10732,10 @@ class SyncController extends core_1.TransportController {
|
|
|
10791
10732
|
if (identityDatawalletVersion === targetDatawalletVersion)
|
|
10792
10733
|
return;
|
|
10793
10734
|
if (this.config.supportedDatawalletVersion < targetDatawalletVersion) {
|
|
10794
|
-
throw core_1.
|
|
10735
|
+
throw core_1.CoreErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, identityDatawalletVersion);
|
|
10795
10736
|
}
|
|
10796
10737
|
if (identityDatawalletVersion > targetDatawalletVersion) {
|
|
10797
|
-
throw core_1.
|
|
10738
|
+
throw core_1.CoreErrors.datawallet.currentBiggerThanTarget(identityDatawalletVersion, targetDatawalletVersion);
|
|
10798
10739
|
}
|
|
10799
10740
|
while (identityDatawalletVersion < targetDatawalletVersion) {
|
|
10800
10741
|
identityDatawalletVersion++;
|
|
@@ -10811,10 +10752,10 @@ class SyncController extends core_1.TransportController {
|
|
|
10811
10752
|
if (deviceDatawalletVersion === targetDatawalletVersion)
|
|
10812
10753
|
return;
|
|
10813
10754
|
if (this.config.supportedDatawalletVersion < targetDatawalletVersion) {
|
|
10814
|
-
throw core_1.
|
|
10755
|
+
throw core_1.CoreErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, deviceDatawalletVersion);
|
|
10815
10756
|
}
|
|
10816
10757
|
if (deviceDatawalletVersion > targetDatawalletVersion) {
|
|
10817
|
-
throw core_1.
|
|
10758
|
+
throw core_1.CoreErrors.datawallet.currentBiggerThanTarget(deviceDatawalletVersion, targetDatawalletVersion);
|
|
10818
10759
|
}
|
|
10819
10760
|
while (deviceDatawalletVersion < targetDatawalletVersion) {
|
|
10820
10761
|
deviceDatawalletVersion++;
|
|
@@ -10941,7 +10882,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10941
10882
|
}
|
|
10942
10883
|
async finalizeExternalEventsSyncRun(externalEventResults) {
|
|
10943
10884
|
if (!this.currentSyncRun) {
|
|
10944
|
-
throw new
|
|
10885
|
+
throw new core_1.TransportError("There is no active sync run to finalize");
|
|
10945
10886
|
}
|
|
10946
10887
|
const { backboneModifications, localModificationIds } = await this.prepareLocalDatawalletModificationsForPush();
|
|
10947
10888
|
await this.client.finalizeExternalEventSync(this.currentSyncRun.id.toString(), {
|
|
@@ -10956,7 +10897,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10956
10897
|
}
|
|
10957
10898
|
async finalizeDatawalletVersionUpgradeSyncRun(newDatawalletVersion) {
|
|
10958
10899
|
if (!this.currentSyncRun) {
|
|
10959
|
-
throw new
|
|
10900
|
+
throw new core_1.TransportError("There is no active sync run to finalize");
|
|
10960
10901
|
}
|
|
10961
10902
|
const { backboneModifications, localModificationIds } = await this.prepareLocalDatawalletModificationsForPush();
|
|
10962
10903
|
await this.client.finalizeDatawalletVersionUpgrade(this.currentSyncRun.id.toString(), {
|
|
@@ -10998,7 +10939,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10998
10939
|
await this.setSyncTimeByName("Datawallet");
|
|
10999
10940
|
}
|
|
11000
10941
|
newNoMigrationAvailableError(version) {
|
|
11001
|
-
return new
|
|
10942
|
+
return new core_1.TransportError(`There is no migration available for the datawallet version '${version}'.`);
|
|
11002
10943
|
}
|
|
11003
10944
|
}
|
|
11004
10945
|
__decorate([
|
|
@@ -11546,7 +11487,7 @@ class AnonymousTokenController {
|
|
|
11546
11487
|
const plaintextTokenBuffer = await core_1.CoreCrypto.decrypt(cipher, secretKey);
|
|
11547
11488
|
const plaintextTokenContent = core_1.CoreSerializable.deserializeUnknown(plaintextTokenBuffer.toUtf8());
|
|
11548
11489
|
if (!(plaintextTokenContent instanceof ts_serval_1.Serializable)) {
|
|
11549
|
-
throw core_1.
|
|
11490
|
+
throw core_1.CoreErrors.tokens.invalidTokenContent(id.toString());
|
|
11550
11491
|
}
|
|
11551
11492
|
const token = Token_1.Token.from({
|
|
11552
11493
|
id: id,
|
|
@@ -11646,7 +11587,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11646
11587
|
const id = idOrToken instanceof core_1.CoreId ? idOrToken.toString() : idOrToken.id.toString();
|
|
11647
11588
|
const tokenDoc = await this.tokens.read(id);
|
|
11648
11589
|
if (!tokenDoc) {
|
|
11649
|
-
throw core_1.
|
|
11590
|
+
throw core_1.CoreErrors.general.recordNotFound(Token_1.Token, id.toString());
|
|
11650
11591
|
}
|
|
11651
11592
|
const token = Token_1.Token.from(tokenDoc);
|
|
11652
11593
|
token.setMetadata(metadata);
|
|
@@ -11661,7 +11602,6 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11661
11602
|
if (ids.length < 1) {
|
|
11662
11603
|
return [];
|
|
11663
11604
|
}
|
|
11664
|
-
// TODO: JSSNMSHDD-2820 (check for items that couldn't be fetched e.g. because it is expired)
|
|
11665
11605
|
const resultItems = (await this.client.getTokens({ ids })).value;
|
|
11666
11606
|
const promises = [];
|
|
11667
11607
|
for await (const resultItem of resultItems) {
|
|
@@ -11684,7 +11624,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11684
11624
|
async updateCacheOfExistingTokenInDb(id, response) {
|
|
11685
11625
|
const tokenDoc = await this.tokens.read(id);
|
|
11686
11626
|
if (!tokenDoc) {
|
|
11687
|
-
core_1.
|
|
11627
|
+
core_1.CoreErrors.general.recordNotFound(Token_1.Token, id);
|
|
11688
11628
|
return;
|
|
11689
11629
|
}
|
|
11690
11630
|
const token = Token_1.Token.from(tokenDoc);
|
|
@@ -11707,7 +11647,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11707
11647
|
const plaintextTokenBuffer = await core_1.CoreCrypto.decrypt(cipher, secretKey);
|
|
11708
11648
|
const plaintextTokenContent = core_1.CoreSerializable.deserializeUnknown(plaintextTokenBuffer.toUtf8());
|
|
11709
11649
|
if (!(plaintextTokenContent instanceof ts_serval_1.Serializable)) {
|
|
11710
|
-
throw core_1.
|
|
11650
|
+
throw core_1.CoreErrors.tokens.invalidTokenContent(response.id);
|
|
11711
11651
|
}
|
|
11712
11652
|
const cachedToken = CachedToken_1.CachedToken.from({
|
|
11713
11653
|
createdAt: core_1.CoreDate.from(response.createdAt),
|
|
@@ -11735,7 +11675,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11735
11675
|
token = await this.updateCacheOfExistingTokenInDb(id.toString());
|
|
11736
11676
|
if (!token) {
|
|
11737
11677
|
// This should not happen, we only update the cache if we found the tokenDoc
|
|
11738
|
-
throw new
|
|
11678
|
+
throw new core_1.TransportError(`Tried to update a token (with ID: '${id.toString()}') that doesn't exist in the local database.`);
|
|
11739
11679
|
}
|
|
11740
11680
|
return token;
|
|
11741
11681
|
}
|
|
@@ -12231,6 +12171,7 @@ exports.TokenReference = TokenReference;
|
|
|
12231
12171
|
|
|
12232
12172
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12233
12173
|
exports.PasswordGenerator = void 0;
|
|
12174
|
+
const TransportError_1 = __webpack_require__(/*! ../core/TransportError */ "./dist/core/TransportError.js");
|
|
12234
12175
|
const Random_1 = __webpack_require__(/*! ./Random */ "./dist/util/Random.js");
|
|
12235
12176
|
const defaultPasswordRange = Random_1.RandomCharacterRange.AlphanumericEase + Random_1.RandomCharacterRange.SpecialCharacters;
|
|
12236
12177
|
class PasswordGenerator {
|
|
@@ -12254,7 +12195,7 @@ class PasswordGenerator {
|
|
|
12254
12195
|
if (minLength > maxLength)
|
|
12255
12196
|
maxLength = minLength;
|
|
12256
12197
|
if (minLength < 8) {
|
|
12257
|
-
throw new
|
|
12198
|
+
throw new TransportError_1.TransportError("Minimum password length for a strong password should be 8 characters.");
|
|
12258
12199
|
}
|
|
12259
12200
|
const specialCharacterBucket = {
|
|
12260
12201
|
minLength: 1,
|
|
@@ -12421,6 +12362,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
12421
12362
|
exports.Random = exports.RandomCharacterRange = void 0;
|
|
12422
12363
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
12423
12364
|
const uuid_1 = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/commonjs-browser/index.js");
|
|
12365
|
+
const TransportError_1 = __webpack_require__(/*! ../core/TransportError */ "./dist/core/TransportError.js");
|
|
12424
12366
|
var RandomCharacterRange;
|
|
12425
12367
|
(function (RandomCharacterRange) {
|
|
12426
12368
|
RandomCharacterRange["Digit"] = "0123456789";
|
|
@@ -12444,7 +12386,7 @@ class Random {
|
|
|
12444
12386
|
}
|
|
12445
12387
|
static async int(length) {
|
|
12446
12388
|
if (length > 21 || length <= 0) {
|
|
12447
|
-
throw new
|
|
12389
|
+
throw new TransportError_1.TransportError("Length must be between 1 and 21.");
|
|
12448
12390
|
}
|
|
12449
12391
|
return parseInt(await this.string(length, RandomCharacterRange.Digit));
|
|
12450
12392
|
}
|
|
@@ -12467,12 +12409,12 @@ class Random {
|
|
|
12467
12409
|
}
|
|
12468
12410
|
static async intBetween(min, max) {
|
|
12469
12411
|
if (max <= min) {
|
|
12470
|
-
throw new
|
|
12412
|
+
throw new TransportError_1.TransportError("Max must be larger than min.");
|
|
12471
12413
|
}
|
|
12472
12414
|
const diff = max - min + 1;
|
|
12473
12415
|
const bitLength = Math.abs(Math.ceil(Math.log2(diff)));
|
|
12474
12416
|
if (bitLength > 32) {
|
|
12475
|
-
throw new
|
|
12417
|
+
throw new TransportError_1.TransportError("The range between the numbers is too big, 32 bit is the maximum -> 4294967296");
|
|
12476
12418
|
}
|
|
12477
12419
|
const byteLength = Math.ceil(bitLength / 8);
|
|
12478
12420
|
const bitMask = Math.pow(2, bitLength) - 1;
|
|
@@ -12491,7 +12433,7 @@ class Random {
|
|
|
12491
12433
|
}
|
|
12492
12434
|
static async intRandomLength(minLength, maxLength) {
|
|
12493
12435
|
if (maxLength > 21) {
|
|
12494
|
-
throw new
|
|
12436
|
+
throw new TransportError_1.TransportError("Max must be below 22.");
|
|
12495
12437
|
}
|
|
12496
12438
|
return parseInt(await this.stringRandomLength(minLength, maxLength, RandomCharacterRange.Digit));
|
|
12497
12439
|
}
|
|
@@ -12510,7 +12452,7 @@ class Random {
|
|
|
12510
12452
|
if (length <= 0)
|
|
12511
12453
|
return "";
|
|
12512
12454
|
if (allowedChars.length > 256) {
|
|
12513
|
-
throw new
|
|
12455
|
+
throw new TransportError_1.TransportError("Input exceeds maximum length of 256.");
|
|
12514
12456
|
}
|
|
12515
12457
|
const ar = [];
|
|
12516
12458
|
const inputLength = allowedChars.length;
|
|
@@ -12533,10 +12475,10 @@ class Random {
|
|
|
12533
12475
|
}
|
|
12534
12476
|
static async stringRandomLength(minLength, maxLength, allowedChars) {
|
|
12535
12477
|
if (minLength > maxLength) {
|
|
12536
|
-
throw new
|
|
12478
|
+
throw new TransportError_1.TransportError("maxLength must be larger than minLength.");
|
|
12537
12479
|
}
|
|
12538
12480
|
if (minLength < 0) {
|
|
12539
|
-
throw new
|
|
12481
|
+
throw new TransportError_1.TransportError("minlength must not be less than zero.");
|
|
12540
12482
|
}
|
|
12541
12483
|
const length = maxLength > minLength ? await this.intBetween(minLength, maxLength) : maxLength;
|
|
12542
12484
|
return await this.string(length, allowedChars);
|