@nmshd/app-runtime 1.0.0
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/LICENSE +7 -0
- package/README.md +24 -0
- package/dist/AppConfig.d.ts +10 -0
- package/dist/AppConfig.js +55 -0
- package/dist/AppConfig.js.map +1 -0
- package/dist/AppRuntime.d.ts +61 -0
- package/dist/AppRuntime.js +306 -0
- package/dist/AppRuntime.js.map +1 -0
- package/dist/AppRuntimeError.d.ts +5 -0
- package/dist/AppRuntimeError.js +12 -0
- package/dist/AppRuntimeError.js.map +1 -0
- package/dist/AppRuntimeErrors.d.ts +33 -0
- package/dist/AppRuntimeErrors.js +67 -0
- package/dist/AppRuntimeErrors.js.map +1 -0
- package/dist/UserfriendlyApplicationError.d.ts +7 -0
- package/dist/UserfriendlyApplicationError.js +18 -0
- package/dist/UserfriendlyApplicationError.js.map +1 -0
- package/dist/UserfriendlyResult.d.ts +4 -0
- package/dist/UserfriendlyResult.js +8 -0
- package/dist/UserfriendlyResult.js.map +1 -0
- package/dist/buildInformation.d.ts +512 -0
- package/dist/buildInformation.js +25 -0
- package/dist/buildInformation.js.map +1 -0
- package/dist/events/AccountSelectedEvent.d.ts +12 -0
- package/dist/events/AccountSelectedEvent.js +16 -0
- package/dist/events/AccountSelectedEvent.js.map +1 -0
- package/dist/events/DatawalletSynchronizedEvent.d.ts +5 -0
- package/dist/events/DatawalletSynchronizedEvent.js +12 -0
- package/dist/events/DatawalletSynchronizedEvent.js.map +1 -0
- package/dist/events/ExternalEventReceivedEvent.d.ts +8 -0
- package/dist/events/ExternalEventReceivedEvent.js +15 -0
- package/dist/events/ExternalEventReceivedEvent.js.map +1 -0
- package/dist/events/MailReceivedEvent.d.ts +5 -0
- package/dist/events/MailReceivedEvent.js +12 -0
- package/dist/events/MailReceivedEvent.js.map +1 -0
- package/dist/events/OnboardingChangeReceivedEvent.d.ts +9 -0
- package/dist/events/OnboardingChangeReceivedEvent.js +16 -0
- package/dist/events/OnboardingChangeReceivedEvent.js.map +1 -0
- package/dist/events/RelationshipSelectedEvent.d.ts +5 -0
- package/dist/events/RelationshipSelectedEvent.js +12 -0
- package/dist/events/RelationshipSelectedEvent.js.map +1 -0
- package/dist/events/RequestReceivedEvent.d.ts +8 -0
- package/dist/events/RequestReceivedEvent.js +15 -0
- package/dist/events/RequestReceivedEvent.js.map +1 -0
- package/dist/events/index.d.ts +7 -0
- package/dist/events/index.js +20 -0
- package/dist/events/index.js.map +1 -0
- package/dist/extensibility/AppServices.d.ts +7 -0
- package/dist/extensibility/AppServices.js +12 -0
- package/dist/extensibility/AppServices.js.map +1 -0
- package/dist/extensibility/DVOs/RelationshipItemsDVO.d.ts +3 -0
- package/dist/extensibility/DVOs/RelationshipItemsDVO.js +3 -0
- package/dist/extensibility/DVOs/RelationshipItemsDVO.js.map +1 -0
- package/dist/extensibility/facades/AppRelationshipFacade.d.ts +21 -0
- package/dist/extensibility/facades/AppRelationshipFacade.js +88 -0
- package/dist/extensibility/facades/AppRelationshipFacade.js.map +1 -0
- package/dist/extensibility/facades/AppRuntimeFacade.d.ts +13 -0
- package/dist/extensibility/facades/AppRuntimeFacade.js +29 -0
- package/dist/extensibility/facades/AppRuntimeFacade.js.map +1 -0
- package/dist/extensibility/facades/AppStringProcessorFacade.d.ts +9 -0
- package/dist/extensibility/facades/AppStringProcessorFacade.js +73 -0
- package/dist/extensibility/facades/AppStringProcessorFacade.js.map +1 -0
- package/dist/extensibility/facades/index.d.ts +2 -0
- package/dist/extensibility/facades/index.js +15 -0
- package/dist/extensibility/facades/index.js.map +1 -0
- package/dist/extensibility/index.d.ts +2 -0
- package/dist/extensibility/index.js +15 -0
- package/dist/extensibility/index.js.map +1 -0
- package/dist/extensibility/ui/IUIBridge.d.ts +14 -0
- package/dist/extensibility/ui/IUIBridge.js +3 -0
- package/dist/extensibility/ui/IUIBridge.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/AppRuntimeModule.d.ts +9 -0
- package/dist/modules/AppRuntimeModule.js +8 -0
- package/dist/modules/AppRuntimeModule.js.map +1 -0
- package/dist/modules/appEvents/AppLaunchModule.d.ts +13 -0
- package/dist/modules/appEvents/AppLaunchModule.js +33 -0
- package/dist/modules/appEvents/AppLaunchModule.js.map +1 -0
- package/dist/modules/appEvents/MailReceivedModule.d.ts +13 -0
- package/dist/modules/appEvents/MailReceivedModule.js +41 -0
- package/dist/modules/appEvents/MailReceivedModule.js.map +1 -0
- package/dist/modules/appEvents/OnboardingChangeReceivedModule.d.ts +13 -0
- package/dist/modules/appEvents/OnboardingChangeReceivedModule.js +62 -0
- package/dist/modules/appEvents/OnboardingChangeReceivedModule.js.map +1 -0
- package/dist/modules/appEvents/index.d.ts +3 -0
- package/dist/modules/appEvents/index.js +16 -0
- package/dist/modules/appEvents/index.js.map +1 -0
- package/dist/modules/appSync/AppSyncModule.d.ts +13 -0
- package/dist/modules/appSync/AppSyncModule.js +37 -0
- package/dist/modules/appSync/AppSyncModule.js.map +1 -0
- package/dist/modules/appSync/index.d.ts +1 -0
- package/dist/modules/appSync/index.js +14 -0
- package/dist/modules/appSync/index.js.map +1 -0
- package/dist/modules/index.d.ts +5 -0
- package/dist/modules/index.js +18 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/pushNotifications/IBackboneEventContent.d.ts +10 -0
- package/dist/modules/pushNotifications/IBackboneEventContent.js +9 -0
- package/dist/modules/pushNotifications/IBackboneEventContent.js.map +1 -0
- package/dist/modules/pushNotifications/PushNotificationModule.d.ts +17 -0
- package/dist/modules/pushNotifications/PushNotificationModule.js +168 -0
- package/dist/modules/pushNotifications/PushNotificationModule.js.map +1 -0
- package/dist/modules/pushNotifications/index.d.ts +2 -0
- package/dist/modules/pushNotifications/index.js +15 -0
- package/dist/modules/pushNotifications/index.js.map +1 -0
- package/dist/modules/runtimeEvents/MessageReceivedModule.d.ts +13 -0
- package/dist/modules/runtimeEvents/MessageReceivedModule.js +52 -0
- package/dist/modules/runtimeEvents/MessageReceivedModule.js.map +1 -0
- package/dist/modules/runtimeEvents/RelationshipChangedModule.d.ts +13 -0
- package/dist/modules/runtimeEvents/RelationshipChangedModule.js +46 -0
- package/dist/modules/runtimeEvents/RelationshipChangedModule.js.map +1 -0
- package/dist/modules/runtimeEvents/index.d.ts +2 -0
- package/dist/modules/runtimeEvents/index.js +15 -0
- package/dist/modules/runtimeEvents/index.js.map +1 -0
- package/dist/multiAccount/AccountServices.d.ts +13 -0
- package/dist/multiAccount/AccountServices.js +37 -0
- package/dist/multiAccount/AccountServices.js.map +1 -0
- package/dist/multiAccount/MultiAccountController.d.ts +28 -0
- package/dist/multiAccount/MultiAccountController.js +155 -0
- package/dist/multiAccount/MultiAccountController.js.map +1 -0
- package/dist/multiAccount/MultiAccountFacade.d.ts +15 -0
- package/dist/multiAccount/MultiAccountFacade.js +46 -0
- package/dist/multiAccount/MultiAccountFacade.js.map +1 -0
- package/dist/multiAccount/data/LocalAccount.d.ts +18 -0
- package/dist/multiAccount/data/LocalAccount.js +55 -0
- package/dist/multiAccount/data/LocalAccount.js.map +1 -0
- package/dist/multiAccount/data/LocalAccountDTO.d.ts +8 -0
- package/dist/multiAccount/data/LocalAccountDTO.js +3 -0
- package/dist/multiAccount/data/LocalAccountDTO.js.map +1 -0
- package/dist/multiAccount/data/LocalAccountMapper.d.ts +5 -0
- package/dist/multiAccount/data/LocalAccountMapper.js +18 -0
- package/dist/multiAccount/data/LocalAccountMapper.js.map +1 -0
- package/dist/multiAccount/data/LocalAccountSession.d.ts +17 -0
- package/dist/multiAccount/data/LocalAccountSession.js +3 -0
- package/dist/multiAccount/data/LocalAccountSession.js.map +1 -0
- package/dist/multiAccount/index.d.ts +6 -0
- package/dist/multiAccount/index.js +19 -0
- package/dist/multiAccount/index.js.map +1 -0
- package/lib-web/nmshd.app-runtime.js +23621 -0
- package/lib-web/nmshd.app-runtime.min.js +3 -0
- package/package.json +71 -0
- package/ui5.yaml +9 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppLaunchModule = exports.AppLaunchModuleError = void 0;
|
|
4
|
+
const native_abstractions_1 = require("@js-soft/native-abstractions");
|
|
5
|
+
const AppRuntimeError_1 = require("../../AppRuntimeError");
|
|
6
|
+
const AppRuntimeModule_1 = require("../AppRuntimeModule");
|
|
7
|
+
class AppLaunchModuleError extends AppRuntimeError_1.AppRuntimeError {
|
|
8
|
+
}
|
|
9
|
+
exports.AppLaunchModuleError = AppLaunchModuleError;
|
|
10
|
+
class AppLaunchModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
11
|
+
async init() {
|
|
12
|
+
// Nothing to do here
|
|
13
|
+
}
|
|
14
|
+
async urlOpenEventListener(event) {
|
|
15
|
+
await this.runtime.appServices.stringProcessor.processURL(event.url);
|
|
16
|
+
}
|
|
17
|
+
start() {
|
|
18
|
+
const subscriptionResult = this.runtime.nativeEnvironment.eventBus.subscribe(native_abstractions_1.UrlOpenEvent, this.urlOpenEventListener.bind(this));
|
|
19
|
+
if (subscriptionResult.isError) {
|
|
20
|
+
this.logger.error(subscriptionResult.error);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.urlOpenSubscriptionId = subscriptionResult.value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
stop() {
|
|
27
|
+
if (this.urlOpenSubscriptionId) {
|
|
28
|
+
this.runtime.nativeEnvironment.eventBus.unsubscribe(native_abstractions_1.UrlOpenEvent, this.urlOpenSubscriptionId);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.AppLaunchModule = AppLaunchModule;
|
|
33
|
+
//# sourceMappingURL=AppLaunchModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppLaunchModule.js","sourceRoot":"","sources":["../../../src/modules/appEvents/AppLaunchModule.ts"],"names":[],"mappings":";;;AAAA,sEAA2D;AAC3D,2DAAuD;AACvD,0DAAqF;AAIrF,MAAa,oBAAqB,SAAQ,iCAAe;CAAG;AAA5D,oDAA4D;AAE5D,MAAa,eAAgB,SAAQ,mCAAuC;IACjE,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,KAAmB;QAClD,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxE,CAAC;IAIM,KAAK;QACR,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CACxE,kCAAY,EACZ,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CACvC,CAAA;QACD,IAAI,kBAAkB,CAAC,OAAO,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;SAC9C;aAAM;YACH,IAAI,CAAC,qBAAqB,GAAG,kBAAkB,CAAC,KAAK,CAAA;SACxD;IACL,CAAC;IAEM,IAAI;QACP,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC5B,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,kCAAY,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;SAChG;IACL,CAAC;CACJ;AA5BD,0CA4BC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppRuntimeError } from "../../AppRuntimeError";
|
|
2
|
+
import { AppRuntimeModule, AppRuntimeModuleConfiguration } from "../AppRuntimeModule";
|
|
3
|
+
export interface MailReceivedModuleConfig extends AppRuntimeModuleConfiguration {
|
|
4
|
+
}
|
|
5
|
+
export declare class MailReceivedModuleError extends AppRuntimeError {
|
|
6
|
+
}
|
|
7
|
+
export declare class MailReceivedModule extends AppRuntimeModule<MailReceivedModuleConfig> {
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
private mailReceivedListener;
|
|
10
|
+
private subscriptionId;
|
|
11
|
+
start(): void;
|
|
12
|
+
stop(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MailReceivedModule = exports.MailReceivedModuleError = void 0;
|
|
4
|
+
const AppRuntimeError_1 = require("../../AppRuntimeError");
|
|
5
|
+
const events_1 = require("../../events");
|
|
6
|
+
const AppRuntimeModule_1 = require("../AppRuntimeModule");
|
|
7
|
+
class MailReceivedModuleError extends AppRuntimeError_1.AppRuntimeError {
|
|
8
|
+
}
|
|
9
|
+
exports.MailReceivedModuleError = MailReceivedModuleError;
|
|
10
|
+
class MailReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
11
|
+
async init() {
|
|
12
|
+
// Nothing to do here
|
|
13
|
+
}
|
|
14
|
+
async mailReceivedListener(event) {
|
|
15
|
+
const mail = event.data;
|
|
16
|
+
const session = this.runtime.findSessionByAddress(event.eventTargetAddress);
|
|
17
|
+
if (!session) {
|
|
18
|
+
this.logger.error(`No session found for address ${event.eventTargetAddress}`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const sender = mail.createdBy;
|
|
22
|
+
await this.runtime.nativeEnvironment.notificationAccess.schedule(mail.name, mail.createdBy.name, {
|
|
23
|
+
callback: async () => {
|
|
24
|
+
await (await this.runtime.uiBridge()).showMessage(session.account, sender, mail);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
start() {
|
|
29
|
+
const subscriptionId = this.runtime.eventBus.subscribe(events_1.MailReceivedEvent, this.mailReceivedListener.bind(this));
|
|
30
|
+
this.subscriptionId = subscriptionId;
|
|
31
|
+
}
|
|
32
|
+
stop() {
|
|
33
|
+
if (!this.subscriptionId) {
|
|
34
|
+
this.logger.warn("No Subscription available.");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.runtime.eventBus.unsubscribe(events_1.MailReceivedEvent, this.subscriptionId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.MailReceivedModule = MailReceivedModule;
|
|
41
|
+
//# sourceMappingURL=MailReceivedModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MailReceivedModule.js","sourceRoot":"","sources":["../../../src/modules/appEvents/MailReceivedModule.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AACvD,yCAAgD;AAChD,0DAAqF;AAIrF,MAAa,uBAAwB,SAAQ,iCAAe;CAAG;AAA/D,0DAA+D;AAE/D,MAAa,kBAAmB,SAAQ,mCAA0C;IACvE,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,KAAwB;QACvD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAC3E,IAAI,CAAC,OAAO,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAA;YAC7E,OAAM;SACT;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;QAE7B,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;YAC7F,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACjB,MAAM,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;YACpF,CAAC;SACJ,CAAC,CAAA;IACN,CAAC;IAIM,KAAK;QACR,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,0BAAiB,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAC/G,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;IACxC,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;YAC9C,OAAM;SACT;QAED,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,0BAAiB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IAC7E,CAAC;CACJ;AApCD,gDAoCC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppRuntimeError } from "../../AppRuntimeError";
|
|
2
|
+
import { AppRuntimeModule, AppRuntimeModuleConfiguration } from "../AppRuntimeModule";
|
|
3
|
+
export interface OnboardingChangeReceivedModuleConfig extends AppRuntimeModuleConfiguration {
|
|
4
|
+
}
|
|
5
|
+
export declare class OnboardingChangeReceivedModuleError extends AppRuntimeError {
|
|
6
|
+
}
|
|
7
|
+
export declare class OnboardingChangeReceivedModule extends AppRuntimeModule<OnboardingChangeReceivedModuleConfig> {
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
private onboardingChangeReceivedHandler;
|
|
10
|
+
private subscriptionId;
|
|
11
|
+
start(): void;
|
|
12
|
+
stop(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnboardingChangeReceivedModule = exports.OnboardingChangeReceivedModuleError = void 0;
|
|
4
|
+
const runtime_1 = require("@nmshd/runtime");
|
|
5
|
+
const AppRuntimeError_1 = require("../../AppRuntimeError");
|
|
6
|
+
const events_1 = require("../../events");
|
|
7
|
+
const AppRuntimeModule_1 = require("../AppRuntimeModule");
|
|
8
|
+
class OnboardingChangeReceivedModuleError extends AppRuntimeError_1.AppRuntimeError {
|
|
9
|
+
}
|
|
10
|
+
exports.OnboardingChangeReceivedModuleError = OnboardingChangeReceivedModuleError;
|
|
11
|
+
class OnboardingChangeReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
12
|
+
async init() {
|
|
13
|
+
// Nothing to do here
|
|
14
|
+
}
|
|
15
|
+
async onboardingChangeReceivedHandler(event) {
|
|
16
|
+
const change = event.data.change;
|
|
17
|
+
const identity = event.data.identity;
|
|
18
|
+
let title = "";
|
|
19
|
+
let text = "";
|
|
20
|
+
const session = this.runtime.findSessionByAddress(event.eventTargetAddress);
|
|
21
|
+
if (!session) {
|
|
22
|
+
this.logger.error(`No session found for address ${event.eventTargetAddress}`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
switch (change.status) {
|
|
26
|
+
case runtime_1.RelationshipChangeStatus.Accepted:
|
|
27
|
+
title = "Kontaktanfrage genehmigt";
|
|
28
|
+
text = `Du kannst nun mit ${identity.name} kommunizieren`;
|
|
29
|
+
break;
|
|
30
|
+
case runtime_1.RelationshipChangeStatus.Pending:
|
|
31
|
+
title = "Kontaktanfrage erhalten";
|
|
32
|
+
text = `Du hast eine Kontaktanfrage von ${identity.name} erhalten`;
|
|
33
|
+
break;
|
|
34
|
+
case runtime_1.RelationshipChangeStatus.Rejected:
|
|
35
|
+
title = "Kontaktanfrage abgelehnt";
|
|
36
|
+
text = `${identity.name} hat ihre Kontaktanfrage abgelehnt`;
|
|
37
|
+
break;
|
|
38
|
+
case runtime_1.RelationshipChangeStatus.Revoked:
|
|
39
|
+
title = "Kontaktanfrage zurückgezogen";
|
|
40
|
+
text = `${identity.name} hat die Kontaktanfrage zurückgezogen`;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
await this.runtime.nativeEnvironment.notificationAccess.schedule(title, text, {
|
|
44
|
+
callback: async () => {
|
|
45
|
+
await (await this.runtime.uiBridge()).showRelationshipChange(session.account, identity, change);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
start() {
|
|
50
|
+
const subscriptionId = this.runtime.eventBus.subscribe(events_1.OnboardingChangeReceivedEvent, this.onboardingChangeReceivedHandler.bind(this));
|
|
51
|
+
this.subscriptionId = subscriptionId;
|
|
52
|
+
}
|
|
53
|
+
stop() {
|
|
54
|
+
if (!this.subscriptionId) {
|
|
55
|
+
this.logger.warn("No Subscription available.");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.runtime.eventBus.unsubscribe(events_1.MailReceivedEvent, this.subscriptionId);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.OnboardingChangeReceivedModule = OnboardingChangeReceivedModule;
|
|
62
|
+
//# sourceMappingURL=OnboardingChangeReceivedModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnboardingChangeReceivedModule.js","sourceRoot":"","sources":["../../../src/modules/appEvents/OnboardingChangeReceivedModule.ts"],"names":[],"mappings":";;;AAAA,4CAAyD;AACzD,2DAAuD;AACvD,yCAA+E;AAC/E,0DAAqF;AAIrF,MAAa,mCAAoC,SAAQ,iCAAe;CAAG;AAA3E,kFAA2E;AAE3E,MAAa,8BAA+B,SAAQ,mCAAsD;IAC/F,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEO,KAAK,CAAC,+BAA+B,CAAC,KAAoC;QAC9E,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAA;QAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAA;QACpC,IAAI,KAAK,GAAG,EAAE,CAAA;QACd,IAAI,IAAI,GAAG,EAAE,CAAA;QACb,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,K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AAI,CAAC,CAClD,CAAA;QACD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;IACxC,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;YAC9C,OAAM;SACT;QAED,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,0BAAiB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IAC7E,CAAC;CACJ;AA7DD,wEA6DC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./AppLaunchModule"), exports);
|
|
14
|
+
__exportStar(require("./MailReceivedModule"), exports);
|
|
15
|
+
__exportStar(require("./OnboardingChangeReceivedModule"), exports);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/appEvents/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiC;AACjC,uDAAoC;AACpC,mEAAgD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppRuntimeModule, AppRuntimeModuleConfiguration } from "../AppRuntimeModule";
|
|
2
|
+
export interface AppSyncModuleConfiguration extends AppRuntimeModuleConfiguration {
|
|
3
|
+
interval: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class AppSyncModule extends AppRuntimeModule<AppSyncModuleConfiguration> {
|
|
6
|
+
private syncTimeout;
|
|
7
|
+
private started;
|
|
8
|
+
get isStarted(): boolean;
|
|
9
|
+
init(): void;
|
|
10
|
+
start(): void;
|
|
11
|
+
private sync;
|
|
12
|
+
stop(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppSyncModule = void 0;
|
|
4
|
+
const AppRuntimeModule_1 = require("../AppRuntimeModule");
|
|
5
|
+
class AppSyncModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.started = false;
|
|
9
|
+
}
|
|
10
|
+
get isStarted() {
|
|
11
|
+
return this.started;
|
|
12
|
+
}
|
|
13
|
+
init() {
|
|
14
|
+
// Nothing to do here
|
|
15
|
+
}
|
|
16
|
+
start() {
|
|
17
|
+
this.sync().catch((e) => {
|
|
18
|
+
this.logger.error(e);
|
|
19
|
+
});
|
|
20
|
+
this.started = true;
|
|
21
|
+
}
|
|
22
|
+
async sync() {
|
|
23
|
+
const result = await this.runtime.transportServices.account.syncEverything();
|
|
24
|
+
if (result.isError) {
|
|
25
|
+
this.logger.error(result.error);
|
|
26
|
+
}
|
|
27
|
+
if (this.started) {
|
|
28
|
+
this.syncTimeout = setTimeout(() => this.sync(), this.configuration.interval * 1000);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
stop() {
|
|
32
|
+
this.started = false;
|
|
33
|
+
clearTimeout(this.syncTimeout);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.AppSyncModule = AppSyncModule;
|
|
37
|
+
//# sourceMappingURL=AppSyncModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppSyncModule.js","sourceRoot":"","sources":["../../../src/modules/appSync/AppSyncModule.ts"],"names":[],"mappings":";;;AAAA,0DAAqF;AAMrF,MAAa,aAAc,SAAQ,mCAA4C;IAA/E;;QAEY,YAAO,GAAG,KAAK,CAAA;IAgC3B,CAAC;IA9BG,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,OAAO,CAAA;IACvB,CAAC;IAEM,IAAI;QACP,qBAAqB;IACzB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACvB,CAAC;IAEO,KAAK,CAAC,IAAI;QACd,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;QAC5E,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;SAClC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAA;SACvF;IACL,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAClC,CAAC;CACJ;AAlCD,sCAkCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AppSyncModule";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./AppSyncModule"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/appSync/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./appEvents"), exports);
|
|
14
|
+
__exportStar(require("./AppRuntimeModule"), exports);
|
|
15
|
+
__exportStar(require("./appSync"), exports);
|
|
16
|
+
__exportStar(require("./pushNotifications"), exports);
|
|
17
|
+
__exportStar(require("./runtimeEvents"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA2B;AAC3B,qDAAkC;AAClC,4CAAyB;AACzB,sDAAmC;AACnC,kDAA+B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum BackboneEventName {
|
|
2
|
+
DatawalletModificationsCreated = "DatawalletModificationsCreated",
|
|
3
|
+
ExternalEventCreated = "ExternalEventCreated"
|
|
4
|
+
}
|
|
5
|
+
export interface IBackboneEventContent {
|
|
6
|
+
accRef: string;
|
|
7
|
+
eventName: BackboneEventName;
|
|
8
|
+
sentAt: string;
|
|
9
|
+
payload: any;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackboneEventName = void 0;
|
|
4
|
+
var BackboneEventName;
|
|
5
|
+
(function (BackboneEventName) {
|
|
6
|
+
BackboneEventName["DatawalletModificationsCreated"] = "DatawalletModificationsCreated";
|
|
7
|
+
BackboneEventName["ExternalEventCreated"] = "ExternalEventCreated";
|
|
8
|
+
})(BackboneEventName = exports.BackboneEventName || (exports.BackboneEventName = {}));
|
|
9
|
+
//# sourceMappingURL=IBackboneEventContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IBackboneEventContent.js","sourceRoot":"","sources":["../../../src/modules/pushNotifications/IBackboneEventContent.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IACzB,sFAAiE,CAAA;IACjE,kEAA6C,CAAA;AACjD,CAAC,EAHW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAG5B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Result } from "@js-soft/ts-utils";
|
|
2
|
+
import { AppRuntimeModule, AppRuntimeModuleConfiguration } from "../AppRuntimeModule";
|
|
3
|
+
export interface PushNotificationModuleConfig extends AppRuntimeModuleConfiguration {
|
|
4
|
+
}
|
|
5
|
+
export declare class PushNotificationModule extends AppRuntimeModule<PushNotificationModuleConfig> {
|
|
6
|
+
init(): Promise<void>;
|
|
7
|
+
private handleRemoteNotificationEvent;
|
|
8
|
+
private handleTokenRegistrationEvent;
|
|
9
|
+
private handleAccountSelectedEvent;
|
|
10
|
+
registerPushTokenForLocalAccount(id: string, token: string): Promise<void>;
|
|
11
|
+
getNotificationTokenFromConfig(): Result<string>;
|
|
12
|
+
private subscriptionIdTokenRegistration;
|
|
13
|
+
private subscriptionIdAccountSelection;
|
|
14
|
+
private subscriptionIdRemoteNotification;
|
|
15
|
+
start(): void;
|
|
16
|
+
stop(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PushNotificationModule = void 0;
|
|
4
|
+
const native_abstractions_1 = require("@js-soft/native-abstractions");
|
|
5
|
+
const ts_utils_1 = require("@js-soft/ts-utils");
|
|
6
|
+
const AppRuntimeErrors_1 = require("../../AppRuntimeErrors");
|
|
7
|
+
const events_1 = require("../../events");
|
|
8
|
+
const AppRuntimeModule_1 = require("../AppRuntimeModule");
|
|
9
|
+
const IBackboneEventContent_1 = require("./IBackboneEventContent");
|
|
10
|
+
class PushNotificationModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
11
|
+
async init() {
|
|
12
|
+
// Nothing to do here
|
|
13
|
+
}
|
|
14
|
+
async handleRemoteNotificationEvent(event) {
|
|
15
|
+
this.logger.trace("PushNotificationModule.handleRemoteNotificationEvent", event);
|
|
16
|
+
const notification = event.notification;
|
|
17
|
+
const content = notification.content;
|
|
18
|
+
try {
|
|
19
|
+
const account = await this.runtime.selectAccountByAddress(content.accRef, "");
|
|
20
|
+
const session = this.runtime.findSession(account.id.toString());
|
|
21
|
+
if (!session) {
|
|
22
|
+
this.logger.error(`No session found for account ref ${content.accRef}`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
switch (content.eventName) {
|
|
26
|
+
case IBackboneEventContent_1.BackboneEventName.DatawalletModificationsCreated:
|
|
27
|
+
const walletResult = await session.transportServices.account.syncDatawallet();
|
|
28
|
+
if (walletResult.isError) {
|
|
29
|
+
this.logger.error(walletResult);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.runtime.eventBus.publish(new events_1.DatawalletSynchronizedEvent(session.address));
|
|
33
|
+
break;
|
|
34
|
+
case IBackboneEventContent_1.BackboneEventName.ExternalEventCreated:
|
|
35
|
+
const syncResult = await session.transportServices.account.syncEverything();
|
|
36
|
+
if (syncResult.isError) {
|
|
37
|
+
this.logger.error(syncResult);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.runtime.eventBus.publish(new events_1.ExternalEventReceivedEvent(session.address, syncResult.value.messages, syncResult.value.relationships));
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
this.logger.error(e);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async handleTokenRegistrationEvent(event) {
|
|
51
|
+
try {
|
|
52
|
+
this.logger.trace("PushNotificationModule.handleTokenRegistrationEvent", event);
|
|
53
|
+
for (const account of this.runtime.getSessions()) {
|
|
54
|
+
await this.registerPushTokenForLocalAccount(account.id, event.token);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
this.logger.error(e);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async handleAccountSelectedEvent(event) {
|
|
62
|
+
try {
|
|
63
|
+
this.logger.trace("PushNotificationModule.handleAccountSelectedEvent", event);
|
|
64
|
+
const tokenResult = this.getNotificationTokenFromConfig();
|
|
65
|
+
if (tokenResult.isSuccess) {
|
|
66
|
+
await this.registerPushTokenForLocalAccount(event.data.localAccountId, tokenResult.value);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this.logger.error(tokenResult.error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
this.logger.error(e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async registerPushTokenForLocalAccount(id, token) {
|
|
77
|
+
if (!token) {
|
|
78
|
+
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
79
|
+
.tokenRegistrationNotPossible("The registered token was empty. This might be the case if you did not allow push notifications.")
|
|
80
|
+
.logWith(this.logger);
|
|
81
|
+
}
|
|
82
|
+
const session = this.runtime.findSession(id);
|
|
83
|
+
if (!session) {
|
|
84
|
+
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
85
|
+
.tokenRegistrationNotPossible("No session for this account found")
|
|
86
|
+
.logWith(this.logger);
|
|
87
|
+
}
|
|
88
|
+
const deviceResult = await session.transportServices.account.getDeviceInfo();
|
|
89
|
+
if (deviceResult.isError) {
|
|
90
|
+
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
91
|
+
.tokenRegistrationNotPossible("No device for this account found", deviceResult.error)
|
|
92
|
+
.logWith(this.logger);
|
|
93
|
+
}
|
|
94
|
+
const device = deviceResult.value;
|
|
95
|
+
const platform = this.runtime.nativeEnvironment.deviceInfoAccess.deviceInfo.pushService;
|
|
96
|
+
const handle = token;
|
|
97
|
+
const installationId = device.id;
|
|
98
|
+
const result = await session.transportServices.account.registerPushNotificationToken({
|
|
99
|
+
platform,
|
|
100
|
+
handle,
|
|
101
|
+
installationId
|
|
102
|
+
});
|
|
103
|
+
if (result.isError) {
|
|
104
|
+
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
105
|
+
.tokenRegistrationNotPossible(result.error.message, result.error)
|
|
106
|
+
.logWith(this.logger);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.logger.trace(`PushNotificationModule.registerPushTokenForLocalAccount: Token ${handle} registered for account ${id} on platform ${platform} and installationId ${installationId}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
getNotificationTokenFromConfig() {
|
|
113
|
+
const pushTokenResult = this.runtime.nativeEnvironment.configAccess.get("pushToken");
|
|
114
|
+
if (pushTokenResult.isError) {
|
|
115
|
+
ts_utils_1.Result.fail(pushTokenResult.error);
|
|
116
|
+
}
|
|
117
|
+
return ts_utils_1.Result.ok(pushTokenResult.value);
|
|
118
|
+
}
|
|
119
|
+
start() {
|
|
120
|
+
const remoteNotificationResult = this.runtime.nativeEnvironment.eventBus.subscribe(native_abstractions_1.RemoteNotificationEvent, this.handleRemoteNotificationEvent.bind(this));
|
|
121
|
+
if (remoteNotificationResult.isError) {
|
|
122
|
+
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
123
|
+
.subscriptionNotPossible(remoteNotificationResult.error.message, remoteNotificationResult.error)
|
|
124
|
+
.logWith(this.logger);
|
|
125
|
+
}
|
|
126
|
+
this.subscriptionIdRemoteNotification = remoteNotificationResult.value;
|
|
127
|
+
const tokenRegistrationResult = this.runtime.nativeEnvironment.eventBus.subscribe(native_abstractions_1.RemoteNotificationRegistrationEvent, this.handleTokenRegistrationEvent.bind(this));
|
|
128
|
+
if (tokenRegistrationResult.isError) {
|
|
129
|
+
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
130
|
+
.subscriptionNotPossible(tokenRegistrationResult.error.message, tokenRegistrationResult.error)
|
|
131
|
+
.logWith(this.logger);
|
|
132
|
+
}
|
|
133
|
+
this.subscriptionIdTokenRegistration = tokenRegistrationResult.value;
|
|
134
|
+
this.subscriptionIdAccountSelection = this.runtime.eventBus.subscribe(events_1.AccountSelectedEvent, this.handleAccountSelectedEvent.bind(this));
|
|
135
|
+
}
|
|
136
|
+
stop() {
|
|
137
|
+
if (!this.subscriptionIdRemoteNotification) {
|
|
138
|
+
this.logger.warn("No RemoteNotificationEvent subscription available.");
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const result = this.runtime.nativeEnvironment.eventBus.unsubscribe(native_abstractions_1.RemoteNotificationEvent, this.subscriptionIdRemoteNotification);
|
|
142
|
+
if (result.isError) {
|
|
143
|
+
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
144
|
+
.unsubscriptionNotPossible(result.error.message, result.error)
|
|
145
|
+
.logWith(this.logger);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (!this.subscriptionIdTokenRegistration) {
|
|
149
|
+
this.logger.warn("No RemoteNotificationRegistrationEvent subscription available.");
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const result = this.runtime.nativeEnvironment.eventBus.unsubscribe(native_abstractions_1.RemoteNotificationRegistrationEvent, this.subscriptionIdTokenRegistration);
|
|
153
|
+
if (result.isError) {
|
|
154
|
+
throw AppRuntimeErrors_1.AppRuntimeErrors.modules.pushNotificationModule
|
|
155
|
+
.unsubscriptionNotPossible(result.error.message, result.error)
|
|
156
|
+
.logWith(this.logger);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!this.subscriptionIdAccountSelection) {
|
|
160
|
+
this.logger.warn("No AccountSelectedEvent subscription available.");
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.runtime.eventBus.unsubscribe(events_1.AccountSelectedEvent, this.subscriptionIdAccountSelection);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.PushNotificationModule = PushNotificationModule;
|
|
168
|
+
//# sourceMappingURL=PushNotificationModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PushNotificationModule.js","s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,MAAM,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAA;SACrF;aAAM;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAC9D,yDAAmC,EACnC,IAAI,CAAC,+BAA+B,CACvC,CAAA;YACD,IAAI,MAAM,CAAC,OAAO,EAAE;gBAChB,MAAM,mCAAgB,CAAC,OAAO,CAAC,sBAAsB;qBAChD,yBAAyB,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;qBAC7D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;aAC5B;SACJ;QAED,IAAI,CAAC,IAAI,CAAC,8BAA8B,EAAE;YACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAA;SACtE;aAAM;YACH,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,6BAAoB,EAAE,IAAI,CAAC,8BAA8B,CAAC,CAAA;SAC/F;IACL,CAAC;CACJ;AAlMD,wDAkMC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./IBackboneEventContent"), exports);
|
|
14
|
+
__exportStar(require("./PushNotificationModule"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/pushNotifications/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAuC;AACvC,2DAAwC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppRuntimeError } from "../../AppRuntimeError";
|
|
2
|
+
import { AppRuntimeModule, AppRuntimeModuleConfiguration } from "../AppRuntimeModule";
|
|
3
|
+
export interface MessageReceivedModuleConfig extends AppRuntimeModuleConfiguration {
|
|
4
|
+
}
|
|
5
|
+
export declare class MessageReceivedModuleError extends AppRuntimeError {
|
|
6
|
+
}
|
|
7
|
+
export declare class MessageReceivedModule extends AppRuntimeModule<MessageReceivedModuleConfig> {
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
private messageReceivedEventListener;
|
|
10
|
+
private subscriptionId;
|
|
11
|
+
start(): void;
|
|
12
|
+
stop(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageReceivedModule = exports.MessageReceivedModuleError = void 0;
|
|
4
|
+
const runtime_1 = require("@nmshd/runtime");
|
|
5
|
+
const AppRuntimeError_1 = require("../../AppRuntimeError");
|
|
6
|
+
const events_1 = require("../../events");
|
|
7
|
+
const AppRuntimeModule_1 = require("../AppRuntimeModule");
|
|
8
|
+
class MessageReceivedModuleError extends AppRuntimeError_1.AppRuntimeError {
|
|
9
|
+
}
|
|
10
|
+
exports.MessageReceivedModuleError = MessageReceivedModuleError;
|
|
11
|
+
class MessageReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
12
|
+
async init() {
|
|
13
|
+
// Nothing to do here
|
|
14
|
+
}
|
|
15
|
+
async messageReceivedEventListener(event) {
|
|
16
|
+
const message = event.data;
|
|
17
|
+
const session = this.runtime.findSessionByAddress(event.eventTargetAddress);
|
|
18
|
+
if (!session) {
|
|
19
|
+
this.logger.error(`No session found for address ${event.eventTargetAddress}`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const messageDVO = await session.expander.expandMessageDTO(message);
|
|
23
|
+
switch (messageDVO.type) {
|
|
24
|
+
case "RequestMailDVO":
|
|
25
|
+
const requestMail = messageDVO;
|
|
26
|
+
this.runtime.eventBus.publish(new events_1.MailReceivedEvent(event.eventTargetAddress, requestMail));
|
|
27
|
+
for (const requestDVO of requestMail.requests) {
|
|
28
|
+
this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, requestDVO, messageDVO));
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
case "MailDVO":
|
|
32
|
+
const mail = messageDVO;
|
|
33
|
+
this.runtime.eventBus.publish(new events_1.MailReceivedEvent(event.eventTargetAddress, mail));
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
start() {
|
|
40
|
+
const subscriptionId = this.runtime.eventBus.subscribe(runtime_1.MessageReceivedEvent, this.messageReceivedEventListener.bind(this));
|
|
41
|
+
this.subscriptionId = subscriptionId;
|
|
42
|
+
}
|
|
43
|
+
stop() {
|
|
44
|
+
if (!this.subscriptionId) {
|
|
45
|
+
this.logger.warn("No Subscription available.");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.runtime.eventBus.unsubscribe(runtime_1.MessageReceivedEvent, this.subscriptionId);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.MessageReceivedModule = MessageReceivedModule;
|
|
52
|
+
//# sourceMappingURL=MessageReceivedModule.js.map
|