@nmshd/app-runtime 2.0.0-beta.1 → 2.0.0-beta.4
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/AppRuntime.d.ts +10 -17
- package/dist/AppRuntime.js +48 -92
- package/dist/AppRuntime.js.map +1 -1
- package/dist/AppRuntimeErrors.d.ts +0 -1
- package/dist/AppRuntimeErrors.js +0 -3
- package/dist/AppRuntimeErrors.js.map +1 -1
- package/dist/SessionStorage.d.ts +10 -0
- package/dist/SessionStorage.js +31 -0
- package/dist/SessionStorage.js.map +1 -0
- package/dist/buildInformation.js +5 -5
- package/dist/events/index.d.ts +0 -1
- package/dist/events/index.js +0 -1
- package/dist/events/index.js.map +1 -1
- package/dist/modules/appEvents/MailReceivedModule.js +1 -5
- package/dist/modules/appEvents/MailReceivedModule.js.map +1 -1
- package/dist/modules/appEvents/OnboardingChangeReceivedModule.js +1 -5
- package/dist/modules/appEvents/OnboardingChangeReceivedModule.js.map +1 -1
- package/dist/modules/appSync/AppSyncModule.js +1 -2
- package/dist/modules/appSync/AppSyncModule.js.map +1 -1
- package/dist/modules/pushNotifications/PushNotificationModule.d.ts +1 -1
- package/dist/modules/pushNotifications/PushNotificationModule.js +18 -34
- package/dist/modules/pushNotifications/PushNotificationModule.js.map +1 -1
- package/dist/modules/runtimeEvents/MessageReceivedModule.js +2 -10
- package/dist/modules/runtimeEvents/MessageReceivedModule.js.map +1 -1
- package/dist/modules/runtimeEvents/RelationshipChangedModule.js +10 -13
- package/dist/modules/runtimeEvents/RelationshipChangedModule.js.map +1 -1
- package/lib-web/nmshd.app-runtime.js +128 -196
- package/lib-web/nmshd.app-runtime.min.js +1 -1
- package/package.json +3 -4
- package/dist/events/RequestReceivedEvent.d.ts +0 -8
- package/dist/events/RequestReceivedEvent.js +0 -15
- package/dist/events/RequestReceivedEvent.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushNotificationModule.js","sourceRoot":"","sources":["../../../src/modules/pushNotifications/PushNotificationModule.ts"],"names":[],"mappings":";;;AAAA,sEAIqC;AACrC,gDAA0C;AAC1C,6DAAyD;AACzD,yCAA4G;AAC5G,0DAAqF;AACrF,mEAAkF;AAIlF,MAAa,sBAAuB,SAAQ,mCAA8C;IAC/E,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,sBAAsB,CAAC,6CAAuB,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAC9F,IAAI,CAAC,sBAAsB,CAAC,yDAAmC,EAAE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACzG,IAAI,CAAC,gBAAgB,CAAC,6BAAoB,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACtF,CAAC;IAEO,KAAK,CAAC,wBAAwB,CAAC,KAA8B;QACjE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iDAAiD,EAAE,KAAK,CAAC,CAAA;QAC3E,MAAM,YAAY,GAA4B,KAAK,CAAC,YAAY,CAAA;QAChE,MAAM,OAAO,GAA0B,YAAY,CAAC,OAAgC,CAAA;QAEpF,IAAI;YACA,MAAM,
|
|
1
|
+
{"version":3,"file":"PushNotificationModule.js","sourceRoot":"","sources":["../../../src/modules/pushNotifications/PushNotificationModule.ts"],"names":[],"mappings":";;;AAAA,sEAIqC;AACrC,gDAA0C;AAC1C,6DAAyD;AACzD,yCAA4G;AAC5G,0DAAqF;AACrF,mEAAkF;AAIlF,MAAa,sBAAuB,SAAQ,mCAA8C;IAC/E,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,sBAAsB,CAAC,6CAAuB,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QA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M,8BAA8B;QACjC,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACpF,IAAI,eAAe,CAAC,OAAO,EAAE;YACzB,iBAAM,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;SACrC;QACD,OAAO,iBAAM,CAAC,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IAC3C,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACnC,CAAC;CACJ;AA5HD,wDA4HC"}
|
|
@@ -16,17 +16,9 @@ class MessageReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
16
16
|
this.subscribeToEvent(runtime_1.MessageReceivedEvent, this.handleMessageReceived.bind(this));
|
|
17
17
|
}
|
|
18
18
|
async handleMessageReceived(event) {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
if (!session) {
|
|
22
|
-
this.logger.error(`No session found for address ${event.eventTargetAddress}`);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const messageDVO = await session.expander.expandMessageDTO(message);
|
|
19
|
+
const services = await this.runtime.getServices(event.eventTargetAddress);
|
|
20
|
+
const messageDVO = await services.dataViewExpander.expandMessageDTO(event.data);
|
|
26
21
|
switch (messageDVO.type) {
|
|
27
|
-
case "RequestMessageDVO":
|
|
28
|
-
this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, messageDVO.request, messageDVO));
|
|
29
|
-
break;
|
|
30
22
|
case "MailDVO":
|
|
31
23
|
const mail = messageDVO;
|
|
32
24
|
this.runtime.eventBus.publish(new events_1.MailReceivedEvent(event.eventTargetAddress, mail));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageReceivedModule.js","sourceRoot":"","sources":["../../../src/modules/runtimeEvents/MessageReceivedModule.ts"],"names":[],"mappings":";;;AAAA,4CAA8D;AAC9D,2DAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"MessageReceivedModule.js","sourceRoot":"","sources":["../../../src/modules/runtimeEvents/MessageReceivedModule.ts"],"names":[],"mappings":";;;AAAA,4CAA8D;AAC9D,2DAAuD;AACvD,yCAAgD;AAChD,0DAAqF;AAIrF,MAAa,0BAA2B,SAAQ,iCAAe;CAAG;AAAlE,gEAAkE;AAElE,MAAa,qBAAsB,SAAQ,mCAA6C;IAC7E,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,gBAAgB,CAAC,8BAAoB,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACtF,CAAC;IAEO,KAAK,CAAC,qBAAqB,CAAC,KAA2B;QAC3D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QACzE,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAE/E,QAAQ,UAAU,CAAC,IAAI,EAAE;YACrB,KAAK,SAAS;gBACV,MAAM,IAAI,GAAY,UAAU,CAAA;gBAChC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,0BAAiB,CAAC,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC,CAAA;gBACpF,MAAK;YACT;gBACI,MAAK;SACZ;IACL,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACnC,CAAC;CACJ;AA1BD,sDA0BC"}
|
|
@@ -16,21 +16,18 @@ class RelationshipChangedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
16
16
|
this.subscribeToEvent(runtime_1.RelationshipChangedEvent, this.handleRelationshipChanged.bind(this));
|
|
17
17
|
}
|
|
18
18
|
async handleRelationshipChanged(event) {
|
|
19
|
+
var _a;
|
|
19
20
|
const relationship = event.data;
|
|
20
|
-
const session = this.runtime.
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const session = await this.runtime.getOrCreateSession(event.eventTargetAddress);
|
|
22
|
+
// Only listen for the onboarding change (the first one)
|
|
23
|
+
if (relationship.changes.length !== 1)
|
|
23
24
|
return;
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(change.response && change.response.createdBy !== session.address)) {
|
|
31
|
-
const relationshipDVO = await session.expander.expandRelationshipDTO(relationship);
|
|
32
|
-
this.runtime.eventBus.publish(new events_1.OnboardingChangeReceivedEvent(session.address, relationship.changes[0], relationship, relationshipDVO));
|
|
33
|
-
}
|
|
25
|
+
const change = relationship.changes[0];
|
|
26
|
+
// Only fire received events if the session did not create it
|
|
27
|
+
if ((!change.response && change.request.createdBy !== session.address) ||
|
|
28
|
+
((_a = change.response) === null || _a === void 0 ? void 0 : _a.createdBy) !== session.address) {
|
|
29
|
+
const relationshipDVO = await session.expander.expandRelationshipDTO(relationship);
|
|
30
|
+
this.runtime.eventBus.publish(new events_1.OnboardingChangeReceivedEvent(session.address, relationship.changes[0], relationship, relationshipDVO));
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
33
|
stop() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipChangedModule.js","sourceRoot":"","sources":["../../../src/modules/runtimeEvents/RelationshipChangedModule.ts"],"names":[],"mappings":";;;AAAA,4CAAyD;AACzD,2DAAuD;AACvD,yCAA4D;AAC5D,0DAAqF;AAIrF,MAAa,8BAA+B,SAAQ,iCAAe;CAAG;AAAtE,wEAAsE;AAEtE,MAAa,yBAA0B,SAAQ,mCAAiD;IACrF,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,gBAAgB,CAAC,kCAAwB,EAAE,I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C,OAAO,CACzB,IAAI,sCAA6B,CAC7B,OAAO,CAAC,OAAO,EACf,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EACvB,YAAY,EACZ,eAAe,CAClB,CACJ,CAAA;SACJ;IACL,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACnC,CAAC;CACJ;AArCD,8DAqCC"}
|
|
@@ -100,12 +100,13 @@ const events_1 = __webpack_require__(/*! ./events */ "./dist/events/index.js");
|
|
|
100
100
|
const extensibility_1 = __webpack_require__(/*! ./extensibility */ "./dist/extensibility/index.js");
|
|
101
101
|
const modules_1 = __webpack_require__(/*! ./modules */ "./dist/modules/index.js");
|
|
102
102
|
const multiAccount_1 = __webpack_require__(/*! ./multiAccount */ "./dist/multiAccount/index.js");
|
|
103
|
+
const SessionStorage_1 = __webpack_require__(/*! ./SessionStorage */ "./dist/SessionStorage.js");
|
|
103
104
|
const UserfriendlyResult_1 = __webpack_require__(/*! ./UserfriendlyResult */ "./dist/UserfriendlyResult.js");
|
|
104
105
|
class AppRuntime extends runtime_1.Runtime {
|
|
105
106
|
constructor(_nativeEnvironment, appConfig) {
|
|
106
107
|
super(appConfig, _nativeEnvironment.loggerFactory);
|
|
107
108
|
this._nativeEnvironment = _nativeEnvironment;
|
|
108
|
-
this.
|
|
109
|
+
this.sessionStorage = new SessionStorage_1.SessionStorage();
|
|
109
110
|
this.translationProvider = {
|
|
110
111
|
translate: (key) => Promise.resolve(ts_utils_1.Result.ok(key))
|
|
111
112
|
};
|
|
@@ -118,17 +119,15 @@ class AppRuntime extends runtime_1.Runtime {
|
|
|
118
119
|
this._uiBridgePromise = new Promise((resolve) => {
|
|
119
120
|
this._uiBridgeResolveFunction = resolve;
|
|
120
121
|
});
|
|
121
|
-
this._uiBridgePromise
|
|
122
|
-
.then(() => {
|
|
123
|
-
this._uiBridgePromise = undefined;
|
|
124
|
-
this._uiBridgeResolveFunction = undefined;
|
|
125
|
-
})
|
|
122
|
+
return this._uiBridgePromise
|
|
126
123
|
.catch((e) => {
|
|
124
|
+
this.logger.error(e);
|
|
125
|
+
throw e;
|
|
126
|
+
})
|
|
127
|
+
.finally(() => {
|
|
127
128
|
this._uiBridgePromise = undefined;
|
|
128
129
|
this._uiBridgeResolveFunction = undefined;
|
|
129
|
-
this.logger.error(e);
|
|
130
130
|
});
|
|
131
|
-
return this._uiBridgePromise;
|
|
132
131
|
}
|
|
133
132
|
registerUIBridge(uiBridge) {
|
|
134
133
|
if (this._uiBridge) {
|
|
@@ -150,28 +149,22 @@ class AppRuntime extends runtime_1.Runtime {
|
|
|
150
149
|
return this._nativeEnvironment;
|
|
151
150
|
}
|
|
152
151
|
get currentAccount() {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return this.
|
|
152
|
+
return this.sessionStorage.currentSession.account;
|
|
153
|
+
}
|
|
154
|
+
get currentSession() {
|
|
155
|
+
return this.sessionStorage.currentSession;
|
|
156
|
+
}
|
|
157
|
+
getSessions() {
|
|
158
|
+
return this.sessionStorage.getSessions();
|
|
157
159
|
}
|
|
158
160
|
async login(accountController, consumptionController) {
|
|
159
161
|
const services = await super.login(accountController, consumptionController);
|
|
160
162
|
const appServices = new extensibility_1.AppServices(this, services.transportServices, services.consumptionServices, services.dataViewExpander);
|
|
161
163
|
return { ...services, appServices };
|
|
162
164
|
}
|
|
163
|
-
|
|
164
|
-
if (!this._currentSession) {
|
|
165
|
-
throw AppRuntimeErrors_1.AppRuntimeErrors.general.currentSessionUnavailable();
|
|
166
|
-
}
|
|
167
|
-
return this._currentSession;
|
|
168
|
-
}
|
|
169
|
-
getServices(address) {
|
|
165
|
+
async getServices(address) {
|
|
170
166
|
const addressString = typeof address === "string" ? address : address.toString();
|
|
171
|
-
const session = this.
|
|
172
|
-
if (!session) {
|
|
173
|
-
throw new Error(`Account ${addressString} not logged in.`);
|
|
174
|
-
}
|
|
167
|
+
const session = await this.getOrCreateSession(addressString);
|
|
175
168
|
return {
|
|
176
169
|
transportServices: session.transportServices,
|
|
177
170
|
consumptionServices: session.consumptionServices,
|
|
@@ -179,70 +172,42 @@ class AppRuntime extends runtime_1.Runtime {
|
|
|
179
172
|
dataViewExpander: session.expander
|
|
180
173
|
};
|
|
181
174
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const session = this.findSession(accountId);
|
|
187
|
-
if (session)
|
|
188
|
-
return session.account;
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
findSession(accountId) {
|
|
192
|
-
return this._availableSessions.find((item) => item.account.id === accountId);
|
|
175
|
+
async selectAccount(accountAddress, _password) {
|
|
176
|
+
const session = await this.getOrCreateSession(accountAddress);
|
|
177
|
+
this.sessionStorage.currentSession = session;
|
|
178
|
+
return session;
|
|
193
179
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (this._currentSession && this._currentSession.address === address) {
|
|
199
|
-
return this._currentSession.account;
|
|
200
|
-
}
|
|
201
|
-
const availableSession = this.findSessionByAddress(address);
|
|
202
|
-
let accountId = availableSession === null || availableSession === void 0 ? void 0 : availableSession.account.id;
|
|
203
|
-
if (!accountId) {
|
|
204
|
-
accountId = (await this.multiAccountController.getAccountByAddress(address)).id.toString();
|
|
180
|
+
async getOrCreateSession(accountReference) {
|
|
181
|
+
const existingSession = this.sessionStorage.findSession(accountReference);
|
|
182
|
+
if (existingSession) {
|
|
183
|
+
return existingSession;
|
|
205
184
|
}
|
|
206
|
-
return await this.
|
|
185
|
+
return await this.createSession(accountReference);
|
|
207
186
|
}
|
|
208
|
-
async
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
await this._selectAccountPromise;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
else if (this._selectAccountPromise) {
|
|
225
|
-
// Same account is currently logging in -> await login and return
|
|
226
|
-
return await this._selectAccountPromise;
|
|
227
|
-
}
|
|
228
|
-
if (availableSession) {
|
|
229
|
-
await this.login(availableSession.accountController, availableSession.consumptionController);
|
|
230
|
-
this._currentSession = availableSession;
|
|
231
|
-
this.eventBus.publish(new events_1.AccountSelectedEvent(availableSession.address, availableSession.account.id));
|
|
232
|
-
return availableSession.account;
|
|
187
|
+
async createSession(accountReference, masterPassword = "") {
|
|
188
|
+
var _a;
|
|
189
|
+
const accountId = accountReference.length === 20
|
|
190
|
+
? accountReference
|
|
191
|
+
: (await this.multiAccountController.getAccountByAddress(accountReference)).id.toString();
|
|
192
|
+
if (((_a = this.currentSessionPromise) === null || _a === void 0 ? void 0 : _a.accountId) === accountId) {
|
|
193
|
+
return await this.currentSessionPromise.promise;
|
|
194
|
+
}
|
|
195
|
+
if (this.currentSessionPromise) {
|
|
196
|
+
await this.currentSessionPromise.promise.catch(() => {
|
|
197
|
+
// ignore
|
|
198
|
+
});
|
|
199
|
+
return await this.createSession(accountReference, masterPassword);
|
|
233
200
|
}
|
|
234
|
-
this.
|
|
201
|
+
this.currentSessionPromise = { promise: this._createSession(accountReference, masterPassword), accountId };
|
|
235
202
|
try {
|
|
236
|
-
return await this.
|
|
203
|
+
return await this.currentSessionPromise.promise;
|
|
237
204
|
}
|
|
238
205
|
finally {
|
|
239
|
-
this.
|
|
240
|
-
this._accountIdToPromise = undefined;
|
|
206
|
+
this.currentSessionPromise = undefined;
|
|
241
207
|
}
|
|
242
208
|
}
|
|
243
|
-
async
|
|
244
|
-
|
|
245
|
-
const [localAccount, accountController] = await this._multiAccountController.selectAccount(transport_1.CoreId.from(accountId), password);
|
|
209
|
+
async _createSession(accountId, masterPassword) {
|
|
210
|
+
const [localAccount, accountController] = await this._multiAccountController.selectAccount(transport_1.CoreId.from(accountId), masterPassword);
|
|
246
211
|
if (!localAccount.address) {
|
|
247
212
|
throw AppRuntimeErrors_1.AppRuntimeErrors.general.addressUnavailable().logWith(this.logger);
|
|
248
213
|
}
|
|
@@ -259,10 +224,8 @@ class AppRuntime extends runtime_1.Runtime {
|
|
|
259
224
|
accountController,
|
|
260
225
|
consumptionController
|
|
261
226
|
};
|
|
262
|
-
this.
|
|
263
|
-
|
|
264
|
-
this.eventBus.publish(new events_1.AccountSelectedEvent(session.address, session.account.id));
|
|
265
|
-
return session.account;
|
|
227
|
+
this.sessionStorage.addSession(session);
|
|
228
|
+
return session;
|
|
266
229
|
}
|
|
267
230
|
async queryAccount(title = "i18n://uibridge.accountSelection.title", description = "i18n://uibridge.accountSelection.description") {
|
|
268
231
|
let selectedAccount;
|
|
@@ -284,20 +247,16 @@ class AppRuntime extends runtime_1.Runtime {
|
|
|
284
247
|
return UserfriendlyResult_1.UserfriendlyResult.ok(selectedAccount);
|
|
285
248
|
}
|
|
286
249
|
async selectRelationship(id) {
|
|
287
|
-
if (!this._currentSession) {
|
|
288
|
-
throw AppRuntimeErrors_1.AppRuntimeErrors.general.currentSessionUnavailable().logWith(this.logger);
|
|
289
|
-
}
|
|
290
250
|
if (!id) {
|
|
291
|
-
this.
|
|
251
|
+
this.currentSession.selectedRelationship = undefined;
|
|
292
252
|
return;
|
|
293
253
|
}
|
|
294
254
|
const result = await this.currentSession.appServices.relationships.renderRelationship(id);
|
|
295
|
-
if (result.isError)
|
|
255
|
+
if (result.isError)
|
|
296
256
|
throw result.error;
|
|
297
|
-
}
|
|
298
257
|
const relationship = result.value;
|
|
299
|
-
this.
|
|
300
|
-
this.eventBus.publish(new events_1.RelationshipSelectedEvent(this.
|
|
258
|
+
this.currentSession.selectedRelationship = relationship;
|
|
259
|
+
this.eventBus.publish(new events_1.RelationshipSelectedEvent(this.currentSession.address, relationship));
|
|
301
260
|
}
|
|
302
261
|
getHealth() {
|
|
303
262
|
const health = {
|
|
@@ -338,9 +297,6 @@ class AppRuntime extends runtime_1.Runtime {
|
|
|
338
297
|
runtime.logger.trace("Runtime started");
|
|
339
298
|
return runtime;
|
|
340
299
|
}
|
|
341
|
-
createLoggerFactory() {
|
|
342
|
-
return this.nativeEnvironment.loggerFactory;
|
|
343
|
-
}
|
|
344
300
|
createDatabaseConnection() {
|
|
345
301
|
this.logger.trace("Creating DatabaseConnection to LokiJS");
|
|
346
302
|
this.lokiConnection = new docdb_access_loki_1.LokiJsConnection("./data", this.nativeEnvironment.databaseFactory);
|
|
@@ -469,9 +425,6 @@ class MultiAccount {
|
|
|
469
425
|
wrongRealm() {
|
|
470
426
|
return new UserfriendlyApplicationError_1.UserfriendlyApplicationError("error.runtime.MultiAccount.WrongRealm", "The given realm is invalid.");
|
|
471
427
|
}
|
|
472
|
-
concurrentLoginOfDifferentAccounts() {
|
|
473
|
-
return new UserfriendlyApplicationError_1.UserfriendlyApplicationError("error.runtime.MultiAccount.ParallelLoginOfDifferentAccounts", "You cannot login different accounts concurrently. Please wait until the login is completed.");
|
|
474
|
-
}
|
|
475
428
|
}
|
|
476
429
|
class Modules {
|
|
477
430
|
constructor() {
|
|
@@ -489,6 +442,47 @@ AppRuntimeErrors.multiAccount = new MultiAccount();
|
|
|
489
442
|
|
|
490
443
|
/***/ }),
|
|
491
444
|
|
|
445
|
+
/***/ "./dist/SessionStorage.js":
|
|
446
|
+
/*!********************************!*\
|
|
447
|
+
!*** ./dist/SessionStorage.js ***!
|
|
448
|
+
\********************************/
|
|
449
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
450
|
+
|
|
451
|
+
"use strict";
|
|
452
|
+
|
|
453
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
454
|
+
exports.SessionStorage = void 0;
|
|
455
|
+
const AppRuntimeErrors_1 = __webpack_require__(/*! ./AppRuntimeErrors */ "./dist/AppRuntimeErrors.js");
|
|
456
|
+
class SessionStorage {
|
|
457
|
+
constructor() {
|
|
458
|
+
this._availableSessions = [];
|
|
459
|
+
}
|
|
460
|
+
set currentSession(session) {
|
|
461
|
+
this._currentSession = session;
|
|
462
|
+
}
|
|
463
|
+
get currentSession() {
|
|
464
|
+
if (!this._currentSession) {
|
|
465
|
+
throw AppRuntimeErrors_1.AppRuntimeErrors.general.currentSessionUnavailable();
|
|
466
|
+
}
|
|
467
|
+
return this._currentSession;
|
|
468
|
+
}
|
|
469
|
+
getSessions() {
|
|
470
|
+
return this._availableSessions;
|
|
471
|
+
}
|
|
472
|
+
findSession(accountReference) {
|
|
473
|
+
return this._availableSessions.find((item) => item.account.address === accountReference || item.account.id === accountReference);
|
|
474
|
+
}
|
|
475
|
+
addSession(session) {
|
|
476
|
+
if (this.findSession(session.account.id))
|
|
477
|
+
throw new Error("Session already exists");
|
|
478
|
+
this._availableSessions.push(session);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
exports.SessionStorage = SessionStorage;
|
|
482
|
+
//# sourceMappingURL=SessionStorage.js.map
|
|
483
|
+
|
|
484
|
+
/***/ }),
|
|
485
|
+
|
|
492
486
|
/***/ "./dist/UserfriendlyApplicationError.js":
|
|
493
487
|
/*!**********************************************!*\
|
|
494
488
|
!*** ./dist/UserfriendlyApplicationError.js ***!
|
|
@@ -552,11 +546,11 @@ const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
|
552
546
|
const runtime_1 = __webpack_require__(/*! @nmshd/runtime */ "@nmshd/runtime");
|
|
553
547
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
554
548
|
exports.buildInformation = {
|
|
555
|
-
version: "2.0.0-beta.
|
|
556
|
-
build: "
|
|
557
|
-
date: "2022-07-
|
|
558
|
-
commit: "
|
|
559
|
-
dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.2.0","@nmshd/runtime":"2.0.0-beta.
|
|
549
|
+
version: "2.0.0-beta.4",
|
|
550
|
+
build: "21",
|
|
551
|
+
date: "2022-07-28T15:28:59+00:00",
|
|
552
|
+
commit: "1abd7bb193880b5b5632bd497e384057ad0abe05",
|
|
553
|
+
dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.2.0","@nmshd/runtime":"2.0.0-beta.12","lodash":"^4.17.21"},
|
|
560
554
|
libraries: {
|
|
561
555
|
serval: ts_serval_1.buildInformation,
|
|
562
556
|
crypto: crypto_1.buildInformation,
|
|
@@ -713,31 +707,6 @@ RelationshipSelectedEvent.namespace = "app.relationshipSelected";
|
|
|
713
707
|
|
|
714
708
|
/***/ }),
|
|
715
709
|
|
|
716
|
-
/***/ "./dist/events/RequestReceivedEvent.js":
|
|
717
|
-
/*!*********************************************!*\
|
|
718
|
-
!*** ./dist/events/RequestReceivedEvent.js ***!
|
|
719
|
-
\*********************************************/
|
|
720
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
721
|
-
|
|
722
|
-
"use strict";
|
|
723
|
-
|
|
724
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
725
|
-
exports.RequestReceivedEvent = void 0;
|
|
726
|
-
const runtime_1 = __webpack_require__(/*! @nmshd/runtime */ "@nmshd/runtime");
|
|
727
|
-
class RequestReceivedEvent extends runtime_1.DataEvent {
|
|
728
|
-
constructor(address, request, message) {
|
|
729
|
-
super(RequestReceivedEvent.namespace, address, {
|
|
730
|
-
request,
|
|
731
|
-
message
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
exports.RequestReceivedEvent = RequestReceivedEvent;
|
|
736
|
-
RequestReceivedEvent.namespace = "app.requestReceived";
|
|
737
|
-
//# sourceMappingURL=RequestReceivedEvent.js.map
|
|
738
|
-
|
|
739
|
-
/***/ }),
|
|
740
|
-
|
|
741
710
|
/***/ "./dist/events/index.js":
|
|
742
711
|
/*!******************************!*\
|
|
743
712
|
!*** ./dist/events/index.js ***!
|
|
@@ -767,7 +736,6 @@ __exportStar(__webpack_require__(/*! ./ExternalEventReceivedEvent */ "./dist/eve
|
|
|
767
736
|
__exportStar(__webpack_require__(/*! ./MailReceivedEvent */ "./dist/events/MailReceivedEvent.js"), exports);
|
|
768
737
|
__exportStar(__webpack_require__(/*! ./OnboardingChangeReceivedEvent */ "./dist/events/OnboardingChangeReceivedEvent.js"), exports);
|
|
769
738
|
__exportStar(__webpack_require__(/*! ./RelationshipSelectedEvent */ "./dist/events/RelationshipSelectedEvent.js"), exports);
|
|
770
|
-
__exportStar(__webpack_require__(/*! ./RequestReceivedEvent */ "./dist/events/RequestReceivedEvent.js"), exports);
|
|
771
739
|
//# sourceMappingURL=index.js.map
|
|
772
740
|
|
|
773
741
|
/***/ }),
|
|
@@ -1217,12 +1185,8 @@ class MailReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1217
1185
|
this.subscribeToEvent(events_1.MailReceivedEvent, this.handleMailReceived.bind(this));
|
|
1218
1186
|
}
|
|
1219
1187
|
async handleMailReceived(event) {
|
|
1188
|
+
const session = await this.runtime.getOrCreateSession(event.eventTargetAddress);
|
|
1220
1189
|
const mail = event.data;
|
|
1221
|
-
const session = this.runtime.findSessionByAddress(event.eventTargetAddress);
|
|
1222
|
-
if (!session) {
|
|
1223
|
-
this.logger.error(`No session found for address ${event.eventTargetAddress}`);
|
|
1224
|
-
return;
|
|
1225
|
-
}
|
|
1226
1190
|
const sender = mail.createdBy;
|
|
1227
1191
|
await this.runtime.nativeEnvironment.notificationAccess.schedule(mail.name, mail.createdBy.name, {
|
|
1228
1192
|
callback: async () => {
|
|
@@ -1268,11 +1232,7 @@ class OnboardingChangeReceivedModule extends AppRuntimeModule_1.AppRuntimeModule
|
|
|
1268
1232
|
const identity = event.data.identity;
|
|
1269
1233
|
let title = "";
|
|
1270
1234
|
let text = "";
|
|
1271
|
-
const session = this.runtime.
|
|
1272
|
-
if (!session) {
|
|
1273
|
-
this.logger.error(`No session found for address ${event.eventTargetAddress}`);
|
|
1274
|
-
return;
|
|
1275
|
-
}
|
|
1235
|
+
const session = await this.runtime.getOrCreateSession(event.eventTargetAddress);
|
|
1276
1236
|
switch (change.status) {
|
|
1277
1237
|
case runtime_1.RelationshipChangeStatus.Accepted:
|
|
1278
1238
|
title = "Kontaktanfrage genehmigt";
|
|
@@ -1366,8 +1326,7 @@ class AppSyncModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1366
1326
|
}
|
|
1367
1327
|
async sync() {
|
|
1368
1328
|
for (const session of this.runtime.getSessions()) {
|
|
1369
|
-
const
|
|
1370
|
-
const result = await services.transportServices.account.syncEverything();
|
|
1329
|
+
const result = await session.transportServices.account.syncEverything();
|
|
1371
1330
|
if (result.isError) {
|
|
1372
1331
|
this.logger.error(result.error);
|
|
1373
1332
|
}
|
|
@@ -1495,28 +1454,23 @@ class PushNotificationModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1495
1454
|
const notification = event.notification;
|
|
1496
1455
|
const content = notification.content;
|
|
1497
1456
|
try {
|
|
1498
|
-
const
|
|
1499
|
-
const session = this.runtime.findSession(account.id.toString());
|
|
1500
|
-
if (!session) {
|
|
1501
|
-
this.logger.error(`No session found for account ref ${content.accRef}`);
|
|
1502
|
-
return;
|
|
1503
|
-
}
|
|
1457
|
+
const services = await this.runtime.getServices(content.accRef);
|
|
1504
1458
|
switch (content.eventName) {
|
|
1505
1459
|
case IBackboneEventContent_1.BackboneEventName.DatawalletModificationsCreated:
|
|
1506
|
-
const walletResult = await
|
|
1460
|
+
const walletResult = await services.transportServices.account.syncDatawallet();
|
|
1507
1461
|
if (walletResult.isError) {
|
|
1508
1462
|
this.logger.error(walletResult);
|
|
1509
1463
|
return;
|
|
1510
1464
|
}
|
|
1511
|
-
this.runtime.eventBus.publish(new events_1.DatawalletSynchronizedEvent(
|
|
1465
|
+
this.runtime.eventBus.publish(new events_1.DatawalletSynchronizedEvent(content.accRef));
|
|
1512
1466
|
break;
|
|
1513
1467
|
case IBackboneEventContent_1.BackboneEventName.ExternalEventCreated:
|
|
1514
|
-
const syncResult = await
|
|
1468
|
+
const syncResult = await services.transportServices.account.syncEverything();
|
|
1515
1469
|
if (syncResult.isError) {
|
|
1516
1470
|
this.logger.error(syncResult);
|
|
1517
1471
|
return;
|
|
1518
1472
|
}
|
|
1519
|
-
this.runtime.eventBus.publish(new events_1.ExternalEventReceivedEvent(
|
|
1473
|
+
this.runtime.eventBus.publish(new events_1.ExternalEventReceivedEvent(content.accRef, syncResult.value.messages, syncResult.value.relationships));
|
|
1520
1474
|
break;
|
|
1521
1475
|
default:
|
|
1522
1476
|
break;
|
|
@@ -1529,8 +1483,8 @@ class PushNotificationModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1529
1483
|
async handleTokenRegistration(event) {
|
|
1530
1484
|
try {
|
|
1531
1485
|
this.logger.trace("PushNotificationModule.handleTokenRegistration", event);
|
|
1532
|
-
for (const
|
|
1533
|
-
await this.registerPushTokenForLocalAccount(account.
|
|
1486
|
+
for (const session of this.runtime.getSessions()) {
|
|
1487
|
+
await this.registerPushTokenForLocalAccount(session.account.address, event.token);
|
|
1534
1488
|
}
|
|
1535
1489
|
}
|
|
1536
1490
|
catch (e) {
|
|
@@ -1538,33 +1492,22 @@ class PushNotificationModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1538
1492
|
}
|
|
1539
1493
|
}
|
|
1540
1494
|
async handleAccountSelected(event) {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
}
|
|
1547
|
-
else {
|
|
1548
|
-
this.logger.error(tokenResult.error);
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
catch (e) {
|
|
1552
|
-
this.logger.error(e);
|
|
1495
|
+
this.logger.trace("PushNotificationModule.handleAccountSelected", event);
|
|
1496
|
+
const tokenResult = this.getNotificationTokenFromConfig();
|
|
1497
|
+
if (tokenResult.isError) {
|
|
1498
|
+
this.logger.error(tokenResult.error);
|
|
1499
|
+
return;
|
|
1553
1500
|
}
|
|
1501
|
+
await this.registerPushTokenForLocalAccount(event.data.address, tokenResult.value);
|
|
1554
1502
|
}
|
|
1555
|
-
async registerPushTokenForLocalAccount(
|
|
1503
|
+
async registerPushTokenForLocalAccount(address, token) {
|
|
1556
1504
|
if (!token) {
|
|
1557
1505
|
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
1558
1506
|
.tokenRegistrationNotPossible("The registered token was empty. This might be the case if you did not allow push notifications.")
|
|
1559
1507
|
.logWith(this.logger);
|
|
1560
1508
|
}
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
1564
|
-
.tokenRegistrationNotPossible("No session for this account found")
|
|
1565
|
-
.logWith(this.logger);
|
|
1566
|
-
}
|
|
1567
|
-
const deviceResult = await session.transportServices.account.getDeviceInfo();
|
|
1509
|
+
const services = await this.runtime.getServices(address);
|
|
1510
|
+
const deviceResult = await services.transportServices.account.getDeviceInfo();
|
|
1568
1511
|
if (deviceResult.isError) {
|
|
1569
1512
|
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
1570
1513
|
.tokenRegistrationNotPossible("No device for this account found", deviceResult.error)
|
|
@@ -1574,7 +1517,7 @@ class PushNotificationModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1574
1517
|
const platform = this.runtime.nativeEnvironment.deviceInfoAccess.deviceInfo.pushService;
|
|
1575
1518
|
const handle = token;
|
|
1576
1519
|
const installationId = device.id;
|
|
1577
|
-
const result = await
|
|
1520
|
+
const result = await services.transportServices.account.registerPushNotificationToken({
|
|
1578
1521
|
platform,
|
|
1579
1522
|
handle,
|
|
1580
1523
|
installationId
|
|
@@ -1585,7 +1528,7 @@ class PushNotificationModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1585
1528
|
.logWith(this.logger);
|
|
1586
1529
|
}
|
|
1587
1530
|
else {
|
|
1588
|
-
this.logger.trace(`PushNotificationModule.registerPushTokenForLocalAccount: Token ${handle} registered for account ${
|
|
1531
|
+
this.logger.trace(`PushNotificationModule.registerPushTokenForLocalAccount: Token ${handle} registered for account ${address} on platform ${platform} and installationId ${installationId}`);
|
|
1589
1532
|
}
|
|
1590
1533
|
}
|
|
1591
1534
|
getNotificationTokenFromConfig() {
|
|
@@ -1658,17 +1601,9 @@ class MessageReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1658
1601
|
this.subscribeToEvent(runtime_1.MessageReceivedEvent, this.handleMessageReceived.bind(this));
|
|
1659
1602
|
}
|
|
1660
1603
|
async handleMessageReceived(event) {
|
|
1661
|
-
const
|
|
1662
|
-
const
|
|
1663
|
-
if (!session) {
|
|
1664
|
-
this.logger.error(`No session found for address ${event.eventTargetAddress}`);
|
|
1665
|
-
return;
|
|
1666
|
-
}
|
|
1667
|
-
const messageDVO = await session.expander.expandMessageDTO(message);
|
|
1604
|
+
const services = await this.runtime.getServices(event.eventTargetAddress);
|
|
1605
|
+
const messageDVO = await services.dataViewExpander.expandMessageDTO(event.data);
|
|
1668
1606
|
switch (messageDVO.type) {
|
|
1669
|
-
case "RequestMessageDVO":
|
|
1670
|
-
this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, messageDVO.request, messageDVO));
|
|
1671
|
-
break;
|
|
1672
1607
|
case "MailDVO":
|
|
1673
1608
|
const mail = messageDVO;
|
|
1674
1609
|
this.runtime.eventBus.publish(new events_1.MailReceivedEvent(event.eventTargetAddress, mail));
|
|
@@ -1711,21 +1646,18 @@ class RelationshipChangedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1711
1646
|
this.subscribeToEvent(runtime_1.RelationshipChangedEvent, this.handleRelationshipChanged.bind(this));
|
|
1712
1647
|
}
|
|
1713
1648
|
async handleRelationshipChanged(event) {
|
|
1649
|
+
var _a;
|
|
1714
1650
|
const relationship = event.data;
|
|
1715
|
-
const session = this.runtime.
|
|
1716
|
-
|
|
1717
|
-
|
|
1651
|
+
const session = await this.runtime.getOrCreateSession(event.eventTargetAddress);
|
|
1652
|
+
// Only listen for the onboarding change (the first one)
|
|
1653
|
+
if (relationship.changes.length !== 1)
|
|
1718
1654
|
return;
|
|
1719
|
-
|
|
1720
|
-
//
|
|
1721
|
-
if (
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
(change.response && change.response.createdBy !== session.address)) {
|
|
1726
|
-
const relationshipDVO = await session.expander.expandRelationshipDTO(relationship);
|
|
1727
|
-
this.runtime.eventBus.publish(new events_1.OnboardingChangeReceivedEvent(session.address, relationship.changes[0], relationship, relationshipDVO));
|
|
1728
|
-
}
|
|
1655
|
+
const change = relationship.changes[0];
|
|
1656
|
+
// Only fire received events if the session did not create it
|
|
1657
|
+
if ((!change.response && change.request.createdBy !== session.address) ||
|
|
1658
|
+
((_a = change.response) === null || _a === void 0 ? void 0 : _a.createdBy) !== session.address) {
|
|
1659
|
+
const relationshipDVO = await session.expander.expandRelationshipDTO(relationship);
|
|
1660
|
+
this.runtime.eventBus.publish(new events_1.OnboardingChangeReceivedEvent(session.address, relationship.changes[0], relationship, relationshipDVO));
|
|
1729
1661
|
}
|
|
1730
1662
|
}
|
|
1731
1663
|
stop() {
|