@nmshd/transport 2.0.0-beta.5 → 2.0.0-beta.6
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 +5 -5
- package/dist/core/CoreCrypto.d.ts +1 -0
- package/dist/core/CoreCrypto.js +14 -12
- package/dist/core/CoreCrypto.js.map +1 -1
- package/dist/core/CoreUtil.js +1 -2
- package/dist/core/CoreUtil.js.map +1 -1
- package/dist/core/Reference.js +2 -2
- package/dist/core/Reference.js.map +1 -1
- package/dist/core/Transport.js +4 -1
- package/dist/core/Transport.js.map +1 -1
- package/dist/core/TransportController.d.ts +1 -1
- package/dist/core/TransportController.js +2 -3
- package/dist/core/TransportController.js.map +1 -1
- package/dist/core/TransportErrors.d.ts +5 -73
- package/dist/core/TransportErrors.js +10 -153
- package/dist/core/TransportErrors.js.map +1 -1
- package/dist/core/TransportLoggerFactory.js +1 -2
- package/dist/core/TransportLoggerFactory.js.map +1 -1
- package/dist/core/types/CoreAddress.d.ts +1 -1
- package/dist/core/types/CoreAddress.js.map +1 -1
- package/dist/core/types/CoreDate.js +3 -4
- package/dist/core/types/CoreDate.js.map +1 -1
- package/dist/core/types/CoreId.d.ts +1 -1
- package/dist/core/types/CoreId.js +1 -2
- package/dist/core/types/CoreId.js.map +1 -1
- package/dist/modules/accounts/AccountController.d.ts +2 -0
- package/dist/modules/accounts/AccountController.js +30 -8
- package/dist/modules/accounts/AccountController.js.map +1 -1
- package/dist/modules/accounts/IdentityController.d.ts +1 -1
- package/dist/modules/accounts/IdentityController.js +24 -4
- package/dist/modules/accounts/IdentityController.js.map +1 -1
- package/dist/modules/accounts/IdentityUtil.d.ts +1 -1
- package/dist/modules/accounts/IdentityUtil.js +3 -4
- package/dist/modules/accounts/IdentityUtil.js.map +1 -1
- package/dist/modules/challenges/ChallengeController.js +26 -3
- package/dist/modules/challenges/ChallengeController.js.map +1 -1
- package/dist/modules/devices/DeviceController.d.ts +1 -1
- package/dist/modules/devices/DeviceController.js +41 -12
- package/dist/modules/devices/DeviceController.js.map +1 -1
- package/dist/modules/devices/DeviceSecretController.js +43 -13
- package/dist/modules/devices/DeviceSecretController.js.map +1 -1
- package/dist/modules/files/FileController.js +42 -8
- package/dist/modules/files/FileController.js.map +1 -1
- package/dist/modules/messages/MessageController.js +66 -12
- package/dist/modules/messages/MessageController.js.map +1 -1
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js +31 -3
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js.map +1 -1
- package/dist/modules/relationships/RelationshipSecretController.js +88 -17
- package/dist/modules/relationships/RelationshipSecretController.js.map +1 -1
- package/dist/modules/relationships/RelationshipsController.d.ts +3 -3
- package/dist/modules/relationships/RelationshipsController.js +112 -59
- package/dist/modules/relationships/RelationshipsController.js.map +1 -1
- package/dist/modules/secrets/SecretController.js +18 -4
- package/dist/modules/secrets/SecretController.js.map +1 -1
- package/dist/modules/sync/DatawalletModificationsProcessor.d.ts +1 -0
- package/dist/modules/sync/DatawalletModificationsProcessor.js +20 -3
- package/dist/modules/sync/DatawalletModificationsProcessor.js.map +1 -1
- package/dist/modules/sync/SyncController.d.ts +1 -0
- package/dist/modules/sync/SyncController.js +53 -24
- package/dist/modules/sync/SyncController.js.map +1 -1
- package/dist/modules/tokens/TokenController.js +31 -3
- package/dist/modules/tokens/TokenController.js.map +1 -1
- package/dist/util/PasswordGenerator.js +1 -2
- package/dist/util/PasswordGenerator.js.map +1 -1
- package/dist/util/Random.js +7 -8
- package/dist/util/Random.js.map +1 -1
- package/lib-web/nmshd.transport.js +734 -407
- 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 +6 -6
|
@@ -15,11 +15,11 @@ exports.buildInformation = void 0;
|
|
|
15
15
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
16
16
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
17
17
|
exports.buildInformation = {
|
|
18
|
-
version: "2.0.0-beta.
|
|
19
|
-
build: "
|
|
20
|
-
date: "2022-09-
|
|
21
|
-
commit: "
|
|
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.
|
|
18
|
+
version: "2.0.0-beta.6",
|
|
19
|
+
build: "37",
|
|
20
|
+
date: "2022-09-28T09:23:28+00:00",
|
|
21
|
+
commit: "3c28b2ad382a88645bc80f45ea3d3b6739218e2b",
|
|
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,
|
|
25
25
|
serval: ts_serval_1.buildInformation
|
|
@@ -41,7 +41,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
41
41
|
exports.CoreCrypto = void 0;
|
|
42
42
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
43
43
|
const util_1 = __webpack_require__(/*! ../util */ "./dist/util/index.js");
|
|
44
|
-
const TransportErrors_1 = __webpack_require__(/*! ./TransportErrors */ "./dist/core/TransportErrors.js");
|
|
45
44
|
const TransportVersion_1 = __webpack_require__(/*! ./types/TransportVersion */ "./dist/core/types/TransportVersion.js");
|
|
46
45
|
class CoreCrypto {
|
|
47
46
|
/**
|
|
@@ -57,7 +56,7 @@ class CoreCrypto {
|
|
|
57
56
|
case TransportVersion_1.TransportVersion.V1:
|
|
58
57
|
return await crypto_1.CryptoSignatures.generateKeypair(3 /* CryptoSignatureAlgorithm.ECDSA_ED25519 */);
|
|
59
58
|
default:
|
|
60
|
-
throw
|
|
59
|
+
throw this.invalidVersion(version);
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
/**
|
|
@@ -74,7 +73,7 @@ class CoreCrypto {
|
|
|
74
73
|
case TransportVersion_1.TransportVersion.V1:
|
|
75
74
|
return await crypto_1.CryptoExchange.generateKeypair(3 /* CryptoExchangeAlgorithm.ECDH_X25519 */);
|
|
76
75
|
default:
|
|
77
|
-
throw
|
|
76
|
+
throw this.invalidVersion(version);
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
/**
|
|
@@ -90,7 +89,7 @@ class CoreCrypto {
|
|
|
90
89
|
case TransportVersion_1.TransportVersion.V1:
|
|
91
90
|
return await crypto_1.CryptoEncryption.generateKey(3 /* CryptoEncryptionAlgorithm.XCHACHA20_POLY1305 */);
|
|
92
91
|
default:
|
|
93
|
-
throw
|
|
92
|
+
throw this.invalidVersion(version);
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
/**
|
|
@@ -115,7 +114,7 @@ class CoreCrypto {
|
|
|
115
114
|
case TransportVersion_1.TransportVersion.V1:
|
|
116
115
|
return await crypto_1.CryptoDerivation.deriveKeyFromMaster(masterBuffer, 150000, keyAlgorithm, saltBuffer);
|
|
117
116
|
default:
|
|
118
|
-
throw
|
|
117
|
+
throw this.invalidVersion(version);
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
static async deriveKeyFromBase(secret, keyId, context, keyAlgorithm = 3 /* CryptoEncryptionAlgorithm.XCHACHA20_POLY1305 */) {
|
|
@@ -127,7 +126,7 @@ class CoreCrypto {
|
|
|
127
126
|
buffer = secret;
|
|
128
127
|
}
|
|
129
128
|
else {
|
|
130
|
-
throw
|
|
129
|
+
throw new Error("The secret type is invalid.");
|
|
131
130
|
}
|
|
132
131
|
return await crypto_1.CryptoDerivation.deriveKeyFromBase(buffer, keyId, context, keyAlgorithm);
|
|
133
132
|
}
|
|
@@ -137,7 +136,7 @@ class CoreCrypto {
|
|
|
137
136
|
const base = await crypto_1.CryptoExchange.deriveTemplator(client, serverPublicKey, keyAlgorithm);
|
|
138
137
|
return base;
|
|
139
138
|
default:
|
|
140
|
-
throw
|
|
139
|
+
throw this.invalidVersion(version);
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
static async deriveServer(server, clientPublicKey, keyAlgorithm = 3 /* CryptoEncryptionAlgorithm.XCHACHA20_POLY1305 */, version = TransportVersion_1.TransportVersion.Latest) {
|
|
@@ -146,7 +145,7 @@ class CoreCrypto {
|
|
|
146
145
|
const base = await crypto_1.CryptoExchange.deriveRequestor(server, clientPublicKey, keyAlgorithm);
|
|
147
146
|
return base;
|
|
148
147
|
default:
|
|
149
|
-
throw
|
|
148
|
+
throw this.invalidVersion(version);
|
|
150
149
|
}
|
|
151
150
|
}
|
|
152
151
|
/**
|
|
@@ -164,7 +163,7 @@ class CoreCrypto {
|
|
|
164
163
|
case TransportVersion_1.TransportVersion.V1:
|
|
165
164
|
return await crypto_1.CryptoSignatures.sign(content, privateKey, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
166
165
|
default:
|
|
167
|
-
throw
|
|
166
|
+
throw this.invalidVersion(version);
|
|
168
167
|
}
|
|
169
168
|
}
|
|
170
169
|
/**
|
|
@@ -183,7 +182,7 @@ class CoreCrypto {
|
|
|
183
182
|
case TransportVersion_1.TransportVersion.V1:
|
|
184
183
|
return await crypto_1.CryptoSignatures.verify(content, signature, publicKey);
|
|
185
184
|
default:
|
|
186
|
-
throw
|
|
185
|
+
throw this.invalidVersion(version);
|
|
187
186
|
}
|
|
188
187
|
}
|
|
189
188
|
/**
|
|
@@ -203,7 +202,7 @@ class CoreCrypto {
|
|
|
203
202
|
case TransportVersion_1.TransportVersion.V1:
|
|
204
203
|
return await crypto_1.CryptoEncryption.encrypt(content, secretKey);
|
|
205
204
|
default:
|
|
206
|
-
throw
|
|
205
|
+
throw this.invalidVersion(version);
|
|
207
206
|
}
|
|
208
207
|
}
|
|
209
208
|
/**
|
|
@@ -223,7 +222,7 @@ class CoreCrypto {
|
|
|
223
222
|
case TransportVersion_1.TransportVersion.V1:
|
|
224
223
|
return await crypto_1.CryptoEncryption.decrypt(cipher, secretKey);
|
|
225
224
|
default:
|
|
226
|
-
throw
|
|
225
|
+
throw this.invalidVersion(version);
|
|
227
226
|
}
|
|
228
227
|
}
|
|
229
228
|
/**
|
|
@@ -238,6 +237,9 @@ class CoreCrypto {
|
|
|
238
237
|
static async createAccountPassword() {
|
|
239
238
|
return await util_1.PasswordGenerator.createStrongPassword(100, 100);
|
|
240
239
|
}
|
|
240
|
+
static invalidVersion(version) {
|
|
241
|
+
return new Error(`The version ${version} is not supported.`);
|
|
242
|
+
}
|
|
241
243
|
}
|
|
242
244
|
exports.CoreCrypto = CoreCrypto;
|
|
243
245
|
//# sourceMappingURL=CoreCrypto.js.map
|
|
@@ -502,7 +504,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
502
504
|
exports.CoreUtil = void 0;
|
|
503
505
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
504
506
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
505
|
-
const TransportErrors_1 = __webpack_require__(/*! ./TransportErrors */ "./dist/core/TransportErrors.js");
|
|
506
507
|
class CoreUtil {
|
|
507
508
|
static toBuffer(content, verbose = false) {
|
|
508
509
|
let buffer;
|
|
@@ -519,7 +520,7 @@ class CoreUtil {
|
|
|
519
520
|
buffer = new crypto_1.CoreBuffer(content);
|
|
520
521
|
}
|
|
521
522
|
else {
|
|
522
|
-
throw
|
|
523
|
+
throw new Error("The given content cannot be transformed to buffer.");
|
|
523
524
|
}
|
|
524
525
|
return buffer;
|
|
525
526
|
}
|
|
@@ -664,7 +665,7 @@ class Reference extends ts_serval_1.Serializable {
|
|
|
664
665
|
const truncatedBuffer = crypto_1.CoreBuffer.fromBase64URL(value);
|
|
665
666
|
const splitted = truncatedBuffer.toUtf8().split("|");
|
|
666
667
|
if (splitted.length !== 3) {
|
|
667
|
-
throw TransportErrors_1.TransportErrors.
|
|
668
|
+
throw TransportErrors_1.TransportErrors.general.invalidTruncatedReference();
|
|
668
669
|
}
|
|
669
670
|
try {
|
|
670
671
|
const id = CoreId_1.CoreId.from(splitted[0]);
|
|
@@ -680,7 +681,7 @@ class Reference extends ts_serval_1.Serializable {
|
|
|
680
681
|
});
|
|
681
682
|
}
|
|
682
683
|
catch (e) {
|
|
683
|
-
throw TransportErrors_1.TransportErrors.
|
|
684
|
+
throw TransportErrors_1.TransportErrors.general.invalidTruncatedReference();
|
|
684
685
|
}
|
|
685
686
|
}
|
|
686
687
|
static validateId(value, helper) {
|
|
@@ -749,7 +750,10 @@ class Transport {
|
|
|
749
750
|
throw TransportErrors_1.TransportErrors.general.baseUrlNotSet().logWith(log);
|
|
750
751
|
}
|
|
751
752
|
if (this._config.supportedDatawalletVersion < 1) {
|
|
752
|
-
throw
|
|
753
|
+
throw new Error("The given identity version is invalid. The value must be 0 or higher.");
|
|
754
|
+
}
|
|
755
|
+
if (this._config.realm.length !== 3) {
|
|
756
|
+
throw TransportErrors_1.TransportErrors.general.realmLength();
|
|
753
757
|
}
|
|
754
758
|
}
|
|
755
759
|
get config() {
|
|
@@ -845,7 +849,6 @@ var TransportContext;
|
|
|
845
849
|
|
|
846
850
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
847
851
|
exports.TransportController = exports.ControllerName = void 0;
|
|
848
|
-
const TransportErrors_1 = __webpack_require__(/*! ./TransportErrors */ "./dist/core/TransportErrors.js");
|
|
849
852
|
const TransportLoggerFactory_1 = __webpack_require__(/*! ./TransportLoggerFactory */ "./dist/core/TransportLoggerFactory.js");
|
|
850
853
|
var ControllerName;
|
|
851
854
|
(function (ControllerName) {
|
|
@@ -909,9 +912,9 @@ class TransportController {
|
|
|
909
912
|
get eventBus() {
|
|
910
913
|
return this.transport.eventBus;
|
|
911
914
|
}
|
|
912
|
-
init() {
|
|
915
|
+
init(..._args) {
|
|
913
916
|
if (this._initialized) {
|
|
914
|
-
throw
|
|
917
|
+
throw new Error(`The controller ${this.controllerName} is already initialized.`);
|
|
915
918
|
}
|
|
916
919
|
this._initialized = true;
|
|
917
920
|
return Promise.resolve(this);
|
|
@@ -940,107 +943,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
940
943
|
exports.TransportErrors = void 0;
|
|
941
944
|
const json_stringify_safe_1 = __importDefault(__webpack_require__(/*! json-stringify-safe */ "./node_modules/json-stringify-safe/stringify.js"));
|
|
942
945
|
const CoreError_1 = __webpack_require__(/*! ./CoreError */ "./dist/core/CoreError.js");
|
|
943
|
-
class Controller {
|
|
944
|
-
alreadyInitialized(controllerName) {
|
|
945
|
-
return new CoreError_1.CoreError("error.transport.controller.alreadyInitialized", `The controller ${controllerName} was already initialized.`);
|
|
946
|
-
}
|
|
947
|
-
contentPropertyUndefined(contentProperty) {
|
|
948
|
-
return new CoreError_1.CoreError("error.transport.controller.contentPropertyUndefined", `The property ${contentProperty} is undefined.`);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
class Crypto {
|
|
952
|
-
invalidVersion(version) {
|
|
953
|
-
return new CoreError_1.CoreError("error.transport.crypto.invalidVersion", `The version ${version} is not supported.`);
|
|
954
|
-
}
|
|
955
|
-
invalidSecretType() {
|
|
956
|
-
return new CoreError_1.CoreError("error.transport.crypto.invalidSecretType", "The secret type is invalid.");
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
class RelationshipTemplates {
|
|
960
|
-
}
|
|
961
946
|
class Relationships {
|
|
962
|
-
responseCryptoIsMissing() {
|
|
963
|
-
return new CoreError_1.CoreError("error.transport.relationships.responseCryptoIsMissing", "The response crypto is missing.");
|
|
964
|
-
}
|
|
965
|
-
requestContainsWrongTemplateId() {
|
|
966
|
-
return new CoreError_1.CoreError("error.transport.relationships.requestContainsWrongTemplateId", "The relationship request contains a wrong template id.");
|
|
967
|
-
}
|
|
968
|
-
responseContainsWrongRequestId() {
|
|
969
|
-
return new CoreError_1.CoreError("error.transport.relationships.requestContainsWrongRequestId", "The relationship response contains a wrong request id.");
|
|
970
|
-
}
|
|
971
947
|
wrongChangeStatus(status) {
|
|
972
948
|
return new CoreError_1.CoreError("error.transport.relationships.wrongChangeStatus", `The relationship change has the wrong status (${status}) to run this operation`);
|
|
973
949
|
}
|
|
974
|
-
wrongChangeType(type) {
|
|
975
|
-
return new CoreError_1.CoreError("error.transport.relationships.wrongChangeType", `The relationship change has the wrong type (${type}) to run this operation`);
|
|
976
|
-
}
|
|
977
|
-
changeResponseMissing(changeId) {
|
|
978
|
-
return new CoreError_1.CoreError("error.transport.relationships.changeResponseMissing", `The response of the relationship change (${changeId}) is missing`);
|
|
979
|
-
}
|
|
980
|
-
emptyOrInvalidContent(change) {
|
|
981
|
-
return new CoreError_1.CoreError("error.transport.relationships.wrongOrEmptyContent", `The relationship change ${change === null || change === void 0 ? void 0 : change.id} requires a content property or its content property is invalid`);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
class Logging {
|
|
985
|
-
loggerNotInitialized() {
|
|
986
|
-
return new CoreError_1.CoreError("error.transport.logging.loggerNotInitialized", "The logger factory is not yet initialized");
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
class CoreDateErrors {
|
|
990
|
-
noIsoStringMethod() {
|
|
991
|
-
return new CoreError_1.CoreError("error.transport.date.noIsoMethod", "The provided object doesn't have an iso string method");
|
|
992
|
-
}
|
|
993
|
-
undefined() {
|
|
994
|
-
return new CoreError_1.CoreError("error.transport.date.undefined", "The provided object is undefined and cannot be deserialized.");
|
|
995
|
-
}
|
|
996
|
-
invalid() {
|
|
997
|
-
return new CoreError_1.CoreError("error.transport.date.invalid", "The provided object is invalid cannot be deserialized.");
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
class Random {
|
|
1001
|
-
minLessThanZero() {
|
|
1002
|
-
return new CoreError_1.CoreError("error.transport.util.random.minLessThanZero", "minlength must not be less than zero");
|
|
1003
|
-
}
|
|
1004
|
-
inputTooLong() {
|
|
1005
|
-
return new CoreError_1.CoreError("error.transport.util.random.inputTooLong", "Input exceeds maximum length of 256!");
|
|
1006
|
-
}
|
|
1007
|
-
maxTooHigh() {
|
|
1008
|
-
return new CoreError_1.CoreError("error.transport.util.random.maxTooHigh", "Max must be below 22.");
|
|
1009
|
-
}
|
|
1010
|
-
mnBiggerThatMax() {
|
|
1011
|
-
return new CoreError_1.CoreError("error.code.util.random.minBiggerThanMax", "Max must be larger than min.");
|
|
1012
|
-
}
|
|
1013
|
-
rangeTooBig() {
|
|
1014
|
-
return new CoreError_1.CoreError("error.transport.util.random.rangeTooBig", "The range between the numbers is too big, 32 bit is the maximum -> 4294967296");
|
|
1015
|
-
}
|
|
1016
|
-
intLength() {
|
|
1017
|
-
return new CoreError_1.CoreError("error.transport.util.random.length", "Length must be between 1 and 21.");
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
class Util {
|
|
1021
|
-
constructor() {
|
|
1022
|
-
this.date = new CoreDateErrors();
|
|
1023
|
-
this.random = new Random();
|
|
1024
|
-
this.logging = new Logging();
|
|
1025
|
-
this.crypto = new Crypto();
|
|
1026
|
-
}
|
|
1027
|
-
passwordMinLengthTooShort() {
|
|
1028
|
-
return new CoreError_1.CoreError("error.transport.passwordMinLengthTooShort", "Minimum password length for a strong password should be 8 characters.");
|
|
1029
|
-
}
|
|
1030
|
-
wrongContentForBuffer() {
|
|
1031
|
-
return new CoreError_1.CoreError("error.transport.wrongContentForBuffer", "The given content cannot be transformed to buffer.");
|
|
1032
|
-
}
|
|
1033
|
-
tooLongCoreIdPrefix(prefix) {
|
|
1034
|
-
return new CoreError_1.CoreError("error.transport.coreid.tooLongPrefix", `The prefix "${prefix}" is too long`);
|
|
1035
|
-
}
|
|
1036
950
|
}
|
|
1037
951
|
class Device {
|
|
1038
|
-
deviceNotSet() {
|
|
1039
|
-
return new CoreError_1.CoreError("error.transport.device.deviceNotSet", "The device must be set");
|
|
1040
|
-
}
|
|
1041
|
-
notOnboardedYet() {
|
|
1042
|
-
return new CoreError_1.CoreError("error.transport.devices.notOnboardedYet", "The device is not onboarded yet and has no public key.");
|
|
1043
|
-
}
|
|
1044
952
|
alreadyOnboarded() {
|
|
1045
953
|
return new CoreError_1.CoreError("error.transport.devices.alreadyOnboarded", "The device has already been onboarded.");
|
|
1046
954
|
}
|
|
@@ -1055,40 +963,14 @@ class Messages {
|
|
|
1055
963
|
signatureNotValid() {
|
|
1056
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.");
|
|
1057
965
|
}
|
|
1058
|
-
noRecipientsSet() {
|
|
1059
|
-
return new CoreError_1.CoreError("error.transport.messages.noRecipientsSet", "No recipients set.");
|
|
1060
|
-
}
|
|
1061
966
|
ownAddressNotInList(messageId) {
|
|
1062
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.`);
|
|
1063
968
|
}
|
|
1064
969
|
noMatchingRelationship(senderAddress) {
|
|
1065
|
-
return new CoreError_1.CoreError("error.transport.messages.noMatchingRelationship", `A relationship with sender ${senderAddress} does not exist
|
|
1066
|
-
}
|
|
1067
|
-
noSecretKeyForOwnMessage(envelopeId) {
|
|
1068
|
-
return new CoreError_1.CoreError(`No secret key found for own message ${envelopeId}`, "The message could not be decrypted, because no secret key was found for it.");
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
class Identity {
|
|
1072
|
-
realmLength() {
|
|
1073
|
-
return new CoreError_1.CoreError("error.transport.identity.realmLength", "Realm must be of length 3.");
|
|
1074
|
-
}
|
|
1075
|
-
identityNotSet() {
|
|
1076
|
-
return new CoreError_1.CoreError("error.transport.identity.identityNotSet", "The identity must be set");
|
|
1077
|
-
}
|
|
1078
|
-
noAddressReceived() {
|
|
1079
|
-
return new CoreError_1.CoreError("error.transport.identity.noAddressReceived", "The backbone did not create an address for the created device.");
|
|
1080
|
-
}
|
|
1081
|
-
addressMismatch() {
|
|
1082
|
-
return new CoreError_1.CoreError("error.transport.identity.addressMismatch", "The backbone address does not match the local address.");
|
|
970
|
+
return new CoreError_1.CoreError("error.transport.messages.noMatchingRelationship", `A relationship with sender ${senderAddress} does not exist.`);
|
|
1083
971
|
}
|
|
1084
972
|
}
|
|
1085
973
|
class Secrets {
|
|
1086
|
-
lengthMismatch() {
|
|
1087
|
-
return new CoreError_1.CoreError("error.transport.secrets.lengthMismatch", "Length mismatch between old number of secrets and new ones.");
|
|
1088
|
-
}
|
|
1089
|
-
wrongBaseKeyType(baseKeyType) {
|
|
1090
|
-
return new CoreError_1.CoreError("error.transport.secrets.wrongBaseKeyType", `Given BaseKey type "${baseKeyType}" is not supported!`);
|
|
1091
|
-
}
|
|
1092
974
|
wrongSecretType(secretId) {
|
|
1093
975
|
return new CoreError_1.CoreError("error.transport.secrets.wrongBaseKeyType", "Given Secret type is not supported!", {
|
|
1094
976
|
secretId: secretId
|
|
@@ -1099,8 +981,8 @@ class Secrets {
|
|
|
1099
981
|
}
|
|
1100
982
|
}
|
|
1101
983
|
class Challenges {
|
|
1102
|
-
|
|
1103
|
-
return new CoreError_1.CoreError("error.transport.challenges.
|
|
984
|
+
challengeTypeRequiresRelationship() {
|
|
985
|
+
return new CoreError_1.CoreError("error.transport.challenges.challengeTypeRequiresRelationship", "The challenge type Relationship requires a relationship.");
|
|
1104
986
|
}
|
|
1105
987
|
}
|
|
1106
988
|
class Datawallet {
|
|
@@ -1123,9 +1005,6 @@ class Datawallet {
|
|
|
1123
1005
|
currentBiggerThanTarget(current, target) {
|
|
1124
1006
|
return new CoreError_1.CoreError("error.transport.datawallet.currentBiggerThanTarget", `The current datawallet version '${current}' is bigger than the target version '${target}'.`);
|
|
1125
1007
|
}
|
|
1126
|
-
noMigrationAvailable(version) {
|
|
1127
|
-
return new CoreError_1.CoreError("error.core.datawallet.noMigrationAvailable", `There is no migration available for the datawallet version '${version}'.`);
|
|
1128
|
-
}
|
|
1129
1008
|
}
|
|
1130
1009
|
class Files {
|
|
1131
1010
|
plaintextHashMismatch() {
|
|
@@ -1137,9 +1016,6 @@ class Files {
|
|
|
1137
1016
|
invalidMetadata(id) {
|
|
1138
1017
|
return new CoreError_1.CoreError("error.transport.files.invalidMetadata", `The metadata of file id "${id}" is invalid.`);
|
|
1139
1018
|
}
|
|
1140
|
-
invalidTruncatedReference() {
|
|
1141
|
-
return new CoreError_1.CoreError("error.transport.files.invalidTruncatedReference", "invalid truncated reference");
|
|
1142
|
-
}
|
|
1143
1019
|
fileContentUndefined() {
|
|
1144
1020
|
return new CoreError_1.CoreError("error.transport.files.fileContentUndefined", "The given file content is undefined.");
|
|
1145
1021
|
}
|
|
@@ -1148,17 +1024,11 @@ class Files {
|
|
|
1148
1024
|
}
|
|
1149
1025
|
}
|
|
1150
1026
|
class Tokens {
|
|
1151
|
-
invalidTruncatedReference() {
|
|
1152
|
-
return new CoreError_1.CoreError("error.transport.tokens.invalidTruncatedReference", "invalid truncated reference");
|
|
1153
|
-
}
|
|
1154
1027
|
invalidTokenContent(id) {
|
|
1155
1028
|
return new CoreError_1.CoreError("error.transport.tokens.invalidTokenContent", `The content of token ${id} is not of type TokenContent`);
|
|
1156
1029
|
}
|
|
1157
1030
|
}
|
|
1158
1031
|
class General {
|
|
1159
|
-
invalidDatawalletVersion() {
|
|
1160
|
-
return new CoreError_1.CoreError("error.transport.general.invalidDatawalletVersion", "The given identity version is invalid. The value must be 0 or higher.");
|
|
1161
|
-
}
|
|
1162
1032
|
baseUrlNotSet() {
|
|
1163
1033
|
return new CoreError_1.CoreError("error.transport.general.baseUrlNotSet", "The baseUrl was not set.");
|
|
1164
1034
|
}
|
|
@@ -1172,7 +1042,7 @@ class General {
|
|
|
1172
1042
|
return new CoreError_1.CoreError("error.transport.general.platformClientInvalid", "The combination of platform clientId and clientSecret is invalid.");
|
|
1173
1043
|
}
|
|
1174
1044
|
cacheEmpty(entityName, id) {
|
|
1175
|
-
return new
|
|
1045
|
+
return new Error(`The cache of ${entityName instanceof Function ? entityName.name : entityName} with id "${id}" is empty.`);
|
|
1176
1046
|
}
|
|
1177
1047
|
incompatibleBackbone() {
|
|
1178
1048
|
return new CoreError_1.CoreError("error.transport.incompatibleBackbone", "The backbone sent an invalid payload.");
|
|
@@ -1183,30 +1053,21 @@ class General {
|
|
|
1183
1053
|
recordNotFound(entityName, entityId) {
|
|
1184
1054
|
return new CoreError_1.CoreError("error.transport.recordNotFound", `'${entityName instanceof Function ? entityName.name : entityName}' not found.`, entityId);
|
|
1185
1055
|
}
|
|
1186
|
-
|
|
1187
|
-
return new CoreError_1.CoreError("error.transport.
|
|
1188
|
-
}
|
|
1189
|
-
typeNotInReflection(type) {
|
|
1190
|
-
return new CoreError_1.CoreError("error.transport.typeNotInReflectionClass", `The type ${type} was not in the reflection classes. You might have to install a module first.`);
|
|
1191
|
-
}
|
|
1192
|
-
datawalletNotAvailable() {
|
|
1193
|
-
return new CoreError_1.CoreError("error.transport.datawalletNotAvailable", "The datawallet is not available (yet?) and was requested.");
|
|
1056
|
+
notSupported() {
|
|
1057
|
+
return new CoreError_1.CoreError("error.transport.notSupported", "The method is not yet supported.");
|
|
1194
1058
|
}
|
|
1195
|
-
|
|
1196
|
-
return new CoreError_1.CoreError("error.transport.
|
|
1059
|
+
realmLength() {
|
|
1060
|
+
return new CoreError_1.CoreError("error.transport.identity.realmLength", "Realm must be of length 3.");
|
|
1197
1061
|
}
|
|
1198
|
-
|
|
1199
|
-
return new CoreError_1.CoreError("error.transport.
|
|
1062
|
+
invalidTruncatedReference() {
|
|
1063
|
+
return new CoreError_1.CoreError("error.transport.files.invalidTruncatedReference", "invalid truncated reference");
|
|
1200
1064
|
}
|
|
1201
1065
|
}
|
|
1202
1066
|
class TransportErrors {
|
|
1203
1067
|
}
|
|
1204
1068
|
exports.TransportErrors = TransportErrors;
|
|
1205
|
-
TransportErrors.controller = new Controller();
|
|
1206
1069
|
TransportErrors.relationships = new Relationships();
|
|
1207
|
-
TransportErrors.util = new Util();
|
|
1208
1070
|
TransportErrors.general = new General();
|
|
1209
|
-
TransportErrors.identity = new Identity();
|
|
1210
1071
|
TransportErrors.messages = new Messages();
|
|
1211
1072
|
TransportErrors.secrets = new Secrets();
|
|
1212
1073
|
TransportErrors.device = new Device();
|
|
@@ -1214,7 +1075,6 @@ TransportErrors.files = new Files();
|
|
|
1214
1075
|
TransportErrors.challenges = new Challenges();
|
|
1215
1076
|
TransportErrors.datawallet = new Datawallet();
|
|
1216
1077
|
TransportErrors.tokens = new Tokens();
|
|
1217
|
-
TransportErrors.relationshipTemplates = new RelationshipTemplates();
|
|
1218
1078
|
//# sourceMappingURL=TransportErrors.js.map
|
|
1219
1079
|
|
|
1220
1080
|
/***/ }),
|
|
@@ -1246,20 +1106,19 @@ TransportIds.datawalletModification = new CoreIdHelper_1.CoreIdHelper("TRPDWM");
|
|
|
1246
1106
|
/*!*********************************************!*\
|
|
1247
1107
|
!*** ./dist/core/TransportLoggerFactory.js ***!
|
|
1248
1108
|
\*********************************************/
|
|
1249
|
-
/***/ ((__unused_webpack_module, exports
|
|
1109
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
1250
1110
|
|
|
1251
1111
|
"use strict";
|
|
1252
1112
|
|
|
1253
1113
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1254
1114
|
exports.TransportLoggerFactory = void 0;
|
|
1255
|
-
const TransportErrors_1 = __webpack_require__(/*! ./TransportErrors */ "./dist/core/TransportErrors.js");
|
|
1256
1115
|
class TransportLoggerFactory {
|
|
1257
1116
|
static init(instance) {
|
|
1258
1117
|
this.instance = instance;
|
|
1259
1118
|
}
|
|
1260
1119
|
static getLogger(name) {
|
|
1261
1120
|
if (!this.isInitialized()) {
|
|
1262
|
-
throw
|
|
1121
|
+
throw new Error("The logger factory is not yet initialized. Call TransportLoggerFactory.init() first.");
|
|
1263
1122
|
}
|
|
1264
1123
|
if (typeof name === "function") {
|
|
1265
1124
|
return this.instance.getLogger(`Transport.${name.name}`);
|
|
@@ -2359,7 +2218,6 @@ exports.CoreDate = void 0;
|
|
|
2359
2218
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2360
2219
|
const luxon_1 = __webpack_require__(/*! luxon */ "./node_modules/luxon/build/node/luxon.js");
|
|
2361
2220
|
const CoreSerializable_1 = __webpack_require__(/*! ../CoreSerializable */ "./dist/core/CoreSerializable.js");
|
|
2362
|
-
const TransportErrors_1 = __webpack_require__(/*! ../TransportErrors */ "./dist/core/TransportErrors.js");
|
|
2363
2221
|
let CoreDate = CoreDate_1 = class CoreDate extends CoreSerializable_1.CoreSerializable {
|
|
2364
2222
|
constructor(dateTime = luxon_1.DateTime.utc()) {
|
|
2365
2223
|
super();
|
|
@@ -2472,12 +2330,12 @@ let CoreDate = CoreDate_1 = class CoreDate extends CoreSerializable_1.CoreSerial
|
|
|
2472
2330
|
}
|
|
2473
2331
|
static preFrom(value) {
|
|
2474
2332
|
if (typeof value === "undefined") {
|
|
2475
|
-
throw
|
|
2333
|
+
throw new Error("The provided object is undefined and cannot be deserialized.");
|
|
2476
2334
|
}
|
|
2477
2335
|
if (typeof value === "object") {
|
|
2478
2336
|
if (typeof value.date === "undefined") {
|
|
2479
2337
|
if (typeof value.toISOString !== "function") {
|
|
2480
|
-
throw
|
|
2338
|
+
throw new Error("The provided object doesn't have an 'toISOString' string method.");
|
|
2481
2339
|
}
|
|
2482
2340
|
const iso = value.toISOString();
|
|
2483
2341
|
return luxon_1.DateTime.fromISO(iso, { zone: "utc" });
|
|
@@ -2490,7 +2348,7 @@ let CoreDate = CoreDate_1 = class CoreDate extends CoreSerializable_1.CoreSerial
|
|
|
2490
2348
|
if (typeof value === "string") {
|
|
2491
2349
|
return luxon_1.DateTime.fromISO(value, { zone: "utc" }).toUTC();
|
|
2492
2350
|
}
|
|
2493
|
-
throw
|
|
2351
|
+
throw new Error("The provided object is invalid cannot be deserialized.");
|
|
2494
2352
|
}
|
|
2495
2353
|
static from(value) {
|
|
2496
2354
|
return this.fromAny(value);
|
|
@@ -2612,7 +2470,6 @@ exports.CoreId = void 0;
|
|
|
2612
2470
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2613
2471
|
const Random_1 = __webpack_require__(/*! ../../util/Random */ "./dist/util/Random.js");
|
|
2614
2472
|
const CoreSerializable_1 = __webpack_require__(/*! ../CoreSerializable */ "./dist/core/CoreSerializable.js");
|
|
2615
|
-
const TransportErrors_1 = __webpack_require__(/*! ../TransportErrors */ "./dist/core/TransportErrors.js");
|
|
2616
2473
|
/**
|
|
2617
2474
|
* A CoreId is any kind of identifier we have in the system.
|
|
2618
2475
|
*/
|
|
@@ -2625,7 +2482,7 @@ let CoreId = class CoreId extends CoreSerializable_1.CoreSerializable {
|
|
|
2625
2482
|
}
|
|
2626
2483
|
static async generate(prefix = "") {
|
|
2627
2484
|
if (prefix.length > 6) {
|
|
2628
|
-
throw
|
|
2485
|
+
throw new Error(`The prefix "${prefix}" is too long. It must not be longer than 6 characters.`);
|
|
2629
2486
|
}
|
|
2630
2487
|
const random = await Random_1.Random.string(20 - prefix.length, Random_1.RandomCharacterRange.Alphanumeric);
|
|
2631
2488
|
return this.from(prefix.toUpperCase() + random);
|
|
@@ -2909,12 +2766,22 @@ __exportStar(__webpack_require__(/*! ./util */ "./dist/util/index.js"), exports)
|
|
|
2909
2766
|
/*!****************************************************!*\
|
|
2910
2767
|
!*** ./dist/modules/accounts/AccountController.js ***!
|
|
2911
2768
|
\****************************************************/
|
|
2912
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
2769
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2913
2770
|
|
|
2914
2771
|
"use strict";
|
|
2915
2772
|
|
|
2773
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2774
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2775
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2776
|
+
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;
|
|
2777
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2778
|
+
};
|
|
2779
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
2780
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2781
|
+
};
|
|
2916
2782
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2917
2783
|
exports.AccountController = void 0;
|
|
2784
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
2918
2785
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
2919
2786
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
2920
2787
|
const Authenticator_1 = __webpack_require__(/*! ../../core/backbone/Authenticator */ "./dist/core/backbone/Authenticator.js");
|
|
@@ -2933,6 +2800,7 @@ const DevicesController_1 = __webpack_require__(/*! ../devices/DevicesController
|
|
|
2933
2800
|
const DeviceSecretController_1 = __webpack_require__(/*! ../devices/DeviceSecretController */ "./dist/modules/devices/DeviceSecretController.js");
|
|
2934
2801
|
const Device_1 = __webpack_require__(/*! ../devices/local/Device */ "./dist/modules/devices/local/Device.js");
|
|
2935
2802
|
const DeviceSecretCredentials_1 = __webpack_require__(/*! ../devices/local/DeviceSecretCredentials */ "./dist/modules/devices/local/DeviceSecretCredentials.js");
|
|
2803
|
+
const DeviceSharedSecret_1 = __webpack_require__(/*! ../devices/transmission/DeviceSharedSecret */ "./dist/modules/devices/transmission/DeviceSharedSecret.js");
|
|
2936
2804
|
const FileController_1 = __webpack_require__(/*! ../files/FileController */ "./dist/modules/files/FileController.js");
|
|
2937
2805
|
const MessageController_1 = __webpack_require__(/*! ../messages/MessageController */ "./dist/modules/messages/MessageController.js");
|
|
2938
2806
|
const RelationshipsController_1 = __webpack_require__(/*! ../relationships/RelationshipsController */ "./dist/modules/relationships/RelationshipsController.js");
|
|
@@ -2961,6 +2829,9 @@ class AccountController {
|
|
|
2961
2829
|
get authenticator() {
|
|
2962
2830
|
return this._authenticator;
|
|
2963
2831
|
}
|
|
2832
|
+
get log() {
|
|
2833
|
+
return this._log;
|
|
2834
|
+
}
|
|
2964
2835
|
get config() {
|
|
2965
2836
|
return this._config;
|
|
2966
2837
|
}
|
|
@@ -3031,7 +2902,7 @@ class AccountController {
|
|
|
3031
2902
|
this.deviceAuthClient = new DeviceAuthClient_1.DeviceAuthClient(this.config, this.authenticator);
|
|
3032
2903
|
}
|
|
3033
2904
|
else {
|
|
3034
|
-
throw
|
|
2905
|
+
throw new Error("The combination of deviceSharedSecret, existing identity or device is not allowed.");
|
|
3035
2906
|
}
|
|
3036
2907
|
this._log.trace(`Using device ${this.activeDevice.id} for identity ${this.identity.address}.`);
|
|
3037
2908
|
await this.initControllers();
|
|
@@ -3093,7 +2964,6 @@ class AccountController {
|
|
|
3093
2964
|
return await this.synchronization.getLastCompletedDatawalletSyncTime();
|
|
3094
2965
|
}
|
|
3095
2966
|
async createIdentityAndDevice(realm = Identity_1.Realm.Prod) {
|
|
3096
|
-
this._log.trace(`Creating new identity for realm ${realm}...`);
|
|
3097
2967
|
const [identityKeypair, devicePwdD1, deviceKeypair, privBaseShared, privBaseDevice] = await Promise.all([
|
|
3098
2968
|
// Generate identity keypair
|
|
3099
2969
|
CoreCrypto_1.CoreCrypto.generateSignatureKeypair(),
|
|
@@ -3128,16 +2998,13 @@ class AccountController {
|
|
|
3128
2998
|
if (deviceResponseResult.isError) {
|
|
3129
2999
|
const error = deviceResponseResult.error;
|
|
3130
3000
|
if (error.code === "error.platform.unauthorized") {
|
|
3131
|
-
throw core_1.TransportErrors.general.platformClientInvalid()
|
|
3001
|
+
throw core_1.TransportErrors.general.platformClientInvalid();
|
|
3132
3002
|
}
|
|
3133
3003
|
}
|
|
3134
3004
|
const deviceResponse = deviceResponseResult.value;
|
|
3135
3005
|
this._log.trace(`Registered identity with address ${deviceResponse.address}, device id is ${deviceResponse.device.id}.`);
|
|
3136
|
-
if (!deviceResponse.address) {
|
|
3137
|
-
throw
|
|
3138
|
-
}
|
|
3139
|
-
if (localAddress.toString() !== deviceResponse.address) {
|
|
3140
|
-
throw core_1.TransportErrors.identity.addressMismatch().logWith(this._log);
|
|
3006
|
+
if (!localAddress.equals(deviceResponse.address)) {
|
|
3007
|
+
throw new Error("The backbone address does not match the local address.");
|
|
3141
3008
|
}
|
|
3142
3009
|
const identity = Identity_1.Identity.from({
|
|
3143
3010
|
address: core_1.CoreAddress.from(deviceResponse.address),
|
|
@@ -3248,6 +3115,18 @@ class AccountController {
|
|
|
3248
3115
|
return new SynchronizedCollection_1.SynchronizedCollection(collection, this.config.supportedDatawalletVersion, this.unpushedDatawalletModifications);
|
|
3249
3116
|
}
|
|
3250
3117
|
}
|
|
3118
|
+
__decorate([
|
|
3119
|
+
(0, ts_utils_1.log)(),
|
|
3120
|
+
__metadata("design:type", Function),
|
|
3121
|
+
__metadata("design:paramtypes", [DeviceSharedSecret_1.DeviceSharedSecret]),
|
|
3122
|
+
__metadata("design:returntype", Promise)
|
|
3123
|
+
], AccountController.prototype, "init", null);
|
|
3124
|
+
__decorate([
|
|
3125
|
+
(0, ts_utils_1.log)(),
|
|
3126
|
+
__metadata("design:type", Function),
|
|
3127
|
+
__metadata("design:paramtypes", [String]),
|
|
3128
|
+
__metadata("design:returntype", Promise)
|
|
3129
|
+
], AccountController.prototype, "createIdentityAndDevice", null);
|
|
3251
3130
|
exports.AccountController = AccountController;
|
|
3252
3131
|
//# sourceMappingURL=AccountController.js.map
|
|
3253
3132
|
|
|
@@ -3257,15 +3136,26 @@ exports.AccountController = AccountController;
|
|
|
3257
3136
|
/*!*****************************************************!*\
|
|
3258
3137
|
!*** ./dist/modules/accounts/IdentityController.js ***!
|
|
3259
3138
|
\*****************************************************/
|
|
3260
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
3139
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3261
3140
|
|
|
3262
3141
|
"use strict";
|
|
3263
3142
|
|
|
3143
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3144
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3145
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3146
|
+
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;
|
|
3147
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3148
|
+
};
|
|
3149
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
3150
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3151
|
+
};
|
|
3264
3152
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3265
3153
|
exports.IdentityController = void 0;
|
|
3154
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
3266
3155
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
3267
3156
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
3268
3157
|
const DeviceSecretController_1 = __webpack_require__(/*! ../devices/DeviceSecretController */ "./dist/modules/devices/DeviceSecretController.js");
|
|
3158
|
+
const Identity_1 = __webpack_require__(/*! ./data/Identity */ "./dist/modules/accounts/data/Identity.js");
|
|
3269
3159
|
class IdentityController extends core_1.TransportController {
|
|
3270
3160
|
constructor(parent) {
|
|
3271
3161
|
super(core_1.ControllerName.Identity, parent);
|
|
@@ -3284,9 +3174,6 @@ class IdentityController extends core_1.TransportController {
|
|
|
3284
3174
|
}
|
|
3285
3175
|
async init(identity) {
|
|
3286
3176
|
await super.init();
|
|
3287
|
-
if (!identity) {
|
|
3288
|
-
throw core_1.TransportErrors.identity.identityNotSet().logWith(this._log);
|
|
3289
|
-
}
|
|
3290
3177
|
this._identity = identity;
|
|
3291
3178
|
return this;
|
|
3292
3179
|
}
|
|
@@ -3299,7 +3186,7 @@ class IdentityController extends core_1.TransportController {
|
|
|
3299
3186
|
async sign(content) {
|
|
3300
3187
|
const privateKeyContainer = await this.parent.activeDevice.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.IdentitySignature);
|
|
3301
3188
|
if (!privateKeyContainer || !(privateKeyContainer.secret instanceof crypto_1.CryptoSignaturePrivateKey)) {
|
|
3302
|
-
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.IdentitySignature)
|
|
3189
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.IdentitySignature);
|
|
3303
3190
|
}
|
|
3304
3191
|
const privateKey = privateKeyContainer.secret;
|
|
3305
3192
|
const signature = await core_1.CoreCrypto.sign(content, privateKey);
|
|
@@ -3311,6 +3198,18 @@ class IdentityController extends core_1.TransportController {
|
|
|
3311
3198
|
return valid;
|
|
3312
3199
|
}
|
|
3313
3200
|
}
|
|
3201
|
+
__decorate([
|
|
3202
|
+
(0, ts_utils_1.log)(),
|
|
3203
|
+
__metadata("design:type", Function),
|
|
3204
|
+
__metadata("design:paramtypes", [Identity_1.Identity]),
|
|
3205
|
+
__metadata("design:returntype", Promise)
|
|
3206
|
+
], IdentityController.prototype, "init", null);
|
|
3207
|
+
__decorate([
|
|
3208
|
+
(0, ts_utils_1.log)(),
|
|
3209
|
+
__metadata("design:type", Function),
|
|
3210
|
+
__metadata("design:paramtypes", [crypto_1.CoreBuffer]),
|
|
3211
|
+
__metadata("design:returntype", Promise)
|
|
3212
|
+
], IdentityController.prototype, "sign", null);
|
|
3314
3213
|
exports.IdentityController = IdentityController;
|
|
3315
3214
|
//# sourceMappingURL=IdentityController.js.map
|
|
3316
3215
|
|
|
@@ -3329,10 +3228,9 @@ exports.IdentityUtil = void 0;
|
|
|
3329
3228
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
3330
3229
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
3331
3230
|
class IdentityUtil {
|
|
3332
|
-
static async createAddress(publicKey, realm
|
|
3333
|
-
if (realm
|
|
3334
|
-
throw core_1.TransportErrors.
|
|
3335
|
-
}
|
|
3231
|
+
static async createAddress(publicKey, realm) {
|
|
3232
|
+
if (realm.length !== 3)
|
|
3233
|
+
throw core_1.TransportErrors.general.realmLength();
|
|
3336
3234
|
const sha512buffer = await crypto_1.CryptoHash.hash(publicKey.publicKey, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
3337
3235
|
const hash = await crypto_1.CryptoHash.hash(sha512buffer, 1 /* CryptoHashAlgorithm.SHA256 */);
|
|
3338
3236
|
const hashedPublicKey = new crypto_1.CoreBuffer(hash.buffer.slice(0, 20));
|
|
@@ -4367,12 +4265,22 @@ exports.CertificateRoleItem = CertificateRoleItem;
|
|
|
4367
4265
|
/*!********************************************************!*\
|
|
4368
4266
|
!*** ./dist/modules/challenges/ChallengeController.js ***!
|
|
4369
4267
|
\********************************************************/
|
|
4370
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
4268
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4371
4269
|
|
|
4372
4270
|
"use strict";
|
|
4373
4271
|
|
|
4272
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4273
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4274
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4275
|
+
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;
|
|
4276
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4277
|
+
};
|
|
4278
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
4279
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4280
|
+
};
|
|
4374
4281
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4375
4282
|
exports.ChallengeController = void 0;
|
|
4283
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
4376
4284
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
4377
4285
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
4378
4286
|
const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
|
|
@@ -4405,7 +4313,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4405
4313
|
isValid = await this.parent.relationships.verifyIdentity(relationship, challengeBuffer, signedChallenge.signature);
|
|
4406
4314
|
break;
|
|
4407
4315
|
case Challenge_1.ChallengeType.Device:
|
|
4408
|
-
throw core_1.TransportErrors.general.
|
|
4316
|
+
throw core_1.TransportErrors.general.notSupported();
|
|
4409
4317
|
case Challenge_1.ChallengeType.Relationship:
|
|
4410
4318
|
isValid = await this.parent.relationships.verify(relationship, challengeBuffer, signedChallenge.signature);
|
|
4411
4319
|
break;
|
|
@@ -4449,7 +4357,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4449
4357
|
}
|
|
4450
4358
|
async createChallenge(type = Challenge_1.ChallengeType.Identity, relationship) {
|
|
4451
4359
|
if (type === Challenge_1.ChallengeType.Relationship && !relationship) {
|
|
4452
|
-
throw core_1.TransportErrors.challenges.
|
|
4360
|
+
throw core_1.TransportErrors.challenges.challengeTypeRequiresRelationship();
|
|
4453
4361
|
}
|
|
4454
4362
|
const backboneResponse = (await this.authClient.createChallenge()).value;
|
|
4455
4363
|
const challenge = Challenge_1.Challenge.from({
|
|
@@ -4473,7 +4381,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4473
4381
|
break;
|
|
4474
4382
|
case Challenge_1.ChallengeType.Relationship:
|
|
4475
4383
|
if (!relationship) {
|
|
4476
|
-
throw core_1.TransportErrors.challenges.
|
|
4384
|
+
throw core_1.TransportErrors.challenges.challengeTypeRequiresRelationship();
|
|
4477
4385
|
}
|
|
4478
4386
|
signature = await this.parent.relationships.sign(relationship, challengeBuffer);
|
|
4479
4387
|
break;
|
|
@@ -4485,6 +4393,19 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4485
4393
|
return signedChallenge;
|
|
4486
4394
|
}
|
|
4487
4395
|
}
|
|
4396
|
+
__decorate([
|
|
4397
|
+
(0, ts_utils_1.log)(),
|
|
4398
|
+
__metadata("design:type", Function),
|
|
4399
|
+
__metadata("design:paramtypes", [Challenge_1.Challenge,
|
|
4400
|
+
ChallengeSigned_1.ChallengeSigned]),
|
|
4401
|
+
__metadata("design:returntype", Promise)
|
|
4402
|
+
], ChallengeController.prototype, "validateChallengeLocally", null);
|
|
4403
|
+
__decorate([
|
|
4404
|
+
(0, ts_utils_1.log)(),
|
|
4405
|
+
__metadata("design:type", Function),
|
|
4406
|
+
__metadata("design:paramtypes", [String, Relationship_1.Relationship]),
|
|
4407
|
+
__metadata("design:returntype", Promise)
|
|
4408
|
+
], ChallengeController.prototype, "createChallenge", null);
|
|
4488
4409
|
exports.ChallengeController = ChallengeController;
|
|
4489
4410
|
//# sourceMappingURL=ChallengeController.js.map
|
|
4490
4411
|
|
|
@@ -4663,15 +4584,26 @@ exports.ChallengeSigned = ChallengeSigned;
|
|
|
4663
4584
|
/*!**************************************************!*\
|
|
4664
4585
|
!*** ./dist/modules/devices/DeviceController.js ***!
|
|
4665
4586
|
\**************************************************/
|
|
4666
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
4587
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4667
4588
|
|
|
4668
4589
|
"use strict";
|
|
4669
4590
|
|
|
4591
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4592
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4593
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4594
|
+
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;
|
|
4595
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4596
|
+
};
|
|
4597
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
4598
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4599
|
+
};
|
|
4670
4600
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4671
4601
|
exports.DeviceController = void 0;
|
|
4602
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
4672
4603
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
4673
4604
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
4674
4605
|
const DeviceSecretController_1 = __webpack_require__(/*! ./DeviceSecretController */ "./dist/modules/devices/DeviceSecretController.js");
|
|
4606
|
+
const Device_1 = __webpack_require__(/*! ./local/Device */ "./dist/modules/devices/local/Device.js");
|
|
4675
4607
|
const DeviceSecretCredentials_1 = __webpack_require__(/*! ./local/DeviceSecretCredentials */ "./dist/modules/devices/local/DeviceSecretCredentials.js");
|
|
4676
4608
|
class DeviceController extends core_1.TransportController {
|
|
4677
4609
|
constructor(parent) {
|
|
@@ -4706,7 +4638,7 @@ class DeviceController extends core_1.TransportController {
|
|
|
4706
4638
|
}
|
|
4707
4639
|
get device() {
|
|
4708
4640
|
if (!this._device)
|
|
4709
|
-
throw
|
|
4641
|
+
throw new Error("The Device controller is not initialized.");
|
|
4710
4642
|
return this._device;
|
|
4711
4643
|
}
|
|
4712
4644
|
get deviceOrUndefined() {
|
|
@@ -4714,12 +4646,6 @@ class DeviceController extends core_1.TransportController {
|
|
|
4714
4646
|
}
|
|
4715
4647
|
async init(baseKey, device) {
|
|
4716
4648
|
await super.init();
|
|
4717
|
-
if (!device) {
|
|
4718
|
-
throw core_1.TransportErrors.device.deviceNotSet().logWith(this._log);
|
|
4719
|
-
}
|
|
4720
|
-
if (!baseKey) {
|
|
4721
|
-
throw core_1.TransportErrors.secrets.secretNotFound("BaseKey").logWith(this._log);
|
|
4722
|
-
}
|
|
4723
4649
|
this._device = device;
|
|
4724
4650
|
this._secrets = await new DeviceSecretController_1.DeviceSecretController(this.parent, baseKey).init();
|
|
4725
4651
|
return this;
|
|
@@ -4758,7 +4684,7 @@ class DeviceController extends core_1.TransportController {
|
|
|
4758
4684
|
async sign(content) {
|
|
4759
4685
|
const privateKeyContainer = await this.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.DeviceSignature);
|
|
4760
4686
|
if (!privateKeyContainer || !(privateKeyContainer.secret instanceof crypto_1.CryptoSignaturePrivateKey)) {
|
|
4761
|
-
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceSignature)
|
|
4687
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceSignature);
|
|
4762
4688
|
}
|
|
4763
4689
|
const privateKey = privateKeyContainer.secret;
|
|
4764
4690
|
const signature = await core_1.CoreCrypto.sign(content, privateKey);
|
|
@@ -4767,21 +4693,21 @@ class DeviceController extends core_1.TransportController {
|
|
|
4767
4693
|
}
|
|
4768
4694
|
async verify(content, signature) {
|
|
4769
4695
|
if (!this.publicKey) {
|
|
4770
|
-
throw
|
|
4696
|
+
throw new Error("The device has no public key to verify a signature. This can happen if the device is not onboarded yet.");
|
|
4771
4697
|
}
|
|
4772
4698
|
return await core_1.CoreCrypto.verify(content, signature, this.publicKey);
|
|
4773
4699
|
}
|
|
4774
4700
|
async getCredentials() {
|
|
4775
4701
|
const credentialContainer = await this.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4776
4702
|
if (!credentialContainer) {
|
|
4777
|
-
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceCredentials)
|
|
4703
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4778
4704
|
}
|
|
4779
4705
|
if (!(credentialContainer.secret instanceof DeviceSecretCredentials_1.DeviceSecretCredentials)) {
|
|
4780
|
-
throw core_1.TransportErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials)
|
|
4706
|
+
throw core_1.TransportErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4781
4707
|
}
|
|
4782
4708
|
const credentials = credentialContainer.secret;
|
|
4783
4709
|
if (!credentials.username || !credentials.password) {
|
|
4784
|
-
throw core_1.TransportErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials)
|
|
4710
|
+
throw core_1.TransportErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4785
4711
|
}
|
|
4786
4712
|
return {
|
|
4787
4713
|
username: credentials.username,
|
|
@@ -4789,6 +4715,30 @@ class DeviceController extends core_1.TransportController {
|
|
|
4789
4715
|
};
|
|
4790
4716
|
}
|
|
4791
4717
|
}
|
|
4718
|
+
__decorate([
|
|
4719
|
+
(0, ts_utils_1.log)(),
|
|
4720
|
+
__metadata("design:type", Function),
|
|
4721
|
+
__metadata("design:paramtypes", [crypto_1.CryptoSecretKey, Device_1.Device]),
|
|
4722
|
+
__metadata("design:returntype", Promise)
|
|
4723
|
+
], DeviceController.prototype, "init", null);
|
|
4724
|
+
__decorate([
|
|
4725
|
+
(0, ts_utils_1.log)(),
|
|
4726
|
+
__metadata("design:type", Function),
|
|
4727
|
+
__metadata("design:paramtypes", [crypto_1.CoreBuffer]),
|
|
4728
|
+
__metadata("design:returntype", Promise)
|
|
4729
|
+
], DeviceController.prototype, "sign", null);
|
|
4730
|
+
__decorate([
|
|
4731
|
+
(0, ts_utils_1.log)(),
|
|
4732
|
+
__metadata("design:type", Function),
|
|
4733
|
+
__metadata("design:paramtypes", [crypto_1.CoreBuffer, crypto_1.CryptoSignature]),
|
|
4734
|
+
__metadata("design:returntype", Promise)
|
|
4735
|
+
], DeviceController.prototype, "verify", null);
|
|
4736
|
+
__decorate([
|
|
4737
|
+
(0, ts_utils_1.log)(),
|
|
4738
|
+
__metadata("design:type", Function),
|
|
4739
|
+
__metadata("design:paramtypes", []),
|
|
4740
|
+
__metadata("design:returntype", Promise)
|
|
4741
|
+
], DeviceController.prototype, "getCredentials", null);
|
|
4792
4742
|
exports.DeviceController = DeviceController;
|
|
4793
4743
|
//# sourceMappingURL=DeviceController.js.map
|
|
4794
4744
|
|
|
@@ -4798,19 +4748,31 @@ exports.DeviceController = DeviceController;
|
|
|
4798
4748
|
/*!********************************************************!*\
|
|
4799
4749
|
!*** ./dist/modules/devices/DeviceSecretController.js ***!
|
|
4800
4750
|
\********************************************************/
|
|
4801
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
4751
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4802
4752
|
|
|
4803
4753
|
"use strict";
|
|
4804
4754
|
|
|
4755
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4756
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4757
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4758
|
+
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;
|
|
4759
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4760
|
+
};
|
|
4761
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
4762
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4763
|
+
};
|
|
4805
4764
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4806
4765
|
exports.DeviceSecretController = exports.DeviceSecretType = void 0;
|
|
4807
4766
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
4767
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
4808
4768
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
4809
4769
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
4810
4770
|
const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
|
|
4811
4771
|
const TransportIds_1 = __webpack_require__(/*! ../../core/TransportIds */ "./dist/core/TransportIds.js");
|
|
4812
4772
|
const SecretContainerCipher_1 = __webpack_require__(/*! ../secrets/data/SecretContainerCipher */ "./dist/modules/secrets/data/SecretContainerCipher.js");
|
|
4813
4773
|
const SecretContainerPlain_1 = __webpack_require__(/*! ../secrets/data/SecretContainerPlain */ "./dist/modules/secrets/data/SecretContainerPlain.js");
|
|
4774
|
+
const DatawalletModification_1 = __webpack_require__(/*! ../sync/local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js");
|
|
4775
|
+
const Device_1 = __webpack_require__(/*! ./local/Device */ "./dist/modules/devices/local/Device.js");
|
|
4814
4776
|
const DeviceSharedSecret_1 = __webpack_require__(/*! ./transmission/DeviceSharedSecret */ "./dist/modules/devices/transmission/DeviceSharedSecret.js");
|
|
4815
4777
|
var DeviceSecretType;
|
|
4816
4778
|
(function (DeviceSecretType) {
|
|
@@ -4889,17 +4851,17 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4889
4851
|
async createDeviceSharedSecret(device, deviceIndex, includeIdentityPrivateKey = false) {
|
|
4890
4852
|
const synchronizationKey = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4891
4853
|
if (!synchronizationKey || !(synchronizationKey.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4892
|
-
throw core_1.TransportErrors.secrets.secretNotFound("SynchronizationKey")
|
|
4854
|
+
throw core_1.TransportErrors.secrets.secretNotFound("SynchronizationKey");
|
|
4893
4855
|
}
|
|
4894
4856
|
const baseKey = await this.loadSecret(DeviceSecretType.SharedSecretBaseKey);
|
|
4895
4857
|
if (!baseKey || !(baseKey.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4896
|
-
throw core_1.TransportErrors.secrets.secretNotFound("baseKey")
|
|
4858
|
+
throw core_1.TransportErrors.secrets.secretNotFound("baseKey");
|
|
4897
4859
|
}
|
|
4898
4860
|
let identityPrivateKey;
|
|
4899
4861
|
if (includeIdentityPrivateKey) {
|
|
4900
4862
|
identityPrivateKey = await this.loadSecret(DeviceSecretType.IdentitySignature);
|
|
4901
4863
|
if (!identityPrivateKey || !(identityPrivateKey.secret instanceof crypto_1.CryptoSignaturePrivateKey)) {
|
|
4902
|
-
throw core_1.TransportErrors.secrets.secretNotFound("IdentityKey")
|
|
4864
|
+
throw core_1.TransportErrors.secrets.secretNotFound("IdentityKey");
|
|
4903
4865
|
}
|
|
4904
4866
|
}
|
|
4905
4867
|
const deviceSharedSecret = DeviceSharedSecret_1.DeviceSharedSecret.from({
|
|
@@ -4926,9 +4888,7 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4926
4888
|
const serializedEvent = crypto_1.CoreBuffer.fromUtf8(JSON.stringify(event.payload));
|
|
4927
4889
|
const privSync = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4928
4890
|
if (!privSync || !(privSync.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4929
|
-
throw core_1.TransportErrors.secrets
|
|
4930
|
-
.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster)
|
|
4931
|
-
.logWith(this._log);
|
|
4891
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4932
4892
|
}
|
|
4933
4893
|
const encryptionKey = await core_1.CoreCrypto.deriveKeyFromBase(privSync.secret, index, "DataSync");
|
|
4934
4894
|
const cipher = await core_1.CoreCrypto.encrypt(serializedEvent, encryptionKey);
|
|
@@ -4942,9 +4902,7 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4942
4902
|
const payloadCipher = crypto_1.CryptoCipher.fromBase64(payloadCipherBase64);
|
|
4943
4903
|
const privSync = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4944
4904
|
if (!privSync || !(privSync.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4945
|
-
throw core_1.TransportErrors.secrets
|
|
4946
|
-
.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster)
|
|
4947
|
-
.logWith(this._log);
|
|
4905
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4948
4906
|
}
|
|
4949
4907
|
const decryptionKey = await core_1.CoreCrypto.deriveKeyFromBase(privSync.secret, index, "DataSync");
|
|
4950
4908
|
const plaintext = await core_1.CoreCrypto.decrypt(payloadCipher, decryptionKey);
|
|
@@ -4954,15 +4912,37 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4954
4912
|
}
|
|
4955
4913
|
getBaseKey() {
|
|
4956
4914
|
if (!this.baseKey) {
|
|
4957
|
-
throw core_1.TransportErrors.general
|
|
4958
|
-
.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretType.SharedSecretBaseKey)
|
|
4959
|
-
.logWith(this._log);
|
|
4915
|
+
throw core_1.TransportErrors.general.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretType.SharedSecretBaseKey);
|
|
4960
4916
|
}
|
|
4961
4917
|
return this.baseKey;
|
|
4962
4918
|
}
|
|
4963
4919
|
}
|
|
4964
|
-
exports.DeviceSecretController = DeviceSecretController;
|
|
4965
4920
|
DeviceSecretController.secretContext = "DEVICE01";
|
|
4921
|
+
__decorate([
|
|
4922
|
+
(0, ts_utils_1.log)(),
|
|
4923
|
+
__metadata("design:type", Function),
|
|
4924
|
+
__metadata("design:paramtypes", [Device_1.Device, Number, Object]),
|
|
4925
|
+
__metadata("design:returntype", Promise)
|
|
4926
|
+
], DeviceSecretController.prototype, "createDeviceSharedSecret", null);
|
|
4927
|
+
__decorate([
|
|
4928
|
+
(0, ts_utils_1.log)(),
|
|
4929
|
+
__metadata("design:type", Function),
|
|
4930
|
+
__metadata("design:paramtypes", [DatawalletModification_1.DatawalletModification, Number]),
|
|
4931
|
+
__metadata("design:returntype", Promise)
|
|
4932
|
+
], DeviceSecretController.prototype, "encryptDatawalletModificationPayload", null);
|
|
4933
|
+
__decorate([
|
|
4934
|
+
(0, ts_utils_1.log)(),
|
|
4935
|
+
__metadata("design:type", Function),
|
|
4936
|
+
__metadata("design:paramtypes", [Object, Number]),
|
|
4937
|
+
__metadata("design:returntype", Promise)
|
|
4938
|
+
], DeviceSecretController.prototype, "decryptDatawalletModificationPayload", null);
|
|
4939
|
+
__decorate([
|
|
4940
|
+
(0, ts_utils_1.log)(),
|
|
4941
|
+
__metadata("design:type", Function),
|
|
4942
|
+
__metadata("design:paramtypes", []),
|
|
4943
|
+
__metadata("design:returntype", crypto_1.CryptoSecretKey)
|
|
4944
|
+
], DeviceSecretController.prototype, "getBaseKey", null);
|
|
4945
|
+
exports.DeviceSecretController = DeviceSecretController;
|
|
4966
4946
|
//# sourceMappingURL=DeviceSecretController.js.map
|
|
4967
4947
|
|
|
4968
4948
|
/***/ }),
|
|
@@ -5470,12 +5450,22 @@ exports.DeviceSharedSecret = DeviceSharedSecret;
|
|
|
5470
5450
|
/*!**********************************************!*\
|
|
5471
5451
|
!*** ./dist/modules/files/FileController.js ***!
|
|
5472
5452
|
\**********************************************/
|
|
5473
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
5453
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
5474
5454
|
|
|
5475
5455
|
"use strict";
|
|
5476
5456
|
|
|
5457
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
5458
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5459
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5460
|
+
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;
|
|
5461
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5462
|
+
};
|
|
5463
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
5464
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5465
|
+
};
|
|
5477
5466
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5478
5467
|
exports.FileController = void 0;
|
|
5468
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
5479
5469
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
5480
5470
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
5481
5471
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -5530,7 +5520,7 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5530
5520
|
async updateCacheOfExistingFileInDb(id, response) {
|
|
5531
5521
|
const fileDoc = await this.files.read(id);
|
|
5532
5522
|
if (!fileDoc) {
|
|
5533
|
-
throw core_1.TransportErrors.general.recordNotFound(File_1.File, id)
|
|
5523
|
+
throw core_1.TransportErrors.general.recordNotFound(File_1.File, id);
|
|
5534
5524
|
}
|
|
5535
5525
|
const file = File_1.File.from(fileDoc);
|
|
5536
5526
|
await this.updateCacheOfFile(file, response);
|
|
@@ -5552,7 +5542,7 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5552
5542
|
const plaintextMetadataBuffer = await core_1.CoreCrypto.decrypt(cipher, secretKey);
|
|
5553
5543
|
const plaintextMetadata = FileMetadata_1.FileMetadata.deserialize(plaintextMetadataBuffer.toUtf8());
|
|
5554
5544
|
if (!(plaintextMetadata instanceof FileMetadata_1.FileMetadata)) {
|
|
5555
|
-
throw core_1.TransportErrors.files.invalidMetadata(response.id)
|
|
5545
|
+
throw core_1.TransportErrors.files.invalidMetadata(response.id);
|
|
5556
5546
|
}
|
|
5557
5547
|
// TODO: JSSNMSHDD-2486 (check signature)
|
|
5558
5548
|
const cachedFile = CachedFile_1.CachedFile.fromBackbone(response, plaintextMetadata);
|
|
@@ -5585,7 +5575,7 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5585
5575
|
const id = idOrFile instanceof core_1.CoreId ? idOrFile.toString() : idOrFile.id.toString();
|
|
5586
5576
|
const fileDoc = await this.files.read(id);
|
|
5587
5577
|
if (!fileDoc) {
|
|
5588
|
-
throw core_1.TransportErrors.general.recordNotFound(File_1.File, id.toString())
|
|
5578
|
+
throw core_1.TransportErrors.general.recordNotFound(File_1.File, id.toString());
|
|
5589
5579
|
}
|
|
5590
5580
|
const file = File_1.File.from(fileDoc);
|
|
5591
5581
|
file.setMetadata(metadata);
|
|
@@ -5660,34 +5650,58 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5660
5650
|
async downloadFileContent(idOrFile) {
|
|
5661
5651
|
const file = idOrFile instanceof File_1.File ? idOrFile : await this.getFile(idOrFile);
|
|
5662
5652
|
if (!file) {
|
|
5663
|
-
throw core_1.TransportErrors.general.recordNotFound(File_1.File, idOrFile.toString())
|
|
5653
|
+
throw core_1.TransportErrors.general.recordNotFound(File_1.File, idOrFile.toString());
|
|
5664
5654
|
}
|
|
5665
5655
|
if (!file.cache) {
|
|
5666
|
-
throw core_1.TransportErrors.general.cacheEmpty(File_1.File, file.id.toString())
|
|
5656
|
+
throw core_1.TransportErrors.general.cacheEmpty(File_1.File, file.id.toString());
|
|
5667
5657
|
}
|
|
5668
5658
|
const downloadResponse = (await this.client.downloadFile(file.id.toString())).value;
|
|
5669
5659
|
const buffer = crypto_1.CoreBuffer.fromObject(downloadResponse);
|
|
5670
5660
|
const hash = await crypto_1.CryptoHash.hash(buffer, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
5671
5661
|
const hashb64 = hash.toBase64URL();
|
|
5672
5662
|
if (hashb64 !== file.cache.cipherHash.hash) {
|
|
5673
|
-
throw core_1.TransportErrors.files.cipherMismatch()
|
|
5663
|
+
throw core_1.TransportErrors.files.cipherMismatch();
|
|
5674
5664
|
}
|
|
5675
5665
|
/*
|
|
5676
5666
|
// TODO: JSSNMSHDD-2486 (verify owner signature)
|
|
5677
5667
|
const valid = await Crypto.verify(parcel.cipher.cipher, parcel.ownerSignature, owner.signing)
|
|
5678
5668
|
if (!valid) {
|
|
5679
|
-
throw CoreErrors.General.SignatureNotValid("file")
|
|
5669
|
+
throw CoreErrors.General.SignatureNotValid("file")
|
|
5680
5670
|
}
|
|
5681
5671
|
*/
|
|
5682
5672
|
const cipher = crypto_1.CryptoCipher.fromBase64(buffer.toBase64URL());
|
|
5683
5673
|
const decrypt = await core_1.CoreCrypto.decrypt(cipher, file.cache.cipherKey);
|
|
5684
5674
|
const plaintextHashesMatch = await file.cache.plaintextHash.verify(decrypt, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
5685
5675
|
if (!plaintextHashesMatch) {
|
|
5686
|
-
throw core_1.TransportErrors.files.plaintextHashMismatch()
|
|
5676
|
+
throw core_1.TransportErrors.files.plaintextHashMismatch();
|
|
5687
5677
|
}
|
|
5688
5678
|
return decrypt;
|
|
5689
5679
|
}
|
|
5690
5680
|
}
|
|
5681
|
+
__decorate([
|
|
5682
|
+
(0, ts_utils_1.log)(),
|
|
5683
|
+
__metadata("design:type", Function),
|
|
5684
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
5685
|
+
__metadata("design:returntype", Promise)
|
|
5686
|
+
], FileController.prototype, "updateCacheOfExistingFileInDb", null);
|
|
5687
|
+
__decorate([
|
|
5688
|
+
(0, ts_utils_1.log)(),
|
|
5689
|
+
__metadata("design:type", Function),
|
|
5690
|
+
__metadata("design:paramtypes", [Object, crypto_1.CryptoSecretKey]),
|
|
5691
|
+
__metadata("design:returntype", Promise)
|
|
5692
|
+
], FileController.prototype, "decryptFile", null);
|
|
5693
|
+
__decorate([
|
|
5694
|
+
(0, ts_utils_1.log)(),
|
|
5695
|
+
__metadata("design:type", Function),
|
|
5696
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
5697
|
+
__metadata("design:returntype", Promise)
|
|
5698
|
+
], FileController.prototype, "setFileMetadata", null);
|
|
5699
|
+
__decorate([
|
|
5700
|
+
(0, ts_utils_1.log)(),
|
|
5701
|
+
__metadata("design:type", Function),
|
|
5702
|
+
__metadata("design:paramtypes", [Object]),
|
|
5703
|
+
__metadata("design:returntype", Promise)
|
|
5704
|
+
], FileController.prototype, "downloadFileContent", null);
|
|
5691
5705
|
exports.FileController = FileController;
|
|
5692
5706
|
//# sourceMappingURL=FileController.js.map
|
|
5693
5707
|
|
|
@@ -6334,12 +6348,22 @@ __exportStar(__webpack_require__(/*! ./tokens/transmission/TokenReference */ "./
|
|
|
6334
6348
|
/*!****************************************************!*\
|
|
6335
6349
|
!*** ./dist/modules/messages/MessageController.js ***!
|
|
6336
6350
|
\****************************************************/
|
|
6337
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
6351
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
6338
6352
|
|
|
6339
6353
|
"use strict";
|
|
6340
6354
|
|
|
6355
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
6356
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6357
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6358
|
+
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;
|
|
6359
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6360
|
+
};
|
|
6361
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
6362
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6363
|
+
};
|
|
6341
6364
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6342
6365
|
exports.MessageController = void 0;
|
|
6366
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
6343
6367
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
6344
6368
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
6345
6369
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
@@ -6385,7 +6409,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6385
6409
|
async getMessagesByAddress(address) {
|
|
6386
6410
|
const relationship = await this.parent.relationships.getActiveRelationshipToIdentity(address);
|
|
6387
6411
|
if (!relationship) {
|
|
6388
|
-
throw core_1.TransportErrors.messages.noMatchingRelationship(address.toString())
|
|
6412
|
+
throw core_1.TransportErrors.messages.noMatchingRelationship(address.toString());
|
|
6389
6413
|
}
|
|
6390
6414
|
return await this.getMessagesByRelationshipId(relationship.id);
|
|
6391
6415
|
}
|
|
@@ -6425,7 +6449,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6425
6449
|
async updateCacheOfExistingMessageInDb(id, response) {
|
|
6426
6450
|
const messageDoc = await this.messages.read(id);
|
|
6427
6451
|
if (!messageDoc) {
|
|
6428
|
-
throw core_1.TransportErrors.general.recordNotFound(Message_1.Message, id)
|
|
6452
|
+
throw core_1.TransportErrors.general.recordNotFound(Message_1.Message, id);
|
|
6429
6453
|
}
|
|
6430
6454
|
const message = Message_1.Message.from(messageDoc);
|
|
6431
6455
|
await this.updateCacheOfMessage(message, response);
|
|
@@ -6447,7 +6471,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6447
6471
|
const envelope = this.getEnvelopeFromBackboneGetMessagesResponse(response);
|
|
6448
6472
|
const [cachedMessage, messageKey, relationship] = await this.decryptMessage(envelope);
|
|
6449
6473
|
if (!relationship) {
|
|
6450
|
-
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, envelope.id.toString())
|
|
6474
|
+
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, envelope.id.toString());
|
|
6451
6475
|
}
|
|
6452
6476
|
const message = Message_1.Message.from({
|
|
6453
6477
|
id: envelope.id,
|
|
@@ -6485,7 +6509,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6485
6509
|
const id = idOrMessage instanceof core_1.CoreId ? idOrMessage.toString() : idOrMessage.id.toString();
|
|
6486
6510
|
const messageDoc = await this.messages.read(id);
|
|
6487
6511
|
if (!messageDoc) {
|
|
6488
|
-
throw core_1.TransportErrors.general.recordNotFound(Message_1.Message, id.toString())
|
|
6512
|
+
throw core_1.TransportErrors.general.recordNotFound(Message_1.Message, id.toString());
|
|
6489
6513
|
}
|
|
6490
6514
|
const message = Message_1.Message.from(messageDoc);
|
|
6491
6515
|
message.setMetadata(metadata);
|
|
@@ -6503,7 +6527,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6503
6527
|
for (const recipient of parameters.recipients) {
|
|
6504
6528
|
const relationship = await this.relationships.getActiveRelationshipToIdentity(core_1.CoreAddress.from(recipient));
|
|
6505
6529
|
if (!relationship) {
|
|
6506
|
-
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString())
|
|
6530
|
+
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString());
|
|
6507
6531
|
}
|
|
6508
6532
|
const cipherForRecipient = await this.secrets.encrypt(relationship.relationshipSecretId, serializedSecret);
|
|
6509
6533
|
envelopeRecipients.push(MessageEnvelopeRecipient_1.MessageEnvelopeRecipient.from({
|
|
@@ -6532,7 +6556,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6532
6556
|
for (const recipient of parameters.recipients) {
|
|
6533
6557
|
const relationship = await this.relationships.getActiveRelationshipToIdentity(core_1.CoreAddress.from(recipient));
|
|
6534
6558
|
if (!relationship) {
|
|
6535
|
-
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString())
|
|
6559
|
+
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString());
|
|
6536
6560
|
}
|
|
6537
6561
|
const signature = await this.secrets.sign(relationship.relationshipSecretId, plaintextBuffer);
|
|
6538
6562
|
const messageSignature = MessageSignature_1.MessageSignature.from({
|
|
@@ -6596,7 +6620,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6596
6620
|
var _a, _b;
|
|
6597
6621
|
const ownKeyCipher = (_a = envelope.recipients.find((r) => this.parent.identity.isMe(r.address))) === null || _a === void 0 ? void 0 : _a.encryptedKey;
|
|
6598
6622
|
if (!ownKeyCipher) {
|
|
6599
|
-
throw core_1.TransportErrors.messages.ownAddressNotInList(envelope.id.toString())
|
|
6623
|
+
throw core_1.TransportErrors.messages.ownAddressNotInList(envelope.id.toString());
|
|
6600
6624
|
}
|
|
6601
6625
|
const plaintextKeyBuffer = await this.secrets.decryptPeer(relationship.relationshipSecretId, ownKeyCipher, true);
|
|
6602
6626
|
const plaintextKey = crypto_1.CryptoSecretKey.deserialize(plaintextKeyBuffer.toUtf8());
|
|
@@ -6604,7 +6628,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6604
6628
|
const signedMessage = MessageSigned_1.MessageSigned.deserialize(plaintextMessageBuffer.toUtf8());
|
|
6605
6629
|
const signature = (_b = signedMessage.signatures.find((s) => this.parent.identity.isMe(s.recipient))) === null || _b === void 0 ? void 0 : _b.signature;
|
|
6606
6630
|
if (!signature) {
|
|
6607
|
-
throw core_1.TransportErrors.messages.signatureListMismatch(envelope.id.toString())
|
|
6631
|
+
throw core_1.TransportErrors.messages.signatureListMismatch(envelope.id.toString());
|
|
6608
6632
|
}
|
|
6609
6633
|
const messagePlain = MessagePlain_1.MessagePlain.from(JSON.parse(signedMessage.message));
|
|
6610
6634
|
if (signedMessage.signatures.length !== messagePlain.recipients.length) {
|
|
@@ -6613,7 +6637,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6613
6637
|
const plainMessageBuffer = crypto_1.CoreBuffer.fromUtf8(signedMessage.message);
|
|
6614
6638
|
const validSignature = await this.secrets.verifyPeer(relationship.relationshipSecretId, plainMessageBuffer, signature);
|
|
6615
6639
|
if (!validSignature) {
|
|
6616
|
-
throw core_1.TransportErrors.messages.signatureNotValid()
|
|
6640
|
+
throw core_1.TransportErrors.messages.signatureNotValid();
|
|
6617
6641
|
}
|
|
6618
6642
|
if (messagePlain.recipients.length !== envelope.recipients.length) {
|
|
6619
6643
|
this.log.debug(`Number of signed recipients within the message does not match number of recipients from envelope ${envelope.id}.`);
|
|
@@ -6623,7 +6647,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6623
6647
|
}
|
|
6624
6648
|
const recipientFound = messagePlain.recipients.some((r) => this.parent.identity.isMe(r));
|
|
6625
6649
|
if (!recipientFound) {
|
|
6626
|
-
throw core_1.TransportErrors.messages.plaintextMismatch(envelope.id.toString())
|
|
6650
|
+
throw core_1.TransportErrors.messages.plaintextMismatch(envelope.id.toString());
|
|
6627
6651
|
}
|
|
6628
6652
|
return [messagePlain, plaintextKey];
|
|
6629
6653
|
}
|
|
@@ -6634,7 +6658,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6634
6658
|
let relationship;
|
|
6635
6659
|
if (this.parent.identity.isMe(envelope.createdBy)) {
|
|
6636
6660
|
if (!secretKey) {
|
|
6637
|
-
throw
|
|
6661
|
+
throw new Error(`The own message (${envelope.id.toString()}) could not be decrypted, because no secret key was passed for it.`);
|
|
6638
6662
|
}
|
|
6639
6663
|
messageKey = secretKey;
|
|
6640
6664
|
plainMessage = await this.decryptOwnEnvelope(envelope, secretKey);
|
|
@@ -6642,7 +6666,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6642
6666
|
else {
|
|
6643
6667
|
relationship = await this.relationships.getActiveRelationshipToIdentity(envelope.createdBy);
|
|
6644
6668
|
if (!relationship) {
|
|
6645
|
-
throw core_1.TransportErrors.messages.noMatchingRelationship(envelope.createdBy.toString())
|
|
6669
|
+
throw core_1.TransportErrors.messages.noMatchingRelationship(envelope.createdBy.toString());
|
|
6646
6670
|
}
|
|
6647
6671
|
const [peerMessage, peerKey] = await this.decryptPeerEnvelope(envelope, relationship);
|
|
6648
6672
|
plainMessage = peerMessage;
|
|
@@ -6669,6 +6693,50 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6669
6693
|
return [cachedMessage, messageKey, relationship];
|
|
6670
6694
|
}
|
|
6671
6695
|
}
|
|
6696
|
+
__decorate([
|
|
6697
|
+
(0, ts_utils_1.log)(),
|
|
6698
|
+
__metadata("design:type", Function),
|
|
6699
|
+
__metadata("design:paramtypes", [core_1.CoreAddress]),
|
|
6700
|
+
__metadata("design:returntype", Promise)
|
|
6701
|
+
], MessageController.prototype, "getMessagesByAddress", null);
|
|
6702
|
+
__decorate([
|
|
6703
|
+
(0, ts_utils_1.log)(),
|
|
6704
|
+
__metadata("design:type", Function),
|
|
6705
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
6706
|
+
__metadata("design:returntype", Promise)
|
|
6707
|
+
], MessageController.prototype, "updateCacheOfExistingMessageInDb", null);
|
|
6708
|
+
__decorate([
|
|
6709
|
+
(0, ts_utils_1.log)(),
|
|
6710
|
+
__metadata("design:type", Function),
|
|
6711
|
+
__metadata("design:paramtypes", [core_1.CoreId]),
|
|
6712
|
+
__metadata("design:returntype", Promise)
|
|
6713
|
+
], MessageController.prototype, "loadPeerMessage", null);
|
|
6714
|
+
__decorate([
|
|
6715
|
+
(0, ts_utils_1.log)(),
|
|
6716
|
+
__metadata("design:type", Function),
|
|
6717
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
6718
|
+
__metadata("design:returntype", Promise)
|
|
6719
|
+
], MessageController.prototype, "setMessageMetadata", null);
|
|
6720
|
+
__decorate([
|
|
6721
|
+
(0, ts_utils_1.log)(),
|
|
6722
|
+
__metadata("design:type", Function),
|
|
6723
|
+
__metadata("design:paramtypes", [Object]),
|
|
6724
|
+
__metadata("design:returntype", Promise)
|
|
6725
|
+
], MessageController.prototype, "sendMessage", null);
|
|
6726
|
+
__decorate([
|
|
6727
|
+
(0, ts_utils_1.log)(),
|
|
6728
|
+
__metadata("design:type", Function),
|
|
6729
|
+
__metadata("design:paramtypes", [MessageEnvelope_1.MessageEnvelope,
|
|
6730
|
+
Relationship_1.Relationship]),
|
|
6731
|
+
__metadata("design:returntype", Promise)
|
|
6732
|
+
], MessageController.prototype, "decryptPeerEnvelope", null);
|
|
6733
|
+
__decorate([
|
|
6734
|
+
(0, ts_utils_1.log)(),
|
|
6735
|
+
__metadata("design:type", Function),
|
|
6736
|
+
__metadata("design:paramtypes", [MessageEnvelope_1.MessageEnvelope,
|
|
6737
|
+
crypto_1.CryptoSecretKey]),
|
|
6738
|
+
__metadata("design:returntype", Promise)
|
|
6739
|
+
], MessageController.prototype, "decryptMessage", null);
|
|
6672
6740
|
exports.MessageController = MessageController;
|
|
6673
6741
|
//# sourceMappingURL=MessageController.js.map
|
|
6674
6742
|
|
|
@@ -7275,12 +7343,22 @@ exports.MessageSigned = MessageSigned;
|
|
|
7275
7343
|
/*!******************************************************************************!*\
|
|
7276
7344
|
!*** ./dist/modules/relationshipTemplates/RelationshipTemplateController.js ***!
|
|
7277
7345
|
\******************************************************************************/
|
|
7278
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
7346
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7279
7347
|
|
|
7280
7348
|
"use strict";
|
|
7281
7349
|
|
|
7350
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7351
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7352
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7353
|
+
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;
|
|
7354
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7355
|
+
};
|
|
7356
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
7357
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7358
|
+
};
|
|
7282
7359
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7283
7360
|
exports.RelationshipTemplateController = void 0;
|
|
7361
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
7284
7362
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
7285
7363
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
7286
7364
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -7386,7 +7464,7 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7386
7464
|
async updateCacheOfExistingTemplateInDb(id, response) {
|
|
7387
7465
|
const templateDoc = await this.templates.read(id);
|
|
7388
7466
|
if (!templateDoc) {
|
|
7389
|
-
throw core_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id)
|
|
7467
|
+
throw core_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id);
|
|
7390
7468
|
}
|
|
7391
7469
|
const template = RelationshipTemplate_1.RelationshipTemplate.from(templateDoc);
|
|
7392
7470
|
await this.updateCacheOfTemplate(template, response);
|
|
@@ -7410,7 +7488,7 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7410
7488
|
const templateContent = RelationshipTemplateContent_1.RelationshipTemplateContent.deserialize(signedTemplate.serializedTemplate);
|
|
7411
7489
|
const templateSignatureValid = await this.secrets.verifyTemplate(crypto_1.CoreBuffer.fromUtf8(signedTemplate.serializedTemplate), signedTemplate.deviceSignature, templateContent.identity.publicKey);
|
|
7412
7490
|
if (!templateSignatureValid) {
|
|
7413
|
-
throw core_1.TransportErrors.general.signatureNotValid("template")
|
|
7491
|
+
throw core_1.TransportErrors.general.signatureNotValid("template");
|
|
7414
7492
|
}
|
|
7415
7493
|
const cachedTemplate = CachedRelationshipTemplate_1.CachedRelationshipTemplate.from({
|
|
7416
7494
|
content: templateContent.content,
|
|
@@ -7436,7 +7514,7 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7436
7514
|
const id = idOrTemplate instanceof core_1.CoreId ? idOrTemplate.toString() : idOrTemplate.id.toString();
|
|
7437
7515
|
const templateDoc = await this.templates.read(id);
|
|
7438
7516
|
if (!templateDoc) {
|
|
7439
|
-
throw core_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id.toString())
|
|
7517
|
+
throw core_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id.toString());
|
|
7440
7518
|
}
|
|
7441
7519
|
const template = RelationshipTemplate_1.RelationshipTemplate.from(templateDoc);
|
|
7442
7520
|
template.setMetadata(metadata);
|
|
@@ -7468,6 +7546,24 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7468
7546
|
return relationshipTemplate;
|
|
7469
7547
|
}
|
|
7470
7548
|
}
|
|
7549
|
+
__decorate([
|
|
7550
|
+
(0, ts_utils_1.log)(),
|
|
7551
|
+
__metadata("design:type", Function),
|
|
7552
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
7553
|
+
__metadata("design:returntype", Promise)
|
|
7554
|
+
], RelationshipTemplateController.prototype, "updateCacheOfExistingTemplateInDb", null);
|
|
7555
|
+
__decorate([
|
|
7556
|
+
(0, ts_utils_1.log)(),
|
|
7557
|
+
__metadata("design:type", Function),
|
|
7558
|
+
__metadata("design:paramtypes", [Object, crypto_1.CryptoSecretKey]),
|
|
7559
|
+
__metadata("design:returntype", Promise)
|
|
7560
|
+
], RelationshipTemplateController.prototype, "decryptRelationshipTemplate", null);
|
|
7561
|
+
__decorate([
|
|
7562
|
+
(0, ts_utils_1.log)(),
|
|
7563
|
+
__metadata("design:type", Function),
|
|
7564
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
7565
|
+
__metadata("design:returntype", Promise)
|
|
7566
|
+
], RelationshipTemplateController.prototype, "setRelationshipTemplateMetadata", null);
|
|
7471
7567
|
exports.RelationshipTemplateController = RelationshipTemplateController;
|
|
7472
7568
|
//# sourceMappingURL=RelationshipTemplateController.js.map
|
|
7473
7569
|
|
|
@@ -7990,17 +8086,28 @@ exports.RelationshipTemplateSigned = RelationshipTemplateSigned;
|
|
|
7990
8086
|
/*!********************************************************************!*\
|
|
7991
8087
|
!*** ./dist/modules/relationships/RelationshipSecretController.js ***!
|
|
7992
8088
|
\********************************************************************/
|
|
7993
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
8089
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7994
8090
|
|
|
7995
8091
|
"use strict";
|
|
7996
8092
|
|
|
8093
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
8094
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8095
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8096
|
+
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;
|
|
8097
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8098
|
+
};
|
|
8099
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8100
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8101
|
+
};
|
|
7997
8102
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7998
8103
|
exports.RelationshipSecretController = void 0;
|
|
8104
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
7999
8105
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
8000
8106
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
8001
8107
|
const CoreUtil_1 = __webpack_require__(/*! ../../core/CoreUtil */ "./dist/core/CoreUtil.js");
|
|
8002
8108
|
const TransportErrors_1 = __webpack_require__(/*! ../../core/TransportErrors */ "./dist/core/TransportErrors.js");
|
|
8003
8109
|
const TransportIds_1 = __webpack_require__(/*! ../../core/TransportIds */ "./dist/core/TransportIds.js");
|
|
8110
|
+
const CachedRelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/CachedRelationshipTemplate */ "./dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js");
|
|
8004
8111
|
const RelationshipTemplatePublicKey_1 = __webpack_require__(/*! ../relationshipTemplates/transmission/RelationshipTemplatePublicKey */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.js");
|
|
8005
8112
|
const SecretController_1 = __webpack_require__(/*! ../secrets/SecretController */ "./dist/modules/secrets/SecretController.js");
|
|
8006
8113
|
class RelationshipSecretController extends SecretController_1.SecretController {
|
|
@@ -8016,13 +8123,11 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8016
8123
|
}
|
|
8017
8124
|
const secretContainer = await this.loadActiveSecretByName(secretIdAsString);
|
|
8018
8125
|
if (!secretContainer) {
|
|
8019
|
-
throw TransportErrors_1.TransportErrors.general
|
|
8020
|
-
.recordNotFound("CryptoRelationshipRequestSecrets | CryptoRelationshipSecrets", secretIdAsString)
|
|
8021
|
-
.logWith(this._log);
|
|
8126
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound("CryptoRelationshipRequestSecrets | CryptoRelationshipSecrets", secretIdAsString);
|
|
8022
8127
|
}
|
|
8023
8128
|
if (!(secretContainer.secret instanceof crypto_1.CryptoRelationshipRequestSecrets) &&
|
|
8024
8129
|
!(secretContainer.secret instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8025
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secretIdAsString)
|
|
8130
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secretIdAsString);
|
|
8026
8131
|
}
|
|
8027
8132
|
const secret = secretContainer.secret;
|
|
8028
8133
|
this.cache.set(relationshipSecretId, secret);
|
|
@@ -8038,10 +8143,10 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8038
8143
|
const templateKeyId = template.templateKey.id.toString();
|
|
8039
8144
|
const exchangeKeypairContainer = await this.loadActiveSecretByName(templateKeyId);
|
|
8040
8145
|
if (!exchangeKeypairContainer) {
|
|
8041
|
-
throw TransportErrors_1.TransportErrors.general.recordNotFound(crypto_1.CryptoExchangeKeypair, templateKeyId)
|
|
8146
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(crypto_1.CryptoExchangeKeypair, templateKeyId);
|
|
8042
8147
|
}
|
|
8043
8148
|
if (!(exchangeKeypairContainer.secret instanceof crypto_1.CryptoExchangeKeypair)) {
|
|
8044
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(templateKeyId)
|
|
8149
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(templateKeyId);
|
|
8045
8150
|
}
|
|
8046
8151
|
const exchangeKeypair = exchangeKeypairContainer.secret;
|
|
8047
8152
|
const secrets = await crypto_1.CryptoRelationshipSecrets.fromRelationshipRequest(publicRequestCrypto, exchangeKeypair);
|
|
@@ -8051,12 +8156,10 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8051
8156
|
async getPublicResponse(relationshipSecretId) {
|
|
8052
8157
|
const secret = await this.loadActiveSecretByName(relationshipSecretId.toString());
|
|
8053
8158
|
if (!secret) {
|
|
8054
|
-
throw TransportErrors_1.TransportErrors.general
|
|
8055
|
-
.recordNotFound(crypto_1.CryptoRelationshipSecrets, relationshipSecretId.toString())
|
|
8056
|
-
.logWith(this._log);
|
|
8159
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(crypto_1.CryptoRelationshipSecrets, relationshipSecretId.toString());
|
|
8057
8160
|
}
|
|
8058
8161
|
if (!(secret.secret instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8059
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secret.id.toString())
|
|
8162
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secret.id.toString());
|
|
8060
8163
|
}
|
|
8061
8164
|
const publicResponse = secret.secret.toPublicResponse();
|
|
8062
8165
|
return publicResponse;
|
|
@@ -8064,7 +8167,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8064
8167
|
async convertSecrets(relationshipSecretId, response) {
|
|
8065
8168
|
const request = await this.getSecret(relationshipSecretId);
|
|
8066
8169
|
if (request instanceof crypto_1.CryptoRelationshipSecrets) {
|
|
8067
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType()
|
|
8170
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType();
|
|
8068
8171
|
}
|
|
8069
8172
|
const secrets = await crypto_1.CryptoRelationshipSecrets.fromRelationshipResponse(response, request);
|
|
8070
8173
|
const container = await this.succeedSecretWithName(secrets, relationshipSecretId.toString());
|
|
@@ -8089,7 +8192,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8089
8192
|
const buffer = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
8090
8193
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8091
8194
|
if (!(secrets instanceof crypto_1.CryptoRelationshipRequestSecrets)) {
|
|
8092
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8195
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8093
8196
|
}
|
|
8094
8197
|
return await secrets.encryptRequest(buffer);
|
|
8095
8198
|
}
|
|
@@ -8097,14 +8200,14 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8097
8200
|
const buffer = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
8098
8201
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8099
8202
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8100
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8203
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8101
8204
|
}
|
|
8102
8205
|
return await secrets.encrypt(buffer);
|
|
8103
8206
|
}
|
|
8104
8207
|
async decryptRequest(relationshipSecretId, cipher) {
|
|
8105
8208
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8106
8209
|
if (!(secrets instanceof crypto_1.CryptoRelationshipRequestSecrets) && !(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8107
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(relationshipSecretId.toString())
|
|
8210
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(relationshipSecretId.toString());
|
|
8108
8211
|
}
|
|
8109
8212
|
return await secrets.decryptRequest(cipher);
|
|
8110
8213
|
}
|
|
@@ -8121,7 +8224,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8121
8224
|
async decryptPeer(relationshipSecretId, cipher, omitCounterCheck = false) {
|
|
8122
8225
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8123
8226
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8124
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8227
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8125
8228
|
}
|
|
8126
8229
|
return await secrets.decryptPeer(cipher, omitCounterCheck);
|
|
8127
8230
|
}
|
|
@@ -8132,7 +8235,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8132
8235
|
async decryptOwn(relationshipSecretId, cipher) {
|
|
8133
8236
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8134
8237
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8135
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8238
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8136
8239
|
}
|
|
8137
8240
|
return await secrets.decryptOwn(cipher);
|
|
8138
8241
|
}
|
|
@@ -8150,12 +8253,76 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8150
8253
|
const bufferToVerify = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
8151
8254
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8152
8255
|
if (secrets instanceof crypto_1.CryptoRelationshipRequestSecrets) {
|
|
8153
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8256
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8154
8257
|
}
|
|
8155
8258
|
const valid = await secrets.verifyPeer(bufferToVerify, signature);
|
|
8156
8259
|
return valid;
|
|
8157
8260
|
}
|
|
8158
8261
|
}
|
|
8262
|
+
__decorate([
|
|
8263
|
+
(0, ts_utils_1.log)(),
|
|
8264
|
+
__metadata("design:type", Function),
|
|
8265
|
+
__metadata("design:paramtypes", [core_1.CoreId]),
|
|
8266
|
+
__metadata("design:returntype", Promise)
|
|
8267
|
+
], RelationshipSecretController.prototype, "getSecret", null);
|
|
8268
|
+
__decorate([
|
|
8269
|
+
(0, ts_utils_1.log)(),
|
|
8270
|
+
__metadata("design:type", Function),
|
|
8271
|
+
__metadata("design:paramtypes", [core_1.CoreId,
|
|
8272
|
+
CachedRelationshipTemplate_1.CachedRelationshipTemplate,
|
|
8273
|
+
crypto_1.CryptoRelationshipPublicRequest]),
|
|
8274
|
+
__metadata("design:returntype", Promise)
|
|
8275
|
+
], RelationshipSecretController.prototype, "createTemplatorSecrets", null);
|
|
8276
|
+
__decorate([
|
|
8277
|
+
(0, ts_utils_1.log)(),
|
|
8278
|
+
__metadata("design:type", Function),
|
|
8279
|
+
__metadata("design:paramtypes", [core_1.CoreId]),
|
|
8280
|
+
__metadata("design:returntype", Promise)
|
|
8281
|
+
], RelationshipSecretController.prototype, "getPublicResponse", null);
|
|
8282
|
+
__decorate([
|
|
8283
|
+
(0, ts_utils_1.log)(),
|
|
8284
|
+
__metadata("design:type", Function),
|
|
8285
|
+
__metadata("design:paramtypes", [core_1.CoreId,
|
|
8286
|
+
crypto_1.CryptoRelationshipPublicResponse]),
|
|
8287
|
+
__metadata("design:returntype", Promise)
|
|
8288
|
+
], RelationshipSecretController.prototype, "convertSecrets", null);
|
|
8289
|
+
__decorate([
|
|
8290
|
+
(0, ts_utils_1.log)(),
|
|
8291
|
+
__metadata("design:type", Function),
|
|
8292
|
+
__metadata("design:paramtypes", [core_1.CoreId, Object]),
|
|
8293
|
+
__metadata("design:returntype", Promise)
|
|
8294
|
+
], RelationshipSecretController.prototype, "encryptRequest", null);
|
|
8295
|
+
__decorate([
|
|
8296
|
+
(0, ts_utils_1.log)(),
|
|
8297
|
+
__metadata("design:type", Function),
|
|
8298
|
+
__metadata("design:paramtypes", [core_1.CoreId, Object]),
|
|
8299
|
+
__metadata("design:returntype", Promise)
|
|
8300
|
+
], RelationshipSecretController.prototype, "encrypt", null);
|
|
8301
|
+
__decorate([
|
|
8302
|
+
(0, ts_utils_1.log)(),
|
|
8303
|
+
__metadata("design:type", Function),
|
|
8304
|
+
__metadata("design:paramtypes", [core_1.CoreId, crypto_1.CryptoCipher]),
|
|
8305
|
+
__metadata("design:returntype", Promise)
|
|
8306
|
+
], RelationshipSecretController.prototype, "decryptRequest", null);
|
|
8307
|
+
__decorate([
|
|
8308
|
+
(0, ts_utils_1.log)(),
|
|
8309
|
+
__metadata("design:type", Function),
|
|
8310
|
+
__metadata("design:paramtypes", [core_1.CoreId,
|
|
8311
|
+
crypto_1.CryptoCipher, Object]),
|
|
8312
|
+
__metadata("design:returntype", Promise)
|
|
8313
|
+
], RelationshipSecretController.prototype, "decryptPeer", null);
|
|
8314
|
+
__decorate([
|
|
8315
|
+
(0, ts_utils_1.log)(),
|
|
8316
|
+
__metadata("design:type", Function),
|
|
8317
|
+
__metadata("design:paramtypes", [core_1.CoreId, crypto_1.CryptoCipher]),
|
|
8318
|
+
__metadata("design:returntype", Promise)
|
|
8319
|
+
], RelationshipSecretController.prototype, "decryptOwn", null);
|
|
8320
|
+
__decorate([
|
|
8321
|
+
(0, ts_utils_1.log)(),
|
|
8322
|
+
__metadata("design:type", Function),
|
|
8323
|
+
__metadata("design:paramtypes", [core_1.CoreId, Object, crypto_1.CryptoSignature]),
|
|
8324
|
+
__metadata("design:returntype", Promise)
|
|
8325
|
+
], RelationshipSecretController.prototype, "verifyPeer", null);
|
|
8159
8326
|
exports.RelationshipSecretController = RelationshipSecretController;
|
|
8160
8327
|
//# sourceMappingURL=RelationshipSecretController.js.map
|
|
8161
8328
|
|
|
@@ -8165,12 +8332,22 @@ exports.RelationshipSecretController = RelationshipSecretController;
|
|
|
8165
8332
|
/*!***************************************************************!*\
|
|
8166
8333
|
!*** ./dist/modules/relationships/RelationshipsController.js ***!
|
|
8167
8334
|
\***************************************************************/
|
|
8168
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
8335
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
8169
8336
|
|
|
8170
8337
|
"use strict";
|
|
8171
8338
|
|
|
8339
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
8340
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8341
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8342
|
+
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;
|
|
8343
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8344
|
+
};
|
|
8345
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8346
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8347
|
+
};
|
|
8172
8348
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
8173
8349
|
exports.RelationshipsController = void 0;
|
|
8350
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
8174
8351
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
8175
8352
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
8176
8353
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
@@ -8237,9 +8414,8 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8237
8414
|
}
|
|
8238
8415
|
async updateCacheOfExistingRelationshipInDb(id, response) {
|
|
8239
8416
|
const relationshipDoc = await this.relationships.read(id);
|
|
8240
|
-
if (!relationshipDoc)
|
|
8241
|
-
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, id)
|
|
8242
|
-
}
|
|
8417
|
+
if (!relationshipDoc)
|
|
8418
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, id);
|
|
8243
8419
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
8244
8420
|
await this.updateCacheOfRelationship(relationship, response);
|
|
8245
8421
|
await this.relationships.update(relationshipDoc, relationship);
|
|
@@ -8281,7 +8457,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8281
8457
|
parameters = SendRelationshipParameters_1.SendRelationshipParameters.from(parameters);
|
|
8282
8458
|
const template = parameters.template;
|
|
8283
8459
|
if (!template.cache) {
|
|
8284
|
-
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString())
|
|
8460
|
+
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
8285
8461
|
}
|
|
8286
8462
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
8287
8463
|
const { requestCipher, requestContent } = await this.prepareRequest(secretId, template, parameters.content);
|
|
@@ -8297,18 +8473,14 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8297
8473
|
async setRelationshipMetadata(idOrRelationship, metadata) {
|
|
8298
8474
|
const id = idOrRelationship instanceof core_1.CoreId ? idOrRelationship.toString() : idOrRelationship.id.toString();
|
|
8299
8475
|
const relationshipDoc = await this.relationships.read(id);
|
|
8300
|
-
if (!relationshipDoc)
|
|
8301
|
-
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, id.toString())
|
|
8302
|
-
}
|
|
8476
|
+
if (!relationshipDoc)
|
|
8477
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, id.toString());
|
|
8303
8478
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
8304
8479
|
relationship.metadata = metadata;
|
|
8305
8480
|
relationship.metadataModifiedAt = core_1.CoreDate.utc();
|
|
8306
8481
|
await this.relationships.update(relationshipDoc, relationship);
|
|
8307
8482
|
return relationship;
|
|
8308
8483
|
}
|
|
8309
|
-
requestTermination() {
|
|
8310
|
-
throw TransportErrors_1.TransportErrors.general.notImplemented();
|
|
8311
|
-
}
|
|
8312
8484
|
async acceptChange(change, content) {
|
|
8313
8485
|
return await this.completeChange(RelationshipChangeStatus_1.RelationshipChangeStatus.Accepted, change, content);
|
|
8314
8486
|
}
|
|
@@ -8352,7 +8524,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8352
8524
|
}
|
|
8353
8525
|
async prepareRequest(relationshipSecretId, template, content) {
|
|
8354
8526
|
if (!template.cache) {
|
|
8355
|
-
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString())
|
|
8527
|
+
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
8356
8528
|
}
|
|
8357
8529
|
const requestPublic = await this.secrets.createRequestorSecrets(template.cache, relationshipSecretId);
|
|
8358
8530
|
const requestContent = RelationshipCreationChangeRequestContent_1.RelationshipCreationChangeRequestContent.from({
|
|
@@ -8387,11 +8559,10 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8387
8559
|
case RelationshipChangeType_1.RelationshipChangeType.Creation:
|
|
8388
8560
|
return await this.applyCreationChange(change);
|
|
8389
8561
|
case RelationshipChangeType_1.RelationshipChangeType.Termination:
|
|
8390
|
-
return await this.applyTerminationChange(change);
|
|
8391
8562
|
case RelationshipChangeType_1.RelationshipChangeType.TerminationCancellation:
|
|
8392
|
-
|
|
8563
|
+
throw TransportErrors_1.TransportErrors.general.notSupported();
|
|
8393
8564
|
default:
|
|
8394
|
-
throw TransportErrors_1.TransportErrors.general.incompatibleBackbone()
|
|
8565
|
+
throw TransportErrors_1.TransportErrors.general.incompatibleBackbone();
|
|
8395
8566
|
}
|
|
8396
8567
|
}
|
|
8397
8568
|
async applyCreationChange(change) {
|
|
@@ -8415,9 +8586,8 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8415
8586
|
return newRelationship;
|
|
8416
8587
|
}
|
|
8417
8588
|
async parseCreationChange(change, relationshipSecretId, templateId) {
|
|
8418
|
-
if (change.type !== RelationshipChangeType_1.RelationshipChangeType.Creation)
|
|
8419
|
-
|
|
8420
|
-
}
|
|
8589
|
+
if (change.type !== RelationshipChangeType_1.RelationshipChangeType.Creation)
|
|
8590
|
+
this.throwWrongChangeType(change.type);
|
|
8421
8591
|
const promises = [];
|
|
8422
8592
|
promises.push(this.decryptCreationChangeRequest(change.request, relationshipSecretId, templateId));
|
|
8423
8593
|
const hasRelationshipSecret = await this.secrets.hasCryptoRelationshipSecrets(relationshipSecretId);
|
|
@@ -8429,9 +8599,8 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8429
8599
|
return creationChange;
|
|
8430
8600
|
}
|
|
8431
8601
|
async decryptCreationChangeRequest(change, secretId, templateId) {
|
|
8432
|
-
if (!change.content)
|
|
8433
|
-
throw
|
|
8434
|
-
}
|
|
8602
|
+
if (!change.content)
|
|
8603
|
+
throw this.newEmptyOrInvalidContentError();
|
|
8435
8604
|
const isOwnChange = this.parent.identity.isMe(core_1.CoreAddress.from(change.createdBy));
|
|
8436
8605
|
const requestCipher = RelationshipCreationChangeRequestCipher_1.RelationshipCreationChangeRequestCipher.fromBase64(change.content);
|
|
8437
8606
|
const signedRequestBuffer = await this.secrets.decryptRequest(secretId, requestCipher.cipher);
|
|
@@ -8444,23 +8613,21 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8444
8613
|
relationshipSignatureValid = await this.secrets.verifyPeer(secretId, crypto_1.CoreBuffer.fromUtf8(signedRequest.serializedRequest), signedRequest.relationshipSignature);
|
|
8445
8614
|
}
|
|
8446
8615
|
if (!relationshipSignatureValid) {
|
|
8447
|
-
throw TransportErrors_1.TransportErrors.general.signatureNotValid("relationshipRequest")
|
|
8616
|
+
throw TransportErrors_1.TransportErrors.general.signatureNotValid("relationshipRequest");
|
|
8448
8617
|
}
|
|
8449
8618
|
const requestContent = RelationshipCreationChangeRequestContent_1.RelationshipCreationChangeRequestContent.deserialize(signedRequest.serializedRequest);
|
|
8450
|
-
if (requestContent.templateId.
|
|
8451
|
-
throw
|
|
8619
|
+
if (!requestContent.templateId.equals(templateId)) {
|
|
8620
|
+
throw new Error("The relationship request contains a wrong template id.");
|
|
8452
8621
|
}
|
|
8453
8622
|
return requestContent;
|
|
8454
8623
|
}
|
|
8455
8624
|
async decryptCreationChangeResponse(change, relationshipSecretId) {
|
|
8456
|
-
if (!change.response)
|
|
8457
|
-
throw
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
throw TransportErrors_1.TransportErrors.relationships.wrongChangeType(change.type).logWith(this._log);
|
|
8461
|
-
}
|
|
8625
|
+
if (!change.response)
|
|
8626
|
+
throw this.newChangeResponseMissingError(change.id);
|
|
8627
|
+
if (change.type !== RelationshipChangeType_1.RelationshipChangeType.Creation)
|
|
8628
|
+
this.throwWrongChangeType(change.type);
|
|
8462
8629
|
if (!change.response.content) {
|
|
8463
|
-
throw
|
|
8630
|
+
throw this.newEmptyOrInvalidContentError(change);
|
|
8464
8631
|
}
|
|
8465
8632
|
const isOwnChange = this.parent.identity.isMe(core_1.CoreAddress.from(change.response.createdBy));
|
|
8466
8633
|
const cipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.fromBase64(change.response.content);
|
|
@@ -8485,11 +8652,11 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8485
8652
|
relationshipSignatureValid = await this.secrets.verifyPeer(relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
|
|
8486
8653
|
}
|
|
8487
8654
|
if (!relationshipSignatureValid) {
|
|
8488
|
-
throw TransportErrors_1.TransportErrors.general.signatureNotValid("relationshipResponse")
|
|
8655
|
+
throw TransportErrors_1.TransportErrors.general.signatureNotValid("relationshipResponse");
|
|
8489
8656
|
}
|
|
8490
8657
|
const responseContent = RelationshipCreationChangeResponseContent_1.RelationshipCreationChangeResponseContent.deserialize(signedResponse.serializedResponse);
|
|
8491
|
-
if (responseContent.relationshipId.
|
|
8492
|
-
throw
|
|
8658
|
+
if (!responseContent.relationshipId.equals(change.relationshipId)) {
|
|
8659
|
+
throw new Error("The relationship response contains a wrong relationship id.");
|
|
8493
8660
|
}
|
|
8494
8661
|
return responseContent;
|
|
8495
8662
|
}
|
|
@@ -8502,16 +8669,15 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8502
8669
|
if (!relationship.cache) {
|
|
8503
8670
|
await this.updateCacheOfRelationship(relationship, undefined);
|
|
8504
8671
|
}
|
|
8505
|
-
if (!change.response)
|
|
8506
|
-
throw
|
|
8507
|
-
}
|
|
8672
|
+
if (!change.response)
|
|
8673
|
+
throw this.newChangeResponseMissingError(change.id);
|
|
8508
8674
|
if (!change.response.content) {
|
|
8509
|
-
throw
|
|
8675
|
+
throw this.newEmptyOrInvalidContentError(change);
|
|
8510
8676
|
}
|
|
8511
8677
|
const cipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.fromBase64(change.response.content);
|
|
8512
8678
|
if (change.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Revoked) {
|
|
8513
8679
|
if (!cipher.publicResponseCrypto) {
|
|
8514
|
-
throw
|
|
8680
|
+
throw new Error("The response crypto is missing.");
|
|
8515
8681
|
}
|
|
8516
8682
|
await this.secrets.convertSecrets(relationship.relationshipSecretId, cipher.publicResponseCrypto);
|
|
8517
8683
|
}
|
|
@@ -8532,7 +8698,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8532
8698
|
relationship.toRevoked(response);
|
|
8533
8699
|
break;
|
|
8534
8700
|
default:
|
|
8535
|
-
throw TransportErrors_1.TransportErrors.general.incompatibleBackbone()
|
|
8701
|
+
throw TransportErrors_1.TransportErrors.general.incompatibleBackbone();
|
|
8536
8702
|
}
|
|
8537
8703
|
await this.relationships.update(relationshipDoc, relationship);
|
|
8538
8704
|
return relationship;
|
|
@@ -8541,15 +8707,12 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8541
8707
|
const backboneRelationship = (await this.client.getRelationship(change.relationshipId)).value;
|
|
8542
8708
|
const templateId = core_1.CoreId.from(backboneRelationship.relationshipTemplateId);
|
|
8543
8709
|
const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId);
|
|
8544
|
-
if (!template)
|
|
8545
|
-
throw TransportErrors_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString())
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
if (!change.request.content) {
|
|
8551
|
-
throw TransportErrors_1.TransportErrors.relationships.emptyOrInvalidContent(change).logWith(this._log);
|
|
8552
|
-
}
|
|
8710
|
+
if (!template)
|
|
8711
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString());
|
|
8712
|
+
if (!template.cache)
|
|
8713
|
+
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
8714
|
+
if (!change.request.content)
|
|
8715
|
+
throw this.newEmptyOrInvalidContentError(change);
|
|
8553
8716
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
8554
8717
|
const requestCipher = RelationshipCreationChangeRequestCipher_1.RelationshipCreationChangeRequestCipher.fromBase64(change.request.content);
|
|
8555
8718
|
await this.secrets.createTemplatorSecrets(secretId, template.cache, requestCipher.publicRequestCrypto);
|
|
@@ -8559,18 +8722,10 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8559
8722
|
await this.relationships.create(relationship);
|
|
8560
8723
|
return relationship;
|
|
8561
8724
|
}
|
|
8562
|
-
applyTerminationChange(_change) {
|
|
8563
|
-
throw TransportErrors_1.TransportErrors.general.notImplemented();
|
|
8564
|
-
}
|
|
8565
|
-
applyTerminationCancellationChange(_change) {
|
|
8566
|
-
throw TransportErrors_1.TransportErrors.general.notImplemented();
|
|
8567
|
-
}
|
|
8568
8725
|
async completeChange(targetStatus, change, content) {
|
|
8569
8726
|
const relationshipDoc = await this.relationships.read(change.relationshipId.toString());
|
|
8570
8727
|
if (!relationshipDoc) {
|
|
8571
|
-
throw TransportErrors_1.TransportErrors.general
|
|
8572
|
-
.recordNotFound(Relationship_1.Relationship, change.relationshipId.toString())
|
|
8573
|
-
.logWith(this._log);
|
|
8728
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, change.relationshipId.toString());
|
|
8574
8729
|
}
|
|
8575
8730
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
8576
8731
|
if (!relationship.cache) {
|
|
@@ -8581,10 +8736,10 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8581
8736
|
}
|
|
8582
8737
|
const queriedChange = relationship.cache.changes.find((r) => r.id.toString() === change.id.toString());
|
|
8583
8738
|
if (!queriedChange) {
|
|
8584
|
-
throw TransportErrors_1.TransportErrors.general.recordNotFound(RelationshipChange_1.RelationshipChange, change.id.toString())
|
|
8739
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(RelationshipChange_1.RelationshipChange, change.id.toString());
|
|
8585
8740
|
}
|
|
8586
8741
|
if (queriedChange.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Pending) {
|
|
8587
|
-
throw TransportErrors_1.TransportErrors.relationships.wrongChangeStatus(queriedChange.status)
|
|
8742
|
+
throw TransportErrors_1.TransportErrors.relationships.wrongChangeStatus(queriedChange.status);
|
|
8588
8743
|
}
|
|
8589
8744
|
let encryptedContent;
|
|
8590
8745
|
if (content) {
|
|
@@ -8661,7 +8816,72 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8661
8816
|
});
|
|
8662
8817
|
return responseCipher.toBase64();
|
|
8663
8818
|
}
|
|
8664
|
-
|
|
8819
|
+
throwWrongChangeType(type) {
|
|
8820
|
+
throw new Error(`The relationship change has the wrong type (${type}) to run this operation`);
|
|
8821
|
+
}
|
|
8822
|
+
newChangeResponseMissingError(changeId) {
|
|
8823
|
+
return new Error(`The response of the relationship change (${changeId}) is missing`);
|
|
8824
|
+
}
|
|
8825
|
+
newEmptyOrInvalidContentError(change) {
|
|
8826
|
+
return new Error(`The content property of the relationship change ${change === null || change === void 0 ? void 0 : change.id} is missing or invalid`);
|
|
8827
|
+
}
|
|
8828
|
+
}
|
|
8829
|
+
__decorate([
|
|
8830
|
+
(0, ts_utils_1.log)(),
|
|
8831
|
+
__metadata("design:type", Function),
|
|
8832
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
8833
|
+
__metadata("design:returntype", Promise)
|
|
8834
|
+
], RelationshipsController.prototype, "updateCacheOfExistingRelationshipInDb", null);
|
|
8835
|
+
__decorate([
|
|
8836
|
+
(0, ts_utils_1.log)(),
|
|
8837
|
+
__metadata("design:type", Function),
|
|
8838
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
8839
|
+
__metadata("design:returntype", Promise)
|
|
8840
|
+
], RelationshipsController.prototype, "setRelationshipMetadata", null);
|
|
8841
|
+
__decorate([
|
|
8842
|
+
(0, ts_utils_1.log)(),
|
|
8843
|
+
__metadata("design:type", Function),
|
|
8844
|
+
__metadata("design:paramtypes", [Object]),
|
|
8845
|
+
__metadata("design:returntype", Promise)
|
|
8846
|
+
], RelationshipsController.prototype, "applyChange", null);
|
|
8847
|
+
__decorate([
|
|
8848
|
+
(0, ts_utils_1.log)(),
|
|
8849
|
+
__metadata("design:type", Function),
|
|
8850
|
+
__metadata("design:paramtypes", [Object, core_1.CoreId,
|
|
8851
|
+
core_1.CoreId]),
|
|
8852
|
+
__metadata("design:returntype", Promise)
|
|
8853
|
+
], RelationshipsController.prototype, "parseCreationChange", null);
|
|
8854
|
+
__decorate([
|
|
8855
|
+
(0, ts_utils_1.log)(),
|
|
8856
|
+
__metadata("design:type", Function),
|
|
8857
|
+
__metadata("design:paramtypes", [Object, core_1.CoreId,
|
|
8858
|
+
core_1.CoreId]),
|
|
8859
|
+
__metadata("design:returntype", Promise)
|
|
8860
|
+
], RelationshipsController.prototype, "decryptCreationChangeRequest", null);
|
|
8861
|
+
__decorate([
|
|
8862
|
+
(0, ts_utils_1.log)(),
|
|
8863
|
+
__metadata("design:type", Function),
|
|
8864
|
+
__metadata("design:paramtypes", [Object, core_1.CoreId]),
|
|
8865
|
+
__metadata("design:returntype", Promise)
|
|
8866
|
+
], RelationshipsController.prototype, "decryptCreationChangeResponse", null);
|
|
8867
|
+
__decorate([
|
|
8868
|
+
(0, ts_utils_1.log)(),
|
|
8869
|
+
__metadata("design:type", Function),
|
|
8870
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
8871
|
+
__metadata("design:returntype", Promise)
|
|
8872
|
+
], RelationshipsController.prototype, "updatePendingRelationshipWithPeerResponse", null);
|
|
8873
|
+
__decorate([
|
|
8874
|
+
(0, ts_utils_1.log)(),
|
|
8875
|
+
__metadata("design:type", Function),
|
|
8876
|
+
__metadata("design:paramtypes", [Object]),
|
|
8877
|
+
__metadata("design:returntype", Promise)
|
|
8878
|
+
], RelationshipsController.prototype, "createNewRelationshipByIncomingCreationChange", null);
|
|
8879
|
+
__decorate([
|
|
8880
|
+
(0, ts_utils_1.log)(),
|
|
8881
|
+
__metadata("design:type", Function),
|
|
8882
|
+
__metadata("design:paramtypes", [String, RelationshipChange_1.RelationshipChange, Object]),
|
|
8883
|
+
__metadata("design:returntype", Promise)
|
|
8884
|
+
], RelationshipsController.prototype, "completeChange", null);
|
|
8665
8885
|
exports.RelationshipsController = RelationshipsController;
|
|
8666
8886
|
//# sourceMappingURL=RelationshipsController.js.map
|
|
8667
8887
|
|
|
@@ -9575,13 +9795,23 @@ exports.RelationshipCreationChangeResponseSigned = RelationshipCreationChangeRes
|
|
|
9575
9795
|
/*!**************************************************!*\
|
|
9576
9796
|
!*** ./dist/modules/secrets/SecretController.js ***!
|
|
9577
9797
|
\**************************************************/
|
|
9578
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
9798
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
9579
9799
|
|
|
9580
9800
|
"use strict";
|
|
9581
9801
|
|
|
9802
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
9803
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9804
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9805
|
+
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;
|
|
9806
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9807
|
+
};
|
|
9808
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9809
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9810
|
+
};
|
|
9582
9811
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9583
9812
|
exports.SecretController = exports.SecretBaseKeyType = void 0;
|
|
9584
9813
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
9814
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
9585
9815
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
9586
9816
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
9587
9817
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -9726,9 +9956,7 @@ class SecretController extends TransportController_1.TransportController {
|
|
|
9726
9956
|
this.baseKey = baseKey.secret;
|
|
9727
9957
|
}
|
|
9728
9958
|
else {
|
|
9729
|
-
throw core_1.TransportErrors.general
|
|
9730
|
-
.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretController_1.DeviceSecretType.SharedSecretBaseKey)
|
|
9731
|
-
.logWith(this._log);
|
|
9959
|
+
throw core_1.TransportErrors.general.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretController_1.DeviceSecretType.SharedSecretBaseKey);
|
|
9732
9960
|
}
|
|
9733
9961
|
return this.baseKey;
|
|
9734
9962
|
}
|
|
@@ -9738,13 +9966,19 @@ class SecretController extends TransportController_1.TransportController {
|
|
|
9738
9966
|
return nextNonce;
|
|
9739
9967
|
}
|
|
9740
9968
|
}
|
|
9741
|
-
exports.SecretController = SecretController;
|
|
9742
9969
|
/**
|
|
9743
9970
|
* Context of the secret derivation function. Doesn't have to be secret.
|
|
9744
9971
|
* Must be 8 characters long.
|
|
9745
9972
|
*/
|
|
9746
9973
|
SecretController.secretContext = "SECRET01";
|
|
9747
9974
|
SecretController.secretNonceKey = "secret_lastnonce";
|
|
9975
|
+
__decorate([
|
|
9976
|
+
(0, ts_utils_1.log)(),
|
|
9977
|
+
__metadata("design:type", Function),
|
|
9978
|
+
__metadata("design:paramtypes", []),
|
|
9979
|
+
__metadata("design:returntype", Promise)
|
|
9980
|
+
], SecretController.prototype, "getBaseKey", null);
|
|
9981
|
+
exports.SecretController = SecretController;
|
|
9748
9982
|
//# sourceMappingURL=SecretController.js.map
|
|
9749
9983
|
|
|
9750
9984
|
/***/ }),
|
|
@@ -10040,11 +10274,21 @@ exports.DatawalletModificationMapper = DatawalletModificationMapper;
|
|
|
10040
10274
|
|
|
10041
10275
|
"use strict";
|
|
10042
10276
|
|
|
10277
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10278
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10279
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10280
|
+
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;
|
|
10281
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10282
|
+
};
|
|
10283
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10284
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10285
|
+
};
|
|
10043
10286
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10044
10287
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10045
10288
|
};
|
|
10046
10289
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
10047
10290
|
exports.CacheFetcher = exports.DatawalletModificationsProcessor = void 0;
|
|
10291
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
10048
10292
|
const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"));
|
|
10049
10293
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
10050
10294
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -10076,6 +10320,9 @@ class DatawalletModificationsProcessor {
|
|
|
10076
10320
|
const totalItems = this.creates.length + this.updates.length + this.deletes.length + this.cacheChanges.length;
|
|
10077
10321
|
this.syncStep = reporter.createStep(SyncCallback_1.SyncStep.DatawalletSyncProcessing, totalItems);
|
|
10078
10322
|
}
|
|
10323
|
+
get log() {
|
|
10324
|
+
return this.logger;
|
|
10325
|
+
}
|
|
10079
10326
|
async execute() {
|
|
10080
10327
|
await this.applyCreates();
|
|
10081
10328
|
await this.applyUpdates();
|
|
@@ -10164,9 +10411,7 @@ class DatawalletModificationsProcessor {
|
|
|
10164
10411
|
const uniqueCollections = [...new Set(collections)];
|
|
10165
10412
|
const collectionsWithUncacheableItems = uniqueCollections.filter((c) => !this.collectionsWithCacheableItems.includes(c));
|
|
10166
10413
|
if (collectionsWithUncacheableItems.length > 0) {
|
|
10167
|
-
throw core_1.TransportErrors.datawallet
|
|
10168
|
-
.unsupportedModification("unsupportedCacheChangedModificationCollection", collectionsWithUncacheableItems)
|
|
10169
|
-
.logWith(this.logger);
|
|
10414
|
+
throw core_1.TransportErrors.datawallet.unsupportedModification("unsupportedCacheChangedModificationCollection", collectionsWithUncacheableItems);
|
|
10170
10415
|
}
|
|
10171
10416
|
}
|
|
10172
10417
|
groupCacheChangesByCollection(cacheChanges) {
|
|
@@ -10202,6 +10447,12 @@ class DatawalletModificationsProcessor {
|
|
|
10202
10447
|
}
|
|
10203
10448
|
}
|
|
10204
10449
|
}
|
|
10450
|
+
__decorate([
|
|
10451
|
+
(0, ts_utils_1.log)(),
|
|
10452
|
+
__metadata("design:type", Function),
|
|
10453
|
+
__metadata("design:paramtypes", []),
|
|
10454
|
+
__metadata("design:returntype", void 0)
|
|
10455
|
+
], DatawalletModificationsProcessor.prototype, "ensureAllItemsAreCacheable", null);
|
|
10205
10456
|
exports.DatawalletModificationsProcessor = DatawalletModificationsProcessor;
|
|
10206
10457
|
class CacheFetcher {
|
|
10207
10458
|
constructor(fileController, messageController, relationshipTemplateController, relationshipController, tokenController) {
|
|
@@ -10385,12 +10636,22 @@ var SyncStep;
|
|
|
10385
10636
|
/*!*********************************************!*\
|
|
10386
10637
|
!*** ./dist/modules/sync/SyncController.js ***!
|
|
10387
10638
|
\*********************************************/
|
|
10388
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
10639
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
10389
10640
|
|
|
10390
10641
|
"use strict";
|
|
10391
10642
|
|
|
10643
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10644
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10645
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10646
|
+
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;
|
|
10647
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10648
|
+
};
|
|
10649
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10650
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10651
|
+
};
|
|
10392
10652
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
10393
10653
|
exports.SyncController = void 0;
|
|
10654
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
10394
10655
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
10395
10656
|
const StartSyncRun_1 = __webpack_require__(/*! ./backbone/StartSyncRun */ "./dist/modules/sync/backbone/StartSyncRun.js");
|
|
10396
10657
|
const SyncClient_1 = __webpack_require__(/*! ./backbone/SyncClient */ "./dist/modules/sync/backbone/SyncClient.js");
|
|
@@ -10466,7 +10727,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10466
10727
|
throw new core_1.CoreError("error.transport.errorWhileApplyingExternalEvents", externalEventSyncResult.externalEventResults
|
|
10467
10728
|
.filter((r) => r.errorCode !== undefined)
|
|
10468
10729
|
.map((r) => r.errorCode)
|
|
10469
|
-
.join(" | "))
|
|
10730
|
+
.join(" | "));
|
|
10470
10731
|
}
|
|
10471
10732
|
syncStep.finish();
|
|
10472
10733
|
if (this.datawalletEnabled && (await this.unpushedDatawalletModifications.exists())) {
|
|
@@ -10496,9 +10757,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10496
10757
|
if (this.config.supportedDatawalletVersion < identityDatawalletVersion) {
|
|
10497
10758
|
// This means that the datawallet of the identity was upgraded by another device with a higher version.
|
|
10498
10759
|
// It is necesssary to update the current device.
|
|
10499
|
-
throw core_1.TransportErrors.datawallet
|
|
10500
|
-
.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion)
|
|
10501
|
-
.logWith(this.log);
|
|
10760
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion);
|
|
10502
10761
|
}
|
|
10503
10762
|
this.log.trace("Synchronization of Datawallet events started...");
|
|
10504
10763
|
try {
|
|
@@ -10510,9 +10769,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10510
10769
|
const outdatedErrorCode = "error.platform.validation.datawallet.insufficientSupportedDatawalletVersion";
|
|
10511
10770
|
if (!(e instanceof core_1.RequestError) || e.code !== outdatedErrorCode)
|
|
10512
10771
|
throw e;
|
|
10513
|
-
throw core_1.TransportErrors.datawallet
|
|
10514
|
-
.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion)
|
|
10515
|
-
.logWith(this.log);
|
|
10772
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion);
|
|
10516
10773
|
}
|
|
10517
10774
|
this.log.trace("Synchronization of Datawallet events ended...");
|
|
10518
10775
|
await this.checkDatawalletVersion(identityDatawalletVersion);
|
|
@@ -10520,9 +10777,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10520
10777
|
async checkDatawalletVersion(identityDatawalletVersion) {
|
|
10521
10778
|
var _a;
|
|
10522
10779
|
if (this.config.supportedDatawalletVersion < identityDatawalletVersion) {
|
|
10523
|
-
throw core_1.TransportErrors.datawallet
|
|
10524
|
-
.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion)
|
|
10525
|
-
.logWith(this.log);
|
|
10780
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion);
|
|
10526
10781
|
}
|
|
10527
10782
|
if (this.config.supportedDatawalletVersion > identityDatawalletVersion) {
|
|
10528
10783
|
await this.upgradeIdentityDatawalletVersion(identityDatawalletVersion, this.config.supportedDatawalletVersion);
|
|
@@ -10536,21 +10791,17 @@ class SyncController extends core_1.TransportController {
|
|
|
10536
10791
|
if (identityDatawalletVersion === targetDatawalletVersion)
|
|
10537
10792
|
return;
|
|
10538
10793
|
if (this.config.supportedDatawalletVersion < targetDatawalletVersion) {
|
|
10539
|
-
throw core_1.TransportErrors.datawallet
|
|
10540
|
-
.insufficientSupportedDatawalletVersion(targetDatawalletVersion, identityDatawalletVersion)
|
|
10541
|
-
.logWith(this.log);
|
|
10794
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, identityDatawalletVersion);
|
|
10542
10795
|
}
|
|
10543
10796
|
if (identityDatawalletVersion > targetDatawalletVersion) {
|
|
10544
|
-
throw core_1.TransportErrors.datawallet
|
|
10545
|
-
.currentBiggerThanTarget(identityDatawalletVersion, targetDatawalletVersion)
|
|
10546
|
-
.logWith(this.log);
|
|
10797
|
+
throw core_1.TransportErrors.datawallet.currentBiggerThanTarget(identityDatawalletVersion, targetDatawalletVersion);
|
|
10547
10798
|
}
|
|
10548
10799
|
while (identityDatawalletVersion < targetDatawalletVersion) {
|
|
10549
10800
|
identityDatawalletVersion++;
|
|
10550
10801
|
await this.startDatawalletVersionUpgradeSyncRun();
|
|
10551
10802
|
const migrationFunction = this.identityMigrations[`v${identityDatawalletVersion}`];
|
|
10552
10803
|
if (!migrationFunction) {
|
|
10553
|
-
throw
|
|
10804
|
+
throw this.newNoMigrationAvailableError(identityDatawalletVersion);
|
|
10554
10805
|
}
|
|
10555
10806
|
await migrationFunction.call(this.identityMigrations);
|
|
10556
10807
|
await this.finalizeDatawalletVersionUpgradeSyncRun(identityDatawalletVersion);
|
|
@@ -10560,20 +10811,16 @@ class SyncController extends core_1.TransportController {
|
|
|
10560
10811
|
if (deviceDatawalletVersion === targetDatawalletVersion)
|
|
10561
10812
|
return;
|
|
10562
10813
|
if (this.config.supportedDatawalletVersion < targetDatawalletVersion) {
|
|
10563
|
-
throw core_1.TransportErrors.datawallet
|
|
10564
|
-
.insufficientSupportedDatawalletVersion(targetDatawalletVersion, deviceDatawalletVersion)
|
|
10565
|
-
.logWith(this.log);
|
|
10814
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, deviceDatawalletVersion);
|
|
10566
10815
|
}
|
|
10567
10816
|
if (deviceDatawalletVersion > targetDatawalletVersion) {
|
|
10568
|
-
throw core_1.TransportErrors.datawallet
|
|
10569
|
-
.currentBiggerThanTarget(deviceDatawalletVersion, targetDatawalletVersion)
|
|
10570
|
-
.logWith(this.log);
|
|
10817
|
+
throw core_1.TransportErrors.datawallet.currentBiggerThanTarget(deviceDatawalletVersion, targetDatawalletVersion);
|
|
10571
10818
|
}
|
|
10572
10819
|
while (deviceDatawalletVersion < targetDatawalletVersion) {
|
|
10573
10820
|
deviceDatawalletVersion++;
|
|
10574
10821
|
const migrationFunction = this.deviceMigrations[`v${deviceDatawalletVersion}`];
|
|
10575
10822
|
if (!migrationFunction) {
|
|
10576
|
-
throw
|
|
10823
|
+
throw this.newNoMigrationAvailableError(deviceDatawalletVersion);
|
|
10577
10824
|
}
|
|
10578
10825
|
await migrationFunction.call(this.deviceMigrations);
|
|
10579
10826
|
await this.parent.activeDevice.update({ datawalletVersion: deviceDatawalletVersion });
|
|
@@ -10750,7 +10997,40 @@ class SyncController extends core_1.TransportController {
|
|
|
10750
10997
|
async setLastCompletedDatawalletSyncTime() {
|
|
10751
10998
|
await this.setSyncTimeByName("Datawallet");
|
|
10752
10999
|
}
|
|
11000
|
+
newNoMigrationAvailableError(version) {
|
|
11001
|
+
return new Error(`There is no migration available for the datawallet version '${version}'.`);
|
|
11002
|
+
}
|
|
10753
11003
|
}
|
|
11004
|
+
__decorate([
|
|
11005
|
+
(0, ts_utils_1.log)(),
|
|
11006
|
+
__metadata("design:type", Function),
|
|
11007
|
+
__metadata("design:paramtypes", [String, SyncCallback_1.SyncProgressReporter]),
|
|
11008
|
+
__metadata("design:returntype", Promise)
|
|
11009
|
+
], SyncController.prototype, "_sync", null);
|
|
11010
|
+
__decorate([
|
|
11011
|
+
(0, ts_utils_1.log)(),
|
|
11012
|
+
__metadata("design:type", Function),
|
|
11013
|
+
__metadata("design:paramtypes", [SyncCallback_1.SyncProgressReporter]),
|
|
11014
|
+
__metadata("design:returntype", Promise)
|
|
11015
|
+
], SyncController.prototype, "syncDatawallet", null);
|
|
11016
|
+
__decorate([
|
|
11017
|
+
(0, ts_utils_1.log)(),
|
|
11018
|
+
__metadata("design:type", Function),
|
|
11019
|
+
__metadata("design:paramtypes", [Number]),
|
|
11020
|
+
__metadata("design:returntype", Promise)
|
|
11021
|
+
], SyncController.prototype, "checkDatawalletVersion", null);
|
|
11022
|
+
__decorate([
|
|
11023
|
+
(0, ts_utils_1.log)(),
|
|
11024
|
+
__metadata("design:type", Function),
|
|
11025
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
11026
|
+
__metadata("design:returntype", Promise)
|
|
11027
|
+
], SyncController.prototype, "upgradeIdentityDatawalletVersion", null);
|
|
11028
|
+
__decorate([
|
|
11029
|
+
(0, ts_utils_1.log)(),
|
|
11030
|
+
__metadata("design:type", Function),
|
|
11031
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
11032
|
+
__metadata("design:returntype", Promise)
|
|
11033
|
+
], SyncController.prototype, "upgradeDeviceDatawalletVersion", null);
|
|
10754
11034
|
exports.SyncController = SyncController;
|
|
10755
11035
|
function descending(modification1, modification2) {
|
|
10756
11036
|
return modification2.index - modification1.index;
|
|
@@ -11293,13 +11573,23 @@ exports.AnonymousTokenController = AnonymousTokenController;
|
|
|
11293
11573
|
/*!************************************************!*\
|
|
11294
11574
|
!*** ./dist/modules/tokens/TokenController.js ***!
|
|
11295
11575
|
\************************************************/
|
|
11296
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
11576
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
11297
11577
|
|
|
11298
11578
|
"use strict";
|
|
11299
11579
|
|
|
11580
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11581
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11582
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11583
|
+
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;
|
|
11584
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11585
|
+
};
|
|
11586
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
11587
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11588
|
+
};
|
|
11300
11589
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11301
11590
|
exports.TokenController = void 0;
|
|
11302
11591
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
11592
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
11303
11593
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
11304
11594
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
11305
11595
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -11356,7 +11646,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11356
11646
|
const id = idOrToken instanceof core_1.CoreId ? idOrToken.toString() : idOrToken.id.toString();
|
|
11357
11647
|
const tokenDoc = await this.tokens.read(id);
|
|
11358
11648
|
if (!tokenDoc) {
|
|
11359
|
-
throw core_1.TransportErrors.general.recordNotFound(Token_1.Token, id.toString())
|
|
11649
|
+
throw core_1.TransportErrors.general.recordNotFound(Token_1.Token, id.toString());
|
|
11360
11650
|
}
|
|
11361
11651
|
const token = Token_1.Token.from(tokenDoc);
|
|
11362
11652
|
token.setMetadata(metadata);
|
|
@@ -11394,7 +11684,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11394
11684
|
async updateCacheOfExistingTokenInDb(id, response) {
|
|
11395
11685
|
const tokenDoc = await this.tokens.read(id);
|
|
11396
11686
|
if (!tokenDoc) {
|
|
11397
|
-
core_1.TransportErrors.general.recordNotFound(Token_1.Token, id)
|
|
11687
|
+
core_1.TransportErrors.general.recordNotFound(Token_1.Token, id);
|
|
11398
11688
|
return;
|
|
11399
11689
|
}
|
|
11400
11690
|
const token = Token_1.Token.from(tokenDoc);
|
|
@@ -11417,7 +11707,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11417
11707
|
const plaintextTokenBuffer = await core_1.CoreCrypto.decrypt(cipher, secretKey);
|
|
11418
11708
|
const plaintextTokenContent = core_1.CoreSerializable.deserializeUnknown(plaintextTokenBuffer.toUtf8());
|
|
11419
11709
|
if (!(plaintextTokenContent instanceof ts_serval_1.Serializable)) {
|
|
11420
|
-
throw core_1.TransportErrors.tokens.invalidTokenContent(response.id)
|
|
11710
|
+
throw core_1.TransportErrors.tokens.invalidTokenContent(response.id);
|
|
11421
11711
|
}
|
|
11422
11712
|
const cachedToken = CachedToken_1.CachedToken.from({
|
|
11423
11713
|
createdAt: core_1.CoreDate.from(response.createdAt),
|
|
@@ -11461,6 +11751,24 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11461
11751
|
return token;
|
|
11462
11752
|
}
|
|
11463
11753
|
}
|
|
11754
|
+
__decorate([
|
|
11755
|
+
(0, ts_utils_1.log)(),
|
|
11756
|
+
__metadata("design:type", Function),
|
|
11757
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
11758
|
+
__metadata("design:returntype", Promise)
|
|
11759
|
+
], TokenController.prototype, "setTokenMetadata", null);
|
|
11760
|
+
__decorate([
|
|
11761
|
+
(0, ts_utils_1.log)(),
|
|
11762
|
+
__metadata("design:type", Function),
|
|
11763
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
11764
|
+
__metadata("design:returntype", Promise)
|
|
11765
|
+
], TokenController.prototype, "updateCacheOfExistingTokenInDb", null);
|
|
11766
|
+
__decorate([
|
|
11767
|
+
(0, ts_utils_1.log)(),
|
|
11768
|
+
__metadata("design:type", Function),
|
|
11769
|
+
__metadata("design:paramtypes", [Object, crypto_1.CryptoSecretKey]),
|
|
11770
|
+
__metadata("design:returntype", Promise)
|
|
11771
|
+
], TokenController.prototype, "decryptToken", null);
|
|
11464
11772
|
exports.TokenController = TokenController;
|
|
11465
11773
|
//# sourceMappingURL=TokenController.js.map
|
|
11466
11774
|
|
|
@@ -11923,7 +12231,6 @@ exports.TokenReference = TokenReference;
|
|
|
11923
12231
|
|
|
11924
12232
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11925
12233
|
exports.PasswordGenerator = void 0;
|
|
11926
|
-
const TransportErrors_1 = __webpack_require__(/*! ../core/TransportErrors */ "./dist/core/TransportErrors.js");
|
|
11927
12234
|
const Random_1 = __webpack_require__(/*! ./Random */ "./dist/util/Random.js");
|
|
11928
12235
|
const defaultPasswordRange = Random_1.RandomCharacterRange.AlphanumericEase + Random_1.RandomCharacterRange.SpecialCharacters;
|
|
11929
12236
|
class PasswordGenerator {
|
|
@@ -11947,7 +12254,7 @@ class PasswordGenerator {
|
|
|
11947
12254
|
if (minLength > maxLength)
|
|
11948
12255
|
maxLength = minLength;
|
|
11949
12256
|
if (minLength < 8) {
|
|
11950
|
-
throw
|
|
12257
|
+
throw new Error("Minimum password length for a strong password should be 8 characters.");
|
|
11951
12258
|
}
|
|
11952
12259
|
const specialCharacterBucket = {
|
|
11953
12260
|
minLength: 1,
|
|
@@ -12114,7 +12421,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
12114
12421
|
exports.Random = exports.RandomCharacterRange = void 0;
|
|
12115
12422
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
12116
12423
|
const uuid_1 = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/commonjs-browser/index.js");
|
|
12117
|
-
const TransportErrors_1 = __webpack_require__(/*! ../core/TransportErrors */ "./dist/core/TransportErrors.js");
|
|
12118
12424
|
var RandomCharacterRange;
|
|
12119
12425
|
(function (RandomCharacterRange) {
|
|
12120
12426
|
RandomCharacterRange["Digit"] = "0123456789";
|
|
@@ -12138,7 +12444,7 @@ class Random {
|
|
|
12138
12444
|
}
|
|
12139
12445
|
static async int(length) {
|
|
12140
12446
|
if (length > 21 || length <= 0) {
|
|
12141
|
-
throw
|
|
12447
|
+
throw new Error("Length must be between 1 and 21.");
|
|
12142
12448
|
}
|
|
12143
12449
|
return parseInt(await this.string(length, RandomCharacterRange.Digit));
|
|
12144
12450
|
}
|
|
@@ -12161,12 +12467,12 @@ class Random {
|
|
|
12161
12467
|
}
|
|
12162
12468
|
static async intBetween(min, max) {
|
|
12163
12469
|
if (max <= min) {
|
|
12164
|
-
throw
|
|
12470
|
+
throw new Error("Max must be larger than min.");
|
|
12165
12471
|
}
|
|
12166
12472
|
const diff = max - min + 1;
|
|
12167
12473
|
const bitLength = Math.abs(Math.ceil(Math.log2(diff)));
|
|
12168
12474
|
if (bitLength > 32) {
|
|
12169
|
-
throw
|
|
12475
|
+
throw new Error("The range between the numbers is too big, 32 bit is the maximum -> 4294967296");
|
|
12170
12476
|
}
|
|
12171
12477
|
const byteLength = Math.ceil(bitLength / 8);
|
|
12172
12478
|
const bitMask = Math.pow(2, bitLength) - 1;
|
|
@@ -12185,7 +12491,7 @@ class Random {
|
|
|
12185
12491
|
}
|
|
12186
12492
|
static async intRandomLength(minLength, maxLength) {
|
|
12187
12493
|
if (maxLength > 21) {
|
|
12188
|
-
|
|
12494
|
+
throw new Error("Max must be below 22.");
|
|
12189
12495
|
}
|
|
12190
12496
|
return parseInt(await this.stringRandomLength(minLength, maxLength, RandomCharacterRange.Digit));
|
|
12191
12497
|
}
|
|
@@ -12204,7 +12510,7 @@ class Random {
|
|
|
12204
12510
|
if (length <= 0)
|
|
12205
12511
|
return "";
|
|
12206
12512
|
if (allowedChars.length > 256) {
|
|
12207
|
-
throw
|
|
12513
|
+
throw new Error("Input exceeds maximum length of 256.");
|
|
12208
12514
|
}
|
|
12209
12515
|
const ar = [];
|
|
12210
12516
|
const inputLength = allowedChars.length;
|
|
@@ -12227,10 +12533,10 @@ class Random {
|
|
|
12227
12533
|
}
|
|
12228
12534
|
static async stringRandomLength(minLength, maxLength, allowedChars) {
|
|
12229
12535
|
if (minLength > maxLength) {
|
|
12230
|
-
throw
|
|
12536
|
+
throw new Error("maxLength must be larger than minLength.");
|
|
12231
12537
|
}
|
|
12232
12538
|
if (minLength < 0) {
|
|
12233
|
-
throw
|
|
12539
|
+
throw new Error("minlength must not be less than zero.");
|
|
12234
12540
|
}
|
|
12235
12541
|
const length = maxLength > minLength ? await this.intBetween(minLength, maxLength) : maxLength;
|
|
12236
12542
|
return await this.string(length, allowedChars);
|
|
@@ -12711,29 +13017,50 @@ __exportStar(__webpack_require__(/*! ./sleep */ "./node_modules/@js-soft/ts-util
|
|
|
12711
13017
|
/*!*************************************************************!*\
|
|
12712
13018
|
!*** ./node_modules/@js-soft/ts-utils/dist/logDecorator.js ***!
|
|
12713
13019
|
\*************************************************************/
|
|
12714
|
-
/***/ ((__unused_webpack_module, exports)
|
|
13020
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
12715
13021
|
|
|
12716
13022
|
"use strict";
|
|
12717
13023
|
|
|
13024
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13025
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13026
|
+
};
|
|
12718
13027
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12719
13028
|
exports.log = void 0;
|
|
12720
|
-
|
|
12721
|
-
function log(
|
|
12722
|
-
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
13029
|
+
const json_stringify_safe_1 = __importDefault(__webpack_require__(/*! json-stringify-safe */ "./node_modules/json-stringify-safe/stringify.js"));
|
|
13030
|
+
function log(params) {
|
|
13031
|
+
return function (_target, propertyName, propertyDescriptorDoNotChangeMyNamePlease) {
|
|
13032
|
+
const method = propertyDescriptorDoNotChangeMyNamePlease.value;
|
|
13033
|
+
propertyDescriptorDoNotChangeMyNamePlease.value = function (...args) {
|
|
13034
|
+
const thisT = this;
|
|
13035
|
+
try {
|
|
13036
|
+
if (params?.logParams) {
|
|
13037
|
+
thisT.log.trace(`Calling ${propertyName}(${args.map((a) => (0, json_stringify_safe_1.default)(a)).join(", ")})`);
|
|
13038
|
+
}
|
|
13039
|
+
else {
|
|
13040
|
+
thisT.log.trace(`Calling ${propertyName}`);
|
|
13041
|
+
}
|
|
13042
|
+
const returnValue = method.apply(this, args);
|
|
13043
|
+
if (params?.logReturnValue) {
|
|
13044
|
+
thisT.log.trace(`Returning from ${propertyName} with: ${(0, json_stringify_safe_1.default)(returnValue)}`);
|
|
13045
|
+
}
|
|
13046
|
+
else {
|
|
13047
|
+
thisT.log.trace(`Returning from ${propertyName}`);
|
|
13048
|
+
}
|
|
13049
|
+
return returnValue;
|
|
13050
|
+
}
|
|
13051
|
+
catch (error) {
|
|
13052
|
+
if (error instanceof Error && error.stack) {
|
|
13053
|
+
error.stack = error.stack
|
|
13054
|
+
.split("\n")
|
|
13055
|
+
.filter((s) => !s.includes(".propertyDescriptorDoNotChangeMyNamePlease.value"))
|
|
13056
|
+
.join("\n");
|
|
13057
|
+
}
|
|
13058
|
+
thisT.log.error(`Error in ${propertyName}:`, error);
|
|
13059
|
+
throw error;
|
|
13060
|
+
}
|
|
13061
|
+
};
|
|
13062
|
+
return propertyDescriptorDoNotChangeMyNamePlease;
|
|
12735
13063
|
};
|
|
12736
|
-
return propertyDesciptor;
|
|
12737
13064
|
}
|
|
12738
13065
|
exports.log = log;
|
|
12739
13066
|
//# sourceMappingURL=logDecorator.js.map
|
|
@@ -39240,7 +39567,7 @@ function dayDiff(earlier, later) {
|
|
|
39240
39567
|
}
|
|
39241
39568
|
|
|
39242
39569
|
function highOrderDiffs(cursor, later, units) {
|
|
39243
|
-
const differs = [["years", (a, b) => b.year - a.year], ["quarters", (a, b) => b.quarter - a.quarter], ["months", (a, b) => b.month - a.month + (b.year - a.year) * 12], ["weeks", (a, b) => {
|
|
39570
|
+
const differs = [["years", (a, b) => b.year - a.year], ["quarters", (a, b) => b.quarter - a.quarter + (b.year - a.year) * 4], ["months", (a, b) => b.month - a.month + (b.year - a.year) * 12], ["weeks", (a, b) => {
|
|
39244
39571
|
const days = dayDiff(a, b);
|
|
39245
39572
|
return (days - days % 7) / 7;
|
|
39246
39573
|
}], ["days", dayDiff]];
|
|
@@ -42429,7 +42756,7 @@ function friendlyDateTime(dateTimeish) {
|
|
|
42429
42756
|
}
|
|
42430
42757
|
}
|
|
42431
42758
|
|
|
42432
|
-
const VERSION = "3.0.
|
|
42759
|
+
const VERSION = "3.0.4";
|
|
42433
42760
|
|
|
42434
42761
|
exports.DateTime = DateTime;
|
|
42435
42762
|
exports.Duration = Duration;
|