@nmshd/transport 2.0.0-beta.6 → 2.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buildInformation.js +4 -4
- package/dist/core/CoreCrypto.js +5 -4
- package/dist/core/CoreCrypto.js.map +1 -1
- package/dist/core/{TransportErrors.d.ts → CoreErrors.d.ts} +1 -2
- package/dist/core/{TransportErrors.js → CoreErrors.js} +13 -16
- package/dist/core/CoreErrors.js.map +1 -0
- package/dist/core/CoreIdHelper.js +2 -1
- package/dist/core/CoreIdHelper.js.map +1 -1
- package/dist/core/CoreUtil.js +2 -1
- package/dist/core/CoreUtil.js.map +1 -1
- package/dist/core/Reference.js +3 -3
- package/dist/core/Reference.js.map +1 -1
- package/dist/core/Transport.js +7 -6
- package/dist/core/Transport.js.map +1 -1
- package/dist/core/TransportController.d.ts +1 -0
- package/dist/core/TransportController.js +5 -1
- package/dist/core/TransportController.js.map +1 -1
- package/dist/core/TransportError.d.ts +2 -0
- package/dist/core/TransportError.js +7 -0
- package/dist/core/TransportError.js.map +1 -0
- package/dist/core/TransportLoggerFactory.js +2 -1
- package/dist/core/TransportLoggerFactory.js.map +1 -1
- package/dist/core/backbone/ClientResult.js +5 -4
- package/dist/core/backbone/ClientResult.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/types/CoreDate.js +4 -3
- package/dist/core/types/CoreDate.js.map +1 -1
- package/dist/core/types/CoreId.js +2 -1
- package/dist/core/types/CoreId.js.map +1 -1
- package/dist/modules/accounts/AccountController.js +5 -7
- package/dist/modules/accounts/AccountController.js.map +1 -1
- package/dist/modules/accounts/IdentityController.js +1 -1
- package/dist/modules/accounts/IdentityController.js.map +1 -1
- package/dist/modules/accounts/IdentityUtil.js +1 -1
- package/dist/modules/accounts/IdentityUtil.js.map +1 -1
- package/dist/modules/accounts/data/Identity.d.ts +0 -18
- package/dist/modules/accounts/data/Identity.js +0 -33
- package/dist/modules/accounts/data/Identity.js.map +1 -1
- package/dist/modules/challenges/ChallengeController.js +4 -6
- package/dist/modules/challenges/ChallengeController.js.map +1 -1
- package/dist/modules/devices/DeviceController.js +8 -9
- package/dist/modules/devices/DeviceController.js.map +1 -1
- package/dist/modules/devices/DeviceSecretController.js +6 -7
- package/dist/modules/devices/DeviceSecretController.js.map +1 -1
- package/dist/modules/devices/DevicesController.js +3 -3
- package/dist/modules/devices/DevicesController.js.map +1 -1
- package/dist/modules/files/FileController.js +9 -19
- package/dist/modules/files/FileController.js.map +1 -1
- package/dist/modules/index.d.ts +4 -4
- package/dist/modules/index.js +4 -4
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/messages/MessageController.js +16 -16
- package/dist/modules/messages/MessageController.js.map +1 -1
- package/dist/modules/messages/transmission/{MessagePlain.d.ts → MessageContentWrapper.d.ts} +4 -4
- package/dist/modules/messages/transmission/{MessagePlain.js → MessageContentWrapper.js} +12 -12
- package/dist/modules/messages/transmission/MessageContentWrapper.js.map +1 -0
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js +7 -14
- package/dist/modules/relationshipTemplates/RelationshipTemplateController.js.map +1 -1
- package/dist/modules/relationshipTemplates/backbone/BackboneGetRelationshipTemplates.d.ts +0 -1
- package/dist/modules/relationshipTemplates/backbone/BackbonePostRelationshipTemplates.d.ts +0 -5
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.d.ts +0 -11
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js +1 -15
- package/dist/modules/relationshipTemplates/local/CachedRelationshipTemplate.js.map +1 -1
- package/dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.d.ts +0 -11
- package/dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js +2 -17
- package/dist/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.js.map +1 -1
- package/dist/modules/relationshipTemplates/transmission/{RelationshipTemplateContent.d.ts → RelationshipTemplateContentWrapper.d.ts} +3 -3
- package/dist/modules/relationshipTemplates/transmission/{RelationshipTemplateContent.js → RelationshipTemplateContentWrapper.js} +10 -10
- package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js.map +1 -0
- package/dist/modules/relationships/RelationshipSecretController.js +14 -14
- package/dist/modules/relationships/RelationshipSecretController.js.map +1 -1
- package/dist/modules/relationships/RelationshipsController.js +32 -32
- package/dist/modules/relationships/RelationshipsController.js.map +1 -1
- package/dist/modules/relationships/local/Relationship.d.ts +1 -0
- package/dist/modules/relationships/local/Relationship.js +9 -9
- package/dist/modules/relationships/local/Relationship.js.map +1 -1
- package/dist/modules/relationships/transmission/requests/{RelationshipCreationChangeRequestContent.d.ts → RelationshipCreationChangeRequestContentWrapper.d.ts} +3 -3
- package/dist/modules/relationships/transmission/requests/{RelationshipCreationChangeRequestContent.js → RelationshipCreationChangeRequestContentWrapper.js} +10 -10
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContentWrapper.js.map +1 -0
- package/dist/modules/relationships/transmission/responses/{RelationshipCreationChangeResponseContent.d.ts → RelationshipCreationChangeResponseContentWrapper.d.ts} +3 -3
- package/dist/modules/relationships/transmission/responses/{RelationshipCreationChangeResponseContent.js → RelationshipCreationChangeResponseContentWrapper.js} +9 -9
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContentWrapper.js.map +1 -0
- package/dist/modules/secrets/SecretController.js +1 -2
- package/dist/modules/secrets/SecretController.js.map +1 -1
- package/dist/modules/sync/DatawalletModificationMapper.js +2 -2
- package/dist/modules/sync/DatawalletModificationMapper.js.map +1 -1
- package/dist/modules/sync/DatawalletModificationsProcessor.js +2 -2
- package/dist/modules/sync/DatawalletModificationsProcessor.js.map +1 -1
- package/dist/modules/sync/ExternalEventsProcessor.js +1 -1
- package/dist/modules/sync/ExternalEventsProcessor.js.map +1 -1
- package/dist/modules/sync/SyncController.js +10 -10
- package/dist/modules/sync/SyncController.js.map +1 -1
- package/dist/modules/tokens/AnonymousTokenController.js +1 -1
- package/dist/modules/tokens/AnonymousTokenController.js.map +1 -1
- package/dist/modules/tokens/TokenController.js +4 -5
- package/dist/modules/tokens/TokenController.js.map +1 -1
- package/dist/util/PasswordGenerator.js +2 -1
- package/dist/util/PasswordGenerator.js.map +1 -1
- package/dist/util/Random.js +8 -7
- package/dist/util/Random.js.map +1 -1
- package/lib-web/nmshd.transport.js +472 -530
- package/lib-web/nmshd.transport.js.map +1 -1
- package/lib-web/nmshd.transport.min.js +1 -1
- package/lib-web/nmshd.transport.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/core/TransportErrors.js.map +0 -1
- package/dist/modules/messages/transmission/MessagePlain.js.map +0 -1
- package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateContent.js.map +0 -1
- package/dist/modules/relationships/transmission/requests/RelationshipCreationChangeRequestContent.js.map +0 -1
- package/dist/modules/relationships/transmission/responses/RelationshipCreationChangeResponseContent.js.map +0 -1
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.validateMaxNumberOfAllocations = exports.
|
|
12
|
+
exports.validateMaxNumberOfAllocations = exports.CachedRelationshipTemplate = void 0;
|
|
13
13
|
const ts_serval_1 = require("@js-soft/ts-serval");
|
|
14
14
|
const core_1 = require("../../../core");
|
|
15
15
|
const CoreId_1 = require("../../../core/types/CoreId");
|
|
@@ -60,24 +60,10 @@ __decorate([
|
|
|
60
60
|
(0, ts_serval_1.serialize)(),
|
|
61
61
|
__metadata("design:type", Number)
|
|
62
62
|
], CachedRelationshipTemplate.prototype, "maxNumberOfAllocations", void 0);
|
|
63
|
-
__decorate([
|
|
64
|
-
(0, ts_serval_1.validate)({ nullable: true, customValidator: validateMaxNumberOfRelationships }),
|
|
65
|
-
(0, ts_serval_1.serialize)(),
|
|
66
|
-
__metadata("design:type", Number)
|
|
67
|
-
], CachedRelationshipTemplate.prototype, "maxNumberOfRelationships", void 0);
|
|
68
63
|
CachedRelationshipTemplate = __decorate([
|
|
69
64
|
(0, ts_serval_1.type)("CachedRelationshipTemplate")
|
|
70
65
|
], CachedRelationshipTemplate);
|
|
71
66
|
exports.CachedRelationshipTemplate = CachedRelationshipTemplate;
|
|
72
|
-
function validateMaxNumberOfRelationships(value) {
|
|
73
|
-
if (value === undefined)
|
|
74
|
-
return;
|
|
75
|
-
if (value <= 0) {
|
|
76
|
-
return "maxNumberOfRelationships must be greater than 0";
|
|
77
|
-
}
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
exports.validateMaxNumberOfRelationships = validateMaxNumberOfRelationships;
|
|
81
67
|
function validateMaxNumberOfAllocations(value) {
|
|
82
68
|
if (value === undefined)
|
|
83
69
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CachedRelationshipTemplate.js","sourceRoot":"","sources":["../../../../src/modules/relationshipTemplates/local/CachedRelationshipTemplate.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2F;AAE3F,wCAAmH;AACnH,uDAA4D;AAC5D,2DAAkE;AAClE,iGAA6F;
|
|
1
|
+
{"version":3,"file":"CachedRelationshipTemplate.js","sourceRoot":"","sources":["../../../../src/modules/relationshipTemplates/local/CachedRelationshipTemplate.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2F;AAE3F,wCAAmH;AACnH,uDAA4D;AAC5D,2DAAkE;AAClE,iGAA6F;AActF,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,uBAAgB;IAiCrD,MAAM,CAAC,IAAI,CAAC,KAAkC;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;CACJ,CAAA;AAnCG;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACK,mBAAQ;4DAAA;AAEzB;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACM,kBAAW;6DAAA;AAE7B;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACY,eAAM;mEAAA;AAE9B;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACQ,6DAA6B;+DAAA;AAEjD;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACI,wBAAY;2DAAA;AAE5B;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACM,eAAQ;6DAAA;AAE1B;IAAC,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,IAAA,qBAAS,GAAE;8BACO,eAAQ;6DAAA;AAE3B;IAAC,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,8BAA8B,EAAE,CAAC;IAC7E,IAAA,qBAAS,GAAE;;0EAC0B;AA/B7B,0BAA0B;IADtC,IAAA,gBAAI,EAAC,4BAA4B,CAAC;GACtB,0BAA0B,CAoCtC;AApCY,gEAA0B;AAsCvC,SAAgB,8BAA8B,CAAC,KAAc;IACzD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAM;IAE/B,IAAI,KAAK,IAAI,CAAC,EAAE;QACZ,OAAO,+CAA+C,CAAA;KACzD;IAED,OAAM;AACV,CAAC;AARD,wEAQC"}
|
|
@@ -4,21 +4,10 @@ export interface ISendRelationshipTemplateParameters extends ICoreSerializable {
|
|
|
4
4
|
content: ISerializable;
|
|
5
5
|
expiresAt: CoreDate;
|
|
6
6
|
maxNumberOfAllocations?: number;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated use `maxNumberOfAllocations` instead
|
|
9
|
-
* @see maxNumberOfAllocations
|
|
10
|
-
*/
|
|
11
|
-
maxNumberOfRelationships?: number;
|
|
12
7
|
}
|
|
13
8
|
export declare class SendRelationshipTemplateParameters extends CoreSerializable implements ISendRelationshipTemplateParameters {
|
|
14
9
|
content: Serializable;
|
|
15
10
|
expiresAt: CoreDate;
|
|
16
11
|
maxNumberOfAllocations?: number;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated use `maxNumberOfAllocations` instead
|
|
19
|
-
* @see maxNumberOfAllocations
|
|
20
|
-
*/
|
|
21
|
-
maxNumberOfRelationships?: number;
|
|
22
|
-
protected static postFrom<T extends Serializable>(value: T): T;
|
|
23
12
|
static from(value: ISendRelationshipTemplateParameters): SendRelationshipTemplateParameters;
|
|
24
13
|
}
|
|
@@ -8,22 +8,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var SendRelationshipTemplateParameters_1;
|
|
12
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
12
|
exports.SendRelationshipTemplateParameters = void 0;
|
|
14
13
|
const ts_serval_1 = require("@js-soft/ts-serval");
|
|
15
|
-
const ts_simple_nameof_1 = require("ts-simple-nameof");
|
|
16
14
|
const core_1 = require("../../../core");
|
|
17
15
|
const CachedRelationshipTemplate_1 = require("./CachedRelationshipTemplate");
|
|
18
|
-
let SendRelationshipTemplateParameters =
|
|
19
|
-
static postFrom(value) {
|
|
20
|
-
if (!(value instanceof SendRelationshipTemplateParameters_1))
|
|
21
|
-
throw new Error("this should never happen");
|
|
22
|
-
if (value.maxNumberOfAllocations && value.maxNumberOfRelationships) {
|
|
23
|
-
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)}.`);
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
16
|
+
let SendRelationshipTemplateParameters = class SendRelationshipTemplateParameters extends core_1.CoreSerializable {
|
|
27
17
|
static from(value) {
|
|
28
18
|
return this.fromAny(value);
|
|
29
19
|
}
|
|
@@ -43,12 +33,7 @@ __decorate([
|
|
|
43
33
|
(0, ts_serval_1.serialize)(),
|
|
44
34
|
__metadata("design:type", Number)
|
|
45
35
|
], SendRelationshipTemplateParameters.prototype, "maxNumberOfAllocations", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, ts_serval_1.validate)({ nullable: true, customValidator: CachedRelationshipTemplate_1.validateMaxNumberOfRelationships }),
|
|
48
|
-
(0, ts_serval_1.serialize)(),
|
|
49
|
-
__metadata("design:type", Number)
|
|
50
|
-
], SendRelationshipTemplateParameters.prototype, "maxNumberOfRelationships", void 0);
|
|
51
|
-
SendRelationshipTemplateParameters = SendRelationshipTemplateParameters_1 = __decorate([
|
|
36
|
+
SendRelationshipTemplateParameters = __decorate([
|
|
52
37
|
(0, ts_serval_1.type)("SendRelationshipTemplateParameters")
|
|
53
38
|
], SendRelationshipTemplateParameters);
|
|
54
39
|
exports.SendRelationshipTemplateParameters = SendRelationshipTemplateParameters;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SendRelationshipTemplateParameters.js","sourceRoot":"","sources":["../../../../src/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SendRelationshipTemplateParameters.js","sourceRoot":"","sources":["../../../../src/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2F;AAC3F,wCAA6E;AAC7E,6EAA6E;AAStE,IAAM,kCAAkC,GAAxC,MAAM,kCACT,SAAQ,uBAAgB;IAejB,MAAM,CAAC,IAAI,CAAC,KAA0C;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;CACJ,CAAA;AAfG;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACI,wBAAY;mEAAA;AAE5B;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACM,eAAQ;qEAAA;AAE1B;IAAC,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,2DAA8B,EAAE,CAAC;IAC7E,IAAA,qBAAS,GAAE;;kFAC0B;AAd7B,kCAAkC;IAD9C,IAAA,gBAAI,EAAC,oCAAoC,CAAC;GAC9B,kCAAkC,CAmB9C;AAnBY,gFAAkC"}
|
|
@@ -2,14 +2,14 @@ import { ISerializable, Serializable } from "@js-soft/ts-serval";
|
|
|
2
2
|
import { CoreSerializable, ICoreSerializable } from "../../../core";
|
|
3
3
|
import { Identity, IIdentity } from "../../accounts/data/Identity";
|
|
4
4
|
import { IRelationshipTemplatePublicKey, RelationshipTemplatePublicKey } from "./RelationshipTemplatePublicKey";
|
|
5
|
-
export interface
|
|
5
|
+
export interface IRelationshipTemplateContentWrapper extends ICoreSerializable {
|
|
6
6
|
identity: IIdentity;
|
|
7
7
|
templateKey: IRelationshipTemplatePublicKey;
|
|
8
8
|
content: ISerializable;
|
|
9
9
|
}
|
|
10
|
-
export declare class
|
|
10
|
+
export declare class RelationshipTemplateContentWrapper extends CoreSerializable implements IRelationshipTemplateContentWrapper {
|
|
11
11
|
identity: Identity;
|
|
12
12
|
templateKey: RelationshipTemplatePublicKey;
|
|
13
13
|
content: Serializable;
|
|
14
|
-
static from(value:
|
|
14
|
+
static from(value: IRelationshipTemplateContentWrapper): RelationshipTemplateContentWrapper;
|
|
15
15
|
}
|
|
@@ -9,12 +9,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.RelationshipTemplateContentWrapper = void 0;
|
|
13
13
|
const ts_serval_1 = require("@js-soft/ts-serval");
|
|
14
14
|
const core_1 = require("../../../core");
|
|
15
15
|
const Identity_1 = require("../../accounts/data/Identity");
|
|
16
16
|
const RelationshipTemplatePublicKey_1 = require("./RelationshipTemplatePublicKey");
|
|
17
|
-
let
|
|
17
|
+
let RelationshipTemplateContentWrapper = class RelationshipTemplateContentWrapper extends core_1.CoreSerializable {
|
|
18
18
|
static from(value) {
|
|
19
19
|
return this.fromAny(value);
|
|
20
20
|
}
|
|
@@ -23,19 +23,19 @@ __decorate([
|
|
|
23
23
|
(0, ts_serval_1.validate)(),
|
|
24
24
|
(0, ts_serval_1.serialize)(),
|
|
25
25
|
__metadata("design:type", Identity_1.Identity)
|
|
26
|
-
],
|
|
26
|
+
], RelationshipTemplateContentWrapper.prototype, "identity", void 0);
|
|
27
27
|
__decorate([
|
|
28
28
|
(0, ts_serval_1.validate)(),
|
|
29
29
|
(0, ts_serval_1.serialize)(),
|
|
30
30
|
__metadata("design:type", RelationshipTemplatePublicKey_1.RelationshipTemplatePublicKey)
|
|
31
|
-
],
|
|
31
|
+
], RelationshipTemplateContentWrapper.prototype, "templateKey", void 0);
|
|
32
32
|
__decorate([
|
|
33
33
|
(0, ts_serval_1.validate)(),
|
|
34
34
|
(0, ts_serval_1.serialize)(),
|
|
35
35
|
__metadata("design:type", ts_serval_1.Serializable)
|
|
36
|
-
],
|
|
37
|
-
|
|
38
|
-
(0, ts_serval_1.type)("
|
|
39
|
-
],
|
|
40
|
-
exports.
|
|
41
|
-
//# sourceMappingURL=
|
|
36
|
+
], RelationshipTemplateContentWrapper.prototype, "content", void 0);
|
|
37
|
+
RelationshipTemplateContentWrapper = __decorate([
|
|
38
|
+
(0, ts_serval_1.type)("RelationshipTemplateContentWrapper")
|
|
39
|
+
], RelationshipTemplateContentWrapper);
|
|
40
|
+
exports.RelationshipTemplateContentWrapper = RelationshipTemplateContentWrapper;
|
|
41
|
+
//# sourceMappingURL=RelationshipTemplateContentWrapper.js.map
|
package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RelationshipTemplateContentWrapper.js","sourceRoot":"","sources":["../../../../src/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2F;AAC3F,wCAAmE;AACnE,2DAAkE;AAClE,mFAA+G;AASxG,IAAM,kCAAkC,GAAxC,MAAM,kCACT,SAAQ,uBAAgB;IAejB,MAAM,CAAC,IAAI,CAAC,KAA0C;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;CACJ,CAAA;AAfG;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACK,mBAAQ;oEAAA;AAEzB;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACQ,6DAA6B;uEAAA;AAEjD;IAAC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACI,wBAAY;mEAAA;AAdnB,kCAAkC;IAD9C,IAAA,gBAAI,EAAC,oCAAoC,CAAC;GAC9B,kCAAkC,CAmB9C;AAnBY,gFAAkC"}
|
|
@@ -13,8 +13,8 @@ exports.RelationshipSecretController = void 0;
|
|
|
13
13
|
const ts_utils_1 = require("@js-soft/ts-utils");
|
|
14
14
|
const crypto_1 = require("@nmshd/crypto");
|
|
15
15
|
const core_1 = require("../../core");
|
|
16
|
+
const CoreErrors_1 = require("../../core/CoreErrors");
|
|
16
17
|
const CoreUtil_1 = require("../../core/CoreUtil");
|
|
17
|
-
const TransportErrors_1 = require("../../core/TransportErrors");
|
|
18
18
|
const TransportIds_1 = require("../../core/TransportIds");
|
|
19
19
|
const CachedRelationshipTemplate_1 = require("../relationshipTemplates/local/CachedRelationshipTemplate");
|
|
20
20
|
const RelationshipTemplatePublicKey_1 = require("../relationshipTemplates/transmission/RelationshipTemplatePublicKey");
|
|
@@ -32,11 +32,11 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
32
32
|
}
|
|
33
33
|
const secretContainer = await this.loadActiveSecretByName(secretIdAsString);
|
|
34
34
|
if (!secretContainer) {
|
|
35
|
-
throw
|
|
35
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound("CryptoRelationshipRequestSecrets | CryptoRelationshipSecrets", secretIdAsString);
|
|
36
36
|
}
|
|
37
37
|
if (!(secretContainer.secret instanceof crypto_1.CryptoRelationshipRequestSecrets) &&
|
|
38
38
|
!(secretContainer.secret instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
39
|
-
throw
|
|
39
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secretIdAsString);
|
|
40
40
|
}
|
|
41
41
|
const secret = secretContainer.secret;
|
|
42
42
|
this.cache.set(relationshipSecretId, secret);
|
|
@@ -52,10 +52,10 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
52
52
|
const templateKeyId = template.templateKey.id.toString();
|
|
53
53
|
const exchangeKeypairContainer = await this.loadActiveSecretByName(templateKeyId);
|
|
54
54
|
if (!exchangeKeypairContainer) {
|
|
55
|
-
throw
|
|
55
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(crypto_1.CryptoExchangeKeypair, templateKeyId);
|
|
56
56
|
}
|
|
57
57
|
if (!(exchangeKeypairContainer.secret instanceof crypto_1.CryptoExchangeKeypair)) {
|
|
58
|
-
throw
|
|
58
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(templateKeyId);
|
|
59
59
|
}
|
|
60
60
|
const exchangeKeypair = exchangeKeypairContainer.secret;
|
|
61
61
|
const secrets = await crypto_1.CryptoRelationshipSecrets.fromRelationshipRequest(publicRequestCrypto, exchangeKeypair);
|
|
@@ -65,10 +65,10 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
65
65
|
async getPublicResponse(relationshipSecretId) {
|
|
66
66
|
const secret = await this.loadActiveSecretByName(relationshipSecretId.toString());
|
|
67
67
|
if (!secret) {
|
|
68
|
-
throw
|
|
68
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(crypto_1.CryptoRelationshipSecrets, relationshipSecretId.toString());
|
|
69
69
|
}
|
|
70
70
|
if (!(secret.secret instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
71
|
-
throw
|
|
71
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secret.id.toString());
|
|
72
72
|
}
|
|
73
73
|
const publicResponse = secret.secret.toPublicResponse();
|
|
74
74
|
return publicResponse;
|
|
@@ -76,7 +76,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
76
76
|
async convertSecrets(relationshipSecretId, response) {
|
|
77
77
|
const request = await this.getSecret(relationshipSecretId);
|
|
78
78
|
if (request instanceof crypto_1.CryptoRelationshipSecrets) {
|
|
79
|
-
throw
|
|
79
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType();
|
|
80
80
|
}
|
|
81
81
|
const secrets = await crypto_1.CryptoRelationshipSecrets.fromRelationshipResponse(response, request);
|
|
82
82
|
const container = await this.succeedSecretWithName(secrets, relationshipSecretId.toString());
|
|
@@ -101,7 +101,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
101
101
|
const buffer = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
102
102
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
103
103
|
if (!(secrets instanceof crypto_1.CryptoRelationshipRequestSecrets)) {
|
|
104
|
-
throw
|
|
104
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
105
105
|
}
|
|
106
106
|
return await secrets.encryptRequest(buffer);
|
|
107
107
|
}
|
|
@@ -109,14 +109,14 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
109
109
|
const buffer = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
110
110
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
111
111
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
112
|
-
throw
|
|
112
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
113
113
|
}
|
|
114
114
|
return await secrets.encrypt(buffer);
|
|
115
115
|
}
|
|
116
116
|
async decryptRequest(relationshipSecretId, cipher) {
|
|
117
117
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
118
118
|
if (!(secrets instanceof crypto_1.CryptoRelationshipRequestSecrets) && !(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
119
|
-
throw
|
|
119
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(relationshipSecretId.toString());
|
|
120
120
|
}
|
|
121
121
|
return await secrets.decryptRequest(cipher);
|
|
122
122
|
}
|
|
@@ -133,7 +133,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
133
133
|
async decryptPeer(relationshipSecretId, cipher, omitCounterCheck = false) {
|
|
134
134
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
135
135
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
136
|
-
throw
|
|
136
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
137
137
|
}
|
|
138
138
|
return await secrets.decryptPeer(cipher, omitCounterCheck);
|
|
139
139
|
}
|
|
@@ -144,7 +144,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
144
144
|
async decryptOwn(relationshipSecretId, cipher) {
|
|
145
145
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
146
146
|
if (!(secrets instanceof crypto_1.CryptoRelationshipSecrets)) {
|
|
147
|
-
throw
|
|
147
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
148
148
|
}
|
|
149
149
|
return await secrets.decryptOwn(cipher);
|
|
150
150
|
}
|
|
@@ -162,7 +162,7 @@ class RelationshipSecretController extends SecretController_1.SecretController {
|
|
|
162
162
|
const bufferToVerify = CoreUtil_1.CoreUtil.toBuffer(content);
|
|
163
163
|
const secrets = await this.getSecret(relationshipSecretId);
|
|
164
164
|
if (secrets instanceof crypto_1.CryptoRelationshipRequestSecrets) {
|
|
165
|
-
throw
|
|
165
|
+
throw CoreErrors_1.CoreErrors.secrets.wrongSecretType(secrets.id);
|
|
166
166
|
}
|
|
167
167
|
const valid = await secrets.verifyPeer(bufferToVerify, signature);
|
|
168
168
|
return valid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipSecretController.js","sourceRoot":"","sources":["../../../src/modules/relationships/RelationshipSecretController.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAuC;AACvC,0CAWsB;AACtB,qCAA+D;AAC/D,kDAA8C;AAC9C,
|
|
1
|
+
{"version":3,"file":"RelationshipSecretController.js","sourceRoot":"","sources":["../../../src/modules/relationships/RelationshipSecretController.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAuC;AACvC,0CAWsB;AACtB,qCAA+D;AAC/D,sDAAkD;AAClD,kDAA8C;AAC9C,0DAAsD;AAGtD,0GAAsG;AACtG,uHAAmH;AAEnH,kEAA8D;AAE9D,MAAa,4BAA6B,SAAQ,mCAAgB;IAM9D,YAAmB,MAAyB;QACxC,KAAK,CAAC,MAAM,EAAE,qBAAc,CAAC,kBAAkB,CAAC,CAAA;QANnC,UAAK,GAA8E,IAAI,GAAG,EAGxG,CAAA;IAIH,CAAC;IAGa,AAAN,KAAK,CAAC,SAAS,CACnB,oBAA4B;QAE5B,MAAM,gBAAgB,GAAW,oBAAoB,CAAC,QAAQ,EAAE,CAAA;QAChE,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;QAC1D,IAAI,aAAa,EAAE;YACf,O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E;;qCAEoB,aAAM;;kEAW/B;AAGY;IADZ,IAAA,cAAG,GAAE;;qCACqC,aAAM;;2DAShD;AAGY;IADZ,IAAA,cAAG,GAAE;;qCAC4C,aAAM,EAAU,qBAAY;;kEAQ7E;AAcY;IADZ,IAAA,cAAG,GAAE;;qCAEoB,aAAM;QACpB,qBAAY;;+DAUvB;AAQY;IADZ,IAAA,cAAG,GAAE;;qCACwC,aAAM,EAAU,qBAAY;;8DAQzE;AAsBY;IADZ,IAAA,cAAG,GAAE;;qCAEoB,aAAM,UAEjB,wBAAe;;8DAW7B;AArPL,oEAsPC"}
|
|
@@ -14,9 +14,9 @@ const ts_utils_1 = require("@js-soft/ts-utils");
|
|
|
14
14
|
const crypto_1 = require("@nmshd/crypto");
|
|
15
15
|
const ts_simple_nameof_1 = require("ts-simple-nameof");
|
|
16
16
|
const core_1 = require("../../core");
|
|
17
|
+
const CoreErrors_1 = require("../../core/CoreErrors");
|
|
17
18
|
const CoreUtil_1 = require("../../core/CoreUtil");
|
|
18
19
|
const DbCollectionName_1 = require("../../core/DbCollectionName");
|
|
19
|
-
const TransportErrors_1 = require("../../core/TransportErrors");
|
|
20
20
|
const TransportIds_1 = require("../../core/TransportIds");
|
|
21
21
|
const events_1 = require("../../events");
|
|
22
22
|
const RelationshipTemplate_1 = require("../relationshipTemplates/local/RelationshipTemplate");
|
|
@@ -30,10 +30,10 @@ const RelationshipChangeStatus_1 = require("./transmission/changes/RelationshipC
|
|
|
30
30
|
const RelationshipChangeType_1 = require("./transmission/changes/RelationshipChangeType");
|
|
31
31
|
const RelationshipStatus_1 = require("./transmission/RelationshipStatus");
|
|
32
32
|
const RelationshipCreationChangeRequestCipher_1 = require("./transmission/requests/RelationshipCreationChangeRequestCipher");
|
|
33
|
-
const
|
|
33
|
+
const RelationshipCreationChangeRequestContentWrapper_1 = require("./transmission/requests/RelationshipCreationChangeRequestContentWrapper");
|
|
34
34
|
const RelationshipCreationChangeRequestSigned_1 = require("./transmission/requests/RelationshipCreationChangeRequestSigned");
|
|
35
35
|
const RelationshipCreationChangeResponseCipher_1 = require("./transmission/responses/RelationshipCreationChangeResponseCipher");
|
|
36
|
-
const
|
|
36
|
+
const RelationshipCreationChangeResponseContentWrapper_1 = require("./transmission/responses/RelationshipCreationChangeResponseContentWrapper");
|
|
37
37
|
const RelationshipCreationChangeResponseSigned_1 = require("./transmission/responses/RelationshipCreationChangeResponseSigned");
|
|
38
38
|
class RelationshipsController extends core_1.TransportController {
|
|
39
39
|
constructor(parent, secrets) {
|
|
@@ -78,7 +78,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
78
78
|
async updateCacheOfExistingRelationshipInDb(id, response) {
|
|
79
79
|
const relationshipDoc = await this.relationships.read(id);
|
|
80
80
|
if (!relationshipDoc)
|
|
81
|
-
throw
|
|
81
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, id);
|
|
82
82
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
83
83
|
await this.updateCacheOfRelationship(relationship, response);
|
|
84
84
|
await this.relationships.update(relationshipDoc, relationship);
|
|
@@ -120,7 +120,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
120
120
|
parameters = SendRelationshipParameters_1.SendRelationshipParameters.from(parameters);
|
|
121
121
|
const template = parameters.template;
|
|
122
122
|
if (!template.cache) {
|
|
123
|
-
throw
|
|
123
|
+
throw this.newCacheEmptyError(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
124
124
|
}
|
|
125
125
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
126
126
|
const { requestCipher, requestContent } = await this.prepareRequest(secretId, template, parameters.content);
|
|
@@ -137,7 +137,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
137
137
|
const id = idOrRelationship instanceof core_1.CoreId ? idOrRelationship.toString() : idOrRelationship.id.toString();
|
|
138
138
|
const relationshipDoc = await this.relationships.read(id);
|
|
139
139
|
if (!relationshipDoc)
|
|
140
|
-
throw
|
|
140
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, id.toString());
|
|
141
141
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
142
142
|
relationship.metadata = metadata;
|
|
143
143
|
relationship.metadataModifiedAt = core_1.CoreDate.utc();
|
|
@@ -165,7 +165,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
165
165
|
this._log.trace(`Parsing relationship template ${templateId} for ${response.id}...`);
|
|
166
166
|
const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId);
|
|
167
167
|
if (!template) {
|
|
168
|
-
throw
|
|
168
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString());
|
|
169
169
|
}
|
|
170
170
|
this._log.trace(`Parsing relationship changes of ${response.id}...`);
|
|
171
171
|
const changesPromises = [];
|
|
@@ -187,10 +187,10 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
187
187
|
}
|
|
188
188
|
async prepareRequest(relationshipSecretId, template, content) {
|
|
189
189
|
if (!template.cache) {
|
|
190
|
-
throw
|
|
190
|
+
throw this.newCacheEmptyError(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
191
191
|
}
|
|
192
192
|
const requestPublic = await this.secrets.createRequestorSecrets(template.cache, relationshipSecretId);
|
|
193
|
-
const requestContent =
|
|
193
|
+
const requestContent = RelationshipCreationChangeRequestContentWrapper_1.RelationshipCreationChangeRequestContentWrapper.from({
|
|
194
194
|
content: content,
|
|
195
195
|
identity: this.parent.identity.identity,
|
|
196
196
|
templateId: template.id
|
|
@@ -223,9 +223,9 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
223
223
|
return await this.applyCreationChange(change);
|
|
224
224
|
case RelationshipChangeType_1.RelationshipChangeType.Termination:
|
|
225
225
|
case RelationshipChangeType_1.RelationshipChangeType.TerminationCancellation:
|
|
226
|
-
throw
|
|
226
|
+
throw CoreErrors_1.CoreErrors.general.notSupported();
|
|
227
227
|
default:
|
|
228
|
-
throw
|
|
228
|
+
throw CoreErrors_1.CoreErrors.general.incompatibleBackbone();
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
async applyCreationChange(change) {
|
|
@@ -276,11 +276,11 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
276
276
|
relationshipSignatureValid = await this.secrets.verifyPeer(secretId, crypto_1.CoreBuffer.fromUtf8(signedRequest.serializedRequest), signedRequest.relationshipSignature);
|
|
277
277
|
}
|
|
278
278
|
if (!relationshipSignatureValid) {
|
|
279
|
-
throw
|
|
279
|
+
throw CoreErrors_1.CoreErrors.general.signatureNotValid("relationshipRequest");
|
|
280
280
|
}
|
|
281
|
-
const requestContent =
|
|
281
|
+
const requestContent = RelationshipCreationChangeRequestContentWrapper_1.RelationshipCreationChangeRequestContentWrapper.deserialize(signedRequest.serializedRequest);
|
|
282
282
|
if (!requestContent.templateId.equals(templateId)) {
|
|
283
|
-
throw new
|
|
283
|
+
throw new core_1.TransportError("The relationship request contains a wrong template id.");
|
|
284
284
|
}
|
|
285
285
|
return requestContent;
|
|
286
286
|
}
|
|
@@ -315,11 +315,11 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
315
315
|
relationshipSignatureValid = await this.secrets.verifyPeer(relationshipSecretId, crypto_1.CoreBuffer.fromUtf8(signedResponse.serializedResponse), signedResponse.relationshipSignature);
|
|
316
316
|
}
|
|
317
317
|
if (!relationshipSignatureValid) {
|
|
318
|
-
throw
|
|
318
|
+
throw CoreErrors_1.CoreErrors.general.signatureNotValid("relationshipResponse");
|
|
319
319
|
}
|
|
320
|
-
const responseContent =
|
|
320
|
+
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.deserialize(signedResponse.serializedResponse);
|
|
321
321
|
if (!responseContent.relationshipId.equals(change.relationshipId)) {
|
|
322
|
-
throw new
|
|
322
|
+
throw new core_1.TransportError("The relationship response contains a wrong relationship id.");
|
|
323
323
|
}
|
|
324
324
|
return responseContent;
|
|
325
325
|
}
|
|
@@ -340,14 +340,14 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
340
340
|
const cipher = RelationshipCreationChangeResponseCipher_1.RelationshipCreationChangeResponseCipher.fromBase64(change.response.content);
|
|
341
341
|
if (change.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Revoked) {
|
|
342
342
|
if (!cipher.publicResponseCrypto) {
|
|
343
|
-
throw new
|
|
343
|
+
throw new core_1.TransportError("The response crypto is missing.");
|
|
344
344
|
}
|
|
345
345
|
await this.secrets.convertSecrets(relationship.relationshipSecretId, cipher.publicResponseCrypto);
|
|
346
346
|
}
|
|
347
347
|
const responseContent = await this.decryptCreationChangeResponse(change, relationship.relationshipSecretId);
|
|
348
348
|
const response = RelationshipChangeResponse_1.RelationshipChangeResponse.fromBackbone(change.response, responseContent.content);
|
|
349
349
|
if (!relationship.cache) {
|
|
350
|
-
throw
|
|
350
|
+
throw this.newCacheEmptyError(Relationship_1.Relationship, relationship.id.toString());
|
|
351
351
|
}
|
|
352
352
|
relationship.cache.changes[0].status = change.status;
|
|
353
353
|
switch (change.status) {
|
|
@@ -361,7 +361,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
361
361
|
relationship.toRevoked(response);
|
|
362
362
|
break;
|
|
363
363
|
default:
|
|
364
|
-
throw
|
|
364
|
+
throw CoreErrors_1.CoreErrors.general.incompatibleBackbone();
|
|
365
365
|
}
|
|
366
366
|
await this.relationships.update(relationshipDoc, relationship);
|
|
367
367
|
return relationship;
|
|
@@ -371,9 +371,9 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
371
371
|
const templateId = core_1.CoreId.from(backboneRelationship.relationshipTemplateId);
|
|
372
372
|
const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId);
|
|
373
373
|
if (!template)
|
|
374
|
-
throw
|
|
374
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(RelationshipTemplate_1.RelationshipTemplate, templateId.toString());
|
|
375
375
|
if (!template.cache)
|
|
376
|
-
throw
|
|
376
|
+
throw this.newCacheEmptyError(RelationshipTemplate_1.RelationshipTemplate, template.id.toString());
|
|
377
377
|
if (!change.request.content)
|
|
378
378
|
throw this.newEmptyOrInvalidContentError(change);
|
|
379
379
|
const secretId = await TransportIds_1.TransportIds.relationshipSecret.generate();
|
|
@@ -388,21 +388,21 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
388
388
|
async completeChange(targetStatus, change, content) {
|
|
389
389
|
const relationshipDoc = await this.relationships.read(change.relationshipId.toString());
|
|
390
390
|
if (!relationshipDoc) {
|
|
391
|
-
throw
|
|
391
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(Relationship_1.Relationship, change.relationshipId.toString());
|
|
392
392
|
}
|
|
393
393
|
const relationship = Relationship_1.Relationship.from(relationshipDoc);
|
|
394
394
|
if (!relationship.cache) {
|
|
395
395
|
await this.updateCacheOfRelationship(relationship);
|
|
396
396
|
}
|
|
397
397
|
if (!relationship.cache) {
|
|
398
|
-
throw
|
|
398
|
+
throw this.newCacheEmptyError(Relationship_1.Relationship, relationship.id.toString());
|
|
399
399
|
}
|
|
400
400
|
const queriedChange = relationship.cache.changes.find((r) => r.id.toString() === change.id.toString());
|
|
401
401
|
if (!queriedChange) {
|
|
402
|
-
throw
|
|
402
|
+
throw CoreErrors_1.CoreErrors.general.recordNotFound(RelationshipChange_1.RelationshipChange, change.id.toString());
|
|
403
403
|
}
|
|
404
404
|
if (queriedChange.status !== RelationshipChangeStatus_1.RelationshipChangeStatus.Pending) {
|
|
405
|
-
throw
|
|
405
|
+
throw CoreErrors_1.CoreErrors.relationships.wrongChangeStatus(queriedChange.status);
|
|
406
406
|
}
|
|
407
407
|
let encryptedContent;
|
|
408
408
|
if (content) {
|
|
@@ -423,7 +423,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
423
423
|
backboneResponse = (await this.client.revokeRelationshipChange(relationship.id.toString(), change.id.toString(), encryptedContent)).value;
|
|
424
424
|
break;
|
|
425
425
|
default:
|
|
426
|
-
throw new
|
|
426
|
+
throw new core_1.TransportError("target change status not supported");
|
|
427
427
|
}
|
|
428
428
|
const backboneChange = backboneResponse.changes[backboneResponse.changes.length - 1];
|
|
429
429
|
queriedChange.response = RelationshipChangeResponse_1.RelationshipChangeResponse.fromBackbone(backboneResponse.changes[backboneResponse.changes.length - 1].response, content);
|
|
@@ -434,7 +434,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
434
434
|
return relationship;
|
|
435
435
|
}
|
|
436
436
|
async encryptRevokeContent(relationship, content) {
|
|
437
|
-
const responseContent =
|
|
437
|
+
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.from({
|
|
438
438
|
relationshipId: relationship.id,
|
|
439
439
|
content: content
|
|
440
440
|
});
|
|
@@ -457,7 +457,7 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
457
457
|
}
|
|
458
458
|
async encryptAcceptRejectContent(relationship, content) {
|
|
459
459
|
const publicResponseCrypto = await this.secrets.getPublicResponse(relationship.relationshipSecretId);
|
|
460
|
-
const responseContent =
|
|
460
|
+
const responseContent = RelationshipCreationChangeResponseContentWrapper_1.RelationshipCreationChangeResponseContentWrapper.from({
|
|
461
461
|
relationshipId: relationship.id,
|
|
462
462
|
content: content
|
|
463
463
|
});
|
|
@@ -480,13 +480,13 @@ class RelationshipsController extends core_1.TransportController {
|
|
|
480
480
|
return responseCipher.toBase64();
|
|
481
481
|
}
|
|
482
482
|
throwWrongChangeType(type) {
|
|
483
|
-
throw new
|
|
483
|
+
throw new core_1.TransportError(`The relationship change has the wrong type (${type}) to run this operation`);
|
|
484
484
|
}
|
|
485
485
|
newChangeResponseMissingError(changeId) {
|
|
486
|
-
return new
|
|
486
|
+
return new core_1.TransportError(`The response of the relationship change (${changeId}) is missing`);
|
|
487
487
|
}
|
|
488
488
|
newEmptyOrInvalidContentError(change) {
|
|
489
|
-
return new
|
|
489
|
+
return new core_1.TransportError(`The content property of the relationship change ${change === null || change === void 0 ? void 0 : change.id} is missing or invalid`);
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
492
|
__decorate([
|