@nmshd/transport 2.0.0-beta.5 → 2.0.0-beta.7
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 -10
- 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/accounts/data/Identity.d.ts +0 -18
- package/dist/modules/accounts/data/Identity.js +0 -33
- package/dist/modules/accounts/data/Identity.js.map +1 -1
- package/dist/modules/challenges/ChallengeController.js +26 -5
- package/dist/modules/challenges/ChallengeController.js.map +1 -1
- package/dist/modules/devices/DeviceController.d.ts +1 -1
- package/dist/modules/devices/DeviceController.js +42 -14
- package/dist/modules/devices/DeviceController.js.map +1 -1
- package/dist/modules/devices/DeviceSecretController.js +43 -14
- package/dist/modules/devices/DeviceSecretController.js.map +1 -1
- package/dist/modules/files/FileController.js +41 -16
- package/dist/modules/files/FileController.js.map +1 -1
- package/dist/modules/index.d.ts +4 -4
- package/dist/modules/index.js +4 -4
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/messages/MessageController.js +70 -16
- package/dist/modules/messages/MessageController.js.map +1 -1
- package/dist/modules/messages/transmission/{MessagePlain.d.ts → MessageContentWrapper.d.ts} +4 -4
- package/dist/modules/messages/transmission/{MessagePlain.js → MessageContentWrapper.js} +12 -12
- package/dist/modules/messages/transmission/MessageContentWrapper.js.map +1 -0
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js +35 -14
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js.map +1 -1
- package/dist/modules/relationshipTemplates/backbone/BackboneGetRelationshipTemplates.d.ts +0 -1
- package/dist/modules/relationshipTemplates/backbone/BackbonePostRelationshipTemplates.d.ts +0 -5
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.d.ts +0 -11
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js +1 -15
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js.map +1 -1
- package/dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.d.ts +0 -11
- package/dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js +2 -17
- package/dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js.map +1 -1
- package/dist/modules/relationshipTemplates/transmission/{RelationshipTemplateContent.d.ts → RelationshipTemplateContentWrapper.d.ts} +3 -3
- package/dist/modules/relationshipTemplates/transmission/{RelationshipTemplateContent.js → RelationshipTemplateContentWrapper.js} +10 -10
- package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js.map +1 -0
- package/dist/modules/relationships/RelationshipSecretController.js +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 +119 -66
- package/dist/modules/relationships/RelationshipsController.js.map +1 -1
- package/dist/modules/relationships/transmission/requests/{RelationshipCreationChangeRequestContent.d.ts → RelationshipCreationChangeRequestContentWrapper.d.ts} +3 -3
- package/dist/modules/relationships/transmission/requests/{RelationshipCreationChangeRequestContent.js → RelationshipCreationChangeRequestContentWrapper.js} +10 -10
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js.map +1 -0
- package/dist/modules/relationships/transmission/responses/{RelationshipCreationChangeResponseContent.d.ts → RelationshipCreationChangeResponseContentWrapper.d.ts} +3 -3
- package/dist/modules/relationships/transmission/responses/{RelationshipCreationChangeResponseContent.js → RelationshipCreationChangeResponseContentWrapper.js} +9 -9
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js.map +1 -0
- package/dist/modules/secrets/SecretController.js +18 -5
- 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 -4
- 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 +874 -633
- 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
- package/dist/modules/messages/transmission/MessagePlain.js.map +0 -1
- package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateContent.js.map +0 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContent.js.map +0 -1
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContent.js.map +0 -1
|
@@ -15,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.7",
|
|
19
|
+
build: "38",
|
|
20
|
+
date: "2022-09-28T11:13:26+00:00",
|
|
21
|
+
commit: "44a803a33359c25924b03d92bece8556be05af18",
|
|
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.`);
|
|
1056
|
+
notSupported() {
|
|
1057
|
+
return new CoreError_1.CoreError("error.transport.notSupported", "The method is not yet supported.");
|
|
1191
1058
|
}
|
|
1192
|
-
|
|
1193
|
-
return new CoreError_1.CoreError("error.transport.
|
|
1194
|
-
}
|
|
1195
|
-
unsupportedDatabaseTypeForQuery(databaseType, query) {
|
|
1196
|
-
return new CoreError_1.CoreError("error.transport.unsupportedDatabaseTypeForQuery", `The query '${query.name}' does not (yet?) support the database type '${databaseType}'.`);
|
|
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
|
}
|
|
@@ -2982,7 +2853,6 @@ class AccountController {
|
|
|
2982
2853
|
get identity() {
|
|
2983
2854
|
return this._identity;
|
|
2984
2855
|
}
|
|
2985
|
-
// TODO: JSSNMSHDD-2487 (last login date)
|
|
2986
2856
|
async init(deviceSharedSecret) {
|
|
2987
2857
|
this.info = await this.db.getMap("AccountInfo");
|
|
2988
2858
|
this.unpushedDatawalletModifications = await this.db.getCollection(DbCollectionName_1.DbCollectionName.UnpushedDatawalletModifications);
|
|
@@ -3031,7 +2901,7 @@ class AccountController {
|
|
|
3031
2901
|
this.deviceAuthClient = new DeviceAuthClient_1.DeviceAuthClient(this.config, this.authenticator);
|
|
3032
2902
|
}
|
|
3033
2903
|
else {
|
|
3034
|
-
throw
|
|
2904
|
+
throw new Error("The combination of deviceSharedSecret, existing identity or device is not allowed.");
|
|
3035
2905
|
}
|
|
3036
2906
|
this._log.trace(`Using device ${this.activeDevice.id} for identity ${this.identity.address}.`);
|
|
3037
2907
|
await this.initControllers();
|
|
@@ -3093,7 +2963,6 @@ class AccountController {
|
|
|
3093
2963
|
return await this.synchronization.getLastCompletedDatawalletSyncTime();
|
|
3094
2964
|
}
|
|
3095
2965
|
async createIdentityAndDevice(realm = Identity_1.Realm.Prod) {
|
|
3096
|
-
this._log.trace(`Creating new identity for realm ${realm}...`);
|
|
3097
2966
|
const [identityKeypair, devicePwdD1, deviceKeypair, privBaseShared, privBaseDevice] = await Promise.all([
|
|
3098
2967
|
// Generate identity keypair
|
|
3099
2968
|
CoreCrypto_1.CoreCrypto.generateSignatureKeypair(),
|
|
@@ -3128,16 +2997,13 @@ class AccountController {
|
|
|
3128
2997
|
if (deviceResponseResult.isError) {
|
|
3129
2998
|
const error = deviceResponseResult.error;
|
|
3130
2999
|
if (error.code === "error.platform.unauthorized") {
|
|
3131
|
-
throw core_1.TransportErrors.general.platformClientInvalid()
|
|
3000
|
+
throw core_1.TransportErrors.general.platformClientInvalid();
|
|
3132
3001
|
}
|
|
3133
3002
|
}
|
|
3134
3003
|
const deviceResponse = deviceResponseResult.value;
|
|
3135
3004
|
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);
|
|
3005
|
+
if (!localAddress.equals(deviceResponse.address)) {
|
|
3006
|
+
throw new Error("The backbone address does not match the local address.");
|
|
3141
3007
|
}
|
|
3142
3008
|
const identity = Identity_1.Identity.from({
|
|
3143
3009
|
address: core_1.CoreAddress.from(deviceResponse.address),
|
|
@@ -3176,7 +3042,6 @@ class AccountController {
|
|
|
3176
3042
|
this.activeDevice.secrets.storeSecret(deviceKeypair.privateKey, DeviceSecretController_1.DeviceSecretType.DeviceSignature),
|
|
3177
3043
|
this.activeDevice.secrets.storeSecret(deviceCredentials, DeviceSecretController_1.DeviceSecretType.DeviceCredentials)
|
|
3178
3044
|
]);
|
|
3179
|
-
// TODO: JSSNMSHDD-2471 (Rollback on error)
|
|
3180
3045
|
return { identity, device };
|
|
3181
3046
|
}
|
|
3182
3047
|
async onboardDevice(deviceSharedSecret) {
|
|
@@ -3248,6 +3113,18 @@ class AccountController {
|
|
|
3248
3113
|
return new SynchronizedCollection_1.SynchronizedCollection(collection, this.config.supportedDatawalletVersion, this.unpushedDatawalletModifications);
|
|
3249
3114
|
}
|
|
3250
3115
|
}
|
|
3116
|
+
__decorate([
|
|
3117
|
+
(0, ts_utils_1.log)(),
|
|
3118
|
+
__metadata("design:type", Function),
|
|
3119
|
+
__metadata("design:paramtypes", [DeviceSharedSecret_1.DeviceSharedSecret]),
|
|
3120
|
+
__metadata("design:returntype", Promise)
|
|
3121
|
+
], AccountController.prototype, "init", null);
|
|
3122
|
+
__decorate([
|
|
3123
|
+
(0, ts_utils_1.log)(),
|
|
3124
|
+
__metadata("design:type", Function),
|
|
3125
|
+
__metadata("design:paramtypes", [String]),
|
|
3126
|
+
__metadata("design:returntype", Promise)
|
|
3127
|
+
], AccountController.prototype, "createIdentityAndDevice", null);
|
|
3251
3128
|
exports.AccountController = AccountController;
|
|
3252
3129
|
//# sourceMappingURL=AccountController.js.map
|
|
3253
3130
|
|
|
@@ -3257,15 +3134,26 @@ exports.AccountController = AccountController;
|
|
|
3257
3134
|
/*!*****************************************************!*\
|
|
3258
3135
|
!*** ./dist/modules/accounts/IdentityController.js ***!
|
|
3259
3136
|
\*****************************************************/
|
|
3260
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
3137
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3261
3138
|
|
|
3262
3139
|
"use strict";
|
|
3263
3140
|
|
|
3141
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3142
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3143
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3144
|
+
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;
|
|
3145
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3146
|
+
};
|
|
3147
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
3148
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3149
|
+
};
|
|
3264
3150
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3265
3151
|
exports.IdentityController = void 0;
|
|
3152
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
3266
3153
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
3267
3154
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
3268
3155
|
const DeviceSecretController_1 = __webpack_require__(/*! ../devices/DeviceSecretController */ "./dist/modules/devices/DeviceSecretController.js");
|
|
3156
|
+
const Identity_1 = __webpack_require__(/*! ./data/Identity */ "./dist/modules/accounts/data/Identity.js");
|
|
3269
3157
|
class IdentityController extends core_1.TransportController {
|
|
3270
3158
|
constructor(parent) {
|
|
3271
3159
|
super(core_1.ControllerName.Identity, parent);
|
|
@@ -3284,9 +3172,6 @@ class IdentityController extends core_1.TransportController {
|
|
|
3284
3172
|
}
|
|
3285
3173
|
async init(identity) {
|
|
3286
3174
|
await super.init();
|
|
3287
|
-
if (!identity) {
|
|
3288
|
-
throw core_1.TransportErrors.identity.identityNotSet().logWith(this._log);
|
|
3289
|
-
}
|
|
3290
3175
|
this._identity = identity;
|
|
3291
3176
|
return this;
|
|
3292
3177
|
}
|
|
@@ -3299,7 +3184,7 @@ class IdentityController extends core_1.TransportController {
|
|
|
3299
3184
|
async sign(content) {
|
|
3300
3185
|
const privateKeyContainer = await this.parent.activeDevice.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.IdentitySignature);
|
|
3301
3186
|
if (!privateKeyContainer || !(privateKeyContainer.secret instanceof crypto_1.CryptoSignaturePrivateKey)) {
|
|
3302
|
-
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.IdentitySignature)
|
|
3187
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.IdentitySignature);
|
|
3303
3188
|
}
|
|
3304
3189
|
const privateKey = privateKeyContainer.secret;
|
|
3305
3190
|
const signature = await core_1.CoreCrypto.sign(content, privateKey);
|
|
@@ -3311,6 +3196,18 @@ class IdentityController extends core_1.TransportController {
|
|
|
3311
3196
|
return valid;
|
|
3312
3197
|
}
|
|
3313
3198
|
}
|
|
3199
|
+
__decorate([
|
|
3200
|
+
(0, ts_utils_1.log)(),
|
|
3201
|
+
__metadata("design:type", Function),
|
|
3202
|
+
__metadata("design:paramtypes", [Identity_1.Identity]),
|
|
3203
|
+
__metadata("design:returntype", Promise)
|
|
3204
|
+
], IdentityController.prototype, "init", null);
|
|
3205
|
+
__decorate([
|
|
3206
|
+
(0, ts_utils_1.log)(),
|
|
3207
|
+
__metadata("design:type", Function),
|
|
3208
|
+
__metadata("design:paramtypes", [crypto_1.CoreBuffer]),
|
|
3209
|
+
__metadata("design:returntype", Promise)
|
|
3210
|
+
], IdentityController.prototype, "sign", null);
|
|
3314
3211
|
exports.IdentityController = IdentityController;
|
|
3315
3212
|
//# sourceMappingURL=IdentityController.js.map
|
|
3316
3213
|
|
|
@@ -3329,10 +3226,9 @@ exports.IdentityUtil = void 0;
|
|
|
3329
3226
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
3330
3227
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
3331
3228
|
class IdentityUtil {
|
|
3332
|
-
static async createAddress(publicKey, realm
|
|
3333
|
-
if (realm
|
|
3334
|
-
throw core_1.TransportErrors.
|
|
3335
|
-
}
|
|
3229
|
+
static async createAddress(publicKey, realm) {
|
|
3230
|
+
if (realm.length !== 3)
|
|
3231
|
+
throw core_1.TransportErrors.general.realmLength();
|
|
3336
3232
|
const sha512buffer = await crypto_1.CryptoHash.hash(publicKey.publicKey, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
3337
3233
|
const hash = await crypto_1.CryptoHash.hash(sha512buffer, 1 /* CryptoHashAlgorithm.SHA256 */);
|
|
3338
3234
|
const hashedPublicKey = new crypto_1.CoreBuffer(hash.buffer.slice(0, 20));
|
|
@@ -3430,7 +3326,6 @@ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-s
|
|
|
3430
3326
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
3431
3327
|
const CoreSerializable_1 = __webpack_require__(/*! ../../../core/CoreSerializable */ "./dist/core/CoreSerializable.js");
|
|
3432
3328
|
const CoreAddress_1 = __webpack_require__(/*! ../../../core/types/CoreAddress */ "./dist/core/types/CoreAddress.js");
|
|
3433
|
-
const CoreDate_1 = __webpack_require__(/*! ../../../core/types/CoreDate */ "./dist/core/types/CoreDate.js");
|
|
3434
3329
|
var Realm;
|
|
3435
3330
|
(function (Realm) {
|
|
3436
3331
|
Realm["Dev"] = "dev";
|
|
@@ -3438,14 +3333,6 @@ var Realm;
|
|
|
3438
3333
|
Realm["Prod"] = "id1";
|
|
3439
3334
|
})(Realm = exports.Realm || (exports.Realm = {}));
|
|
3440
3335
|
let Identity = class Identity extends CoreSerializable_1.CoreSerializable {
|
|
3441
|
-
static postFrom(value) {
|
|
3442
|
-
// TODO: Remove these default values once we're sure that nobody is accessing the deprecated properties anymore
|
|
3443
|
-
value.name = "";
|
|
3444
|
-
value.description = "";
|
|
3445
|
-
value.type = "unknown";
|
|
3446
|
-
value.createdAt = CoreDate_1.CoreDate.from("2020-01-01T00:00:00Z");
|
|
3447
|
-
return value;
|
|
3448
|
-
}
|
|
3449
3336
|
static from(value) {
|
|
3450
3337
|
return this.fromAny(value);
|
|
3451
3338
|
}
|
|
@@ -3465,30 +3352,6 @@ __decorate([
|
|
|
3465
3352
|
(0, ts_serval_1.serialize)(),
|
|
3466
3353
|
__metadata("design:type", String)
|
|
3467
3354
|
], Identity.prototype, "realm", void 0);
|
|
3468
|
-
__decorate([
|
|
3469
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3470
|
-
(0, ts_serval_1.serialize)(),
|
|
3471
|
-
__metadata("design:type", String)
|
|
3472
|
-
], Identity.prototype, "name", void 0);
|
|
3473
|
-
__decorate([
|
|
3474
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3475
|
-
(0, ts_serval_1.serialize)(),
|
|
3476
|
-
__metadata("design:type", String)
|
|
3477
|
-
], Identity.prototype, "description", void 0);
|
|
3478
|
-
__decorate([
|
|
3479
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3480
|
-
(0, ts_serval_1.serialize)(),
|
|
3481
|
-
__metadata("design:type", CoreDate_1.CoreDate
|
|
3482
|
-
/**
|
|
3483
|
-
* @deprecated
|
|
3484
|
-
*/
|
|
3485
|
-
)
|
|
3486
|
-
], Identity.prototype, "createdAt", void 0);
|
|
3487
|
-
__decorate([
|
|
3488
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3489
|
-
(0, ts_serval_1.serialize)(),
|
|
3490
|
-
__metadata("design:type", String)
|
|
3491
|
-
], Identity.prototype, "type", void 0);
|
|
3492
3355
|
Identity = __decorate([
|
|
3493
3356
|
(0, ts_serval_1.type)("Identity")
|
|
3494
3357
|
], Identity);
|
|
@@ -4367,12 +4230,22 @@ exports.CertificateRoleItem = CertificateRoleItem;
|
|
|
4367
4230
|
/*!********************************************************!*\
|
|
4368
4231
|
!*** ./dist/modules/challenges/ChallengeController.js ***!
|
|
4369
4232
|
\********************************************************/
|
|
4370
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
4233
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4371
4234
|
|
|
4372
4235
|
"use strict";
|
|
4373
4236
|
|
|
4237
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4238
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4239
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4240
|
+
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;
|
|
4241
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4242
|
+
};
|
|
4243
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
4244
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4245
|
+
};
|
|
4374
4246
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4375
4247
|
exports.ChallengeController = void 0;
|
|
4248
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
4376
4249
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
4377
4250
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
4378
4251
|
const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
|
|
@@ -4405,7 +4278,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4405
4278
|
isValid = await this.parent.relationships.verifyIdentity(relationship, challengeBuffer, signedChallenge.signature);
|
|
4406
4279
|
break;
|
|
4407
4280
|
case Challenge_1.ChallengeType.Device:
|
|
4408
|
-
throw core_1.TransportErrors.general.
|
|
4281
|
+
throw core_1.TransportErrors.general.notSupported();
|
|
4409
4282
|
case Challenge_1.ChallengeType.Relationship:
|
|
4410
4283
|
isValid = await this.parent.relationships.verify(relationship, challengeBuffer, signedChallenge.signature);
|
|
4411
4284
|
break;
|
|
@@ -4424,8 +4297,6 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4424
4297
|
if (backboneChallengeResponse.isError)
|
|
4425
4298
|
return { isValid: false };
|
|
4426
4299
|
if ((challenge.createdBy && backboneChallengeResponse.value.createdBy !== challenge.createdBy.toString()) ||
|
|
4427
|
-
// TODO: JSSNMSHDD-2472 (Reenable check once the backbone returns with same timestamp)
|
|
4428
|
-
// response.expiresAt !== challenge.expiresAt.toString() ||
|
|
4429
4300
|
backboneChallengeResponse.value.id !== challenge.id.toString()) {
|
|
4430
4301
|
return { isValid: false };
|
|
4431
4302
|
}
|
|
@@ -4449,7 +4320,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4449
4320
|
}
|
|
4450
4321
|
async createChallenge(type = Challenge_1.ChallengeType.Identity, relationship) {
|
|
4451
4322
|
if (type === Challenge_1.ChallengeType.Relationship && !relationship) {
|
|
4452
|
-
throw core_1.TransportErrors.challenges.
|
|
4323
|
+
throw core_1.TransportErrors.challenges.challengeTypeRequiresRelationship();
|
|
4453
4324
|
}
|
|
4454
4325
|
const backboneResponse = (await this.authClient.createChallenge()).value;
|
|
4455
4326
|
const challenge = Challenge_1.Challenge.from({
|
|
@@ -4473,7 +4344,7 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4473
4344
|
break;
|
|
4474
4345
|
case Challenge_1.ChallengeType.Relationship:
|
|
4475
4346
|
if (!relationship) {
|
|
4476
|
-
throw core_1.TransportErrors.challenges.
|
|
4347
|
+
throw core_1.TransportErrors.challenges.challengeTypeRequiresRelationship();
|
|
4477
4348
|
}
|
|
4478
4349
|
signature = await this.parent.relationships.sign(relationship, challengeBuffer);
|
|
4479
4350
|
break;
|
|
@@ -4485,6 +4356,19 @@ class ChallengeController extends TransportController_1.TransportController {
|
|
|
4485
4356
|
return signedChallenge;
|
|
4486
4357
|
}
|
|
4487
4358
|
}
|
|
4359
|
+
__decorate([
|
|
4360
|
+
(0, ts_utils_1.log)(),
|
|
4361
|
+
__metadata("design:type", Function),
|
|
4362
|
+
__metadata("design:paramtypes", [Challenge_1.Challenge,
|
|
4363
|
+
ChallengeSigned_1.ChallengeSigned]),
|
|
4364
|
+
__metadata("design:returntype", Promise)
|
|
4365
|
+
], ChallengeController.prototype, "validateChallengeLocally", null);
|
|
4366
|
+
__decorate([
|
|
4367
|
+
(0, ts_utils_1.log)(),
|
|
4368
|
+
__metadata("design:type", Function),
|
|
4369
|
+
__metadata("design:paramtypes", [String, Relationship_1.Relationship]),
|
|
4370
|
+
__metadata("design:returntype", Promise)
|
|
4371
|
+
], ChallengeController.prototype, "createChallenge", null);
|
|
4488
4372
|
exports.ChallengeController = ChallengeController;
|
|
4489
4373
|
//# sourceMappingURL=ChallengeController.js.map
|
|
4490
4374
|
|
|
@@ -4663,15 +4547,26 @@ exports.ChallengeSigned = ChallengeSigned;
|
|
|
4663
4547
|
/*!**************************************************!*\
|
|
4664
4548
|
!*** ./dist/modules/devices/DeviceController.js ***!
|
|
4665
4549
|
\**************************************************/
|
|
4666
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
4550
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4667
4551
|
|
|
4668
4552
|
"use strict";
|
|
4669
4553
|
|
|
4554
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4555
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4556
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4557
|
+
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;
|
|
4558
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4559
|
+
};
|
|
4560
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
4561
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4562
|
+
};
|
|
4670
4563
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4671
4564
|
exports.DeviceController = void 0;
|
|
4565
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
4672
4566
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
4673
4567
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
4674
4568
|
const DeviceSecretController_1 = __webpack_require__(/*! ./DeviceSecretController */ "./dist/modules/devices/DeviceSecretController.js");
|
|
4569
|
+
const Device_1 = __webpack_require__(/*! ./local/Device */ "./dist/modules/devices/local/Device.js");
|
|
4675
4570
|
const DeviceSecretCredentials_1 = __webpack_require__(/*! ./local/DeviceSecretCredentials */ "./dist/modules/devices/local/DeviceSecretCredentials.js");
|
|
4676
4571
|
class DeviceController extends core_1.TransportController {
|
|
4677
4572
|
constructor(parent) {
|
|
@@ -4706,7 +4601,7 @@ class DeviceController extends core_1.TransportController {
|
|
|
4706
4601
|
}
|
|
4707
4602
|
get device() {
|
|
4708
4603
|
if (!this._device)
|
|
4709
|
-
throw
|
|
4604
|
+
throw new Error("The Device controller is not initialized.");
|
|
4710
4605
|
return this._device;
|
|
4711
4606
|
}
|
|
4712
4607
|
get deviceOrUndefined() {
|
|
@@ -4714,12 +4609,6 @@ class DeviceController extends core_1.TransportController {
|
|
|
4714
4609
|
}
|
|
4715
4610
|
async init(baseKey, device) {
|
|
4716
4611
|
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
4612
|
this._device = device;
|
|
4724
4613
|
this._secrets = await new DeviceSecretController_1.DeviceSecretController(this.parent, baseKey).init();
|
|
4725
4614
|
return this;
|
|
@@ -4740,8 +4629,7 @@ class DeviceController extends core_1.TransportController {
|
|
|
4740
4629
|
await this.secrets.storeSecret(credentials, DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4741
4630
|
}
|
|
4742
4631
|
catch (e) {
|
|
4743
|
-
|
|
4744
|
-
this.log.warn(`We've changed the device password on the backboen but weren't able to store it to the database. The new password is '${newPassword}'.`);
|
|
4632
|
+
this.log.warn(`We've changed the device password on the backbone but weren't able to store it to the database. The new password is '${newPassword}'.`);
|
|
4745
4633
|
throw e;
|
|
4746
4634
|
}
|
|
4747
4635
|
}
|
|
@@ -4758,7 +4646,7 @@ class DeviceController extends core_1.TransportController {
|
|
|
4758
4646
|
async sign(content) {
|
|
4759
4647
|
const privateKeyContainer = await this.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.DeviceSignature);
|
|
4760
4648
|
if (!privateKeyContainer || !(privateKeyContainer.secret instanceof crypto_1.CryptoSignaturePrivateKey)) {
|
|
4761
|
-
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceSignature)
|
|
4649
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceSignature);
|
|
4762
4650
|
}
|
|
4763
4651
|
const privateKey = privateKeyContainer.secret;
|
|
4764
4652
|
const signature = await core_1.CoreCrypto.sign(content, privateKey);
|
|
@@ -4767,21 +4655,21 @@ class DeviceController extends core_1.TransportController {
|
|
|
4767
4655
|
}
|
|
4768
4656
|
async verify(content, signature) {
|
|
4769
4657
|
if (!this.publicKey) {
|
|
4770
|
-
throw
|
|
4658
|
+
throw new Error("The device has no public key to verify a signature. This can happen if the device is not onboarded yet.");
|
|
4771
4659
|
}
|
|
4772
4660
|
return await core_1.CoreCrypto.verify(content, signature, this.publicKey);
|
|
4773
4661
|
}
|
|
4774
4662
|
async getCredentials() {
|
|
4775
4663
|
const credentialContainer = await this.secrets.loadSecret(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4776
4664
|
if (!credentialContainer) {
|
|
4777
|
-
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceCredentials)
|
|
4665
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4778
4666
|
}
|
|
4779
4667
|
if (!(credentialContainer.secret instanceof DeviceSecretCredentials_1.DeviceSecretCredentials)) {
|
|
4780
|
-
throw core_1.TransportErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials)
|
|
4668
|
+
throw core_1.TransportErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4781
4669
|
}
|
|
4782
4670
|
const credentials = credentialContainer.secret;
|
|
4783
4671
|
if (!credentials.username || !credentials.password) {
|
|
4784
|
-
throw core_1.TransportErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials)
|
|
4672
|
+
throw core_1.TransportErrors.secrets.wrongSecretType(DeviceSecretController_1.DeviceSecretType.DeviceCredentials);
|
|
4785
4673
|
}
|
|
4786
4674
|
return {
|
|
4787
4675
|
username: credentials.username,
|
|
@@ -4789,6 +4677,30 @@ class DeviceController extends core_1.TransportController {
|
|
|
4789
4677
|
};
|
|
4790
4678
|
}
|
|
4791
4679
|
}
|
|
4680
|
+
__decorate([
|
|
4681
|
+
(0, ts_utils_1.log)(),
|
|
4682
|
+
__metadata("design:type", Function),
|
|
4683
|
+
__metadata("design:paramtypes", [crypto_1.CryptoSecretKey, Device_1.Device]),
|
|
4684
|
+
__metadata("design:returntype", Promise)
|
|
4685
|
+
], DeviceController.prototype, "init", null);
|
|
4686
|
+
__decorate([
|
|
4687
|
+
(0, ts_utils_1.log)(),
|
|
4688
|
+
__metadata("design:type", Function),
|
|
4689
|
+
__metadata("design:paramtypes", [crypto_1.CoreBuffer]),
|
|
4690
|
+
__metadata("design:returntype", Promise)
|
|
4691
|
+
], DeviceController.prototype, "sign", null);
|
|
4692
|
+
__decorate([
|
|
4693
|
+
(0, ts_utils_1.log)(),
|
|
4694
|
+
__metadata("design:type", Function),
|
|
4695
|
+
__metadata("design:paramtypes", [crypto_1.CoreBuffer, crypto_1.CryptoSignature]),
|
|
4696
|
+
__metadata("design:returntype", Promise)
|
|
4697
|
+
], DeviceController.prototype, "verify", null);
|
|
4698
|
+
__decorate([
|
|
4699
|
+
(0, ts_utils_1.log)(),
|
|
4700
|
+
__metadata("design:type", Function),
|
|
4701
|
+
__metadata("design:paramtypes", []),
|
|
4702
|
+
__metadata("design:returntype", Promise)
|
|
4703
|
+
], DeviceController.prototype, "getCredentials", null);
|
|
4792
4704
|
exports.DeviceController = DeviceController;
|
|
4793
4705
|
//# sourceMappingURL=DeviceController.js.map
|
|
4794
4706
|
|
|
@@ -4798,19 +4710,31 @@ exports.DeviceController = DeviceController;
|
|
|
4798
4710
|
/*!********************************************************!*\
|
|
4799
4711
|
!*** ./dist/modules/devices/DeviceSecretController.js ***!
|
|
4800
4712
|
\********************************************************/
|
|
4801
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
4713
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4802
4714
|
|
|
4803
4715
|
"use strict";
|
|
4804
4716
|
|
|
4717
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4718
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4719
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4720
|
+
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;
|
|
4721
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4722
|
+
};
|
|
4723
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
4724
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4725
|
+
};
|
|
4805
4726
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4806
4727
|
exports.DeviceSecretController = exports.DeviceSecretType = void 0;
|
|
4807
4728
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
4729
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
4808
4730
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
4809
4731
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
4810
4732
|
const TransportController_1 = __webpack_require__(/*! ../../core/TransportController */ "./dist/core/TransportController.js");
|
|
4811
4733
|
const TransportIds_1 = __webpack_require__(/*! ../../core/TransportIds */ "./dist/core/TransportIds.js");
|
|
4812
4734
|
const SecretContainerCipher_1 = __webpack_require__(/*! ../secrets/data/SecretContainerCipher */ "./dist/modules/secrets/data/SecretContainerCipher.js");
|
|
4813
4735
|
const SecretContainerPlain_1 = __webpack_require__(/*! ../secrets/data/SecretContainerPlain */ "./dist/modules/secrets/data/SecretContainerPlain.js");
|
|
4736
|
+
const DatawalletModification_1 = __webpack_require__(/*! ../sync/local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js");
|
|
4737
|
+
const Device_1 = __webpack_require__(/*! ./local/Device */ "./dist/modules/devices/local/Device.js");
|
|
4814
4738
|
const DeviceSharedSecret_1 = __webpack_require__(/*! ./transmission/DeviceSharedSecret */ "./dist/modules/devices/transmission/DeviceSharedSecret.js");
|
|
4815
4739
|
var DeviceSecretType;
|
|
4816
4740
|
(function (DeviceSecretType) {
|
|
@@ -4889,17 +4813,17 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4889
4813
|
async createDeviceSharedSecret(device, deviceIndex, includeIdentityPrivateKey = false) {
|
|
4890
4814
|
const synchronizationKey = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4891
4815
|
if (!synchronizationKey || !(synchronizationKey.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4892
|
-
throw core_1.TransportErrors.secrets.secretNotFound("SynchronizationKey")
|
|
4816
|
+
throw core_1.TransportErrors.secrets.secretNotFound("SynchronizationKey");
|
|
4893
4817
|
}
|
|
4894
4818
|
const baseKey = await this.loadSecret(DeviceSecretType.SharedSecretBaseKey);
|
|
4895
4819
|
if (!baseKey || !(baseKey.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4896
|
-
throw core_1.TransportErrors.secrets.secretNotFound("baseKey")
|
|
4820
|
+
throw core_1.TransportErrors.secrets.secretNotFound("baseKey");
|
|
4897
4821
|
}
|
|
4898
4822
|
let identityPrivateKey;
|
|
4899
4823
|
if (includeIdentityPrivateKey) {
|
|
4900
4824
|
identityPrivateKey = await this.loadSecret(DeviceSecretType.IdentitySignature);
|
|
4901
4825
|
if (!identityPrivateKey || !(identityPrivateKey.secret instanceof crypto_1.CryptoSignaturePrivateKey)) {
|
|
4902
|
-
throw core_1.TransportErrors.secrets.secretNotFound("IdentityKey")
|
|
4826
|
+
throw core_1.TransportErrors.secrets.secretNotFound("IdentityKey");
|
|
4903
4827
|
}
|
|
4904
4828
|
}
|
|
4905
4829
|
const deviceSharedSecret = DeviceSharedSecret_1.DeviceSharedSecret.from({
|
|
@@ -4916,7 +4840,6 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4916
4840
|
password: device.initialPassword,
|
|
4917
4841
|
identity: this.parent.identity.identity
|
|
4918
4842
|
});
|
|
4919
|
-
// TODO: JSSNMSHDD-2474 (Rollback on error)
|
|
4920
4843
|
return deviceSharedSecret;
|
|
4921
4844
|
}
|
|
4922
4845
|
async encryptDatawalletModificationPayload(event, index) {
|
|
@@ -4926,9 +4849,7 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4926
4849
|
const serializedEvent = crypto_1.CoreBuffer.fromUtf8(JSON.stringify(event.payload));
|
|
4927
4850
|
const privSync = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4928
4851
|
if (!privSync || !(privSync.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4929
|
-
throw core_1.TransportErrors.secrets
|
|
4930
|
-
.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster)
|
|
4931
|
-
.logWith(this._log);
|
|
4852
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4932
4853
|
}
|
|
4933
4854
|
const encryptionKey = await core_1.CoreCrypto.deriveKeyFromBase(privSync.secret, index, "DataSync");
|
|
4934
4855
|
const cipher = await core_1.CoreCrypto.encrypt(serializedEvent, encryptionKey);
|
|
@@ -4942,9 +4863,7 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4942
4863
|
const payloadCipher = crypto_1.CryptoCipher.fromBase64(payloadCipherBase64);
|
|
4943
4864
|
const privSync = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4944
4865
|
if (!privSync || !(privSync.secret instanceof crypto_1.CryptoSecretKey)) {
|
|
4945
|
-
throw core_1.TransportErrors.secrets
|
|
4946
|
-
.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster)
|
|
4947
|
-
.logWith(this._log);
|
|
4866
|
+
throw core_1.TransportErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster);
|
|
4948
4867
|
}
|
|
4949
4868
|
const decryptionKey = await core_1.CoreCrypto.deriveKeyFromBase(privSync.secret, index, "DataSync");
|
|
4950
4869
|
const plaintext = await core_1.CoreCrypto.decrypt(payloadCipher, decryptionKey);
|
|
@@ -4954,15 +4873,37 @@ class DeviceSecretController extends TransportController_1.TransportController {
|
|
|
4954
4873
|
}
|
|
4955
4874
|
getBaseKey() {
|
|
4956
4875
|
if (!this.baseKey) {
|
|
4957
|
-
throw core_1.TransportErrors.general
|
|
4958
|
-
.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretType.SharedSecretBaseKey)
|
|
4959
|
-
.logWith(this._log);
|
|
4876
|
+
throw core_1.TransportErrors.general.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretType.SharedSecretBaseKey);
|
|
4960
4877
|
}
|
|
4961
4878
|
return this.baseKey;
|
|
4962
4879
|
}
|
|
4963
4880
|
}
|
|
4964
|
-
exports.DeviceSecretController = DeviceSecretController;
|
|
4965
4881
|
DeviceSecretController.secretContext = "DEVICE01";
|
|
4882
|
+
__decorate([
|
|
4883
|
+
(0, ts_utils_1.log)(),
|
|
4884
|
+
__metadata("design:type", Function),
|
|
4885
|
+
__metadata("design:paramtypes", [Device_1.Device, Number, Object]),
|
|
4886
|
+
__metadata("design:returntype", Promise)
|
|
4887
|
+
], DeviceSecretController.prototype, "createDeviceSharedSecret", null);
|
|
4888
|
+
__decorate([
|
|
4889
|
+
(0, ts_utils_1.log)(),
|
|
4890
|
+
__metadata("design:type", Function),
|
|
4891
|
+
__metadata("design:paramtypes", [DatawalletModification_1.DatawalletModification, Number]),
|
|
4892
|
+
__metadata("design:returntype", Promise)
|
|
4893
|
+
], DeviceSecretController.prototype, "encryptDatawalletModificationPayload", null);
|
|
4894
|
+
__decorate([
|
|
4895
|
+
(0, ts_utils_1.log)(),
|
|
4896
|
+
__metadata("design:type", Function),
|
|
4897
|
+
__metadata("design:paramtypes", [Object, Number]),
|
|
4898
|
+
__metadata("design:returntype", Promise)
|
|
4899
|
+
], DeviceSecretController.prototype, "decryptDatawalletModificationPayload", null);
|
|
4900
|
+
__decorate([
|
|
4901
|
+
(0, ts_utils_1.log)(),
|
|
4902
|
+
__metadata("design:type", Function),
|
|
4903
|
+
__metadata("design:paramtypes", []),
|
|
4904
|
+
__metadata("design:returntype", crypto_1.CryptoSecretKey)
|
|
4905
|
+
], DeviceSecretController.prototype, "getBaseKey", null);
|
|
4906
|
+
exports.DeviceSecretController = DeviceSecretController;
|
|
4966
4907
|
//# sourceMappingURL=DeviceSecretController.js.map
|
|
4967
4908
|
|
|
4968
4909
|
/***/ }),
|
|
@@ -5470,12 +5411,22 @@ exports.DeviceSharedSecret = DeviceSharedSecret;
|
|
|
5470
5411
|
/*!**********************************************!*\
|
|
5471
5412
|
!*** ./dist/modules/files/FileController.js ***!
|
|
5472
5413
|
\**********************************************/
|
|
5473
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
5414
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
5474
5415
|
|
|
5475
5416
|
"use strict";
|
|
5476
5417
|
|
|
5418
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
5419
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5420
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5421
|
+
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;
|
|
5422
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5423
|
+
};
|
|
5424
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
5425
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5426
|
+
};
|
|
5477
5427
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5478
5428
|
exports.FileController = void 0;
|
|
5429
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
5479
5430
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
5480
5431
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
5481
5432
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -5519,7 +5470,6 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5519
5470
|
if (ids.length < 1) {
|
|
5520
5471
|
return [];
|
|
5521
5472
|
}
|
|
5522
|
-
// TODO: JSSNMSHDD-2820 (check for items that couldn't be fetched e.g. because it is expired)
|
|
5523
5473
|
const resultItems = (await this.client.getFiles({ ids })).value;
|
|
5524
5474
|
const promises = [];
|
|
5525
5475
|
for await (const resultItem of resultItems) {
|
|
@@ -5530,7 +5480,7 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5530
5480
|
async updateCacheOfExistingFileInDb(id, response) {
|
|
5531
5481
|
const fileDoc = await this.files.read(id);
|
|
5532
5482
|
if (!fileDoc) {
|
|
5533
|
-
throw core_1.TransportErrors.general.recordNotFound(File_1.File, id)
|
|
5483
|
+
throw core_1.TransportErrors.general.recordNotFound(File_1.File, id);
|
|
5534
5484
|
}
|
|
5535
5485
|
const file = File_1.File.from(fileDoc);
|
|
5536
5486
|
await this.updateCacheOfFile(file, response);
|
|
@@ -5552,9 +5502,8 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5552
5502
|
const plaintextMetadataBuffer = await core_1.CoreCrypto.decrypt(cipher, secretKey);
|
|
5553
5503
|
const plaintextMetadata = FileMetadata_1.FileMetadata.deserialize(plaintextMetadataBuffer.toUtf8());
|
|
5554
5504
|
if (!(plaintextMetadata instanceof FileMetadata_1.FileMetadata)) {
|
|
5555
|
-
throw core_1.TransportErrors.files.invalidMetadata(response.id)
|
|
5505
|
+
throw core_1.TransportErrors.files.invalidMetadata(response.id);
|
|
5556
5506
|
}
|
|
5557
|
-
// TODO: JSSNMSHDD-2486 (check signature)
|
|
5558
5507
|
const cachedFile = CachedFile_1.CachedFile.fromBackbone(response, plaintextMetadata);
|
|
5559
5508
|
return cachedFile;
|
|
5560
5509
|
}
|
|
@@ -5585,7 +5534,7 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5585
5534
|
const id = idOrFile instanceof core_1.CoreId ? idOrFile.toString() : idOrFile.id.toString();
|
|
5586
5535
|
const fileDoc = await this.files.read(id);
|
|
5587
5536
|
if (!fileDoc) {
|
|
5588
|
-
throw core_1.TransportErrors.general.recordNotFound(File_1.File, id.toString())
|
|
5537
|
+
throw core_1.TransportErrors.general.recordNotFound(File_1.File, id.toString());
|
|
5589
5538
|
}
|
|
5590
5539
|
const file = File_1.File.from(fileDoc);
|
|
5591
5540
|
file.setMetadata(metadata);
|
|
@@ -5660,34 +5609,51 @@ class FileController extends TransportController_1.TransportController {
|
|
|
5660
5609
|
async downloadFileContent(idOrFile) {
|
|
5661
5610
|
const file = idOrFile instanceof File_1.File ? idOrFile : await this.getFile(idOrFile);
|
|
5662
5611
|
if (!file) {
|
|
5663
|
-
throw core_1.TransportErrors.general.recordNotFound(File_1.File, idOrFile.toString())
|
|
5612
|
+
throw core_1.TransportErrors.general.recordNotFound(File_1.File, idOrFile.toString());
|
|
5664
5613
|
}
|
|
5665
5614
|
if (!file.cache) {
|
|
5666
|
-
throw core_1.TransportErrors.general.cacheEmpty(File_1.File, file.id.toString())
|
|
5615
|
+
throw core_1.TransportErrors.general.cacheEmpty(File_1.File, file.id.toString());
|
|
5667
5616
|
}
|
|
5668
5617
|
const downloadResponse = (await this.client.downloadFile(file.id.toString())).value;
|
|
5669
5618
|
const buffer = crypto_1.CoreBuffer.fromObject(downloadResponse);
|
|
5670
5619
|
const hash = await crypto_1.CryptoHash.hash(buffer, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
5671
5620
|
const hashb64 = hash.toBase64URL();
|
|
5672
5621
|
if (hashb64 !== file.cache.cipherHash.hash) {
|
|
5673
|
-
throw core_1.TransportErrors.files.cipherMismatch()
|
|
5674
|
-
}
|
|
5675
|
-
/*
|
|
5676
|
-
// TODO: JSSNMSHDD-2486 (verify owner signature)
|
|
5677
|
-
const valid = await Crypto.verify(parcel.cipher.cipher, parcel.ownerSignature, owner.signing)
|
|
5678
|
-
if (!valid) {
|
|
5679
|
-
throw CoreErrors.General.SignatureNotValid("file").logWith(this._log)
|
|
5622
|
+
throw core_1.TransportErrors.files.cipherMismatch();
|
|
5680
5623
|
}
|
|
5681
|
-
*/
|
|
5682
5624
|
const cipher = crypto_1.CryptoCipher.fromBase64(buffer.toBase64URL());
|
|
5683
5625
|
const decrypt = await core_1.CoreCrypto.decrypt(cipher, file.cache.cipherKey);
|
|
5684
5626
|
const plaintextHashesMatch = await file.cache.plaintextHash.verify(decrypt, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
5685
5627
|
if (!plaintextHashesMatch) {
|
|
5686
|
-
throw core_1.TransportErrors.files.plaintextHashMismatch()
|
|
5628
|
+
throw core_1.TransportErrors.files.plaintextHashMismatch();
|
|
5687
5629
|
}
|
|
5688
5630
|
return decrypt;
|
|
5689
5631
|
}
|
|
5690
5632
|
}
|
|
5633
|
+
__decorate([
|
|
5634
|
+
(0, ts_utils_1.log)(),
|
|
5635
|
+
__metadata("design:type", Function),
|
|
5636
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
5637
|
+
__metadata("design:returntype", Promise)
|
|
5638
|
+
], FileController.prototype, "updateCacheOfExistingFileInDb", null);
|
|
5639
|
+
__decorate([
|
|
5640
|
+
(0, ts_utils_1.log)(),
|
|
5641
|
+
__metadata("design:type", Function),
|
|
5642
|
+
__metadata("design:paramtypes", [Object, crypto_1.CryptoSecretKey]),
|
|
5643
|
+
__metadata("design:returntype", Promise)
|
|
5644
|
+
], FileController.prototype, "decryptFile", null);
|
|
5645
|
+
__decorate([
|
|
5646
|
+
(0, ts_utils_1.log)(),
|
|
5647
|
+
__metadata("design:type", Function),
|
|
5648
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
5649
|
+
__metadata("design:returntype", Promise)
|
|
5650
|
+
], FileController.prototype, "setFileMetadata", null);
|
|
5651
|
+
__decorate([
|
|
5652
|
+
(0, ts_utils_1.log)(),
|
|
5653
|
+
__metadata("design:type", Function),
|
|
5654
|
+
__metadata("design:paramtypes", [Object]),
|
|
5655
|
+
__metadata("design:returntype", Promise)
|
|
5656
|
+
], FileController.prototype, "downloadFileContent", null);
|
|
5691
5657
|
exports.FileController = FileController;
|
|
5692
5658
|
//# sourceMappingURL=FileController.js.map
|
|
5693
5659
|
|
|
@@ -6258,9 +6224,9 @@ __exportStar(__webpack_require__(/*! ./messages/local/CachedMessage */ "./dist/m
|
|
|
6258
6224
|
__exportStar(__webpack_require__(/*! ./messages/local/Message */ "./dist/modules/messages/local/Message.js"), exports);
|
|
6259
6225
|
__exportStar(__webpack_require__(/*! ./messages/local/SendMessageParameters */ "./dist/modules/messages/local/SendMessageParameters.js"), exports);
|
|
6260
6226
|
__exportStar(__webpack_require__(/*! ./messages/MessageController */ "./dist/modules/messages/MessageController.js"), exports);
|
|
6227
|
+
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageContentWrapper */ "./dist/modules/messages/transmission/MessageContentWrapper.js"), exports);
|
|
6261
6228
|
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageEnvelope */ "./dist/modules/messages/transmission/MessageEnvelope.js"), exports);
|
|
6262
6229
|
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageEnvelopeRecipient */ "./dist/modules/messages/transmission/MessageEnvelopeRecipient.js"), exports);
|
|
6263
|
-
__exportStar(__webpack_require__(/*! ./messages/transmission/MessagePlain */ "./dist/modules/messages/transmission/MessagePlain.js"), exports);
|
|
6264
6230
|
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageSignature */ "./dist/modules/messages/transmission/MessageSignature.js"), exports);
|
|
6265
6231
|
__exportStar(__webpack_require__(/*! ./messages/transmission/MessageSigned */ "./dist/modules/messages/transmission/MessageSigned.js"), exports);
|
|
6266
6232
|
__exportStar(__webpack_require__(/*! ./relationships/backbone/BackboneGetRelationships */ "./dist/modules/relationships/backbone/BackboneGetRelationships.js"), exports);
|
|
@@ -6279,10 +6245,10 @@ __exportStar(__webpack_require__(/*! ./relationships/transmission/changes/Relati
|
|
|
6279
6245
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/changes/RelationshipChangeType */ "./dist/modules/relationships/transmission/changes/RelationshipChangeType.js"), exports);
|
|
6280
6246
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/RelationshipStatus */ "./dist/modules/relationships/transmission/RelationshipStatus.js"), exports);
|
|
6281
6247
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/requests/RelationshipCreationChangeRequestCipher */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestCipher.js"), exports);
|
|
6282
|
-
__exportStar(__webpack_require__(/*! ./relationships/transmission/requests/
|
|
6248
|
+
__exportStar(__webpack_require__(/*! ./relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js"), exports);
|
|
6283
6249
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/requests/RelationshipCreationChangeRequestSigned */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestSigned.js"), exports);
|
|
6284
6250
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/responses/RelationshipCreationChangeResponseCipher */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseCipher.js"), exports);
|
|
6285
|
-
__exportStar(__webpack_require__(/*! ./relationships/transmission/responses/
|
|
6251
|
+
__exportStar(__webpack_require__(/*! ./relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js"), exports);
|
|
6286
6252
|
__exportStar(__webpack_require__(/*! ./relationships/transmission/responses/RelationshipCreationChangeResponseSigned */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseSigned.js"), exports);
|
|
6287
6253
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/backbone/BackboneGetRelationshipTemplates */ "./dist/modules/relationshipTemplates/backbone/BackboneGetRelationshipTemplates.js"), exports);
|
|
6288
6254
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/backbone/BackbonePostRelationshipTemplates */ "./dist/modules/relationshipTemplates/backbone/BackbonePostRelationshipTemplates.js"), exports);
|
|
@@ -6291,7 +6257,7 @@ __exportStar(__webpack_require__(/*! ./relationshipTemplates/local/CachedRelatio
|
|
|
6291
6257
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js"), exports);
|
|
6292
6258
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/local/SendRelationshipTemplateParameters */ "./dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js"), exports);
|
|
6293
6259
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/RelationshipTemplateController */ "./dist/modules/relationshipTemplates/RelationshipTemplateController.js"), exports);
|
|
6294
|
-
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/
|
|
6260
|
+
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/RelationshipTemplateContentWrapper */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js"), exports);
|
|
6295
6261
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/RelationshipTemplatePublicKey */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.js"), exports);
|
|
6296
6262
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/RelationshipTemplateReference */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.js"), exports);
|
|
6297
6263
|
__exportStar(__webpack_require__(/*! ./relationshipTemplates/transmission/RelationshipTemplateSigned */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateSigned.js"), exports);
|
|
@@ -6334,12 +6300,22 @@ __exportStar(__webpack_require__(/*! ./tokens/transmission/TokenReference */ "./
|
|
|
6334
6300
|
/*!****************************************************!*\
|
|
6335
6301
|
!*** ./dist/modules/messages/MessageController.js ***!
|
|
6336
6302
|
\****************************************************/
|
|
6337
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
6303
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
6338
6304
|
|
|
6339
6305
|
"use strict";
|
|
6340
6306
|
|
|
6307
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
6308
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6309
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6310
|
+
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;
|
|
6311
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6312
|
+
};
|
|
6313
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
6314
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6315
|
+
};
|
|
6341
6316
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6342
6317
|
exports.MessageController = void 0;
|
|
6318
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
6343
6319
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
6344
6320
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
6345
6321
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
@@ -6353,9 +6329,9 @@ const MessageClient_1 = __webpack_require__(/*! ./backbone/MessageClient */ "./d
|
|
|
6353
6329
|
const CachedMessage_1 = __webpack_require__(/*! ./local/CachedMessage */ "./dist/modules/messages/local/CachedMessage.js");
|
|
6354
6330
|
const Message_1 = __webpack_require__(/*! ./local/Message */ "./dist/modules/messages/local/Message.js");
|
|
6355
6331
|
const SendMessageParameters_1 = __webpack_require__(/*! ./local/SendMessageParameters */ "./dist/modules/messages/local/SendMessageParameters.js");
|
|
6332
|
+
const MessageContentWrapper_1 = __webpack_require__(/*! ./transmission/MessageContentWrapper */ "./dist/modules/messages/transmission/MessageContentWrapper.js");
|
|
6356
6333
|
const MessageEnvelope_1 = __webpack_require__(/*! ./transmission/MessageEnvelope */ "./dist/modules/messages/transmission/MessageEnvelope.js");
|
|
6357
6334
|
const MessageEnvelopeRecipient_1 = __webpack_require__(/*! ./transmission/MessageEnvelopeRecipient */ "./dist/modules/messages/transmission/MessageEnvelopeRecipient.js");
|
|
6358
|
-
const MessagePlain_1 = __webpack_require__(/*! ./transmission/MessagePlain */ "./dist/modules/messages/transmission/MessagePlain.js");
|
|
6359
6335
|
const MessageSignature_1 = __webpack_require__(/*! ./transmission/MessageSignature */ "./dist/modules/messages/transmission/MessageSignature.js");
|
|
6360
6336
|
const MessageSigned_1 = __webpack_require__(/*! ./transmission/MessageSigned */ "./dist/modules/messages/transmission/MessageSigned.js");
|
|
6361
6337
|
class MessageController extends TransportController_1.TransportController {
|
|
@@ -6385,7 +6361,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6385
6361
|
async getMessagesByAddress(address) {
|
|
6386
6362
|
const relationship = await this.parent.relationships.getActiveRelationshipToIdentity(address);
|
|
6387
6363
|
if (!relationship) {
|
|
6388
|
-
throw core_1.TransportErrors.messages.noMatchingRelationship(address.toString())
|
|
6364
|
+
throw core_1.TransportErrors.messages.noMatchingRelationship(address.toString());
|
|
6389
6365
|
}
|
|
6390
6366
|
return await this.getMessagesByRelationshipId(relationship.id);
|
|
6391
6367
|
}
|
|
@@ -6425,7 +6401,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6425
6401
|
async updateCacheOfExistingMessageInDb(id, response) {
|
|
6426
6402
|
const messageDoc = await this.messages.read(id);
|
|
6427
6403
|
if (!messageDoc) {
|
|
6428
|
-
throw core_1.TransportErrors.general.recordNotFound(Message_1.Message, id)
|
|
6404
|
+
throw core_1.TransportErrors.general.recordNotFound(Message_1.Message, id);
|
|
6429
6405
|
}
|
|
6430
6406
|
const message = Message_1.Message.from(messageDoc);
|
|
6431
6407
|
await this.updateCacheOfMessage(message, response);
|
|
@@ -6447,7 +6423,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6447
6423
|
const envelope = this.getEnvelopeFromBackboneGetMessagesResponse(response);
|
|
6448
6424
|
const [cachedMessage, messageKey, relationship] = await this.decryptMessage(envelope);
|
|
6449
6425
|
if (!relationship) {
|
|
6450
|
-
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, envelope.id.toString())
|
|
6426
|
+
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, envelope.id.toString());
|
|
6451
6427
|
}
|
|
6452
6428
|
const message = Message_1.Message.from({
|
|
6453
6429
|
id: envelope.id,
|
|
@@ -6485,7 +6461,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6485
6461
|
const id = idOrMessage instanceof core_1.CoreId ? idOrMessage.toString() : idOrMessage.id.toString();
|
|
6486
6462
|
const messageDoc = await this.messages.read(id);
|
|
6487
6463
|
if (!messageDoc) {
|
|
6488
|
-
throw core_1.TransportErrors.general.recordNotFound(Message_1.Message, id.toString())
|
|
6464
|
+
throw core_1.TransportErrors.general.recordNotFound(Message_1.Message, id.toString());
|
|
6489
6465
|
}
|
|
6490
6466
|
const message = Message_1.Message.from(messageDoc);
|
|
6491
6467
|
message.setMetadata(metadata);
|
|
@@ -6503,7 +6479,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6503
6479
|
for (const recipient of parameters.recipients) {
|
|
6504
6480
|
const relationship = await this.relationships.getActiveRelationshipToIdentity(core_1.CoreAddress.from(recipient));
|
|
6505
6481
|
if (!relationship) {
|
|
6506
|
-
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString())
|
|
6482
|
+
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString());
|
|
6507
6483
|
}
|
|
6508
6484
|
const cipherForRecipient = await this.secrets.encrypt(relationship.relationshipSecretId, serializedSecret);
|
|
6509
6485
|
envelopeRecipients.push(MessageEnvelopeRecipient_1.MessageEnvelopeRecipient.from({
|
|
@@ -6519,7 +6495,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6519
6495
|
fileReferences.push(file.toFileReference());
|
|
6520
6496
|
publicAttachmentArray.push(file.id);
|
|
6521
6497
|
}
|
|
6522
|
-
const plaintext =
|
|
6498
|
+
const plaintext = MessageContentWrapper_1.MessageContentWrapper.from({
|
|
6523
6499
|
content: parameters.content,
|
|
6524
6500
|
recipients: addressArray,
|
|
6525
6501
|
createdAt: core_1.CoreDate.utc(),
|
|
@@ -6532,7 +6508,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6532
6508
|
for (const recipient of parameters.recipients) {
|
|
6533
6509
|
const relationship = await this.relationships.getActiveRelationshipToIdentity(core_1.CoreAddress.from(recipient));
|
|
6534
6510
|
if (!relationship) {
|
|
6535
|
-
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString())
|
|
6511
|
+
throw core_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, recipient.toString());
|
|
6536
6512
|
}
|
|
6537
6513
|
const signature = await this.secrets.sign(relationship.relationshipSecretId, plaintextBuffer);
|
|
6538
6514
|
const messageSignature = MessageSignature_1.MessageSignature.from({
|
|
@@ -6589,14 +6565,14 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6589
6565
|
this.log.trace(`Decrypting own envelope with id ${envelope.id.toString()}...`);
|
|
6590
6566
|
const plaintextMessageBuffer = await core_1.CoreCrypto.decrypt(envelope.cipher, secretKey);
|
|
6591
6567
|
const signedMessage = MessageSigned_1.MessageSigned.deserialize(plaintextMessageBuffer.toUtf8());
|
|
6592
|
-
const messagePlain =
|
|
6568
|
+
const messagePlain = MessageContentWrapper_1.MessageContentWrapper.from(JSON.parse(signedMessage.message));
|
|
6593
6569
|
return messagePlain;
|
|
6594
6570
|
}
|
|
6595
6571
|
async decryptPeerEnvelope(envelope, relationship) {
|
|
6596
6572
|
var _a, _b;
|
|
6597
6573
|
const ownKeyCipher = (_a = envelope.recipients.find((r) => this.parent.identity.isMe(r.address))) === null || _a === void 0 ? void 0 : _a.encryptedKey;
|
|
6598
6574
|
if (!ownKeyCipher) {
|
|
6599
|
-
throw core_1.TransportErrors.messages.ownAddressNotInList(envelope.id.toString())
|
|
6575
|
+
throw core_1.TransportErrors.messages.ownAddressNotInList(envelope.id.toString());
|
|
6600
6576
|
}
|
|
6601
6577
|
const plaintextKeyBuffer = await this.secrets.decryptPeer(relationship.relationshipSecretId, ownKeyCipher, true);
|
|
6602
6578
|
const plaintextKey = crypto_1.CryptoSecretKey.deserialize(plaintextKeyBuffer.toUtf8());
|
|
@@ -6604,16 +6580,16 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6604
6580
|
const signedMessage = MessageSigned_1.MessageSigned.deserialize(plaintextMessageBuffer.toUtf8());
|
|
6605
6581
|
const signature = (_b = signedMessage.signatures.find((s) => this.parent.identity.isMe(s.recipient))) === null || _b === void 0 ? void 0 : _b.signature;
|
|
6606
6582
|
if (!signature) {
|
|
6607
|
-
throw core_1.TransportErrors.messages.signatureListMismatch(envelope.id.toString())
|
|
6583
|
+
throw core_1.TransportErrors.messages.signatureListMismatch(envelope.id.toString());
|
|
6608
6584
|
}
|
|
6609
|
-
const messagePlain =
|
|
6585
|
+
const messagePlain = MessageContentWrapper_1.MessageContentWrapper.from(JSON.parse(signedMessage.message));
|
|
6610
6586
|
if (signedMessage.signatures.length !== messagePlain.recipients.length) {
|
|
6611
6587
|
this.log.debug(`Number of signatures does not match number of recipients from envelope ${envelope.id}.`);
|
|
6612
6588
|
}
|
|
6613
6589
|
const plainMessageBuffer = crypto_1.CoreBuffer.fromUtf8(signedMessage.message);
|
|
6614
6590
|
const validSignature = await this.secrets.verifyPeer(relationship.relationshipSecretId, plainMessageBuffer, signature);
|
|
6615
6591
|
if (!validSignature) {
|
|
6616
|
-
throw core_1.TransportErrors.messages.signatureNotValid()
|
|
6592
|
+
throw core_1.TransportErrors.messages.signatureNotValid();
|
|
6617
6593
|
}
|
|
6618
6594
|
if (messagePlain.recipients.length !== envelope.recipients.length) {
|
|
6619
6595
|
this.log.debug(`Number of signed recipients within the message does not match number of recipients from envelope ${envelope.id}.`);
|
|
@@ -6623,7 +6599,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6623
6599
|
}
|
|
6624
6600
|
const recipientFound = messagePlain.recipients.some((r) => this.parent.identity.isMe(r));
|
|
6625
6601
|
if (!recipientFound) {
|
|
6626
|
-
throw core_1.TransportErrors.messages.plaintextMismatch(envelope.id.toString())
|
|
6602
|
+
throw core_1.TransportErrors.messages.plaintextMismatch(envelope.id.toString());
|
|
6627
6603
|
}
|
|
6628
6604
|
return [messagePlain, plaintextKey];
|
|
6629
6605
|
}
|
|
@@ -6634,7 +6610,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6634
6610
|
let relationship;
|
|
6635
6611
|
if (this.parent.identity.isMe(envelope.createdBy)) {
|
|
6636
6612
|
if (!secretKey) {
|
|
6637
|
-
throw
|
|
6613
|
+
throw new Error(`The own message (${envelope.id.toString()}) could not be decrypted, because no secret key was passed for it.`);
|
|
6638
6614
|
}
|
|
6639
6615
|
messageKey = secretKey;
|
|
6640
6616
|
plainMessage = await this.decryptOwnEnvelope(envelope, secretKey);
|
|
@@ -6642,7 +6618,7 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6642
6618
|
else {
|
|
6643
6619
|
relationship = await this.relationships.getActiveRelationshipToIdentity(envelope.createdBy);
|
|
6644
6620
|
if (!relationship) {
|
|
6645
|
-
throw core_1.TransportErrors.messages.noMatchingRelationship(envelope.createdBy.toString())
|
|
6621
|
+
throw core_1.TransportErrors.messages.noMatchingRelationship(envelope.createdBy.toString());
|
|
6646
6622
|
}
|
|
6647
6623
|
const [peerMessage, peerKey] = await this.decryptPeerEnvelope(envelope, relationship);
|
|
6648
6624
|
plainMessage = peerMessage;
|
|
@@ -6669,6 +6645,50 @@ class MessageController extends TransportController_1.TransportController {
|
|
|
6669
6645
|
return [cachedMessage, messageKey, relationship];
|
|
6670
6646
|
}
|
|
6671
6647
|
}
|
|
6648
|
+
__decorate([
|
|
6649
|
+
(0, ts_utils_1.log)(),
|
|
6650
|
+
__metadata("design:type", Function),
|
|
6651
|
+
__metadata("design:paramtypes", [core_1.CoreAddress]),
|
|
6652
|
+
__metadata("design:returntype", Promise)
|
|
6653
|
+
], MessageController.prototype, "getMessagesByAddress", null);
|
|
6654
|
+
__decorate([
|
|
6655
|
+
(0, ts_utils_1.log)(),
|
|
6656
|
+
__metadata("design:type", Function),
|
|
6657
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
6658
|
+
__metadata("design:returntype", Promise)
|
|
6659
|
+
], MessageController.prototype, "updateCacheOfExistingMessageInDb", null);
|
|
6660
|
+
__decorate([
|
|
6661
|
+
(0, ts_utils_1.log)(),
|
|
6662
|
+
__metadata("design:type", Function),
|
|
6663
|
+
__metadata("design:paramtypes", [core_1.CoreId]),
|
|
6664
|
+
__metadata("design:returntype", Promise)
|
|
6665
|
+
], MessageController.prototype, "loadPeerMessage", null);
|
|
6666
|
+
__decorate([
|
|
6667
|
+
(0, ts_utils_1.log)(),
|
|
6668
|
+
__metadata("design:type", Function),
|
|
6669
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
6670
|
+
__metadata("design:returntype", Promise)
|
|
6671
|
+
], MessageController.prototype, "setMessageMetadata", null);
|
|
6672
|
+
__decorate([
|
|
6673
|
+
(0, ts_utils_1.log)(),
|
|
6674
|
+
__metadata("design:type", Function),
|
|
6675
|
+
__metadata("design:paramtypes", [Object]),
|
|
6676
|
+
__metadata("design:returntype", Promise)
|
|
6677
|
+
], MessageController.prototype, "sendMessage", null);
|
|
6678
|
+
__decorate([
|
|
6679
|
+
(0, ts_utils_1.log)(),
|
|
6680
|
+
__metadata("design:type", Function),
|
|
6681
|
+
__metadata("design:paramtypes", [MessageEnvelope_1.MessageEnvelope,
|
|
6682
|
+
Relationship_1.Relationship]),
|
|
6683
|
+
__metadata("design:returntype", Promise)
|
|
6684
|
+
], MessageController.prototype, "decryptPeerEnvelope", null);
|
|
6685
|
+
__decorate([
|
|
6686
|
+
(0, ts_utils_1.log)(),
|
|
6687
|
+
__metadata("design:type", Function),
|
|
6688
|
+
__metadata("design:paramtypes", [MessageEnvelope_1.MessageEnvelope,
|
|
6689
|
+
crypto_1.CryptoSecretKey]),
|
|
6690
|
+
__metadata("design:returntype", Promise)
|
|
6691
|
+
], MessageController.prototype, "decryptMessage", null);
|
|
6672
6692
|
exports.MessageController = MessageController;
|
|
6673
6693
|
//# sourceMappingURL=MessageController.js.map
|
|
6674
6694
|
|
|
@@ -6955,6 +6975,83 @@ exports.SendMessageParameters = SendMessageParameters;
|
|
|
6955
6975
|
|
|
6956
6976
|
/***/ }),
|
|
6957
6977
|
|
|
6978
|
+
/***/ "./dist/modules/messages/transmission/MessageContentWrapper.js":
|
|
6979
|
+
/*!*********************************************************************!*\
|
|
6980
|
+
!*** ./dist/modules/messages/transmission/MessageContentWrapper.js ***!
|
|
6981
|
+
\*********************************************************************/
|
|
6982
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
6983
|
+
|
|
6984
|
+
"use strict";
|
|
6985
|
+
|
|
6986
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
6987
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6988
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6989
|
+
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;
|
|
6990
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6991
|
+
};
|
|
6992
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
6993
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
6994
|
+
};
|
|
6995
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6996
|
+
exports.MessageContentWrapper = void 0;
|
|
6997
|
+
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
6998
|
+
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
6999
|
+
const CoreAddress_1 = __webpack_require__(/*! ../../../core/types/CoreAddress */ "./dist/core/types/CoreAddress.js");
|
|
7000
|
+
const CoreDate_1 = __webpack_require__(/*! ../../../core/types/CoreDate */ "./dist/core/types/CoreDate.js");
|
|
7001
|
+
const FileReference_1 = __webpack_require__(/*! ../../files/transmission/FileReference */ "./dist/modules/files/transmission/FileReference.js");
|
|
7002
|
+
/**
|
|
7003
|
+
* MessageContentWrapper is a container for the actual message as [[IMessage]], its creationDate and
|
|
7004
|
+
* the list of recipients as [[IAddress]]. This container instance is then digitally signed
|
|
7005
|
+
* by the sender via an [[MessageSigned]] object.
|
|
7006
|
+
*
|
|
7007
|
+
* Insofar, the sender digitally signs the date of creation of this message (which could act as a
|
|
7008
|
+
* legal proof). Additionally, all recipients can - and must - check if they are addressed by
|
|
7009
|
+
* the sender. If a recipient is not in the signed list of recipients, the message needs to be
|
|
7010
|
+
* ignored (as the whole message could have been forwarded by bad party to a wrong recipient).
|
|
7011
|
+
*/
|
|
7012
|
+
let MessageContentWrapper = class MessageContentWrapper extends core_1.CoreSerializable {
|
|
7013
|
+
constructor() {
|
|
7014
|
+
super(...arguments);
|
|
7015
|
+
this.attachments = [];
|
|
7016
|
+
}
|
|
7017
|
+
static preFrom(value) {
|
|
7018
|
+
if (typeof value.attachments === "undefined") {
|
|
7019
|
+
value.attachments = [];
|
|
7020
|
+
}
|
|
7021
|
+
return value;
|
|
7022
|
+
}
|
|
7023
|
+
static from(value) {
|
|
7024
|
+
return this.fromAny(value);
|
|
7025
|
+
}
|
|
7026
|
+
};
|
|
7027
|
+
__decorate([
|
|
7028
|
+
(0, ts_serval_1.validate)(),
|
|
7029
|
+
(0, ts_serval_1.serialize)({ type: FileReference_1.FileReference }),
|
|
7030
|
+
__metadata("design:type", Array)
|
|
7031
|
+
], MessageContentWrapper.prototype, "attachments", void 0);
|
|
7032
|
+
__decorate([
|
|
7033
|
+
(0, ts_serval_1.validate)(),
|
|
7034
|
+
(0, ts_serval_1.serialize)(),
|
|
7035
|
+
__metadata("design:type", ts_serval_1.Serializable)
|
|
7036
|
+
], MessageContentWrapper.prototype, "content", void 0);
|
|
7037
|
+
__decorate([
|
|
7038
|
+
(0, ts_serval_1.validate)(),
|
|
7039
|
+
(0, ts_serval_1.serialize)(),
|
|
7040
|
+
__metadata("design:type", CoreDate_1.CoreDate)
|
|
7041
|
+
], MessageContentWrapper.prototype, "createdAt", void 0);
|
|
7042
|
+
__decorate([
|
|
7043
|
+
(0, ts_serval_1.validate)(),
|
|
7044
|
+
(0, ts_serval_1.serialize)({ type: CoreAddress_1.CoreAddress }),
|
|
7045
|
+
__metadata("design:type", Array)
|
|
7046
|
+
], MessageContentWrapper.prototype, "recipients", void 0);
|
|
7047
|
+
MessageContentWrapper = __decorate([
|
|
7048
|
+
(0, ts_serval_1.type)("MessageContentWrapper")
|
|
7049
|
+
], MessageContentWrapper);
|
|
7050
|
+
exports.MessageContentWrapper = MessageContentWrapper;
|
|
7051
|
+
//# sourceMappingURL=MessageContentWrapper.js.map
|
|
7052
|
+
|
|
7053
|
+
/***/ }),
|
|
7054
|
+
|
|
6958
7055
|
/***/ "./dist/modules/messages/transmission/MessageEnvelope.js":
|
|
6959
7056
|
/*!***************************************************************!*\
|
|
6960
7057
|
!*** ./dist/modules/messages/transmission/MessageEnvelope.js ***!
|
|
@@ -7101,83 +7198,6 @@ exports.MessageEnvelopeRecipient = MessageEnvelopeRecipient;
|
|
|
7101
7198
|
|
|
7102
7199
|
/***/ }),
|
|
7103
7200
|
|
|
7104
|
-
/***/ "./dist/modules/messages/transmission/MessagePlain.js":
|
|
7105
|
-
/*!************************************************************!*\
|
|
7106
|
-
!*** ./dist/modules/messages/transmission/MessagePlain.js ***!
|
|
7107
|
-
\************************************************************/
|
|
7108
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7109
|
-
|
|
7110
|
-
"use strict";
|
|
7111
|
-
|
|
7112
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7113
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7114
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7115
|
-
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;
|
|
7116
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7117
|
-
};
|
|
7118
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
7119
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7120
|
-
};
|
|
7121
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7122
|
-
exports.MessagePlain = void 0;
|
|
7123
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
7124
|
-
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
7125
|
-
const CoreAddress_1 = __webpack_require__(/*! ../../../core/types/CoreAddress */ "./dist/core/types/CoreAddress.js");
|
|
7126
|
-
const CoreDate_1 = __webpack_require__(/*! ../../../core/types/CoreDate */ "./dist/core/types/CoreDate.js");
|
|
7127
|
-
const FileReference_1 = __webpack_require__(/*! ../../files/transmission/FileReference */ "./dist/modules/files/transmission/FileReference.js");
|
|
7128
|
-
/**
|
|
7129
|
-
* MessagePlain is a container for the actual message as [[IMessage]], its creationDate and
|
|
7130
|
-
* the list of recipients as [[IAddress]]. This container instance is then digitally signed
|
|
7131
|
-
* by the sender via an [[MessageSigned]] object.
|
|
7132
|
-
*
|
|
7133
|
-
* Insofar, the sender digitally signs the date of creation of this message (which could act as a
|
|
7134
|
-
* legal proof). Additionally, all recipients can - and must - check if they are addressed by
|
|
7135
|
-
* the sender. If a recipient is not in the signed list of recipients, the message needs to be
|
|
7136
|
-
* ignored (as the whole message could have been forwarded by bad party to a wrong recipient).
|
|
7137
|
-
*/
|
|
7138
|
-
let MessagePlain = class MessagePlain extends core_1.CoreSerializable {
|
|
7139
|
-
constructor() {
|
|
7140
|
-
super(...arguments);
|
|
7141
|
-
this.attachments = [];
|
|
7142
|
-
}
|
|
7143
|
-
static preFrom(value) {
|
|
7144
|
-
if (typeof value.attachments === "undefined") {
|
|
7145
|
-
value.attachments = [];
|
|
7146
|
-
}
|
|
7147
|
-
return value;
|
|
7148
|
-
}
|
|
7149
|
-
static from(value) {
|
|
7150
|
-
return this.fromAny(value);
|
|
7151
|
-
}
|
|
7152
|
-
};
|
|
7153
|
-
__decorate([
|
|
7154
|
-
(0, ts_serval_1.validate)(),
|
|
7155
|
-
(0, ts_serval_1.serialize)({ type: FileReference_1.FileReference }),
|
|
7156
|
-
__metadata("design:type", Array)
|
|
7157
|
-
], MessagePlain.prototype, "attachments", void 0);
|
|
7158
|
-
__decorate([
|
|
7159
|
-
(0, ts_serval_1.validate)(),
|
|
7160
|
-
(0, ts_serval_1.serialize)(),
|
|
7161
|
-
__metadata("design:type", ts_serval_1.Serializable)
|
|
7162
|
-
], MessagePlain.prototype, "content", void 0);
|
|
7163
|
-
__decorate([
|
|
7164
|
-
(0, ts_serval_1.validate)(),
|
|
7165
|
-
(0, ts_serval_1.serialize)(),
|
|
7166
|
-
__metadata("design:type", CoreDate_1.CoreDate)
|
|
7167
|
-
], MessagePlain.prototype, "createdAt", void 0);
|
|
7168
|
-
__decorate([
|
|
7169
|
-
(0, ts_serval_1.validate)(),
|
|
7170
|
-
(0, ts_serval_1.serialize)({ type: CoreAddress_1.CoreAddress }),
|
|
7171
|
-
__metadata("design:type", Array)
|
|
7172
|
-
], MessagePlain.prototype, "recipients", void 0);
|
|
7173
|
-
MessagePlain = __decorate([
|
|
7174
|
-
(0, ts_serval_1.type)("MessagePlain")
|
|
7175
|
-
], MessagePlain);
|
|
7176
|
-
exports.MessagePlain = MessagePlain;
|
|
7177
|
-
//# sourceMappingURL=MessagePlain.js.map
|
|
7178
|
-
|
|
7179
|
-
/***/ }),
|
|
7180
|
-
|
|
7181
7201
|
/***/ "./dist/modules/messages/transmission/MessageSignature.js":
|
|
7182
7202
|
/*!****************************************************************!*\
|
|
7183
7203
|
!*** ./dist/modules/messages/transmission/MessageSignature.js ***!
|
|
@@ -7275,12 +7295,22 @@ exports.MessageSigned = MessageSigned;
|
|
|
7275
7295
|
/*!******************************************************************************!*\
|
|
7276
7296
|
!*** ./dist/modules/relationshipTemplates/RelationshipTemplateController.js ***!
|
|
7277
7297
|
\******************************************************************************/
|
|
7278
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
7298
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7279
7299
|
|
|
7280
7300
|
"use strict";
|
|
7281
7301
|
|
|
7302
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7303
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7304
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7305
|
+
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;
|
|
7306
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7307
|
+
};
|
|
7308
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
7309
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7310
|
+
};
|
|
7282
7311
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7283
7312
|
exports.RelationshipTemplateController = void 0;
|
|
7313
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
7284
7314
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
7285
7315
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
7286
7316
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -7290,7 +7320,7 @@ const RelationshipTemplateClient_1 = __webpack_require__(/*! ./backbone/Relation
|
|
|
7290
7320
|
const CachedRelationshipTemplate_1 = __webpack_require__(/*! ./local/CachedRelationshipTemplate */ "./dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js");
|
|
7291
7321
|
const RelationshipTemplate_1 = __webpack_require__(/*! ./local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js");
|
|
7292
7322
|
const SendRelationshipTemplateParameters_1 = __webpack_require__(/*! ./local/SendRelationshipTemplateParameters */ "./dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js");
|
|
7293
|
-
const
|
|
7323
|
+
const RelationshipTemplateContentWrapper_1 = __webpack_require__(/*! ./transmission/RelationshipTemplateContentWrapper */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js");
|
|
7294
7324
|
const RelationshipTemplateReference_1 = __webpack_require__(/*! ./transmission/RelationshipTemplateReference */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.js");
|
|
7295
7325
|
const RelationshipTemplateSigned_1 = __webpack_require__(/*! ./transmission/RelationshipTemplateSigned */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateSigned.js");
|
|
7296
7326
|
class RelationshipTemplateController extends TransportController_1.TransportController {
|
|
@@ -7306,11 +7336,8 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7306
7336
|
}
|
|
7307
7337
|
async sendRelationshipTemplate(parameters) {
|
|
7308
7338
|
parameters = SendRelationshipTemplateParameters_1.SendRelationshipTemplateParameters.from(parameters);
|
|
7309
|
-
if (parameters.maxNumberOfRelationships) {
|
|
7310
|
-
this.log.warn("`maxNumberOfRelationships` is deprecated and will be removed in the future. Please use `maxNumberOfAllocations` instead.");
|
|
7311
|
-
}
|
|
7312
7339
|
const templateKey = await this.secrets.createTemplateKey();
|
|
7313
|
-
const templateContent =
|
|
7340
|
+
const templateContent = RelationshipTemplateContentWrapper_1.RelationshipTemplateContentWrapper.from({
|
|
7314
7341
|
content: parameters.content,
|
|
7315
7342
|
identity: this.parent.identity.identity,
|
|
7316
7343
|
templateKey: templateKey
|
|
@@ -7328,7 +7355,6 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7328
7355
|
const backboneResponse = (await this.client.createRelationshipTemplate({
|
|
7329
7356
|
expiresAt: parameters.expiresAt.toString(),
|
|
7330
7357
|
maxNumberOfAllocations: parameters.maxNumberOfAllocations,
|
|
7331
|
-
maxNumberOfRelationships: parameters.maxNumberOfRelationships,
|
|
7332
7358
|
content: cipher.toBase64()
|
|
7333
7359
|
})).value;
|
|
7334
7360
|
const templateCache = CachedRelationshipTemplate_1.CachedRelationshipTemplate.from({
|
|
@@ -7339,7 +7365,6 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7339
7365
|
expiresAt: parameters.expiresAt,
|
|
7340
7366
|
identity: this.parent.identity.identity,
|
|
7341
7367
|
maxNumberOfAllocations: parameters.maxNumberOfAllocations,
|
|
7342
|
-
maxNumberOfRelationships: parameters.maxNumberOfRelationships,
|
|
7343
7368
|
templateKey: templateKey
|
|
7344
7369
|
});
|
|
7345
7370
|
const template = RelationshipTemplate_1.RelationshipTemplate.from({
|
|
@@ -7364,7 +7389,6 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7364
7389
|
if (ids.length < 1) {
|
|
7365
7390
|
return [];
|
|
7366
7391
|
}
|
|
7367
|
-
// TODO: JSSNMSHDD-2820 (check for items that couldn't be fetched e.g. because it is expired)
|
|
7368
7392
|
const resultItems = (await this.client.getRelationshipTemplates({ ids })).value;
|
|
7369
7393
|
const promises = [];
|
|
7370
7394
|
for await (const resultItem of resultItems) {
|
|
@@ -7386,7 +7410,7 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7386
7410
|
async updateCacheOfExistingTemplateInDb(id, response) {
|
|
7387
7411
|
const templateDoc = await this.templates.read(id);
|
|
7388
7412
|
if (!templateDoc) {
|
|
7389
|
-
throw core_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id)
|
|
7413
|
+
throw core_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id);
|
|
7390
7414
|
}
|
|
7391
7415
|
const template = RelationshipTemplate_1.RelationshipTemplate.from(templateDoc);
|
|
7392
7416
|
await this.updateCacheOfTemplate(template, response);
|
|
@@ -7403,14 +7427,14 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7403
7427
|
template.isOwn = this.parent.identity.isMe(cachedTemplate.createdBy);
|
|
7404
7428
|
}
|
|
7405
7429
|
async decryptRelationshipTemplate(response, secretKey) {
|
|
7406
|
-
var _a
|
|
7430
|
+
var _a;
|
|
7407
7431
|
const cipher = crypto_1.CryptoCipher.fromBase64(response.content);
|
|
7408
7432
|
const signedTemplateBuffer = await this.secrets.decryptTemplate(cipher, secretKey);
|
|
7409
7433
|
const signedTemplate = RelationshipTemplateSigned_1.RelationshipTemplateSigned.deserialize(signedTemplateBuffer.toUtf8());
|
|
7410
|
-
const templateContent =
|
|
7434
|
+
const templateContent = RelationshipTemplateContentWrapper_1.RelationshipTemplateContentWrapper.deserialize(signedTemplate.serializedTemplate);
|
|
7411
7435
|
const templateSignatureValid = await this.secrets.verifyTemplate(crypto_1.CoreBuffer.fromUtf8(signedTemplate.serializedTemplate), signedTemplate.deviceSignature, templateContent.identity.publicKey);
|
|
7412
7436
|
if (!templateSignatureValid) {
|
|
7413
|
-
throw core_1.TransportErrors.general.signatureNotValid("template")
|
|
7437
|
+
throw core_1.TransportErrors.general.signatureNotValid("template");
|
|
7414
7438
|
}
|
|
7415
7439
|
const cachedTemplate = CachedRelationshipTemplate_1.CachedRelationshipTemplate.from({
|
|
7416
7440
|
content: templateContent.content,
|
|
@@ -7420,7 +7444,6 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7420
7444
|
expiresAt: response.expiresAt ? core_1.CoreDate.from(response.expiresAt) : undefined,
|
|
7421
7445
|
identity: templateContent.identity,
|
|
7422
7446
|
maxNumberOfAllocations: (_a = response.maxNumberOfAllocations) !== null && _a !== void 0 ? _a : undefined,
|
|
7423
|
-
maxNumberOfRelationships: (_b = response.maxNumberOfRelationships) !== null && _b !== void 0 ? _b : undefined,
|
|
7424
7447
|
templateKey: templateContent.templateKey
|
|
7425
7448
|
});
|
|
7426
7449
|
return cachedTemplate;
|
|
@@ -7436,7 +7459,7 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7436
7459
|
const id = idOrTemplate instanceof core_1.CoreId ? idOrTemplate.toString() : idOrTemplate.id.toString();
|
|
7437
7460
|
const templateDoc = await this.templates.read(id);
|
|
7438
7461
|
if (!templateDoc) {
|
|
7439
|
-
throw core_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id.toString())
|
|
7462
|
+
throw core_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, id.toString());
|
|
7440
7463
|
}
|
|
7441
7464
|
const template = RelationshipTemplate_1.RelationshipTemplate.from(templateDoc);
|
|
7442
7465
|
template.setMetadata(metadata);
|
|
@@ -7468,6 +7491,24 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
|
|
|
7468
7491
|
return relationshipTemplate;
|
|
7469
7492
|
}
|
|
7470
7493
|
}
|
|
7494
|
+
__decorate([
|
|
7495
|
+
(0, ts_utils_1.log)(),
|
|
7496
|
+
__metadata("design:type", Function),
|
|
7497
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
7498
|
+
__metadata("design:returntype", Promise)
|
|
7499
|
+
], RelationshipTemplateController.prototype, "updateCacheOfExistingTemplateInDb", null);
|
|
7500
|
+
__decorate([
|
|
7501
|
+
(0, ts_utils_1.log)(),
|
|
7502
|
+
__metadata("design:type", Function),
|
|
7503
|
+
__metadata("design:paramtypes", [Object, crypto_1.CryptoSecretKey]),
|
|
7504
|
+
__metadata("design:returntype", Promise)
|
|
7505
|
+
], RelationshipTemplateController.prototype, "decryptRelationshipTemplate", null);
|
|
7506
|
+
__decorate([
|
|
7507
|
+
(0, ts_utils_1.log)(),
|
|
7508
|
+
__metadata("design:type", Function),
|
|
7509
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
7510
|
+
__metadata("design:returntype", Promise)
|
|
7511
|
+
], RelationshipTemplateController.prototype, "setRelationshipTemplateMetadata", null);
|
|
7471
7512
|
exports.RelationshipTemplateController = RelationshipTemplateController;
|
|
7472
7513
|
//# sourceMappingURL=RelationshipTemplateController.js.map
|
|
7473
7514
|
|
|
@@ -7547,7 +7588,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
7547
7588
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7548
7589
|
};
|
|
7549
7590
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7550
|
-
exports.validateMaxNumberOfAllocations = exports.
|
|
7591
|
+
exports.validateMaxNumberOfAllocations = exports.CachedRelationshipTemplate = void 0;
|
|
7551
7592
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
7552
7593
|
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
7553
7594
|
const CoreId_1 = __webpack_require__(/*! ../../../core/types/CoreId */ "./dist/core/types/CoreId.js");
|
|
@@ -7598,24 +7639,10 @@ __decorate([
|
|
|
7598
7639
|
(0, ts_serval_1.serialize)(),
|
|
7599
7640
|
__metadata("design:type", Number)
|
|
7600
7641
|
], CachedRelationshipTemplate.prototype, "maxNumberOfAllocations", void 0);
|
|
7601
|
-
__decorate([
|
|
7602
|
-
(0, ts_serval_1.validate)({ nullable: true, customValidator: validateMaxNumberOfRelationships }),
|
|
7603
|
-
(0, ts_serval_1.serialize)(),
|
|
7604
|
-
__metadata("design:type", Number)
|
|
7605
|
-
], CachedRelationshipTemplate.prototype, "maxNumberOfRelationships", void 0);
|
|
7606
7642
|
CachedRelationshipTemplate = __decorate([
|
|
7607
7643
|
(0, ts_serval_1.type)("CachedRelationshipTemplate")
|
|
7608
7644
|
], CachedRelationshipTemplate);
|
|
7609
7645
|
exports.CachedRelationshipTemplate = CachedRelationshipTemplate;
|
|
7610
|
-
function validateMaxNumberOfRelationships(value) {
|
|
7611
|
-
if (value === undefined)
|
|
7612
|
-
return;
|
|
7613
|
-
if (value <= 0) {
|
|
7614
|
-
return "maxNumberOfRelationships must be greater than 0";
|
|
7615
|
-
}
|
|
7616
|
-
return;
|
|
7617
|
-
}
|
|
7618
|
-
exports.validateMaxNumberOfRelationships = validateMaxNumberOfRelationships;
|
|
7619
7646
|
function validateMaxNumberOfAllocations(value) {
|
|
7620
7647
|
if (value === undefined)
|
|
7621
7648
|
return;
|
|
@@ -7745,22 +7772,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7745
7772
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
7746
7773
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7747
7774
|
};
|
|
7748
|
-
var SendRelationshipTemplateParameters_1;
|
|
7749
7775
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7750
7776
|
exports.SendRelationshipTemplateParameters = void 0;
|
|
7751
7777
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
7752
|
-
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
7753
7778
|
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
7754
7779
|
const CachedRelationshipTemplate_1 = __webpack_require__(/*! ./CachedRelationshipTemplate */ "./dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js");
|
|
7755
|
-
let SendRelationshipTemplateParameters =
|
|
7756
|
-
static postFrom(value) {
|
|
7757
|
-
if (!(value instanceof SendRelationshipTemplateParameters_1))
|
|
7758
|
-
throw new Error("this should never happen");
|
|
7759
|
-
if (value.maxNumberOfAllocations && value.maxNumberOfRelationships) {
|
|
7760
|
-
throw new ts_serval_1.ValidationError(SendRelationshipTemplateParameters_1.name, (0, ts_simple_nameof_1.nameof)((x) => x.maxNumberOfAllocations), `You cannot specify both ${(0, ts_simple_nameof_1.nameof)((x) => x.maxNumberOfAllocations)} and ${(0, ts_simple_nameof_1.nameof)((x) => x.maxNumberOfRelationships)}.`);
|
|
7761
|
-
}
|
|
7762
|
-
return value;
|
|
7763
|
-
}
|
|
7780
|
+
let SendRelationshipTemplateParameters = class SendRelationshipTemplateParameters extends core_1.CoreSerializable {
|
|
7764
7781
|
static from(value) {
|
|
7765
7782
|
return this.fromAny(value);
|
|
7766
7783
|
}
|
|
@@ -7780,12 +7797,7 @@ __decorate([
|
|
|
7780
7797
|
(0, ts_serval_1.serialize)(),
|
|
7781
7798
|
__metadata("design:type", Number)
|
|
7782
7799
|
], SendRelationshipTemplateParameters.prototype, "maxNumberOfAllocations", void 0);
|
|
7783
|
-
__decorate([
|
|
7784
|
-
(0, ts_serval_1.validate)({ nullable: true, customValidator: CachedRelationshipTemplate_1.validateMaxNumberOfRelationships }),
|
|
7785
|
-
(0, ts_serval_1.serialize)(),
|
|
7786
|
-
__metadata("design:type", Number)
|
|
7787
|
-
], SendRelationshipTemplateParameters.prototype, "maxNumberOfRelationships", void 0);
|
|
7788
|
-
SendRelationshipTemplateParameters = SendRelationshipTemplateParameters_1 = __decorate([
|
|
7800
|
+
SendRelationshipTemplateParameters = __decorate([
|
|
7789
7801
|
(0, ts_serval_1.type)("SendRelationshipTemplateParameters")
|
|
7790
7802
|
], SendRelationshipTemplateParameters);
|
|
7791
7803
|
exports.SendRelationshipTemplateParameters = SendRelationshipTemplateParameters;
|
|
@@ -7793,10 +7805,10 @@ exports.SendRelationshipTemplateParameters = SendRelationshipTemplateParameters;
|
|
|
7793
7805
|
|
|
7794
7806
|
/***/ }),
|
|
7795
7807
|
|
|
7796
|
-
/***/ "./dist/modules/relationshipTemplates/transmission/
|
|
7797
|
-
|
|
7798
|
-
!*** ./dist/modules/relationshipTemplates/transmission/
|
|
7799
|
-
|
|
7808
|
+
/***/ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js":
|
|
7809
|
+
/*!***********************************************************************************************!*\
|
|
7810
|
+
!*** ./dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js ***!
|
|
7811
|
+
\***********************************************************************************************/
|
|
7800
7812
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7801
7813
|
|
|
7802
7814
|
"use strict";
|
|
@@ -7811,12 +7823,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
7811
7823
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7812
7824
|
};
|
|
7813
7825
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7814
|
-
exports.
|
|
7826
|
+
exports.RelationshipTemplateContentWrapper = void 0;
|
|
7815
7827
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
7816
7828
|
const core_1 = __webpack_require__(/*! ../../../core */ "./dist/core/index.js");
|
|
7817
7829
|
const Identity_1 = __webpack_require__(/*! ../../accounts/data/Identity */ "./dist/modules/accounts/data/Identity.js");
|
|
7818
7830
|
const RelationshipTemplatePublicKey_1 = __webpack_require__(/*! ./RelationshipTemplatePublicKey */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.js");
|
|
7819
|
-
let
|
|
7831
|
+
let RelationshipTemplateContentWrapper = class RelationshipTemplateContentWrapper extends core_1.CoreSerializable {
|
|
7820
7832
|
static from(value) {
|
|
7821
7833
|
return this.fromAny(value);
|
|
7822
7834
|
}
|
|
@@ -7825,22 +7837,22 @@ __decorate([
|
|
|
7825
7837
|
(0, ts_serval_1.validate)(),
|
|
7826
7838
|
(0, ts_serval_1.serialize)(),
|
|
7827
7839
|
__metadata("design:type", Identity_1.Identity)
|
|
7828
|
-
],
|
|
7840
|
+
], RelationshipTemplateContentWrapper.prototype, "identity", void 0);
|
|
7829
7841
|
__decorate([
|
|
7830
7842
|
(0, ts_serval_1.validate)(),
|
|
7831
7843
|
(0, ts_serval_1.serialize)(),
|
|
7832
7844
|
__metadata("design:type", RelationshipTemplatePublicKey_1.RelationshipTemplatePublicKey)
|
|
7833
|
-
],
|
|
7845
|
+
], RelationshipTemplateContentWrapper.prototype, "templateKey", void 0);
|
|
7834
7846
|
__decorate([
|
|
7835
7847
|
(0, ts_serval_1.validate)(),
|
|
7836
7848
|
(0, ts_serval_1.serialize)(),
|
|
7837
7849
|
__metadata("design:type", ts_serval_1.Serializable)
|
|
7838
|
-
],
|
|
7839
|
-
|
|
7840
|
-
(0, ts_serval_1.type)("
|
|
7841
|
-
],
|
|
7842
|
-
exports.
|
|
7843
|
-
//# sourceMappingURL=
|
|
7850
|
+
], RelationshipTemplateContentWrapper.prototype, "content", void 0);
|
|
7851
|
+
RelationshipTemplateContentWrapper = __decorate([
|
|
7852
|
+
(0, ts_serval_1.type)("RelationshipTemplateContentWrapper")
|
|
7853
|
+
], RelationshipTemplateContentWrapper);
|
|
7854
|
+
exports.RelationshipTemplateContentWrapper = RelationshipTemplateContentWrapper;
|
|
7855
|
+
//# sourceMappingURL=RelationshipTemplateContentWrapper.js.map
|
|
7844
7856
|
|
|
7845
7857
|
/***/ }),
|
|
7846
7858
|
|
|
@@ -7990,17 +8002,28 @@ exports.RelationshipTemplateSigned = RelationshipTemplateSigned;
|
|
|
7990
8002
|
/*!********************************************************************!*\
|
|
7991
8003
|
!*** ./dist/modules/relationships/RelationshipSecretController.js ***!
|
|
7992
8004
|
\********************************************************************/
|
|
7993
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
8005
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
7994
8006
|
|
|
7995
8007
|
"use strict";
|
|
7996
8008
|
|
|
8009
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
8010
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8011
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8012
|
+
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;
|
|
8013
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8014
|
+
};
|
|
8015
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8016
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8017
|
+
};
|
|
7997
8018
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7998
8019
|
exports.RelationshipSecretController = void 0;
|
|
8020
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
7999
8021
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
8000
8022
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
8001
8023
|
const CoreUtil_1 = __webpack_require__(/*! ../../core/CoreUtil */ "./dist/core/CoreUtil.js");
|
|
8002
8024
|
const TransportErrors_1 = __webpack_require__(/*! ../../core/TransportErrors */ "./dist/core/TransportErrors.js");
|
|
8003
8025
|
const TransportIds_1 = __webpack_require__(/*! ../../core/TransportIds */ "./dist/core/TransportIds.js");
|
|
8026
|
+
const CachedRelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/CachedRelationshipTemplate */ "./dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js");
|
|
8004
8027
|
const RelationshipTemplatePublicKey_1 = __webpack_require__(/*! ../relationshipTemplates/transmission/RelationshipTemplatePublicKey */ "./dist/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.js");
|
|
8005
8028
|
const SecretController_1 = __webpack_require__(/*! ../secrets/SecretController */ "./dist/modules/secrets/SecretController.js");
|
|
8006
8029
|
class RelationshipSecretController extends SecretController_1.SecretController {
|
|
@@ -8016,13 +8039,11 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8016
8039
|
}
|
|
8017
8040
|
const secretContainer = await this.loadActiveSecretByName(secretIdAsString);
|
|
8018
8041
|
if (!secretContainer) {
|
|
8019
|
-
throw TransportErrors_1.TransportErrors.general
|
|
8020
|
-
.recordNotFound("CryptoRelationshipRequestSecrets | CryptoRelationshipSecrets", secretIdAsString)
|
|
8021
|
-
.logWith(this._log);
|
|
8042
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound("CryptoRelationshipRequestSecrets | CryptoRelationshipSecrets", secretIdAsString);
|
|
8022
8043
|
}
|
|
8023
8044
|
if (!(secretContainer.secret instanceof crypto_1.CryptoRelationshipRequestSecrets) &&
|
|
8024
8045
|
!(secretContainer.secret instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8025
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secretIdAsString)
|
|
8046
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secretIdAsString);
|
|
8026
8047
|
}
|
|
8027
8048
|
const secret = secretContainer.secret;
|
|
8028
8049
|
this.cache.set(relationshipSecretId, secret);
|
|
@@ -8038,10 +8059,10 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8038
8059
|
const templateKeyId = template.templateKey.id.toString();
|
|
8039
8060
|
const exchangeKeypairContainer = await this.loadActiveSecretByName(templateKeyId);
|
|
8040
8061
|
if (!exchangeKeypairContainer) {
|
|
8041
|
-
throw TransportErrors_1.TransportErrors.general.recordNotFound(crypto_1.CryptoExchangeKeypair, templateKeyId)
|
|
8062
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(crypto_1.CryptoExchangeKeypair, templateKeyId);
|
|
8042
8063
|
}
|
|
8043
8064
|
if (!(exchangeKeypairContainer.secret instanceof crypto_1.CryptoExchangeKeypair)) {
|
|
8044
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(templateKeyId)
|
|
8065
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(templateKeyId);
|
|
8045
8066
|
}
|
|
8046
8067
|
const exchangeKeypair = exchangeKeypairContainer.secret;
|
|
8047
8068
|
const secrets = await crypto_1.CryptoRelationshipSecrets.fromRelationshipRequest(publicRequestCrypto, exchangeKeypair);
|
|
@@ -8051,12 +8072,10 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8051
8072
|
async getPublicResponse(relationshipSecretId) {
|
|
8052
8073
|
const secret = await this.loadActiveSecretByName(relationshipSecretId.toString());
|
|
8053
8074
|
if (!secret) {
|
|
8054
|
-
throw TransportErrors_1.TransportErrors.general
|
|
8055
|
-
.recordNotFound(crypto_1.CryptoRelationshipSecrets, relationshipSecretId.toString())
|
|
8056
|
-
.logWith(this._log);
|
|
8075
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(crypto_1.CryptoRelationshipSecrets, relationshipSecretId.toString());
|
|
8057
8076
|
}
|
|
8058
8077
|
if (!(secret.secret instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8059
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secret.id.toString())
|
|
8078
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secret.id.toString());
|
|
8060
8079
|
}
|
|
8061
8080
|
const publicResponse = secret.secret.toPublicResponse();
|
|
8062
8081
|
return publicResponse;
|
|
@@ -8064,7 +8083,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8064
8083
|
async convertSecrets(relationshipSecretId, response) {
|
|
8065
8084
|
const request = await this.getSecret(relationshipSecretId);
|
|
8066
8085
|
if (request instanceof crypto_1.CryptoRelationshipSecrets) {
|
|
8067
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType()
|
|
8086
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType();
|
|
8068
8087
|
}
|
|
8069
8088
|
const secrets = await crypto_1.CryptoRelationshipSecrets.fromRelationshipResponse(response, request);
|
|
8070
8089
|
const container = await this.succeedSecretWithName(secrets, relationshipSecretId.toString());
|
|
@@ -8089,7 +8108,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8089
8108
|
const buffer = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
8090
8109
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8091
8110
|
if (!(secrets instanceof crypto_1.CryptoRelationshipRequestSecrets)) {
|
|
8092
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8111
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8093
8112
|
}
|
|
8094
8113
|
return await secrets.encryptRequest(buffer);
|
|
8095
8114
|
}
|
|
@@ -8097,14 +8116,14 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8097
8116
|
const buffer = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
8098
8117
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8099
8118
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8100
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8119
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8101
8120
|
}
|
|
8102
8121
|
return await secrets.encrypt(buffer);
|
|
8103
8122
|
}
|
|
8104
8123
|
async decryptRequest(relationshipSecretId, cipher) {
|
|
8105
8124
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8106
8125
|
if (!(secrets instanceof crypto_1.CryptoRelationshipRequestSecrets) && !(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8107
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(relationshipSecretId.toString())
|
|
8126
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(relationshipSecretId.toString());
|
|
8108
8127
|
}
|
|
8109
8128
|
return await secrets.decryptRequest(cipher);
|
|
8110
8129
|
}
|
|
@@ -8121,7 +8140,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8121
8140
|
async decryptPeer(relationshipSecretId, cipher, omitCounterCheck = false) {
|
|
8122
8141
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8123
8142
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8124
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8143
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8125
8144
|
}
|
|
8126
8145
|
return await secrets.decryptPeer(cipher, omitCounterCheck);
|
|
8127
8146
|
}
|
|
@@ -8132,7 +8151,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8132
8151
|
async decryptOwn(relationshipSecretId, cipher) {
|
|
8133
8152
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8134
8153
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
8135
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8154
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8136
8155
|
}
|
|
8137
8156
|
return await secrets.decryptOwn(cipher);
|
|
8138
8157
|
}
|
|
@@ -8150,12 +8169,76 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
8150
8169
|
const bufferToVerify = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
8151
8170
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
8152
8171
|
if (secrets instanceof crypto_1.CryptoRelationshipRequestSecrets) {
|
|
8153
|
-
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id)
|
|
8172
|
+
throw TransportErrors_1.TransportErrors.secrets.wrongSecretType(secrets.id);
|
|
8154
8173
|
}
|
|
8155
8174
|
const valid = await secrets.verifyPeer(bufferToVerify, signature);
|
|
8156
8175
|
return valid;
|
|
8157
8176
|
}
|
|
8158
8177
|
}
|
|
8178
|
+
__decorate([
|
|
8179
|
+
(0, ts_utils_1.log)(),
|
|
8180
|
+
__metadata("design:type", Function),
|
|
8181
|
+
__metadata("design:paramtypes", [core_1.CoreId]),
|
|
8182
|
+
__metadata("design:returntype", Promise)
|
|
8183
|
+
], RelationshipSecretController.prototype, "getSecret", null);
|
|
8184
|
+
__decorate([
|
|
8185
|
+
(0, ts_utils_1.log)(),
|
|
8186
|
+
__metadata("design:type", Function),
|
|
8187
|
+
__metadata("design:paramtypes", [core_1.CoreId,
|
|
8188
|
+
CachedRelationshipTemplate_1.CachedRelationshipTemplate,
|
|
8189
|
+
crypto_1.CryptoRelationshipPublicRequest]),
|
|
8190
|
+
__metadata("design:returntype", Promise)
|
|
8191
|
+
], RelationshipSecretController.prototype, "createTemplatorSecrets", null);
|
|
8192
|
+
__decorate([
|
|
8193
|
+
(0, ts_utils_1.log)(),
|
|
8194
|
+
__metadata("design:type", Function),
|
|
8195
|
+
__metadata("design:paramtypes", [core_1.CoreId]),
|
|
8196
|
+
__metadata("design:returntype", Promise)
|
|
8197
|
+
], RelationshipSecretController.prototype, "getPublicResponse", null);
|
|
8198
|
+
__decorate([
|
|
8199
|
+
(0, ts_utils_1.log)(),
|
|
8200
|
+
__metadata("design:type", Function),
|
|
8201
|
+
__metadata("design:paramtypes", [core_1.CoreId,
|
|
8202
|
+
crypto_1.CryptoRelationshipPublicResponse]),
|
|
8203
|
+
__metadata("design:returntype", Promise)
|
|
8204
|
+
], RelationshipSecretController.prototype, "convertSecrets", null);
|
|
8205
|
+
__decorate([
|
|
8206
|
+
(0, ts_utils_1.log)(),
|
|
8207
|
+
__metadata("design:type", Function),
|
|
8208
|
+
__metadata("design:paramtypes", [core_1.CoreId, Object]),
|
|
8209
|
+
__metadata("design:returntype", Promise)
|
|
8210
|
+
], RelationshipSecretController.prototype, "encryptRequest", null);
|
|
8211
|
+
__decorate([
|
|
8212
|
+
(0, ts_utils_1.log)(),
|
|
8213
|
+
__metadata("design:type", Function),
|
|
8214
|
+
__metadata("design:paramtypes", [core_1.CoreId, Object]),
|
|
8215
|
+
__metadata("design:returntype", Promise)
|
|
8216
|
+
], RelationshipSecretController.prototype, "encrypt", null);
|
|
8217
|
+
__decorate([
|
|
8218
|
+
(0, ts_utils_1.log)(),
|
|
8219
|
+
__metadata("design:type", Function),
|
|
8220
|
+
__metadata("design:paramtypes", [core_1.CoreId, crypto_1.CryptoCipher]),
|
|
8221
|
+
__metadata("design:returntype", Promise)
|
|
8222
|
+
], RelationshipSecretController.prototype, "decryptRequest", null);
|
|
8223
|
+
__decorate([
|
|
8224
|
+
(0, ts_utils_1.log)(),
|
|
8225
|
+
__metadata("design:type", Function),
|
|
8226
|
+
__metadata("design:paramtypes", [core_1.CoreId,
|
|
8227
|
+
crypto_1.CryptoCipher, Object]),
|
|
8228
|
+
__metadata("design:returntype", Promise)
|
|
8229
|
+
], RelationshipSecretController.prototype, "decryptPeer", null);
|
|
8230
|
+
__decorate([
|
|
8231
|
+
(0, ts_utils_1.log)(),
|
|
8232
|
+
__metadata("design:type", Function),
|
|
8233
|
+
__metadata("design:paramtypes", [core_1.CoreId, crypto_1.CryptoCipher]),
|
|
8234
|
+
__metadata("design:returntype", Promise)
|
|
8235
|
+
], RelationshipSecretController.prototype, "decryptOwn", null);
|
|
8236
|
+
__decorate([
|
|
8237
|
+
(0, ts_utils_1.log)(),
|
|
8238
|
+
__metadata("design:type", Function),
|
|
8239
|
+
__metadata("design:paramtypes", [core_1.CoreId, Object, crypto_1.CryptoSignature]),
|
|
8240
|
+
__metadata("design:returntype", Promise)
|
|
8241
|
+
], RelationshipSecretController.prototype, "verifyPeer", null);
|
|
8159
8242
|
exports.RelationshipSecretController = RelationshipSecretController;
|
|
8160
8243
|
//# sourceMappingURL=RelationshipSecretController.js.map
|
|
8161
8244
|
|
|
@@ -8165,12 +8248,22 @@ exports.RelationshipSecretController = RelationshipSecretController;
|
|
|
8165
8248
|
/*!***************************************************************!*\
|
|
8166
8249
|
!*** ./dist/modules/relationships/RelationshipsController.js ***!
|
|
8167
8250
|
\***************************************************************/
|
|
8168
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
8251
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
8169
8252
|
|
|
8170
8253
|
"use strict";
|
|
8171
8254
|
|
|
8255
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
8256
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8257
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8258
|
+
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;
|
|
8259
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8260
|
+
};
|
|
8261
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8262
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8263
|
+
};
|
|
8172
8264
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
8173
8265
|
exports.RelationshipsController = void 0;
|
|
8266
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
8174
8267
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
8175
8268
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
8176
8269
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
@@ -8190,10 +8283,10 @@ const RelationshipChangeStatus_1 = __webpack_require__(/*! ./transmission/change
|
|
|
8190
8283
|
const RelationshipChangeType_1 = __webpack_require__(/*! ./transmission/changes/RelationshipChangeType */ "./dist/modules/relationships/transmission/changes/RelationshipChangeType.js");
|
|
8191
8284
|
const RelationshipStatus_1 = __webpack_require__(/*! ./transmission/RelationshipStatus */ "./dist/modules/relationships/transmission/RelationshipStatus.js");
|
|
8192
8285
|
const RelationshipCreationChangeRequestCipher_1 = __webpack_require__(/*! ./transmission/requests/RelationshipCreationChangeRequestCipher */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestCipher.js");
|
|
8193
|
-
const
|
|
8286
|
+
const RelationshipCreationChangeRequestContentWrapper_1 = __webpack_require__(/*! ./transmission/requests/RelationshipCreationChangeRequestContentWrapper */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js");
|
|
8194
8287
|
const RelationshipCreationChangeRequestSigned_1 = __webpack_require__(/*! ./transmission/requests/RelationshipCreationChangeRequestSigned */ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestSigned.js");
|
|
8195
8288
|
const RelationshipCreationChangeResponseCipher_1 = __webpack_require__(/*! ./transmission/responses/RelationshipCreationChangeResponseCipher */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseCipher.js");
|
|
8196
|
-
const
|
|
8289
|
+
const RelationshipCreationChangeResponseContentWrapper_1 = __webpack_require__(/*! ./transmission/responses/RelationshipCreationChangeResponseContentWrapper */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js");
|
|
8197
8290
|
const RelationshipCreationChangeResponseSigned_1 = __webpack_require__(/*! ./transmission/responses/RelationshipCreationChangeResponseSigned */ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseSigned.js");
|
|
8198
8291
|
class RelationshipsController extends core_1.TransportController {
|
|
8199
8292
|
constructor(parent, secrets) {
|
|
@@ -8237,9 +8330,8 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8237
8330
|
}
|
|
8238
8331
|
async updateCacheOfExistingRelationshipInDb(id, response) {
|
|
8239
8332
|
const relationshipDoc = await this.relationships.read(id);
|
|
8240
|
-
if (!relationshipDoc)
|
|
8241
|
-
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, id)
|
|
8242
|
-
}
|
|
8333
|
+
if (!relationshipDoc)
|
|
8334
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, id);
|
|
8243
8335
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
8244
8336
|
await this.updateCacheOfRelationship(relationship, response);
|
|
8245
8337
|
await this.relationships.update(relationshipDoc, relationship);
|
|
@@ -8281,7 +8373,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8281
8373
|
parameters = SendRelationshipParameters_1.SendRelationshipParameters.from(parameters);
|
|
8282
8374
|
const template = parameters.template;
|
|
8283
8375
|
if (!template.cache) {
|
|
8284
|
-
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString())
|
|
8376
|
+
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
8285
8377
|
}
|
|
8286
8378
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
8287
8379
|
const { requestCipher, requestContent } = await this.prepareRequest(secretId, template, parameters.content);
|
|
@@ -8297,18 +8389,14 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8297
8389
|
async setRelationshipMetadata(idOrRelationship, metadata) {
|
|
8298
8390
|
const id = idOrRelationship instanceof core_1.CoreId ? idOrRelationship.toString() : idOrRelationship.id.toString();
|
|
8299
8391
|
const relationshipDoc = await this.relationships.read(id);
|
|
8300
|
-
if (!relationshipDoc)
|
|
8301
|
-
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, id.toString())
|
|
8302
|
-
}
|
|
8392
|
+
if (!relationshipDoc)
|
|
8393
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, id.toString());
|
|
8303
8394
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
8304
8395
|
relationship.metadata = metadata;
|
|
8305
8396
|
relationship.metadataModifiedAt = core_1.CoreDate.utc();
|
|
8306
8397
|
await this.relationships.update(relationshipDoc, relationship);
|
|
8307
8398
|
return relationship;
|
|
8308
8399
|
}
|
|
8309
|
-
requestTermination() {
|
|
8310
|
-
throw TransportErrors_1.TransportErrors.general.notImplemented();
|
|
8311
|
-
}
|
|
8312
8400
|
async acceptChange(change, content) {
|
|
8313
8401
|
return await this.completeChange(RelationshipChangeStatus_1.RelationshipChangeStatus.Accepted, change, content);
|
|
8314
8402
|
}
|
|
@@ -8352,10 +8440,10 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8352
8440
|
}
|
|
8353
8441
|
async prepareRequest(relationshipSecretId, template, content) {
|
|
8354
8442
|
if (!template.cache) {
|
|
8355
|
-
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString())
|
|
8443
|
+
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
8356
8444
|
}
|
|
8357
8445
|
const requestPublic = await this.secrets.createRequestorSecrets(template.cache, relationshipSecretId);
|
|
8358
|
-
const requestContent =
|
|
8446
|
+
const requestContent = RelationshipCreationChangeRequestContentWrapper_1.RelationshipCreationChangeRequestContentWrapper.from({
|
|
8359
8447
|
content: content,
|
|
8360
8448
|
identity: this.parent.identity.identity,
|
|
8361
8449
|
templateId: template.id
|
|
@@ -8387,11 +8475,10 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8387
8475
|
case RelationshipChangeType_1.RelationshipChangeType.Creation:
|
|
8388
8476
|
return await this.applyCreationChange(change);
|
|
8389
8477
|
case RelationshipChangeType_1.RelationshipChangeType.Termination:
|
|
8390
|
-
return await this.applyTerminationChange(change);
|
|
8391
8478
|
case RelationshipChangeType_1.RelationshipChangeType.TerminationCancellation:
|
|
8392
|
-
|
|
8479
|
+
throw TransportErrors_1.TransportErrors.general.notSupported();
|
|
8393
8480
|
default:
|
|
8394
|
-
throw TransportErrors_1.TransportErrors.general.incompatibleBackbone()
|
|
8481
|
+
throw TransportErrors_1.TransportErrors.general.incompatibleBackbone();
|
|
8395
8482
|
}
|
|
8396
8483
|
}
|
|
8397
8484
|
async applyCreationChange(change) {
|
|
@@ -8415,9 +8502,8 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8415
8502
|
return newRelationship;
|
|
8416
8503
|
}
|
|
8417
8504
|
async parseCreationChange(change, relationshipSecretId, templateId) {
|
|
8418
|
-
if (change.type !== RelationshipChangeType_1.RelationshipChangeType.Creation)
|
|
8419
|
-
|
|
8420
|
-
}
|
|
8505
|
+
if (change.type !== RelationshipChangeType_1.RelationshipChangeType.Creation)
|
|
8506
|
+
this.throwWrongChangeType(change.type);
|
|
8421
8507
|
const promises = [];
|
|
8422
8508
|
promises.push(this.decryptCreationChangeRequest(change.request, relationshipSecretId, templateId));
|
|
8423
8509
|
const hasRelationshipSecret = await this.secrets.hasCryptoRelationshipSecrets(relationshipSecretId);
|
|
@@ -8429,9 +8515,8 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8429
8515
|
return creationChange;
|
|
8430
8516
|
}
|
|
8431
8517
|
async decryptCreationChangeRequest(change, secretId, templateId) {
|
|
8432
|
-
if (!change.content)
|
|
8433
|
-
throw
|
|
8434
|
-
}
|
|
8518
|
+
if (!change.content)
|
|
8519
|
+
throw this.newEmptyOrInvalidContentError();
|
|
8435
8520
|
const isOwnChange = this.parent.identity.isMe(core_1.CoreAddress.from(change.createdBy));
|
|
8436
8521
|
const requestCipher = RelationshipCreationChangeRequestCipher_1.RelationshipCreationChangeRequestCipher.fromBase64(change.content);
|
|
8437
8522
|
const signedRequestBuffer = await this.secrets.decryptRequest(secretId, requestCipher.cipher);
|
|
@@ -8444,23 +8529,21 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8444
8529
|
relationshipSignatureValid = await this.secrets.verifyPeer(secretId, crypto_1.CoreBuffer.fromUtf8(signedRequest.serializedRequest), signedRequest.relationshipSignature);
|
|
8445
8530
|
}
|
|
8446
8531
|
if (!relationshipSignatureValid) {
|
|
8447
|
-
throw TransportErrors_1.TransportErrors.general.signatureNotValid("relationshipRequest")
|
|
8532
|
+
throw TransportErrors_1.TransportErrors.general.signatureNotValid("relationshipRequest");
|
|
8448
8533
|
}
|
|
8449
|
-
const requestContent =
|
|
8450
|
-
if (requestContent.templateId.
|
|
8451
|
-
throw
|
|
8534
|
+
const requestContent = RelationshipCreationChangeRequestContentWrapper_1.RelationshipCreationChangeRequestContentWrapper.deserialize(signedRequest.serializedRequest);
|
|
8535
|
+
if (!requestContent.templateId.equals(templateId)) {
|
|
8536
|
+
throw new Error("The relationship request contains a wrong template id.");
|
|
8452
8537
|
}
|
|
8453
8538
|
return requestContent;
|
|
8454
8539
|
}
|
|
8455
8540
|
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
|
-
}
|
|
8541
|
+
if (!change.response)
|
|
8542
|
+
throw this.newChangeResponseMissingError(change.id);
|
|
8543
|
+
if (change.type !== RelationshipChangeType_1.RelationshipChangeType.Creation)
|
|
8544
|
+
this.throwWrongChangeType(change.type);
|
|
8462
8545
|
if (!change.response.content) {
|
|
8463
|
-
throw
|
|
8546
|
+
throw this.newEmptyOrInvalidContentError(change);
|
|
8464
8547
|
}
|
|
8465
8548
|
const isOwnChange = this.parent.identity.isMe(core_1.CoreAddress.from(change.response.createdBy));
|
|
8466
8549
|
const cipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.fromBase64(change.response.content);
|
|
@@ -8485,11 +8568,11 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8485
8568
|
relationshipSignatureValid = await this.secrets.verifyPeer(relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
|
|
8486
8569
|
}
|
|
8487
8570
|
if (!relationshipSignatureValid) {
|
|
8488
|
-
throw TransportErrors_1.TransportErrors.general.signatureNotValid("relationshipResponse")
|
|
8571
|
+
throw TransportErrors_1.TransportErrors.general.signatureNotValid("relationshipResponse");
|
|
8489
8572
|
}
|
|
8490
|
-
const responseContent =
|
|
8491
|
-
if (responseContent.relationshipId.
|
|
8492
|
-
throw
|
|
8573
|
+
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.deserialize(signedResponse.serializedResponse);
|
|
8574
|
+
if (!responseContent.relationshipId.equals(change.relationshipId)) {
|
|
8575
|
+
throw new Error("The relationship response contains a wrong relationship id.");
|
|
8493
8576
|
}
|
|
8494
8577
|
return responseContent;
|
|
8495
8578
|
}
|
|
@@ -8502,16 +8585,15 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8502
8585
|
if (!relationship.cache) {
|
|
8503
8586
|
await this.updateCacheOfRelationship(relationship, undefined);
|
|
8504
8587
|
}
|
|
8505
|
-
if (!change.response)
|
|
8506
|
-
throw
|
|
8507
|
-
}
|
|
8588
|
+
if (!change.response)
|
|
8589
|
+
throw this.newChangeResponseMissingError(change.id);
|
|
8508
8590
|
if (!change.response.content) {
|
|
8509
|
-
throw
|
|
8591
|
+
throw this.newEmptyOrInvalidContentError(change);
|
|
8510
8592
|
}
|
|
8511
8593
|
const cipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.fromBase64(change.response.content);
|
|
8512
8594
|
if (change.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Revoked) {
|
|
8513
8595
|
if (!cipher.publicResponseCrypto) {
|
|
8514
|
-
throw
|
|
8596
|
+
throw new Error("The response crypto is missing.");
|
|
8515
8597
|
}
|
|
8516
8598
|
await this.secrets.convertSecrets(relationship.relationshipSecretId, cipher.publicResponseCrypto);
|
|
8517
8599
|
}
|
|
@@ -8532,7 +8614,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8532
8614
|
relationship.toRevoked(response);
|
|
8533
8615
|
break;
|
|
8534
8616
|
default:
|
|
8535
|
-
throw TransportErrors_1.TransportErrors.general.incompatibleBackbone()
|
|
8617
|
+
throw TransportErrors_1.TransportErrors.general.incompatibleBackbone();
|
|
8536
8618
|
}
|
|
8537
8619
|
await this.relationships.update(relationshipDoc, relationship);
|
|
8538
8620
|
return relationship;
|
|
@@ -8541,15 +8623,12 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8541
8623
|
const backboneRelationship = (await this.client.getRelationship(change.relationshipId)).value;
|
|
8542
8624
|
const templateId = core_1.CoreId.from(backboneRelationship.relationshipTemplateId);
|
|
8543
8625
|
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
|
-
}
|
|
8626
|
+
if (!template)
|
|
8627
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString());
|
|
8628
|
+
if (!template.cache)
|
|
8629
|
+
throw TransportErrors_1.TransportErrors.general.cacheEmpty(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
8630
|
+
if (!change.request.content)
|
|
8631
|
+
throw this.newEmptyOrInvalidContentError(change);
|
|
8553
8632
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
8554
8633
|
const requestCipher = RelationshipCreationChangeRequestCipher_1.RelationshipCreationChangeRequestCipher.fromBase64(change.request.content);
|
|
8555
8634
|
await this.secrets.createTemplatorSecrets(secretId, template.cache, requestCipher.publicRequestCrypto);
|
|
@@ -8559,18 +8638,10 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8559
8638
|
await this.relationships.create(relationship);
|
|
8560
8639
|
return relationship;
|
|
8561
8640
|
}
|
|
8562
|
-
applyTerminationChange(_change) {
|
|
8563
|
-
throw TransportErrors_1.TransportErrors.general.notImplemented();
|
|
8564
|
-
}
|
|
8565
|
-
applyTerminationCancellationChange(_change) {
|
|
8566
|
-
throw TransportErrors_1.TransportErrors.general.notImplemented();
|
|
8567
|
-
}
|
|
8568
8641
|
async completeChange(targetStatus, change, content) {
|
|
8569
8642
|
const relationshipDoc = await this.relationships.read(change.relationshipId.toString());
|
|
8570
8643
|
if (!relationshipDoc) {
|
|
8571
|
-
throw TransportErrors_1.TransportErrors.general
|
|
8572
|
-
.recordNotFound(Relationship_1.Relationship, change.relationshipId.toString())
|
|
8573
|
-
.logWith(this._log);
|
|
8644
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(Relationship_1.Relationship, change.relationshipId.toString());
|
|
8574
8645
|
}
|
|
8575
8646
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
8576
8647
|
if (!relationship.cache) {
|
|
@@ -8581,10 +8652,10 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8581
8652
|
}
|
|
8582
8653
|
const queriedChange = relationship.cache.changes.find((r) => r.id.toString() === change.id.toString());
|
|
8583
8654
|
if (!queriedChange) {
|
|
8584
|
-
throw TransportErrors_1.TransportErrors.general.recordNotFound(RelationshipChange_1.RelationshipChange, change.id.toString())
|
|
8655
|
+
throw TransportErrors_1.TransportErrors.general.recordNotFound(RelationshipChange_1.RelationshipChange, change.id.toString());
|
|
8585
8656
|
}
|
|
8586
8657
|
if (queriedChange.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Pending) {
|
|
8587
|
-
throw TransportErrors_1.TransportErrors.relationships.wrongChangeStatus(queriedChange.status)
|
|
8658
|
+
throw TransportErrors_1.TransportErrors.relationships.wrongChangeStatus(queriedChange.status);
|
|
8588
8659
|
}
|
|
8589
8660
|
let encryptedContent;
|
|
8590
8661
|
if (content) {
|
|
@@ -8616,7 +8687,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8616
8687
|
return relationship;
|
|
8617
8688
|
}
|
|
8618
8689
|
async encryptRevokeContent(relationship, content) {
|
|
8619
|
-
const responseContent =
|
|
8690
|
+
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.from({
|
|
8620
8691
|
relationshipId: relationship.id,
|
|
8621
8692
|
content: content
|
|
8622
8693
|
});
|
|
@@ -8639,7 +8710,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8639
8710
|
}
|
|
8640
8711
|
async encryptAcceptRejectContent(relationship, content) {
|
|
8641
8712
|
const publicResponseCrypto = await this.secrets.getPublicResponse(relationship.relationshipSecretId);
|
|
8642
|
-
const responseContent =
|
|
8713
|
+
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.from({
|
|
8643
8714
|
relationshipId: relationship.id,
|
|
8644
8715
|
content: content
|
|
8645
8716
|
});
|
|
@@ -8661,7 +8732,72 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
8661
8732
|
});
|
|
8662
8733
|
return responseCipher.toBase64();
|
|
8663
8734
|
}
|
|
8664
|
-
|
|
8735
|
+
throwWrongChangeType(type) {
|
|
8736
|
+
throw new Error(`The relationship change has the wrong type (${type}) to run this operation`);
|
|
8737
|
+
}
|
|
8738
|
+
newChangeResponseMissingError(changeId) {
|
|
8739
|
+
return new Error(`The response of the relationship change (${changeId}) is missing`);
|
|
8740
|
+
}
|
|
8741
|
+
newEmptyOrInvalidContentError(change) {
|
|
8742
|
+
return new Error(`The content property of the relationship change ${change === null || change === void 0 ? void 0 : change.id} is missing or invalid`);
|
|
8743
|
+
}
|
|
8744
|
+
}
|
|
8745
|
+
__decorate([
|
|
8746
|
+
(0, ts_utils_1.log)(),
|
|
8747
|
+
__metadata("design:type", Function),
|
|
8748
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
8749
|
+
__metadata("design:returntype", Promise)
|
|
8750
|
+
], RelationshipsController.prototype, "updateCacheOfExistingRelationshipInDb", null);
|
|
8751
|
+
__decorate([
|
|
8752
|
+
(0, ts_utils_1.log)(),
|
|
8753
|
+
__metadata("design:type", Function),
|
|
8754
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
8755
|
+
__metadata("design:returntype", Promise)
|
|
8756
|
+
], RelationshipsController.prototype, "setRelationshipMetadata", null);
|
|
8757
|
+
__decorate([
|
|
8758
|
+
(0, ts_utils_1.log)(),
|
|
8759
|
+
__metadata("design:type", Function),
|
|
8760
|
+
__metadata("design:paramtypes", [Object]),
|
|
8761
|
+
__metadata("design:returntype", Promise)
|
|
8762
|
+
], RelationshipsController.prototype, "applyChange", null);
|
|
8763
|
+
__decorate([
|
|
8764
|
+
(0, ts_utils_1.log)(),
|
|
8765
|
+
__metadata("design:type", Function),
|
|
8766
|
+
__metadata("design:paramtypes", [Object, core_1.CoreId,
|
|
8767
|
+
core_1.CoreId]),
|
|
8768
|
+
__metadata("design:returntype", Promise)
|
|
8769
|
+
], RelationshipsController.prototype, "parseCreationChange", null);
|
|
8770
|
+
__decorate([
|
|
8771
|
+
(0, ts_utils_1.log)(),
|
|
8772
|
+
__metadata("design:type", Function),
|
|
8773
|
+
__metadata("design:paramtypes", [Object, core_1.CoreId,
|
|
8774
|
+
core_1.CoreId]),
|
|
8775
|
+
__metadata("design:returntype", Promise)
|
|
8776
|
+
], RelationshipsController.prototype, "decryptCreationChangeRequest", null);
|
|
8777
|
+
__decorate([
|
|
8778
|
+
(0, ts_utils_1.log)(),
|
|
8779
|
+
__metadata("design:type", Function),
|
|
8780
|
+
__metadata("design:paramtypes", [Object, core_1.CoreId]),
|
|
8781
|
+
__metadata("design:returntype", Promise)
|
|
8782
|
+
], RelationshipsController.prototype, "decryptCreationChangeResponse", null);
|
|
8783
|
+
__decorate([
|
|
8784
|
+
(0, ts_utils_1.log)(),
|
|
8785
|
+
__metadata("design:type", Function),
|
|
8786
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
8787
|
+
__metadata("design:returntype", Promise)
|
|
8788
|
+
], RelationshipsController.prototype, "updatePendingRelationshipWithPeerResponse", null);
|
|
8789
|
+
__decorate([
|
|
8790
|
+
(0, ts_utils_1.log)(),
|
|
8791
|
+
__metadata("design:type", Function),
|
|
8792
|
+
__metadata("design:paramtypes", [Object]),
|
|
8793
|
+
__metadata("design:returntype", Promise)
|
|
8794
|
+
], RelationshipsController.prototype, "createNewRelationshipByIncomingCreationChange", null);
|
|
8795
|
+
__decorate([
|
|
8796
|
+
(0, ts_utils_1.log)(),
|
|
8797
|
+
__metadata("design:type", Function),
|
|
8798
|
+
__metadata("design:paramtypes", [String, RelationshipChange_1.RelationshipChange, Object]),
|
|
8799
|
+
__metadata("design:returntype", Promise)
|
|
8800
|
+
], RelationshipsController.prototype, "completeChange", null);
|
|
8665
8801
|
exports.RelationshipsController = RelationshipsController;
|
|
8666
8802
|
//# sourceMappingURL=RelationshipsController.js.map
|
|
8667
8803
|
|
|
@@ -9329,10 +9465,10 @@ exports.RelationshipCreationChangeRequestCipher = RelationshipCreationChangeRequ
|
|
|
9329
9465
|
|
|
9330
9466
|
/***/ }),
|
|
9331
9467
|
|
|
9332
|
-
/***/ "./dist/modules/relationships/transmission/requests/
|
|
9333
|
-
|
|
9334
|
-
!*** ./dist/modules/relationships/transmission/requests/
|
|
9335
|
-
|
|
9468
|
+
/***/ "./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js":
|
|
9469
|
+
/*!*************************************************************************************************************!*\
|
|
9470
|
+
!*** ./dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js ***!
|
|
9471
|
+
\*************************************************************************************************************/
|
|
9336
9472
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
9337
9473
|
|
|
9338
9474
|
"use strict";
|
|
@@ -9347,11 +9483,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9347
9483
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9348
9484
|
};
|
|
9349
9485
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9350
|
-
exports.
|
|
9486
|
+
exports.RelationshipCreationChangeRequestContentWrapper = void 0;
|
|
9351
9487
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
9352
9488
|
const core_1 = __webpack_require__(/*! ../../../../core */ "./dist/core/index.js");
|
|
9353
9489
|
const Identity_1 = __webpack_require__(/*! ../../../accounts/data/Identity */ "./dist/modules/accounts/data/Identity.js");
|
|
9354
|
-
let
|
|
9490
|
+
let RelationshipCreationChangeRequestContentWrapper = class RelationshipCreationChangeRequestContentWrapper extends core_1.CoreSerializable {
|
|
9355
9491
|
static from(value) {
|
|
9356
9492
|
return this.fromAny(value);
|
|
9357
9493
|
}
|
|
@@ -9360,22 +9496,22 @@ __decorate([
|
|
|
9360
9496
|
(0, ts_serval_1.validate)(),
|
|
9361
9497
|
(0, ts_serval_1.serialize)(),
|
|
9362
9498
|
__metadata("design:type", Identity_1.Identity)
|
|
9363
|
-
],
|
|
9499
|
+
], RelationshipCreationChangeRequestContentWrapper.prototype, "identity", void 0);
|
|
9364
9500
|
__decorate([
|
|
9365
9501
|
(0, ts_serval_1.validate)(),
|
|
9366
9502
|
(0, ts_serval_1.serialize)(),
|
|
9367
9503
|
__metadata("design:type", ts_serval_1.Serializable)
|
|
9368
|
-
],
|
|
9504
|
+
], RelationshipCreationChangeRequestContentWrapper.prototype, "content", void 0);
|
|
9369
9505
|
__decorate([
|
|
9370
9506
|
(0, ts_serval_1.validate)(),
|
|
9371
9507
|
(0, ts_serval_1.serialize)(),
|
|
9372
9508
|
__metadata("design:type", core_1.CoreId)
|
|
9373
|
-
],
|
|
9374
|
-
|
|
9375
|
-
(0, ts_serval_1.type)("
|
|
9376
|
-
],
|
|
9377
|
-
exports.
|
|
9378
|
-
//# sourceMappingURL=
|
|
9509
|
+
], RelationshipCreationChangeRequestContentWrapper.prototype, "templateId", void 0);
|
|
9510
|
+
RelationshipCreationChangeRequestContentWrapper = __decorate([
|
|
9511
|
+
(0, ts_serval_1.type)("RelationshipCreationChangeRequestContentWrapper")
|
|
9512
|
+
], RelationshipCreationChangeRequestContentWrapper);
|
|
9513
|
+
exports.RelationshipCreationChangeRequestContentWrapper = RelationshipCreationChangeRequestContentWrapper;
|
|
9514
|
+
//# sourceMappingURL=RelationshipCreationChangeRequestContentWrapper.js.map
|
|
9379
9515
|
|
|
9380
9516
|
/***/ }),
|
|
9381
9517
|
|
|
@@ -9477,10 +9613,10 @@ exports.RelationshipCreationChangeResponseCipher = RelationshipCreationChangeRes
|
|
|
9477
9613
|
|
|
9478
9614
|
/***/ }),
|
|
9479
9615
|
|
|
9480
|
-
/***/ "./dist/modules/relationships/transmission/responses/
|
|
9481
|
-
|
|
9482
|
-
!*** ./dist/modules/relationships/transmission/responses/
|
|
9483
|
-
|
|
9616
|
+
/***/ "./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js":
|
|
9617
|
+
/*!***************************************************************************************************************!*\
|
|
9618
|
+
!*** ./dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js ***!
|
|
9619
|
+
\***************************************************************************************************************/
|
|
9484
9620
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
9485
9621
|
|
|
9486
9622
|
"use strict";
|
|
@@ -9495,10 +9631,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9495
9631
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9496
9632
|
};
|
|
9497
9633
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9498
|
-
exports.
|
|
9634
|
+
exports.RelationshipCreationChangeResponseContentWrapper = void 0;
|
|
9499
9635
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
9500
9636
|
const core_1 = __webpack_require__(/*! ../../../../core */ "./dist/core/index.js");
|
|
9501
|
-
let
|
|
9637
|
+
let RelationshipCreationChangeResponseContentWrapper = class RelationshipCreationChangeResponseContentWrapper extends core_1.CoreSerializable {
|
|
9502
9638
|
static from(value) {
|
|
9503
9639
|
return this.fromAny(value);
|
|
9504
9640
|
}
|
|
@@ -9507,17 +9643,17 @@ __decorate([
|
|
|
9507
9643
|
(0, ts_serval_1.validate)(),
|
|
9508
9644
|
(0, ts_serval_1.serialize)(),
|
|
9509
9645
|
__metadata("design:type", ts_serval_1.Serializable)
|
|
9510
|
-
],
|
|
9646
|
+
], RelationshipCreationChangeResponseContentWrapper.prototype, "content", void 0);
|
|
9511
9647
|
__decorate([
|
|
9512
9648
|
(0, ts_serval_1.validate)(),
|
|
9513
9649
|
(0, ts_serval_1.serialize)(),
|
|
9514
9650
|
__metadata("design:type", core_1.CoreId)
|
|
9515
|
-
],
|
|
9516
|
-
|
|
9517
|
-
(0, ts_serval_1.type)("
|
|
9518
|
-
],
|
|
9519
|
-
exports.
|
|
9520
|
-
//# sourceMappingURL=
|
|
9651
|
+
], RelationshipCreationChangeResponseContentWrapper.prototype, "relationshipId", void 0);
|
|
9652
|
+
RelationshipCreationChangeResponseContentWrapper = __decorate([
|
|
9653
|
+
(0, ts_serval_1.type)("RelationshipCreationChangeResponseContentWrapper")
|
|
9654
|
+
], RelationshipCreationChangeResponseContentWrapper);
|
|
9655
|
+
exports.RelationshipCreationChangeResponseContentWrapper = RelationshipCreationChangeResponseContentWrapper;
|
|
9656
|
+
//# sourceMappingURL=RelationshipCreationChangeResponseContentWrapper.js.map
|
|
9521
9657
|
|
|
9522
9658
|
/***/ }),
|
|
9523
9659
|
|
|
@@ -9575,13 +9711,23 @@ exports.RelationshipCreationChangeResponseSigned = RelationshipCreationChangeRes
|
|
|
9575
9711
|
/*!**************************************************!*\
|
|
9576
9712
|
!*** ./dist/modules/secrets/SecretController.js ***!
|
|
9577
9713
|
\**************************************************/
|
|
9578
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
9714
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
9579
9715
|
|
|
9580
9716
|
"use strict";
|
|
9581
9717
|
|
|
9718
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
9719
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9720
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9721
|
+
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;
|
|
9722
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9723
|
+
};
|
|
9724
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9725
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9726
|
+
};
|
|
9582
9727
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9583
9728
|
exports.SecretController = exports.SecretBaseKeyType = void 0;
|
|
9584
9729
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
9730
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
9585
9731
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
9586
9732
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
9587
9733
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -9714,7 +9860,6 @@ class SecretController extends TransportController_1.TransportController {
|
|
|
9714
9860
|
async createExchangeKey(name = "", description = "", validTo) {
|
|
9715
9861
|
const exchangeKeypair = await core_1.CoreCrypto.generateExchangeKeypair();
|
|
9716
9862
|
const secretContainer = await this.storeSecret(exchangeKeypair, name, description, validTo);
|
|
9717
|
-
// TODO: JSSNMSHDD-2485 (wipe private key)
|
|
9718
9863
|
return [exchangeKeypair.publicKey, secretContainer];
|
|
9719
9864
|
}
|
|
9720
9865
|
async getBaseKey() {
|
|
@@ -9726,9 +9871,7 @@ class SecretController extends TransportController_1.TransportController {
|
|
|
9726
9871
|
this.baseKey = baseKey.secret;
|
|
9727
9872
|
}
|
|
9728
9873
|
else {
|
|
9729
|
-
throw core_1.TransportErrors.general
|
|
9730
|
-
.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretController_1.DeviceSecretType.SharedSecretBaseKey)
|
|
9731
|
-
.logWith(this._log);
|
|
9874
|
+
throw core_1.TransportErrors.general.recordNotFound(crypto_1.CryptoSecretKey, DeviceSecretController_1.DeviceSecretType.SharedSecretBaseKey);
|
|
9732
9875
|
}
|
|
9733
9876
|
return this.baseKey;
|
|
9734
9877
|
}
|
|
@@ -9738,13 +9881,19 @@ class SecretController extends TransportController_1.TransportController {
|
|
|
9738
9881
|
return nextNonce;
|
|
9739
9882
|
}
|
|
9740
9883
|
}
|
|
9741
|
-
exports.SecretController = SecretController;
|
|
9742
9884
|
/**
|
|
9743
9885
|
* Context of the secret derivation function. Doesn't have to be secret.
|
|
9744
9886
|
* Must be 8 characters long.
|
|
9745
9887
|
*/
|
|
9746
9888
|
SecretController.secretContext = "SECRET01";
|
|
9747
9889
|
SecretController.secretNonceKey = "secret_lastnonce";
|
|
9890
|
+
__decorate([
|
|
9891
|
+
(0, ts_utils_1.log)(),
|
|
9892
|
+
__metadata("design:type", Function),
|
|
9893
|
+
__metadata("design:paramtypes", []),
|
|
9894
|
+
__metadata("design:returntype", Promise)
|
|
9895
|
+
], SecretController.prototype, "getBaseKey", null);
|
|
9896
|
+
exports.SecretController = SecretController;
|
|
9748
9897
|
//# sourceMappingURL=SecretController.js.map
|
|
9749
9898
|
|
|
9750
9899
|
/***/ }),
|
|
@@ -10040,11 +10189,21 @@ exports.DatawalletModificationMapper = DatawalletModificationMapper;
|
|
|
10040
10189
|
|
|
10041
10190
|
"use strict";
|
|
10042
10191
|
|
|
10192
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10193
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10194
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10195
|
+
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;
|
|
10196
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10197
|
+
};
|
|
10198
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10199
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10200
|
+
};
|
|
10043
10201
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10044
10202
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10045
10203
|
};
|
|
10046
10204
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
10047
10205
|
exports.CacheFetcher = exports.DatawalletModificationsProcessor = void 0;
|
|
10206
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
10048
10207
|
const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"));
|
|
10049
10208
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
10050
10209
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -10076,6 +10235,9 @@ class DatawalletModificationsProcessor {
|
|
|
10076
10235
|
const totalItems = this.creates.length + this.updates.length + this.deletes.length + this.cacheChanges.length;
|
|
10077
10236
|
this.syncStep = reporter.createStep(SyncCallback_1.SyncStep.DatawalletSyncProcessing, totalItems);
|
|
10078
10237
|
}
|
|
10238
|
+
get log() {
|
|
10239
|
+
return this.logger;
|
|
10240
|
+
}
|
|
10079
10241
|
async execute() {
|
|
10080
10242
|
await this.applyCreates();
|
|
10081
10243
|
await this.applyUpdates();
|
|
@@ -10164,9 +10326,7 @@ class DatawalletModificationsProcessor {
|
|
|
10164
10326
|
const uniqueCollections = [...new Set(collections)];
|
|
10165
10327
|
const collectionsWithUncacheableItems = uniqueCollections.filter((c) => !this.collectionsWithCacheableItems.includes(c));
|
|
10166
10328
|
if (collectionsWithUncacheableItems.length > 0) {
|
|
10167
|
-
throw core_1.TransportErrors.datawallet
|
|
10168
|
-
.unsupportedModification("unsupportedCacheChangedModificationCollection", collectionsWithUncacheableItems)
|
|
10169
|
-
.logWith(this.logger);
|
|
10329
|
+
throw core_1.TransportErrors.datawallet.unsupportedModification("unsupportedCacheChangedModificationCollection", collectionsWithUncacheableItems);
|
|
10170
10330
|
}
|
|
10171
10331
|
}
|
|
10172
10332
|
groupCacheChangesByCollection(cacheChanges) {
|
|
@@ -10202,6 +10362,12 @@ class DatawalletModificationsProcessor {
|
|
|
10202
10362
|
}
|
|
10203
10363
|
}
|
|
10204
10364
|
}
|
|
10365
|
+
__decorate([
|
|
10366
|
+
(0, ts_utils_1.log)(),
|
|
10367
|
+
__metadata("design:type", Function),
|
|
10368
|
+
__metadata("design:paramtypes", []),
|
|
10369
|
+
__metadata("design:returntype", void 0)
|
|
10370
|
+
], DatawalletModificationsProcessor.prototype, "ensureAllItemsAreCacheable", null);
|
|
10205
10371
|
exports.DatawalletModificationsProcessor = DatawalletModificationsProcessor;
|
|
10206
10372
|
class CacheFetcher {
|
|
10207
10373
|
constructor(fileController, messageController, relationshipTemplateController, relationshipController, tokenController) {
|
|
@@ -10385,12 +10551,22 @@ var SyncStep;
|
|
|
10385
10551
|
/*!*********************************************!*\
|
|
10386
10552
|
!*** ./dist/modules/sync/SyncController.js ***!
|
|
10387
10553
|
\*********************************************/
|
|
10388
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
10554
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
10389
10555
|
|
|
10390
10556
|
"use strict";
|
|
10391
10557
|
|
|
10558
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10559
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10560
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10561
|
+
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;
|
|
10562
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10563
|
+
};
|
|
10564
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10565
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10566
|
+
};
|
|
10392
10567
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
10393
10568
|
exports.SyncController = void 0;
|
|
10569
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
10394
10570
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
10395
10571
|
const StartSyncRun_1 = __webpack_require__(/*! ./backbone/StartSyncRun */ "./dist/modules/sync/backbone/StartSyncRun.js");
|
|
10396
10572
|
const SyncClient_1 = __webpack_require__(/*! ./backbone/SyncClient */ "./dist/modules/sync/backbone/SyncClient.js");
|
|
@@ -10466,7 +10642,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10466
10642
|
throw new core_1.CoreError("error.transport.errorWhileApplyingExternalEvents", externalEventSyncResult.externalEventResults
|
|
10467
10643
|
.filter((r) => r.errorCode !== undefined)
|
|
10468
10644
|
.map((r) => r.errorCode)
|
|
10469
|
-
.join(" | "))
|
|
10645
|
+
.join(" | "));
|
|
10470
10646
|
}
|
|
10471
10647
|
syncStep.finish();
|
|
10472
10648
|
if (this.datawalletEnabled && (await this.unpushedDatawalletModifications.exists())) {
|
|
@@ -10496,9 +10672,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10496
10672
|
if (this.config.supportedDatawalletVersion < identityDatawalletVersion) {
|
|
10497
10673
|
// This means that the datawallet of the identity was upgraded by another device with a higher version.
|
|
10498
10674
|
// It is necesssary to update the current device.
|
|
10499
|
-
throw core_1.TransportErrors.datawallet
|
|
10500
|
-
.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion)
|
|
10501
|
-
.logWith(this.log);
|
|
10675
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion);
|
|
10502
10676
|
}
|
|
10503
10677
|
this.log.trace("Synchronization of Datawallet events started...");
|
|
10504
10678
|
try {
|
|
@@ -10510,9 +10684,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10510
10684
|
const outdatedErrorCode = "error.platform.validation.datawallet.insufficientSupportedDatawalletVersion";
|
|
10511
10685
|
if (!(e instanceof core_1.RequestError) || e.code !== outdatedErrorCode)
|
|
10512
10686
|
throw e;
|
|
10513
|
-
throw core_1.TransportErrors.datawallet
|
|
10514
|
-
.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion)
|
|
10515
|
-
.logWith(this.log);
|
|
10687
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion);
|
|
10516
10688
|
}
|
|
10517
10689
|
this.log.trace("Synchronization of Datawallet events ended...");
|
|
10518
10690
|
await this.checkDatawalletVersion(identityDatawalletVersion);
|
|
@@ -10520,9 +10692,7 @@ class SyncController extends core_1.TransportController {
|
|
|
10520
10692
|
async checkDatawalletVersion(identityDatawalletVersion) {
|
|
10521
10693
|
var _a;
|
|
10522
10694
|
if (this.config.supportedDatawalletVersion < identityDatawalletVersion) {
|
|
10523
|
-
throw core_1.TransportErrors.datawallet
|
|
10524
|
-
.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion)
|
|
10525
|
-
.logWith(this.log);
|
|
10695
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion);
|
|
10526
10696
|
}
|
|
10527
10697
|
if (this.config.supportedDatawalletVersion > identityDatawalletVersion) {
|
|
10528
10698
|
await this.upgradeIdentityDatawalletVersion(identityDatawalletVersion, this.config.supportedDatawalletVersion);
|
|
@@ -10536,21 +10706,17 @@ class SyncController extends core_1.TransportController {
|
|
|
10536
10706
|
if (identityDatawalletVersion === targetDatawalletVersion)
|
|
10537
10707
|
return;
|
|
10538
10708
|
if (this.config.supportedDatawalletVersion < targetDatawalletVersion) {
|
|
10539
|
-
throw core_1.TransportErrors.datawallet
|
|
10540
|
-
.insufficientSupportedDatawalletVersion(targetDatawalletVersion, identityDatawalletVersion)
|
|
10541
|
-
.logWith(this.log);
|
|
10709
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, identityDatawalletVersion);
|
|
10542
10710
|
}
|
|
10543
10711
|
if (identityDatawalletVersion > targetDatawalletVersion) {
|
|
10544
|
-
throw core_1.TransportErrors.datawallet
|
|
10545
|
-
.currentBiggerThanTarget(identityDatawalletVersion, targetDatawalletVersion)
|
|
10546
|
-
.logWith(this.log);
|
|
10712
|
+
throw core_1.TransportErrors.datawallet.currentBiggerThanTarget(identityDatawalletVersion, targetDatawalletVersion);
|
|
10547
10713
|
}
|
|
10548
10714
|
while (identityDatawalletVersion < targetDatawalletVersion) {
|
|
10549
10715
|
identityDatawalletVersion++;
|
|
10550
10716
|
await this.startDatawalletVersionUpgradeSyncRun();
|
|
10551
10717
|
const migrationFunction = this.identityMigrations[`v${identityDatawalletVersion}`];
|
|
10552
10718
|
if (!migrationFunction) {
|
|
10553
|
-
throw
|
|
10719
|
+
throw this.newNoMigrationAvailableError(identityDatawalletVersion);
|
|
10554
10720
|
}
|
|
10555
10721
|
await migrationFunction.call(this.identityMigrations);
|
|
10556
10722
|
await this.finalizeDatawalletVersionUpgradeSyncRun(identityDatawalletVersion);
|
|
@@ -10560,20 +10726,16 @@ class SyncController extends core_1.TransportController {
|
|
|
10560
10726
|
if (deviceDatawalletVersion === targetDatawalletVersion)
|
|
10561
10727
|
return;
|
|
10562
10728
|
if (this.config.supportedDatawalletVersion < targetDatawalletVersion) {
|
|
10563
|
-
throw core_1.TransportErrors.datawallet
|
|
10564
|
-
.insufficientSupportedDatawalletVersion(targetDatawalletVersion, deviceDatawalletVersion)
|
|
10565
|
-
.logWith(this.log);
|
|
10729
|
+
throw core_1.TransportErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, deviceDatawalletVersion);
|
|
10566
10730
|
}
|
|
10567
10731
|
if (deviceDatawalletVersion > targetDatawalletVersion) {
|
|
10568
|
-
throw core_1.TransportErrors.datawallet
|
|
10569
|
-
.currentBiggerThanTarget(deviceDatawalletVersion, targetDatawalletVersion)
|
|
10570
|
-
.logWith(this.log);
|
|
10732
|
+
throw core_1.TransportErrors.datawallet.currentBiggerThanTarget(deviceDatawalletVersion, targetDatawalletVersion);
|
|
10571
10733
|
}
|
|
10572
10734
|
while (deviceDatawalletVersion < targetDatawalletVersion) {
|
|
10573
10735
|
deviceDatawalletVersion++;
|
|
10574
10736
|
const migrationFunction = this.deviceMigrations[`v${deviceDatawalletVersion}`];
|
|
10575
10737
|
if (!migrationFunction) {
|
|
10576
|
-
throw
|
|
10738
|
+
throw this.newNoMigrationAvailableError(deviceDatawalletVersion);
|
|
10577
10739
|
}
|
|
10578
10740
|
await migrationFunction.call(this.deviceMigrations);
|
|
10579
10741
|
await this.parent.activeDevice.update({ datawalletVersion: deviceDatawalletVersion });
|
|
@@ -10750,7 +10912,40 @@ class SyncController extends core_1.TransportController {
|
|
|
10750
10912
|
async setLastCompletedDatawalletSyncTime() {
|
|
10751
10913
|
await this.setSyncTimeByName("Datawallet");
|
|
10752
10914
|
}
|
|
10915
|
+
newNoMigrationAvailableError(version) {
|
|
10916
|
+
return new Error(`There is no migration available for the datawallet version '${version}'.`);
|
|
10917
|
+
}
|
|
10753
10918
|
}
|
|
10919
|
+
__decorate([
|
|
10920
|
+
(0, ts_utils_1.log)(),
|
|
10921
|
+
__metadata("design:type", Function),
|
|
10922
|
+
__metadata("design:paramtypes", [String, SyncCallback_1.SyncProgressReporter]),
|
|
10923
|
+
__metadata("design:returntype", Promise)
|
|
10924
|
+
], SyncController.prototype, "_sync", null);
|
|
10925
|
+
__decorate([
|
|
10926
|
+
(0, ts_utils_1.log)(),
|
|
10927
|
+
__metadata("design:type", Function),
|
|
10928
|
+
__metadata("design:paramtypes", [SyncCallback_1.SyncProgressReporter]),
|
|
10929
|
+
__metadata("design:returntype", Promise)
|
|
10930
|
+
], SyncController.prototype, "syncDatawallet", null);
|
|
10931
|
+
__decorate([
|
|
10932
|
+
(0, ts_utils_1.log)(),
|
|
10933
|
+
__metadata("design:type", Function),
|
|
10934
|
+
__metadata("design:paramtypes", [Number]),
|
|
10935
|
+
__metadata("design:returntype", Promise)
|
|
10936
|
+
], SyncController.prototype, "checkDatawalletVersion", null);
|
|
10937
|
+
__decorate([
|
|
10938
|
+
(0, ts_utils_1.log)(),
|
|
10939
|
+
__metadata("design:type", Function),
|
|
10940
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
10941
|
+
__metadata("design:returntype", Promise)
|
|
10942
|
+
], SyncController.prototype, "upgradeIdentityDatawalletVersion", null);
|
|
10943
|
+
__decorate([
|
|
10944
|
+
(0, ts_utils_1.log)(),
|
|
10945
|
+
__metadata("design:type", Function),
|
|
10946
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
10947
|
+
__metadata("design:returntype", Promise)
|
|
10948
|
+
], SyncController.prototype, "upgradeDeviceDatawalletVersion", null);
|
|
10754
10949
|
exports.SyncController = SyncController;
|
|
10755
10950
|
function descending(modification1, modification2) {
|
|
10756
10951
|
return modification2.index - modification1.index;
|
|
@@ -11293,13 +11488,23 @@ exports.AnonymousTokenController = AnonymousTokenController;
|
|
|
11293
11488
|
/*!************************************************!*\
|
|
11294
11489
|
!*** ./dist/modules/tokens/TokenController.js ***!
|
|
11295
11490
|
\************************************************/
|
|
11296
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
11491
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
11297
11492
|
|
|
11298
11493
|
"use strict";
|
|
11299
11494
|
|
|
11495
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11496
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11497
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11498
|
+
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;
|
|
11499
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11500
|
+
};
|
|
11501
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
11502
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11503
|
+
};
|
|
11300
11504
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11301
11505
|
exports.TokenController = void 0;
|
|
11302
11506
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
11507
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
11303
11508
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
11304
11509
|
const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
11305
11510
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
@@ -11356,7 +11561,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11356
11561
|
const id = idOrToken instanceof core_1.CoreId ? idOrToken.toString() : idOrToken.id.toString();
|
|
11357
11562
|
const tokenDoc = await this.tokens.read(id);
|
|
11358
11563
|
if (!tokenDoc) {
|
|
11359
|
-
throw core_1.TransportErrors.general.recordNotFound(Token_1.Token, id.toString())
|
|
11564
|
+
throw core_1.TransportErrors.general.recordNotFound(Token_1.Token, id.toString());
|
|
11360
11565
|
}
|
|
11361
11566
|
const token = Token_1.Token.from(tokenDoc);
|
|
11362
11567
|
token.setMetadata(metadata);
|
|
@@ -11371,7 +11576,6 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11371
11576
|
if (ids.length < 1) {
|
|
11372
11577
|
return [];
|
|
11373
11578
|
}
|
|
11374
|
-
// TODO: JSSNMSHDD-2820 (check for items that couldn't be fetched e.g. because it is expired)
|
|
11375
11579
|
const resultItems = (await this.client.getTokens({ ids })).value;
|
|
11376
11580
|
const promises = [];
|
|
11377
11581
|
for await (const resultItem of resultItems) {
|
|
@@ -11394,7 +11598,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11394
11598
|
async updateCacheOfExistingTokenInDb(id, response) {
|
|
11395
11599
|
const tokenDoc = await this.tokens.read(id);
|
|
11396
11600
|
if (!tokenDoc) {
|
|
11397
|
-
core_1.TransportErrors.general.recordNotFound(Token_1.Token, id)
|
|
11601
|
+
core_1.TransportErrors.general.recordNotFound(Token_1.Token, id);
|
|
11398
11602
|
return;
|
|
11399
11603
|
}
|
|
11400
11604
|
const token = Token_1.Token.from(tokenDoc);
|
|
@@ -11417,7 +11621,7 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11417
11621
|
const plaintextTokenBuffer = await core_1.CoreCrypto.decrypt(cipher, secretKey);
|
|
11418
11622
|
const plaintextTokenContent = core_1.CoreSerializable.deserializeUnknown(plaintextTokenBuffer.toUtf8());
|
|
11419
11623
|
if (!(plaintextTokenContent instanceof ts_serval_1.Serializable)) {
|
|
11420
|
-
throw core_1.TransportErrors.tokens.invalidTokenContent(response.id)
|
|
11624
|
+
throw core_1.TransportErrors.tokens.invalidTokenContent(response.id);
|
|
11421
11625
|
}
|
|
11422
11626
|
const cachedToken = CachedToken_1.CachedToken.from({
|
|
11423
11627
|
createdAt: core_1.CoreDate.from(response.createdAt),
|
|
@@ -11461,6 +11665,24 @@ class TokenController extends TransportController_1.TransportController {
|
|
|
11461
11665
|
return token;
|
|
11462
11666
|
}
|
|
11463
11667
|
}
|
|
11668
|
+
__decorate([
|
|
11669
|
+
(0, ts_utils_1.log)(),
|
|
11670
|
+
__metadata("design:type", Function),
|
|
11671
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
11672
|
+
__metadata("design:returntype", Promise)
|
|
11673
|
+
], TokenController.prototype, "setTokenMetadata", null);
|
|
11674
|
+
__decorate([
|
|
11675
|
+
(0, ts_utils_1.log)(),
|
|
11676
|
+
__metadata("design:type", Function),
|
|
11677
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
11678
|
+
__metadata("design:returntype", Promise)
|
|
11679
|
+
], TokenController.prototype, "updateCacheOfExistingTokenInDb", null);
|
|
11680
|
+
__decorate([
|
|
11681
|
+
(0, ts_utils_1.log)(),
|
|
11682
|
+
__metadata("design:type", Function),
|
|
11683
|
+
__metadata("design:paramtypes", [Object, crypto_1.CryptoSecretKey]),
|
|
11684
|
+
__metadata("design:returntype", Promise)
|
|
11685
|
+
], TokenController.prototype, "decryptToken", null);
|
|
11464
11686
|
exports.TokenController = TokenController;
|
|
11465
11687
|
//# sourceMappingURL=TokenController.js.map
|
|
11466
11688
|
|
|
@@ -11923,7 +12145,6 @@ exports.TokenReference = TokenReference;
|
|
|
11923
12145
|
|
|
11924
12146
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11925
12147
|
exports.PasswordGenerator = void 0;
|
|
11926
|
-
const TransportErrors_1 = __webpack_require__(/*! ../core/TransportErrors */ "./dist/core/TransportErrors.js");
|
|
11927
12148
|
const Random_1 = __webpack_require__(/*! ./Random */ "./dist/util/Random.js");
|
|
11928
12149
|
const defaultPasswordRange = Random_1.RandomCharacterRange.AlphanumericEase + Random_1.RandomCharacterRange.SpecialCharacters;
|
|
11929
12150
|
class PasswordGenerator {
|
|
@@ -11947,7 +12168,7 @@ class PasswordGenerator {
|
|
|
11947
12168
|
if (minLength > maxLength)
|
|
11948
12169
|
maxLength = minLength;
|
|
11949
12170
|
if (minLength < 8) {
|
|
11950
|
-
throw
|
|
12171
|
+
throw new Error("Minimum password length for a strong password should be 8 characters.");
|
|
11951
12172
|
}
|
|
11952
12173
|
const specialCharacterBucket = {
|
|
11953
12174
|
minLength: 1,
|
|
@@ -12114,7 +12335,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
12114
12335
|
exports.Random = exports.RandomCharacterRange = void 0;
|
|
12115
12336
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
12116
12337
|
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
12338
|
var RandomCharacterRange;
|
|
12119
12339
|
(function (RandomCharacterRange) {
|
|
12120
12340
|
RandomCharacterRange["Digit"] = "0123456789";
|
|
@@ -12138,7 +12358,7 @@ class Random {
|
|
|
12138
12358
|
}
|
|
12139
12359
|
static async int(length) {
|
|
12140
12360
|
if (length > 21 || length <= 0) {
|
|
12141
|
-
throw
|
|
12361
|
+
throw new Error("Length must be between 1 and 21.");
|
|
12142
12362
|
}
|
|
12143
12363
|
return parseInt(await this.string(length, RandomCharacterRange.Digit));
|
|
12144
12364
|
}
|
|
@@ -12161,12 +12381,12 @@ class Random {
|
|
|
12161
12381
|
}
|
|
12162
12382
|
static async intBetween(min, max) {
|
|
12163
12383
|
if (max <= min) {
|
|
12164
|
-
throw
|
|
12384
|
+
throw new Error("Max must be larger than min.");
|
|
12165
12385
|
}
|
|
12166
12386
|
const diff = max - min + 1;
|
|
12167
12387
|
const bitLength = Math.abs(Math.ceil(Math.log2(diff)));
|
|
12168
12388
|
if (bitLength > 32) {
|
|
12169
|
-
throw
|
|
12389
|
+
throw new Error("The range between the numbers is too big, 32 bit is the maximum -> 4294967296");
|
|
12170
12390
|
}
|
|
12171
12391
|
const byteLength = Math.ceil(bitLength / 8);
|
|
12172
12392
|
const bitMask = Math.pow(2, bitLength) - 1;
|
|
@@ -12185,7 +12405,7 @@ class Random {
|
|
|
12185
12405
|
}
|
|
12186
12406
|
static async intRandomLength(minLength, maxLength) {
|
|
12187
12407
|
if (maxLength > 21) {
|
|
12188
|
-
|
|
12408
|
+
throw new Error("Max must be below 22.");
|
|
12189
12409
|
}
|
|
12190
12410
|
return parseInt(await this.stringRandomLength(minLength, maxLength, RandomCharacterRange.Digit));
|
|
12191
12411
|
}
|
|
@@ -12204,7 +12424,7 @@ class Random {
|
|
|
12204
12424
|
if (length <= 0)
|
|
12205
12425
|
return "";
|
|
12206
12426
|
if (allowedChars.length > 256) {
|
|
12207
|
-
throw
|
|
12427
|
+
throw new Error("Input exceeds maximum length of 256.");
|
|
12208
12428
|
}
|
|
12209
12429
|
const ar = [];
|
|
12210
12430
|
const inputLength = allowedChars.length;
|
|
@@ -12227,10 +12447,10 @@ class Random {
|
|
|
12227
12447
|
}
|
|
12228
12448
|
static async stringRandomLength(minLength, maxLength, allowedChars) {
|
|
12229
12449
|
if (minLength > maxLength) {
|
|
12230
|
-
throw
|
|
12450
|
+
throw new Error("maxLength must be larger than minLength.");
|
|
12231
12451
|
}
|
|
12232
12452
|
if (minLength < 0) {
|
|
12233
|
-
throw
|
|
12453
|
+
throw new Error("minlength must not be less than zero.");
|
|
12234
12454
|
}
|
|
12235
12455
|
const length = maxLength > minLength ? await this.intBetween(minLength, maxLength) : maxLength;
|
|
12236
12456
|
return await this.string(length, allowedChars);
|
|
@@ -12711,29 +12931,50 @@ __exportStar(__webpack_require__(/*! ./sleep */ "./node_modules/@js-soft/ts-util
|
|
|
12711
12931
|
/*!*************************************************************!*\
|
|
12712
12932
|
!*** ./node_modules/@js-soft/ts-utils/dist/logDecorator.js ***!
|
|
12713
12933
|
\*************************************************************/
|
|
12714
|
-
/***/ ((__unused_webpack_module, exports)
|
|
12934
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
12715
12935
|
|
|
12716
12936
|
"use strict";
|
|
12717
12937
|
|
|
12938
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12939
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12940
|
+
};
|
|
12718
12941
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12719
12942
|
exports.log = void 0;
|
|
12720
|
-
|
|
12721
|
-
function log(
|
|
12722
|
-
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12943
|
+
const json_stringify_safe_1 = __importDefault(__webpack_require__(/*! json-stringify-safe */ "./node_modules/json-stringify-safe/stringify.js"));
|
|
12944
|
+
function log(params) {
|
|
12945
|
+
return function (_target, propertyName, propertyDescriptorDoNotChangeMyNamePlease) {
|
|
12946
|
+
const method = propertyDescriptorDoNotChangeMyNamePlease.value;
|
|
12947
|
+
propertyDescriptorDoNotChangeMyNamePlease.value = function (...args) {
|
|
12948
|
+
const thisT = this;
|
|
12949
|
+
try {
|
|
12950
|
+
if (params?.logParams) {
|
|
12951
|
+
thisT.log.trace(`Calling ${propertyName}(${args.map((a) => (0, json_stringify_safe_1.default)(a)).join(", ")})`);
|
|
12952
|
+
}
|
|
12953
|
+
else {
|
|
12954
|
+
thisT.log.trace(`Calling ${propertyName}`);
|
|
12955
|
+
}
|
|
12956
|
+
const returnValue = method.apply(this, args);
|
|
12957
|
+
if (params?.logReturnValue) {
|
|
12958
|
+
thisT.log.trace(`Returning from ${propertyName} with: ${(0, json_stringify_safe_1.default)(returnValue)}`);
|
|
12959
|
+
}
|
|
12960
|
+
else {
|
|
12961
|
+
thisT.log.trace(`Returning from ${propertyName}`);
|
|
12962
|
+
}
|
|
12963
|
+
return returnValue;
|
|
12964
|
+
}
|
|
12965
|
+
catch (error) {
|
|
12966
|
+
if (error instanceof Error && error.stack) {
|
|
12967
|
+
error.stack = error.stack
|
|
12968
|
+
.split("\n")
|
|
12969
|
+
.filter((s) => !s.includes(".propertyDescriptorDoNotChangeMyNamePlease.value"))
|
|
12970
|
+
.join("\n");
|
|
12971
|
+
}
|
|
12972
|
+
thisT.log.error(`Error in ${propertyName}:`, error);
|
|
12973
|
+
throw error;
|
|
12974
|
+
}
|
|
12975
|
+
};
|
|
12976
|
+
return propertyDescriptorDoNotChangeMyNamePlease;
|
|
12735
12977
|
};
|
|
12736
|
-
return propertyDesciptor;
|
|
12737
12978
|
}
|
|
12738
12979
|
exports.log = log;
|
|
12739
12980
|
//# sourceMappingURL=logDecorator.js.map
|
|
@@ -39240,7 +39481,7 @@ function dayDiff(earlier, later) {
|
|
|
39240
39481
|
}
|
|
39241
39482
|
|
|
39242
39483
|
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) => {
|
|
39484
|
+
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
39485
|
const days = dayDiff(a, b);
|
|
39245
39486
|
return (days - days % 7) / 7;
|
|
39246
39487
|
}], ["days", dayDiff]];
|
|
@@ -42429,7 +42670,7 @@ function friendlyDateTime(dateTimeish) {
|
|
|
42429
42670
|
}
|
|
42430
42671
|
}
|
|
42431
42672
|
|
|
42432
|
-
const VERSION = "3.0.
|
|
42673
|
+
const VERSION = "3.0.4";
|
|
42433
42674
|
|
|
42434
42675
|
exports.DateTime = DateTime;
|
|
42435
42676
|
exports.Duration = Duration;
|