@interopio/browser 3.1.3 → 3.2.1

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.
@@ -73,10 +73,8 @@ const enterprise = (config) => {
73
73
  libraries: (_a = config === null || config === void 0 ? void 0 : config.libraries) !== null && _a !== void 0 ? _a : [],
74
74
  logger: (_c = (_b = config === null || config === void 0 ? void 0 : config.systemLogger) === null || _b === void 0 ? void 0 : _b.level) !== null && _c !== void 0 ? _c : "warn"
75
75
  };
76
- if (window.glue42gd) {
77
- return window.Glue(enterpriseConfig);
78
- }
79
- return window.Glue(enterpriseConfig);
76
+ const injectedFactory = window.IODesktop || window.Glue;
77
+ return injectedFactory(enterpriseConfig);
80
78
  };
81
79
 
82
80
  /**
@@ -1800,7 +1798,7 @@ class FDC3Service {
1800
1798
  isFdc3Definition(definition) {
1801
1799
  const decodeRes = allDefinitionsDecoder.run(definition);
1802
1800
  if (!decodeRes.ok) {
1803
- return { isFdc3: false };
1801
+ return { isFdc3: false, reason: parseDecoderErrorToStringMessage(decodeRes.error) };
1804
1802
  }
1805
1803
  if (definition.appId && definition.details) {
1806
1804
  return { isFdc3: true, version: "2.0" };
@@ -1808,7 +1806,7 @@ class FDC3Service {
1808
1806
  if (definition.manifest) {
1809
1807
  return { isFdc3: true, version: "1.2" };
1810
1808
  }
1811
- return { isFdc3: false };
1809
+ return { isFdc3: false, reason: "The passed definition is not FDC3" };
1812
1810
  }
1813
1811
  parseToBrowserBaseAppData(definition) {
1814
1812
  var _a;
@@ -1979,9 +1977,27 @@ const decoders$1 = {
1979
1977
  }
1980
1978
  };
1981
1979
 
1980
+ var INTENTS_ERRORS;
1981
+ (function (INTENTS_ERRORS) {
1982
+ INTENTS_ERRORS["USER_CANCELLED"] = "User Closed Intents Resolver UI without choosing a handler";
1983
+ INTENTS_ERRORS["CALLER_NOT_DEFINED"] = "Caller Id is not defined";
1984
+ INTENTS_ERRORS["TIMEOUT_HIT"] = "Timeout hit";
1985
+ INTENTS_ERRORS["INTENT_NOT_FOUND"] = "Cannot find Intent";
1986
+ INTENTS_ERRORS["HANDLER_NOT_FOUND"] = "Cannot find Intent Handler";
1987
+ INTENTS_ERRORS["TARGET_INSTANCE_UNAVAILABLE"] = "Cannot start Target Instance";
1988
+ INTENTS_ERRORS["INTENT_DELIVERY_FAILED"] = "Target Instance did not add a listener";
1989
+ INTENTS_ERRORS["RESOLVER_UNAVAILABLE"] = "Intents Resolver UI unavailable";
1990
+ INTENTS_ERRORS["RESOLVER_TIMEOUT"] = "User did not choose a handler";
1991
+ INTENTS_ERRORS["INVALID_RESOLVER_RESPONSE"] = "Intents Resolver UI returned invalid response";
1992
+ INTENTS_ERRORS["INTENT_HANDLER_REJECTION"] = "Intent Handler function processing the raised intent threw an error or rejected the promise it returned";
1993
+ })(INTENTS_ERRORS || (INTENTS_ERRORS = {}));
1994
+
1982
1995
  let IoC$1 = class IoC {
1983
1996
  constructor() {
1984
1997
  this._decoders = decoders$1;
1998
+ this._errors = {
1999
+ intents: INTENTS_ERRORS
2000
+ };
1985
2001
  }
1986
2002
  get fdc3() {
1987
2003
  if (!this._fdc3) {
@@ -1992,20 +2008,24 @@ let IoC$1 = class IoC {
1992
2008
  get decoders() {
1993
2009
  return this._decoders;
1994
2010
  }
2011
+ get errors() {
2012
+ return this._errors;
2013
+ }
1995
2014
  };
1996
2015
 
1997
2016
  const ioc = new IoC$1();
1998
2017
  ioc.fdc3;
1999
2018
  const decoders = ioc.decoders;
2019
+ ioc.errors;
2000
2020
 
2001
2021
  const nonEmptyStringDecoder = string$1().where((s) => s.length > 0, "Expected a non-empty string");
2002
2022
  const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
2003
2023
  const optionalNonEmptyStringDecoder = optional$1(nonEmptyStringDecoder);
2004
- const libDomainDecoder = oneOf$1(constant$1("system"), constant$1("windows"), constant$1("appManager"), constant$1("layouts"), constant$1("intents"), constant$1("notifications"), constant$1("channels"), constant$1("extension"), constant$1("themes"));
2024
+ const libDomainDecoder = oneOf$1(constant$1("system"), constant$1("windows"), constant$1("appManager"), constant$1("layouts"), constant$1("intents"), constant$1("notifications"), constant$1("channels"), constant$1("extension"), constant$1("themes"), constant$1("prefs"));
2005
2025
  const windowOperationTypesDecoder = oneOf$1(constant$1("openWindow"), constant$1("windowHello"), constant$1("windowAdded"), constant$1("windowRemoved"), constant$1("getBounds"), constant$1("getFrameBounds"), constant$1("getUrl"), constant$1("moveResize"), constant$1("focus"), constant$1("close"), constant$1("getTitle"), constant$1("setTitle"), constant$1("focusChange"), constant$1("getChannel"));
2006
2026
  const appManagerOperationTypesDecoder = oneOf$1(constant$1("appHello"), constant$1("appDirectoryStateChange"), constant$1("instanceStarted"), constant$1("instanceStopped"), constant$1("applicationStart"), constant$1("instanceStop"), constant$1("clear"));
2007
2027
  const layoutsOperationTypesDecoder = oneOf$1(constant$1("layoutAdded"), constant$1("layoutChanged"), constant$1("layoutRemoved"), constant$1("get"), constant$1("getAll"), constant$1("export"), constant$1("import"), constant$1("remove"), constant$1("clientSaveRequest"), constant$1("getGlobalPermissionState"), constant$1("checkGlobalActivated"), constant$1("requestGlobalPermission"), constant$1("getDefaultGlobal"), constant$1("setDefaultGlobal"), constant$1("clearDefaultGlobal"));
2008
- const notificationsOperationTypesDecoder = oneOf$1(constant$1("raiseNotification"), constant$1("requestPermission"), constant$1("notificationShow"), constant$1("notificationClick"), constant$1("getPermission"), constant$1("list"), constant$1("notificationRaised"), constant$1("notificationClosed"), constant$1("click"), constant$1("clear"), constant$1("clearAll"));
2028
+ const notificationsOperationTypesDecoder = oneOf$1(constant$1("raiseNotification"), constant$1("requestPermission"), constant$1("notificationShow"), constant$1("notificationClick"), constant$1("getPermission"), constant$1("list"), constant$1("notificationRaised"), constant$1("notificationClosed"), constant$1("click"), constant$1("clear"), constant$1("clearAll"), constant$1("configure"), constant$1("getConfiguration"), constant$1("configurationChanged"), constant$1("setState"), constant$1("clearOld"), constant$1("activeCountChange"), constant$1("stateChange"));
2009
2029
  const systemOperationTypesDecoder = oneOf$1(constant$1("getEnvironment"), constant$1("getBase"), constant$1("platformShutdown"));
2010
2030
  const windowRelativeDirectionDecoder = oneOf$1(constant$1("top"), constant$1("left"), constant$1("right"), constant$1("bottom"));
2011
2031
  const windowBoundsDecoder = object$1({
@@ -2332,7 +2352,7 @@ const optionalSimpleLayoutResult = object$1({
2332
2352
  const setDefaultGlobalConfigDecoder = object$1({
2333
2353
  name: nonEmptyStringDecoder
2334
2354
  });
2335
- const intentsOperationTypesDecoder = oneOf$1(constant$1("findIntent"), constant$1("getIntents"), constant$1("raiseIntent"), constant$1("raise"));
2355
+ const intentsOperationTypesDecoder = oneOf$1(constant$1("findIntent"), constant$1("getIntents"), constant$1("raiseIntent"), constant$1("raise"), constant$1("filterHandlers"));
2336
2356
  const intentHandlerDecoder = object$1({
2337
2357
  applicationName: nonEmptyStringDecoder,
2338
2358
  applicationTitle: optional$1(string$1()),
@@ -2389,20 +2409,36 @@ const intentRequestDecoder = object$1({
2389
2409
  waitUserResponseIndefinitely: optional$1(boolean$1())
2390
2410
  });
2391
2411
  const raiseRequestDecoder = oneOf$1(nonEmptyStringDecoder, intentRequestDecoder);
2392
- const intentRequestResolverConfigDecoder = object$1({
2412
+ const resolverConfigDecoder = object$1({
2393
2413
  enabled: boolean$1(),
2394
2414
  appName: nonEmptyStringDecoder,
2395
2415
  waitResponseTimeout: number$1()
2396
2416
  });
2397
2417
  const raiseIntentRequestDecoder = object$1({
2398
2418
  intentRequest: intentRequestDecoder,
2399
- resolverConfig: intentRequestResolverConfigDecoder
2419
+ resolverConfig: resolverConfigDecoder
2400
2420
  });
2401
2421
  const intentResultDecoder = object$1({
2402
2422
  request: intentRequestDecoder,
2403
2423
  handler: intentHandlerDecoder,
2404
2424
  result: anyJson$1()
2405
2425
  });
2426
+ const handlersFilterDecoder = object$1({
2427
+ title: optional$1(nonEmptyStringDecoder),
2428
+ openResolver: optional$1(boolean$1()),
2429
+ timeout: optional$1(nonNegativeNumberDecoder),
2430
+ intent: optional$1(nonEmptyStringDecoder),
2431
+ contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
2432
+ resultType: optional$1(nonEmptyStringDecoder),
2433
+ applicationNames: optional$1(array$1(nonEmptyStringDecoder))
2434
+ });
2435
+ const filterHandlersResultDecoder = object$1({
2436
+ handlers: array$1(intentHandlerDecoder)
2437
+ });
2438
+ const filterHandlersWithResolverConfigDecoder = object$1({
2439
+ filterHandlersRequest: handlersFilterDecoder,
2440
+ resolverConfig: resolverConfigDecoder
2441
+ });
2406
2442
  const AddIntentListenerRequestDecoder = object$1({
2407
2443
  intent: nonEmptyStringDecoder,
2408
2444
  contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
@@ -2412,6 +2448,17 @@ const AddIntentListenerRequestDecoder = object$1({
2412
2448
  resultType: optional$1(string$1())
2413
2449
  });
2414
2450
  const AddIntentListenerDecoder = oneOf$1(nonEmptyStringDecoder, AddIntentListenerRequestDecoder);
2451
+ const intentInfoDecoder = object$1({
2452
+ intent: nonEmptyStringDecoder,
2453
+ contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
2454
+ description: optional$1(nonEmptyStringDecoder),
2455
+ displayName: optional$1(nonEmptyStringDecoder),
2456
+ icon: optional$1(nonEmptyStringDecoder),
2457
+ resultType: optional$1(nonEmptyStringDecoder)
2458
+ });
2459
+ const getIntentsResultDecoder = object$1({
2460
+ intents: array$1(intentInfoDecoder)
2461
+ });
2415
2462
  const channelNameDecoder = (channelNames) => {
2416
2463
  return nonEmptyStringDecoder.where(s => channelNames.includes(s), "Expected a valid channel name");
2417
2464
  };
@@ -2426,6 +2473,10 @@ const glue42NotificationActionDecoder = object$1({
2426
2473
  icon: optional$1(string$1()),
2427
2474
  interop: optional$1(interopActionSettingsDecoder)
2428
2475
  });
2476
+ const notificationStateDecoder = oneOf$1(constant$1("Active"), constant$1("Acknowledged"), constant$1("Seen"), constant$1("Closed"), constant$1("Stale"), constant$1("Snoozed"), constant$1("Processing"));
2477
+ const activeNotificationsCountChangeDecoder = object$1({
2478
+ count: number$1()
2479
+ });
2429
2480
  const notificationDefinitionDecoder = object$1({
2430
2481
  badge: optional$1(string$1()),
2431
2482
  body: optional$1(string$1()),
@@ -2461,7 +2512,12 @@ const glue42NotificationOptionsDecoder = object$1({
2461
2512
  vibrate: optional$1(array$1(number$1())),
2462
2513
  severity: optional$1(oneOf$1(constant$1("Low"), constant$1("None"), constant$1("Medium"), constant$1("High"), constant$1("Critical"))),
2463
2514
  showToast: optional$1(boolean$1()),
2464
- showInPanel: optional$1(boolean$1())
2515
+ showInPanel: optional$1(boolean$1()),
2516
+ state: optional$1(notificationStateDecoder)
2517
+ });
2518
+ const notificationSetStateRequestDecoder = object$1({
2519
+ id: nonEmptyStringDecoder,
2520
+ state: notificationStateDecoder
2465
2521
  });
2466
2522
  const channelContextDecoder = object$1({
2467
2523
  name: nonEmptyStringDecoder,
@@ -2488,6 +2544,28 @@ const notificationEventPayloadDecoder = object$1({
2488
2544
  action: optional$1(string$1()),
2489
2545
  id: optional$1(nonEmptyStringDecoder)
2490
2546
  });
2547
+ const notificationFilterDecoder = object$1({
2548
+ allowed: optional$1(array$1(nonEmptyStringDecoder)),
2549
+ blocked: optional$1(array$1(nonEmptyStringDecoder))
2550
+ });
2551
+ const notificationsConfigurationDecoder = object$1({
2552
+ enable: optional$1(boolean$1()),
2553
+ enableToasts: optional$1(boolean$1()),
2554
+ sourceFilter: optional$1(notificationFilterDecoder),
2555
+ });
2556
+ const notificationsConfigurationProtocolDecoder = object$1({
2557
+ configuration: notificationsConfigurationDecoder
2558
+ });
2559
+ const strictNotificationsConfigurationProtocolDecoder = object$1({
2560
+ configuration: object$1({
2561
+ enable: boolean$1(),
2562
+ enableToasts: boolean$1(),
2563
+ sourceFilter: object$1({
2564
+ allowed: array$1(nonEmptyStringDecoder),
2565
+ blocked: array$1(nonEmptyStringDecoder)
2566
+ })
2567
+ })
2568
+ });
2491
2569
  const platformSaveRequestConfigDecoder = object$1({
2492
2570
  layoutType: oneOf$1(constant$1("Global"), constant$1("Workspace")),
2493
2571
  layoutName: nonEmptyStringDecoder,
@@ -2548,7 +2626,8 @@ const notificationsDataDecoder = object$1({
2548
2626
  vibrate: optional$1(array$1(number$1())),
2549
2627
  severity: optional$1(oneOf$1(constant$1("Low"), constant$1("None"), constant$1("Medium"), constant$1("High"), constant$1("Critical"))),
2550
2628
  showToast: optional$1(boolean$1()),
2551
- showInPanel: optional$1(boolean$1())
2629
+ showInPanel: optional$1(boolean$1()),
2630
+ state: optional$1(notificationStateDecoder)
2552
2631
  });
2553
2632
  const simpleNotificationDataDecoder = object$1({
2554
2633
  notification: notificationsDataDecoder
@@ -2602,9 +2681,33 @@ const joinChannelDataDecoder = object$1({
2602
2681
  });
2603
2682
  const windowChannelResultDecoder = object$1({
2604
2683
  channel: optional$1(nonEmptyStringDecoder),
2684
+ });
2685
+ const prefsOperationTypesDecoder = oneOf$1(constant$1("clear"), constant$1("clearAll"), constant$1("get"), constant$1("getAll"), constant$1("set"), constant$1("update"), constant$1("prefsChanged"), constant$1("prefsHello"));
2686
+ const appPreferencesDecoder = object$1({
2687
+ app: nonEmptyStringDecoder,
2688
+ data: object$1(),
2689
+ lastUpdate: optional$1(nonEmptyStringDecoder),
2690
+ });
2691
+ const basePrefsConfigDecoder = object$1({
2692
+ app: nonEmptyStringDecoder,
2693
+ });
2694
+ const getPrefsResultDecoder = object$1({
2695
+ prefs: appPreferencesDecoder,
2696
+ });
2697
+ const getAllPrefsResultDecoder = object$1({
2698
+ all: array$1(appPreferencesDecoder),
2699
+ });
2700
+ const changePrefsDataDecoder = object$1({
2701
+ app: nonEmptyStringDecoder,
2702
+ data: object$1(),
2703
+ });
2704
+ const prefsHelloSuccessDecoder = object$1({
2705
+ platform: object$1({
2706
+ app: nonEmptyStringDecoder,
2707
+ }),
2605
2708
  });
2606
2709
 
2607
- const operations$8 = {
2710
+ const operations$9 = {
2608
2711
  openWindow: { name: "openWindow", dataDecoder: openWindowConfigDecoder, resultDecoder: coreWindowDataDecoder },
2609
2712
  windowHello: { name: "windowHello", dataDecoder: windowHelloDecoder, resultDecoder: helloSuccessDecoder },
2610
2713
  windowAdded: { name: "windowAdded", dataDecoder: coreWindowDataDecoder },
@@ -2793,7 +2896,7 @@ class WebWindowModel {
2793
2896
  }
2794
2897
  getURL() {
2795
2898
  return __awaiter$1(this, void 0, void 0, function* () {
2796
- const result = yield this._bridge.send("windows", operations$8.getUrl, { windowId: this.id });
2899
+ const result = yield this._bridge.send("windows", operations$9.getUrl, { windowId: this.id });
2797
2900
  return result.url;
2798
2901
  });
2799
2902
  }
@@ -2807,7 +2910,7 @@ class WebWindowModel {
2807
2910
  return __awaiter$1(this, void 0, void 0, function* () {
2808
2911
  const targetBounds = boundsDecoder.runWithException(dimension);
2809
2912
  const commandArgs = Object.assign({}, targetBounds, { windowId: this.id, relative: false });
2810
- yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
2913
+ yield this._bridge.send("windows", operations$9.moveResize, commandArgs);
2811
2914
  return this.me;
2812
2915
  });
2813
2916
  }
@@ -2823,7 +2926,7 @@ class WebWindowModel {
2823
2926
  nonNegativeNumberDecoder.runWithException(height);
2824
2927
  }
2825
2928
  const commandArgs = Object.assign({}, { width, height }, { windowId: this.id, relative: true });
2826
- yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
2929
+ yield this._bridge.send("windows", operations$9.moveResize, commandArgs);
2827
2930
  return this.me;
2828
2931
  });
2829
2932
  }
@@ -2839,7 +2942,7 @@ class WebWindowModel {
2839
2942
  number$1().runWithException(left);
2840
2943
  }
2841
2944
  const commandArgs = Object.assign({}, { top, left }, { windowId: this.id, relative: true });
2842
- yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
2945
+ yield this._bridge.send("windows", operations$9.moveResize, commandArgs);
2843
2946
  return this.me;
2844
2947
  });
2845
2948
  }
@@ -2849,33 +2952,33 @@ class WebWindowModel {
2849
2952
  window.open(undefined, this.id);
2850
2953
  }
2851
2954
  else {
2852
- yield this._bridge.send("windows", operations$8.focus, { windowId: this.id });
2955
+ yield this._bridge.send("windows", operations$9.focus, { windowId: this.id });
2853
2956
  }
2854
2957
  return this.me;
2855
2958
  });
2856
2959
  }
2857
2960
  close() {
2858
2961
  return __awaiter$1(this, void 0, void 0, function* () {
2859
- yield this._bridge.send("windows", operations$8.close, { windowId: this.id });
2962
+ yield this._bridge.send("windows", operations$9.close, { windowId: this.id });
2860
2963
  return this.me;
2861
2964
  });
2862
2965
  }
2863
2966
  getTitle() {
2864
2967
  return __awaiter$1(this, void 0, void 0, function* () {
2865
- const result = yield this._bridge.send("windows", operations$8.getTitle, { windowId: this.id });
2968
+ const result = yield this._bridge.send("windows", operations$9.getTitle, { windowId: this.id });
2866
2969
  return result.title;
2867
2970
  });
2868
2971
  }
2869
2972
  setTitle(title) {
2870
2973
  return __awaiter$1(this, void 0, void 0, function* () {
2871
2974
  const ttl = nonEmptyStringDecoder.runWithException(title);
2872
- yield this._bridge.send("windows", operations$8.setTitle, { windowId: this.id, title: ttl });
2975
+ yield this._bridge.send("windows", operations$9.setTitle, { windowId: this.id, title: ttl });
2873
2976
  return this.me;
2874
2977
  });
2875
2978
  }
2876
2979
  getBounds() {
2877
2980
  return __awaiter$1(this, void 0, void 0, function* () {
2878
- const result = yield this._bridge.send("windows", operations$8.getBounds, { windowId: this.id });
2981
+ const result = yield this._bridge.send("windows", operations$9.getBounds, { windowId: this.id });
2879
2982
  return result.bounds;
2880
2983
  });
2881
2984
  }
@@ -2910,7 +3013,7 @@ class WebWindowModel {
2910
3013
  }
2911
3014
  getChannel() {
2912
3015
  return __awaiter$1(this, void 0, void 0, function* () {
2913
- const result = yield this._bridge.send("windows", operations$8.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
3016
+ const result = yield this._bridge.send("windows", operations$9.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
2914
3017
  return result.channel;
2915
3018
  });
2916
3019
  }
@@ -3008,7 +3111,7 @@ class WindowsController {
3008
3111
  return __awaiter$1(this, void 0, void 0, function* () {
3009
3112
  yield this.platformRegistration;
3010
3113
  const operationName = windowOperationTypesDecoder.runWithException(args.operation);
3011
- const operation = operations$8[operationName];
3114
+ const operation = operations$9[operationName];
3012
3115
  if (!operation.execute) {
3013
3116
  return;
3014
3117
  }
@@ -3024,7 +3127,7 @@ class WindowsController {
3024
3127
  nonEmptyStringDecoder.runWithException(name);
3025
3128
  nonEmptyStringDecoder.runWithException(url);
3026
3129
  const settings = windowOpenSettingsDecoder.runWithException(options);
3027
- const windowSuccess = yield this.bridge.send("windows", operations$8.openWindow, { name, url, options: settings });
3130
+ const windowSuccess = yield this.bridge.send("windows", operations$9.openWindow, { name, url, options: settings });
3028
3131
  return this.waitForWindowAdded(windowSuccess.windowId);
3029
3132
  });
3030
3133
  }
@@ -3049,16 +3152,16 @@ class WindowsController {
3049
3152
  };
3050
3153
  }
3051
3154
  addWindowOperationExecutors() {
3052
- operations$8.focusChange.execute = this.handleFocusChangeEvent.bind(this);
3053
- operations$8.windowAdded.execute = this.handleWindowAdded.bind(this);
3054
- operations$8.windowRemoved.execute = this.handleWindowRemoved.bind(this);
3055
- operations$8.getBounds.execute = this.handleGetBounds.bind(this);
3056
- operations$8.getFrameBounds.execute = this.handleGetBounds.bind(this);
3057
- operations$8.getTitle.execute = this.handleGetTitle.bind(this);
3058
- operations$8.getUrl.execute = this.handleGetUrl.bind(this);
3059
- operations$8.moveResize.execute = this.handleMoveResize.bind(this);
3060
- operations$8.setTitle.execute = this.handleSetTitle.bind(this);
3061
- operations$8.getChannel.execute = this.handleGetChannel.bind(this);
3155
+ operations$9.focusChange.execute = this.handleFocusChangeEvent.bind(this);
3156
+ operations$9.windowAdded.execute = this.handleWindowAdded.bind(this);
3157
+ operations$9.windowRemoved.execute = this.handleWindowRemoved.bind(this);
3158
+ operations$9.getBounds.execute = this.handleGetBounds.bind(this);
3159
+ operations$9.getFrameBounds.execute = this.handleGetBounds.bind(this);
3160
+ operations$9.getTitle.execute = this.handleGetTitle.bind(this);
3161
+ operations$9.getUrl.execute = this.handleGetUrl.bind(this);
3162
+ operations$9.moveResize.execute = this.handleMoveResize.bind(this);
3163
+ operations$9.setTitle.execute = this.handleSetTitle.bind(this);
3164
+ operations$9.getChannel.execute = this.handleGetChannel.bind(this);
3062
3165
  }
3063
3166
  my() {
3064
3167
  return Object.assign({}, this.me);
@@ -3089,7 +3192,7 @@ class WindowsController {
3089
3192
  }
3090
3193
  sayHello() {
3091
3194
  return __awaiter$1(this, void 0, void 0, function* () {
3092
- const helloSuccess = yield this.bridge.send("windows", operations$8.windowHello, { windowId: this.publicWindowId });
3195
+ const helloSuccess = yield this.bridge.send("windows", operations$9.windowHello, { windowId: this.publicWindowId });
3093
3196
  return helloSuccess;
3094
3197
  });
3095
3198
  }
@@ -3255,7 +3358,7 @@ class WindowsController {
3255
3358
  if (this.me) {
3256
3359
  this.me.isFocused = hasFocus;
3257
3360
  }
3258
- yield this.bridge.send("windows", operations$8.focusChange, eventData);
3361
+ yield this.bridge.send("windows", operations$9.focusChange, eventData);
3259
3362
  });
3260
3363
  }
3261
3364
  defineEventListeners() {
@@ -3455,7 +3558,7 @@ class GlueBridge {
3455
3558
  }
3456
3559
  }
3457
3560
 
3458
- const operations$7 = {
3561
+ const operations$8 = {
3459
3562
  appHello: { name: "appHello", dataDecoder: windowHelloDecoder, resultDecoder: appHelloSuccessDecoder },
3460
3563
  appDirectoryStateChange: { name: "appDirectoryStateChange", dataDecoder: appDirectoryStateChangeDecoder },
3461
3564
  instanceStarted: { name: "instanceStarted", dataDecoder: instanceDataDecoder },
@@ -3503,7 +3606,7 @@ class AppManagerController {
3503
3606
  return __awaiter$1(this, void 0, void 0, function* () {
3504
3607
  yield this.platformRegistration;
3505
3608
  const operationName = appManagerOperationTypesDecoder.runWithException(args.operation);
3506
- const operation = operations$7[operationName];
3609
+ const operation = operations$8[operationName];
3507
3610
  if (!operation.execute) {
3508
3611
  return;
3509
3612
  }
@@ -3548,7 +3651,7 @@ class AppManagerController {
3548
3651
  layoutComponentId: options === null || options === void 0 ? void 0 : options.layoutComponentId,
3549
3652
  channelId: options === null || options === void 0 ? void 0 : options.channelId
3550
3653
  };
3551
- const openResult = yield this.bridge.send("appManager", operations$7.applicationStart, startOptions);
3654
+ const openResult = yield this.bridge.send("appManager", operations$8.applicationStart, startOptions);
3552
3655
  const app = this.applications.find((a) => a.name === openResult.applicationName);
3553
3656
  return this.ioc.buildInstance(openResult, app);
3554
3657
  });
@@ -3581,9 +3684,9 @@ class AppManagerController {
3581
3684
  return api;
3582
3685
  }
3583
3686
  addOperationsExecutors() {
3584
- operations$7.appDirectoryStateChange.execute = this.handleAppDirectoryStateChange.bind(this);
3585
- operations$7.instanceStarted.execute = this.handleInstanceStartedMessage.bind(this);
3586
- operations$7.instanceStopped.execute = this.handleInstanceStoppedMessage.bind(this);
3687
+ operations$8.appDirectoryStateChange.execute = this.handleAppDirectoryStateChange.bind(this);
3688
+ operations$8.instanceStarted.execute = this.handleInstanceStartedMessage.bind(this);
3689
+ operations$8.instanceStopped.execute = this.handleInstanceStoppedMessage.bind(this);
3587
3690
  }
3588
3691
  handleAppDirectoryStateChange(data) {
3589
3692
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -3700,7 +3803,7 @@ class AppManagerController {
3700
3803
  return soFar;
3701
3804
  }, { valid: [], invalid: [] });
3702
3805
  const responseTimeout = this.baseApplicationsTimeoutMS + this.appImportTimeoutMS * parseResult.valid.length;
3703
- yield this.bridge.send("appManager", operations$7.import, { definitions: parseResult.valid, mode }, { methodResponseTimeoutMs: responseTimeout });
3806
+ yield this.bridge.send("appManager", operations$8.import, { definitions: parseResult.valid, mode }, { methodResponseTimeoutMs: responseTimeout });
3704
3807
  return {
3705
3808
  imported: parseResult.valid.map((valid) => valid.name),
3706
3809
  errors: parseResult.invalid
@@ -3710,17 +3813,17 @@ class AppManagerController {
3710
3813
  remove(name) {
3711
3814
  return __awaiter$1(this, void 0, void 0, function* () {
3712
3815
  nonEmptyStringDecoder.runWithException(name);
3713
- yield this.bridge.send("appManager", operations$7.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3816
+ yield this.bridge.send("appManager", operations$8.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3714
3817
  });
3715
3818
  }
3716
3819
  clear() {
3717
3820
  return __awaiter$1(this, void 0, void 0, function* () {
3718
- yield this.bridge.send("appManager", operations$7.clear, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3821
+ yield this.bridge.send("appManager", operations$8.clear, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3719
3822
  });
3720
3823
  }
3721
3824
  export() {
3722
3825
  return __awaiter$1(this, void 0, void 0, function* () {
3723
- const response = yield this.bridge.send("appManager", operations$7.export, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3826
+ const response = yield this.bridge.send("appManager", operations$8.export, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3724
3827
  return response.definitions;
3725
3828
  });
3726
3829
  }
@@ -3739,7 +3842,7 @@ class AppManagerController {
3739
3842
  }
3740
3843
  registerWithPlatform() {
3741
3844
  return __awaiter$1(this, void 0, void 0, function* () {
3742
- const result = yield this.bridge.send("appManager", operations$7.appHello, { windowId: this.publicWindowId }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3845
+ const result = yield this.bridge.send("appManager", operations$8.appHello, { windowId: this.publicWindowId }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3743
3846
  this.logger.trace("the platform responded to the hello message with a full list of apps");
3744
3847
  this.applications = yield Promise.all(result.apps.map((app) => this.ioc.buildApplication(app, app.instances)));
3745
3848
  this.instances = this.applications.reduce((instancesSoFar, app) => {
@@ -3792,7 +3895,7 @@ class InstanceModel {
3792
3895
  }
3793
3896
  stop() {
3794
3897
  return __awaiter$1(this, void 0, void 0, function* () {
3795
- yield this.bridge.send("appManager", operations$7.instanceStop, { id: this.data.id });
3898
+ yield this.bridge.send("appManager", operations$8.instanceStop, { id: this.data.id });
3796
3899
  });
3797
3900
  }
3798
3901
  }
@@ -3848,7 +3951,7 @@ class ApplicationModel {
3848
3951
  }
3849
3952
  }
3850
3953
 
3851
- const operations$6 = {
3954
+ const operations$7 = {
3852
3955
  layoutAdded: { name: "layoutAdded", dataDecoder: glueLayoutDecoder },
3853
3956
  layoutChanged: { name: "layoutChanged", dataDecoder: glueLayoutDecoder },
3854
3957
  layoutRemoved: { name: "layoutRemoved", dataDecoder: glueLayoutDecoder },
@@ -3891,7 +3994,7 @@ class LayoutsController {
3891
3994
  handleBridgeMessage(args) {
3892
3995
  return __awaiter$1(this, void 0, void 0, function* () {
3893
3996
  const operationName = layoutsOperationTypesDecoder.runWithException(args.operation);
3894
- const operation = operations$6[operationName];
3997
+ const operation = operations$7[operationName];
3895
3998
  if (!operation.execute) {
3896
3999
  return;
3897
4000
  }
@@ -3925,30 +4028,30 @@ class LayoutsController {
3925
4028
  return Object.freeze(api);
3926
4029
  }
3927
4030
  addOperationsExecutors() {
3928
- operations$6.layoutAdded.execute = this.handleOnAdded.bind(this);
3929
- operations$6.layoutChanged.execute = this.handleOnChanged.bind(this);
3930
- operations$6.layoutRemoved.execute = this.handleOnRemoved.bind(this);
3931
- operations$6.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
4031
+ operations$7.layoutAdded.execute = this.handleOnAdded.bind(this);
4032
+ operations$7.layoutChanged.execute = this.handleOnChanged.bind(this);
4033
+ operations$7.layoutRemoved.execute = this.handleOnRemoved.bind(this);
4034
+ operations$7.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
3932
4035
  }
3933
4036
  get(name, type) {
3934
4037
  return __awaiter$1(this, void 0, void 0, function* () {
3935
4038
  nonEmptyStringDecoder.runWithException(name);
3936
4039
  layoutTypeDecoder.runWithException(type);
3937
- const result = yield this.bridge.send("layouts", operations$6.get, { name, type });
4040
+ const result = yield this.bridge.send("layouts", operations$7.get, { name, type });
3938
4041
  return result.layout;
3939
4042
  });
3940
4043
  }
3941
4044
  getAll(type) {
3942
4045
  return __awaiter$1(this, void 0, void 0, function* () {
3943
4046
  layoutTypeDecoder.runWithException(type);
3944
- const result = yield this.bridge.send("layouts", operations$6.getAll, { type });
4047
+ const result = yield this.bridge.send("layouts", operations$7.getAll, { type });
3945
4048
  return result.summaries;
3946
4049
  });
3947
4050
  }
3948
4051
  export(type) {
3949
4052
  return __awaiter$1(this, void 0, void 0, function* () {
3950
4053
  layoutTypeDecoder.runWithException(type);
3951
- const result = yield this.bridge.send("layouts", operations$6.export, { type });
4054
+ const result = yield this.bridge.send("layouts", operations$7.export, { type });
3952
4055
  return result.layouts;
3953
4056
  });
3954
4057
  }
@@ -3972,13 +4075,13 @@ class LayoutsController {
3972
4075
  return soFar;
3973
4076
  }, { valid: [] });
3974
4077
  const layoutsToImport = layouts.filter((layout) => parseResult.valid.some((validLayout) => validLayout.name === layout.name));
3975
- yield this.bridge.send("layouts", operations$6.import, { layouts: layoutsToImport, mode });
4078
+ yield this.bridge.send("layouts", operations$7.import, { layouts: layoutsToImport, mode });
3976
4079
  });
3977
4080
  }
3978
4081
  save(layout) {
3979
4082
  return __awaiter$1(this, void 0, void 0, function* () {
3980
4083
  newLayoutOptionsDecoder.runWithException(layout);
3981
- const saveResult = yield this.bridge.send("layouts", operations$6.save, { layout });
4084
+ const saveResult = yield this.bridge.send("layouts", operations$7.save, { layout });
3982
4085
  return saveResult.layout;
3983
4086
  });
3984
4087
  }
@@ -3986,14 +4089,14 @@ class LayoutsController {
3986
4089
  return __awaiter$1(this, void 0, void 0, function* () {
3987
4090
  restoreOptionsDecoder.runWithException(options);
3988
4091
  const invocationTimeout = options.timeout ? options.timeout * 2 : this.defaultLayoutRestoreTimeoutMS;
3989
- yield this.bridge.send("layouts", operations$6.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
4092
+ yield this.bridge.send("layouts", operations$7.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
3990
4093
  });
3991
4094
  }
3992
4095
  remove(type, name) {
3993
4096
  return __awaiter$1(this, void 0, void 0, function* () {
3994
4097
  layoutTypeDecoder.runWithException(type);
3995
4098
  nonEmptyStringDecoder.runWithException(name);
3996
- yield this.bridge.send("layouts", operations$6.remove, { type, name });
4099
+ yield this.bridge.send("layouts", operations$7.remove, { type, name });
3997
4100
  });
3998
4101
  }
3999
4102
  handleSaveRequest(config) {
@@ -4013,7 +4116,7 @@ class LayoutsController {
4013
4116
  }
4014
4117
  getGlobalPermissionState() {
4015
4118
  return __awaiter$1(this, void 0, void 0, function* () {
4016
- const requestResult = yield this.bridge.send("layouts", operations$6.getGlobalPermissionState, undefined);
4119
+ const requestResult = yield this.bridge.send("layouts", operations$7.getGlobalPermissionState, undefined);
4017
4120
  return requestResult;
4018
4121
  });
4019
4122
  }
@@ -4032,43 +4135,43 @@ class LayoutsController {
4032
4135
  if (myWindow.name !== "Platform" && !amIWorkspaceFrame) {
4033
4136
  throw new Error("Cannot request permission for multi-window placement from any app other than the Platform.");
4034
4137
  }
4035
- const requestResult = yield this.bridge.send("layouts", operations$6.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
4138
+ const requestResult = yield this.bridge.send("layouts", operations$7.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
4036
4139
  return { permissionGranted: requestResult.isAvailable };
4037
4140
  });
4038
4141
  }
4039
4142
  checkGlobalActivated() {
4040
4143
  return __awaiter$1(this, void 0, void 0, function* () {
4041
- const requestResult = yield this.bridge.send("layouts", operations$6.checkGlobalActivated, undefined);
4144
+ const requestResult = yield this.bridge.send("layouts", operations$7.checkGlobalActivated, undefined);
4042
4145
  return { activated: requestResult.isAvailable };
4043
4146
  });
4044
4147
  }
4045
4148
  getDefaultGlobal() {
4046
4149
  return __awaiter$1(this, void 0, void 0, function* () {
4047
- const requestResult = yield this.bridge.send("layouts", operations$6.getDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4150
+ const requestResult = yield this.bridge.send("layouts", operations$7.getDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4048
4151
  return requestResult.layout;
4049
4152
  });
4050
4153
  }
4051
4154
  setDefaultGlobal(name) {
4052
4155
  return __awaiter$1(this, void 0, void 0, function* () {
4053
4156
  nonEmptyStringDecoder.runWithException(name);
4054
- yield this.bridge.send("layouts", operations$6.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
4157
+ yield this.bridge.send("layouts", operations$7.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
4055
4158
  });
4056
4159
  }
4057
4160
  clearDefaultGlobal() {
4058
4161
  return __awaiter$1(this, void 0, void 0, function* () {
4059
- yield this.bridge.send("layouts", operations$6.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4162
+ yield this.bridge.send("layouts", operations$7.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4060
4163
  });
4061
4164
  }
4062
4165
  onAdded(callback) {
4063
4166
  this.export("Global").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
4064
4167
  this.export("Workspace").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
4065
- return this.registry.add(operations$6.layoutAdded.name, callback);
4168
+ return this.registry.add(operations$7.layoutAdded.name, callback);
4066
4169
  }
4067
4170
  onChanged(callback) {
4068
- return this.registry.add(operations$6.layoutChanged.name, callback);
4171
+ return this.registry.add(operations$7.layoutChanged.name, callback);
4069
4172
  }
4070
4173
  onRemoved(callback) {
4071
- return this.registry.add(operations$6.layoutRemoved.name, callback);
4174
+ return this.registry.add(operations$7.layoutRemoved.name, callback);
4072
4175
  }
4073
4176
  subscribeOnSaveRequested(callback) {
4074
4177
  if (typeof callback !== "function") {
@@ -4084,22 +4187,22 @@ class LayoutsController {
4084
4187
  }
4085
4188
  handleOnAdded(layout) {
4086
4189
  return __awaiter$1(this, void 0, void 0, function* () {
4087
- this.registry.execute(operations$6.layoutAdded.name, layout);
4190
+ this.registry.execute(operations$7.layoutAdded.name, layout);
4088
4191
  });
4089
4192
  }
4090
4193
  handleOnChanged(layout) {
4091
4194
  return __awaiter$1(this, void 0, void 0, function* () {
4092
- this.registry.execute(operations$6.layoutChanged.name, layout);
4195
+ this.registry.execute(operations$7.layoutChanged.name, layout);
4093
4196
  });
4094
4197
  }
4095
4198
  handleOnRemoved(layout) {
4096
4199
  return __awaiter$1(this, void 0, void 0, function* () {
4097
- this.registry.execute(operations$6.layoutRemoved.name, layout);
4200
+ this.registry.execute(operations$7.layoutRemoved.name, layout);
4098
4201
  });
4099
4202
  }
4100
4203
  }
4101
4204
 
4102
- const operations$5 = {
4205
+ const operations$6 = {
4103
4206
  raiseNotification: { name: "raiseNotification", dataDecoder: raiseNotificationDecoder, resultDecoder: raiseNotificationResultDecoder },
4104
4207
  requestPermission: { name: "requestPermission", resultDecoder: permissionRequestResultDecoder },
4105
4208
  notificationShow: { name: "notificationShow", dataDecoder: notificationEventPayloadDecoder },
@@ -4110,7 +4213,14 @@ const operations$5 = {
4110
4213
  notificationClosed: { name: "notificationClosed", dataDecoder: simpleNotificationSelectDecoder },
4111
4214
  click: { name: "click" },
4112
4215
  clear: { name: "clear" },
4113
- clearAll: { name: "clearAll" }
4216
+ clearAll: { name: "clearAll" },
4217
+ clearOld: { name: "clearOld" },
4218
+ configure: { name: "configure", dataDecoder: notificationsConfigurationProtocolDecoder },
4219
+ getConfiguration: { name: "getConfiguration", resultDecoder: strictNotificationsConfigurationProtocolDecoder },
4220
+ configurationChanged: { name: "configurationChanged", resultDecoder: strictNotificationsConfigurationProtocolDecoder },
4221
+ setState: { name: "setState", dataDecoder: notificationSetStateRequestDecoder },
4222
+ activeCountChange: { name: "activeCountChange", resultDecoder: activeNotificationsCountChangeDecoder },
4223
+ stateChange: { name: "stateChange", resultDecoder: notificationSetStateRequestDecoder }
4114
4224
  };
4115
4225
 
4116
4226
  var shortidExports$1 = {};
@@ -4487,7 +4597,7 @@ class NotificationsController {
4487
4597
  handleBridgeMessage(args) {
4488
4598
  return __awaiter$1(this, void 0, void 0, function* () {
4489
4599
  const operationName = notificationsOperationTypesDecoder.runWithException(args.operation);
4490
- const operation = operations$5[operationName];
4600
+ const operation = operations$6[operationName];
4491
4601
  if (!operation.execute) {
4492
4602
  return;
4493
4603
  }
@@ -4508,19 +4618,28 @@ class NotificationsController {
4508
4618
  onClosed: this.onClosed.bind(this),
4509
4619
  click: this.click.bind(this),
4510
4620
  clear: this.clear.bind(this),
4511
- clearAll: this.clearAll.bind(this)
4621
+ clearAll: this.clearAll.bind(this),
4622
+ clearOld: this.clearOld.bind(this),
4623
+ configure: this.configure.bind(this),
4624
+ getConfiguration: this.getConfiguration.bind(this),
4625
+ getFilter: this.getFilter.bind(this),
4626
+ setFilter: this.setFilter.bind(this),
4627
+ setState: this.setState.bind(this),
4628
+ onConfigurationChanged: this.onConfigurationChanged.bind(this),
4629
+ onActiveCountChanged: this.onActiveCountChanged.bind(this),
4630
+ onStateChanged: this.onStateChanged.bind(this)
4512
4631
  };
4513
4632
  return Object.freeze(api);
4514
4633
  }
4515
4634
  getPermission() {
4516
4635
  return __awaiter$1(this, void 0, void 0, function* () {
4517
- const queryResult = yield this.bridge.send("notifications", operations$5.getPermission, undefined);
4636
+ const queryResult = yield this.bridge.send("notifications", operations$6.getPermission, undefined);
4518
4637
  return queryResult.permission;
4519
4638
  });
4520
4639
  }
4521
4640
  requestPermission() {
4522
4641
  return __awaiter$1(this, void 0, void 0, function* () {
4523
- const permissionResult = yield this.bridge.send("notifications", operations$5.requestPermission, undefined);
4642
+ const permissionResult = yield this.bridge.send("notifications", operations$6.requestPermission, undefined);
4524
4643
  return permissionResult.permissionGranted;
4525
4644
  });
4526
4645
  }
@@ -4534,7 +4653,7 @@ class NotificationsController {
4534
4653
  throw new Error("Cannot raise the notification, because the user has declined the permission request");
4535
4654
  }
4536
4655
  const id = shortidExports$1.generate();
4537
- const raiseResult = yield this.bridge.send("notifications", operations$5.raiseNotification, { settings, id });
4656
+ const raiseResult = yield this.bridge.send("notifications", operations$6.raiseNotification, { settings, id });
4538
4657
  const notification = this.buildNotificationFunc(raiseResult.settings, id);
4539
4658
  this.notifications[id] = notification;
4540
4659
  return notification;
@@ -4542,7 +4661,7 @@ class NotificationsController {
4542
4661
  }
4543
4662
  list() {
4544
4663
  return __awaiter$1(this, void 0, void 0, function* () {
4545
- const bridgeResponse = yield this.bridge.send("notifications", operations$5.list, undefined, undefined, { includeOperationCheck: true });
4664
+ const bridgeResponse = yield this.bridge.send("notifications", operations$6.list, undefined, undefined, { includeOperationCheck: true });
4546
4665
  return bridgeResponse.notifications;
4547
4666
  });
4548
4667
  }
@@ -4564,25 +4683,98 @@ class NotificationsController {
4564
4683
  if (action) {
4565
4684
  nonEmptyStringDecoder.runWithException(action);
4566
4685
  }
4567
- yield this.bridge.send("notifications", operations$5.click, { id, action }, undefined, { includeOperationCheck: true });
4686
+ yield this.bridge.send("notifications", operations$6.click, { id, action }, undefined, { includeOperationCheck: true });
4568
4687
  });
4569
4688
  }
4570
4689
  clear(id) {
4571
4690
  return __awaiter$1(this, void 0, void 0, function* () {
4572
4691
  nonEmptyStringDecoder.runWithException(id);
4573
- yield this.bridge.send("notifications", operations$5.clear, { id }, undefined, { includeOperationCheck: true });
4692
+ yield this.bridge.send("notifications", operations$6.clear, { id }, undefined, { includeOperationCheck: true });
4574
4693
  });
4575
4694
  }
4576
4695
  clearAll() {
4577
4696
  return __awaiter$1(this, void 0, void 0, function* () {
4578
- yield this.bridge.send("notifications", operations$5.clearAll, undefined, undefined, { includeOperationCheck: true });
4697
+ yield this.bridge.send("notifications", operations$6.clearAll, undefined, undefined, { includeOperationCheck: true });
4698
+ });
4699
+ }
4700
+ clearOld() {
4701
+ return __awaiter$1(this, void 0, void 0, function* () {
4702
+ yield this.bridge.send("notifications", operations$6.clearOld, undefined, undefined, { includeOperationCheck: true });
4703
+ });
4704
+ }
4705
+ configure(config) {
4706
+ return __awaiter$1(this, void 0, void 0, function* () {
4707
+ const verifiedConfig = notificationsConfigurationDecoder.runWithException(config);
4708
+ yield this.bridge.send("notifications", operations$6.configure, { configuration: verifiedConfig }, undefined, { includeOperationCheck: true });
4709
+ });
4710
+ }
4711
+ getConfiguration() {
4712
+ return __awaiter$1(this, void 0, void 0, function* () {
4713
+ const response = yield this.bridge.send("notifications", operations$6.getConfiguration, undefined, undefined, { includeOperationCheck: true });
4714
+ return response.configuration;
4715
+ });
4716
+ }
4717
+ getFilter() {
4718
+ return __awaiter$1(this, void 0, void 0, function* () {
4719
+ const response = yield this.bridge.send("notifications", operations$6.getConfiguration, undefined, undefined, { includeOperationCheck: true });
4720
+ return response.configuration.sourceFilter;
4721
+ });
4722
+ }
4723
+ setFilter(filter) {
4724
+ return __awaiter$1(this, void 0, void 0, function* () {
4725
+ const verifiedFilter = notificationFilterDecoder.runWithException(filter);
4726
+ yield this.bridge.send("notifications", operations$6.configure, { configuration: { sourceFilter: verifiedFilter } }, undefined, { includeOperationCheck: true });
4727
+ return verifiedFilter;
4579
4728
  });
4580
4729
  }
4730
+ setState(id, state) {
4731
+ return __awaiter$1(this, void 0, void 0, function* () {
4732
+ nonEmptyStringDecoder.runWithException(id);
4733
+ notificationStateDecoder.runWithException(state);
4734
+ yield this.bridge.send("notifications", operations$6.setState, { id, state }, undefined, { includeOperationCheck: true });
4735
+ });
4736
+ }
4737
+ onConfigurationChanged(callback) {
4738
+ if (typeof callback !== "function") {
4739
+ throw new Error("Cannot subscribe to configuration changed, because the provided callback is not a function!");
4740
+ }
4741
+ return this.registry.add("notifications-config-changed", callback);
4742
+ }
4743
+ onActiveCountChanged(callback) {
4744
+ if (typeof callback !== "function") {
4745
+ throw new Error("Cannot subscribe to onActiveCountChanged changed, because the provided callback is not a function!");
4746
+ }
4747
+ return this.registry.add("notifications-active-count-changed", callback);
4748
+ }
4749
+ onStateChanged(callback) {
4750
+ if (typeof callback !== "function") {
4751
+ throw new Error("Cannot subscribe to onStateChanged changed, because the provided callback is not a function!");
4752
+ }
4753
+ return this.registry.add("notification-state-changed", callback);
4754
+ }
4581
4755
  addOperationExecutors() {
4582
- operations$5.notificationShow.execute = this.handleNotificationShow.bind(this);
4583
- operations$5.notificationClick.execute = this.handleNotificationClick.bind(this);
4584
- operations$5.notificationRaised.execute = this.handleNotificationRaised.bind(this);
4585
- operations$5.notificationClosed.execute = this.handleNotificationClosed.bind(this);
4756
+ operations$6.notificationShow.execute = this.handleNotificationShow.bind(this);
4757
+ operations$6.notificationClick.execute = this.handleNotificationClick.bind(this);
4758
+ operations$6.notificationRaised.execute = this.handleNotificationRaised.bind(this);
4759
+ operations$6.notificationClosed.execute = this.handleNotificationClosed.bind(this);
4760
+ operations$6.configurationChanged.execute = this.handleConfigurationChanged.bind(this);
4761
+ operations$6.activeCountChange.execute = this.handleActiveCountChanged.bind(this);
4762
+ operations$6.stateChange.execute = this.handleNotificationStateChanged.bind(this);
4763
+ }
4764
+ handleConfigurationChanged(data) {
4765
+ return __awaiter$1(this, void 0, void 0, function* () {
4766
+ this.registry.execute("notifications-config-changed", data.configuration);
4767
+ });
4768
+ }
4769
+ handleActiveCountChanged(data) {
4770
+ return __awaiter$1(this, void 0, void 0, function* () {
4771
+ this.registry.execute("notifications-active-count-changed", data);
4772
+ });
4773
+ }
4774
+ handleNotificationStateChanged(data) {
4775
+ return __awaiter$1(this, void 0, void 0, function* () {
4776
+ this.registry.execute("notification-state-changed", { id: data.id }, data.state);
4777
+ });
4586
4778
  }
4587
4779
  handleNotificationShow(data) {
4588
4780
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -4627,21 +4819,24 @@ class NotificationsController {
4627
4819
  }
4628
4820
  }
4629
4821
 
4630
- const operations$4 = {
4822
+ const operations$5 = {
4631
4823
  getIntents: { name: "getIntents", resultDecoder: wrappedIntentsDecoder },
4632
4824
  findIntent: { name: "findIntent", dataDecoder: wrappedIntentFilterDecoder, resultDecoder: wrappedIntentsDecoder },
4633
4825
  raiseIntent: { name: "raiseIntent", dataDecoder: intentRequestDecoder, resultDecoder: intentResultDecoder },
4634
4826
  raise: { name: "raise", dataDecoder: raiseIntentRequestDecoder, resultDecoder: intentResultDecoder },
4827
+ filterHandlers: { name: "filterHandlers", dataDecoder: filterHandlersWithResolverConfigDecoder, resultDecoder: filterHandlersResultDecoder },
4828
+ getIntentsByHandler: { name: "getIntentsByHandler", dataDecoder: intentHandlerDecoder, resultDecoder: getIntentsResultDecoder }
4635
4829
  };
4636
4830
 
4637
4831
  const GLUE42_FDC3_INTENTS_METHOD_PREFIX = "Tick42.FDC3.Intents.";
4638
4832
  const INTENTS_RESOLVER_INTEROP_PREFIX = "T42.Intents.Resolver.Control.";
4639
4833
  const INTENTS_RESOLVER_APP_NAME = "intentsResolver";
4640
- const DEFAULT_RESOLVER_RESPONSE_TIMEOUT = 60000;
4641
- const ADDITIONAL_BRIDGE_OPERATION_TIMEOUT = 30000;
4834
+ const DEFAULT_RESOLVER_RESPONSE_TIMEOUT = 60 * 1000;
4835
+ const ADDITIONAL_BRIDGE_OPERATION_TIMEOUT = 30 * 1000;
4642
4836
  const INTENTS_RESOLVER_WIDTH = 400;
4643
4837
  const INTENTS_RESOLVER_HEIGHT = 440;
4644
- const MAX_SET_TIMEOUT_DELAY = 2147483647;
4838
+ const MAX_SET_TIMEOUT_DELAY = 2147483647;
4839
+ const DEFAULT_PICK_HANDLER_BY_TIMEOUT = 90 * 1000;
4645
4840
 
4646
4841
  class IntentsController {
4647
4842
  constructor() {
@@ -4669,7 +4864,7 @@ class IntentsController {
4669
4864
  handleBridgeMessage(args) {
4670
4865
  return __awaiter$1(this, void 0, void 0, function* () {
4671
4866
  const operationName = intentsOperationTypesDecoder.runWithException(args.operation);
4672
- const operation = operations$4[operationName];
4867
+ const operation = operations$5[operationName];
4673
4868
  if (!operation.execute) {
4674
4869
  return;
4675
4870
  }
@@ -4686,7 +4881,9 @@ class IntentsController {
4686
4881
  all: this.all.bind(this),
4687
4882
  addIntentListener: this.addIntentListener.bind(this),
4688
4883
  register: this.register.bind(this),
4689
- find: this.find.bind(this)
4884
+ find: this.find.bind(this),
4885
+ filterHandlers: this.filterHandlers.bind(this),
4886
+ getIntents: this.getIntentsByHandler.bind(this)
4690
4887
  };
4691
4888
  return api;
4692
4889
  }
@@ -4697,7 +4894,7 @@ class IntentsController {
4697
4894
  ? { intent: validatedIntentRequest }
4698
4895
  : validatedIntentRequest;
4699
4896
  yield Promise.all(this.unregisterIntentPromises);
4700
- const requestWithResolverInfo = this.buildIntentRequestWithResolverInfo(intentRequest);
4897
+ const requestWithResolverInfo = { intentRequest, resolverConfig: this.getResolverConfigByRequest({ intentRequest }) };
4701
4898
  const isRaiseOperationSupported = yield this.isRaiseOperationSupported();
4702
4899
  if (!isRaiseOperationSupported.supported) {
4703
4900
  this.logger.warn(`${isRaiseOperationSupported.reason}. Invoking legacy raise method`);
@@ -4707,18 +4904,24 @@ class IntentsController {
4707
4904
  const methodResponseTimeoutMs = intentRequest.waitUserResponseIndefinitely
4708
4905
  ? MAX_SET_TIMEOUT_DELAY
4709
4906
  : (intentRequest.timeout || this.intentResolverResponseTimeout) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
4710
- const response = yield this.bridge.send("intents", operations$4.raise, requestWithResolverInfo, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs });
4907
+ const response = yield this.bridge.send("intents", operations$5.raise, requestWithResolverInfo, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs });
4711
4908
  return response;
4712
4909
  });
4713
4910
  }
4714
- buildIntentRequestWithResolverInfo(request) {
4715
- return {
4716
- intentRequest: request,
4717
- resolverConfig: {
4718
- enabled: this.useIntentsResolverUI,
4911
+ getResolverConfigByRequest(filter) {
4912
+ var _a, _b, _c, _d;
4913
+ if (filter.handlerFilter) {
4914
+ return {
4915
+ enabled: typeof ((_a = filter.handlerFilter) === null || _a === void 0 ? void 0 : _a.openResolver) === "boolean" ? (_b = filter.handlerFilter) === null || _b === void 0 ? void 0 : _b.openResolver : this.useIntentsResolverUI,
4719
4916
  appName: this.intentsResolverAppName,
4720
- waitResponseTimeout: request.waitUserResponseIndefinitely ? MAX_SET_TIMEOUT_DELAY : this.intentResolverResponseTimeout
4721
- }
4917
+ waitResponseTimeout: ((_c = filter.handlerFilter) === null || _c === void 0 ? void 0 : _c.timeout) || DEFAULT_PICK_HANDLER_BY_TIMEOUT
4918
+ };
4919
+ }
4920
+ const waitResponseTimeout = ((_d = filter.intentRequest) === null || _d === void 0 ? void 0 : _d.waitUserResponseIndefinitely) ? MAX_SET_TIMEOUT_DELAY : this.intentResolverResponseTimeout;
4921
+ return {
4922
+ enabled: this.useIntentsResolverUI,
4923
+ appName: this.intentsResolverAppName,
4924
+ waitResponseTimeout
4722
4925
  };
4723
4926
  }
4724
4927
  isRaiseOperationSupported() {
@@ -4741,7 +4944,7 @@ class IntentsController {
4741
4944
  all() {
4742
4945
  return __awaiter$1(this, void 0, void 0, function* () {
4743
4946
  yield Promise.all(this.unregisterIntentPromises);
4744
- const result = yield this.bridge.send("intents", operations$4.getIntents, undefined);
4947
+ const result = yield this.bridge.send("intents", operations$5.getIntents, undefined);
4745
4948
  return result.intents;
4746
4949
  });
4747
4950
  }
@@ -4839,7 +5042,7 @@ class IntentsController {
4839
5042
  }
4840
5043
  }
4841
5044
  yield Promise.all(this.unregisterIntentPromises);
4842
- const result = yield this.bridge.send("intents", operations$4.findIntent, data);
5045
+ const result = yield this.bridge.send("intents", operations$5.findIntent, data);
4843
5046
  return result.intents;
4844
5047
  });
4845
5048
  }
@@ -4871,6 +5074,38 @@ class IntentsController {
4871
5074
  this.clearUnregistrationPromise(unregisterPromise);
4872
5075
  });
4873
5076
  }
5077
+ filterHandlers(handlerFilter) {
5078
+ return __awaiter$1(this, void 0, void 0, function* () {
5079
+ handlersFilterDecoder.runWithException(handlerFilter);
5080
+ this.checkIfAtLeastOneFilterIsPresent(handlerFilter);
5081
+ if (handlerFilter.openResolver && !this.useIntentsResolverUI) {
5082
+ throw new Error("Cannot resolve 'filterHandlers' request using Intents Resolver UI because it's globally disabled");
5083
+ }
5084
+ const methodResponseTimeoutMs = (handlerFilter.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
5085
+ const filterHandlersRequestWithResolverConfig = { filterHandlersRequest: handlerFilter, resolverConfig: this.getResolverConfigByRequest({ handlerFilter }) };
5086
+ const result = yield this.bridge.send("intents", operations$5.filterHandlers, filterHandlersRequestWithResolverConfig, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs }, { includeOperationCheck: true });
5087
+ return result;
5088
+ });
5089
+ }
5090
+ checkIfAtLeastOneFilterIsPresent(filter) {
5091
+ const errorMsg = "Provide at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'";
5092
+ if (!Object.keys(filter).length) {
5093
+ throw new Error(errorMsg);
5094
+ }
5095
+ const { intent, resultType, contextTypes, applicationNames } = filter;
5096
+ const existingValidContextTypes = contextTypes === null || contextTypes === void 0 ? void 0 : contextTypes.length;
5097
+ const existingValidApplicationNames = applicationNames === null || applicationNames === void 0 ? void 0 : applicationNames.length;
5098
+ if (!intent && !resultType && !existingValidContextTypes && !existingValidApplicationNames) {
5099
+ throw new Error(errorMsg);
5100
+ }
5101
+ }
5102
+ getIntentsByHandler(handler) {
5103
+ return __awaiter$1(this, void 0, void 0, function* () {
5104
+ intentHandlerDecoder.runWithException(handler);
5105
+ const result = yield this.bridge.send("intents", operations$5.getIntentsByHandler, handler, undefined, { includeOperationCheck: true });
5106
+ return result;
5107
+ });
5108
+ }
4874
5109
  }
4875
5110
 
4876
5111
  const Glue42CoreMessageTypes = {
@@ -4887,7 +5122,7 @@ const Glue42CoreMessageTypes = {
4887
5122
  const webPlatformTransportName = "web-platform";
4888
5123
  const latestFDC3Type = "latest_fdc3_type";
4889
5124
 
4890
- const operations$3 = {
5125
+ const operations$4 = {
4891
5126
  addChannel: { name: "addChannel", dataDecoder: channelContextDecoder },
4892
5127
  getMyChannel: { name: "getMyChannel", resultDecoder: getMyChanelResultDecoder },
4893
5128
  getWindowIdsOnChannel: { name: "getWindowIdsOnChannel", dataDecoder: getWindowIdsOnChannelDataDecoder, resultDecoder: getWindowIdsOnChannelResultDecoder },
@@ -4924,8 +5159,8 @@ class ChannelsController {
4924
5159
  this.registry.clear();
4925
5160
  }
4926
5161
  addOperationsExecutors() {
4927
- operations$3.getMyChannel.execute = this.handleGetMyChannel.bind(this);
4928
- operations$3.joinChannel.execute = this.handleJoinChannel.bind(this);
5162
+ operations$4.getMyChannel.execute = this.handleGetMyChannel.bind(this);
5163
+ operations$4.joinChannel.execute = this.handleJoinChannel.bind(this);
4929
5164
  }
4930
5165
  start(coreGlue, ioc) {
4931
5166
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -4944,7 +5179,7 @@ class ChannelsController {
4944
5179
  handleBridgeMessage(args) {
4945
5180
  return __awaiter$1(this, void 0, void 0, function* () {
4946
5181
  const operationName = channelsOperationTypesDecoder.runWithException(args.operation);
4947
- const operation = operations$3[operationName];
5182
+ const operation = operations$4[operationName];
4948
5183
  if (!operation.execute) {
4949
5184
  return;
4950
5185
  }
@@ -4980,7 +5215,7 @@ class ChannelsController {
4980
5215
  yield this.switchToChannel(name);
4981
5216
  }
4982
5217
  else {
4983
- yield this.bridge.send("channels", operations$3.joinChannel, { channel: name, windowId }, undefined, { includeOperationCheck: true });
5218
+ yield this.bridge.send("channels", operations$4.joinChannel, { channel: name, windowId }, undefined, { includeOperationCheck: true });
4984
5219
  }
4985
5220
  });
4986
5221
  }
@@ -5151,7 +5386,7 @@ class ChannelsController {
5151
5386
  if (channelWithSuchNameExists) {
5152
5387
  throw new Error("There's an already existing channel with such name");
5153
5388
  }
5154
- yield this.bridge.send("channels", operations$3.addChannel, channelContext);
5389
+ yield this.bridge.send("channels", operations$4.addChannel, channelContext);
5155
5390
  return channelContext;
5156
5391
  });
5157
5392
  }
@@ -5167,7 +5402,7 @@ class ChannelsController {
5167
5402
  return __awaiter$1(this, void 0, void 0, function* () {
5168
5403
  const channelNames = this.getAllChannelNames();
5169
5404
  channelNameDecoder(channelNames).runWithException(channel);
5170
- const { windowIds } = yield this.bridge.send("channels", operations$3.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
5405
+ const { windowIds } = yield this.bridge.send("channels", operations$4.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
5171
5406
  const result = windowIds.reduce((windows, windowId) => {
5172
5407
  const window = this.windowsController.findById(windowId);
5173
5408
  return window ? [...windows, window] : windows;
@@ -5180,7 +5415,7 @@ class ChannelsController {
5180
5415
  const operationData = filter !== undefined
5181
5416
  ? { filter: windowWithChannelFilterDecoder.runWithException(filter) }
5182
5417
  : {};
5183
- const { windowIdsWithChannels } = yield this.bridge.send("channels", operations$3.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
5418
+ const { windowIdsWithChannels } = yield this.bridge.send("channels", operations$4.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
5184
5419
  const result = windowIdsWithChannels.reduce((windowsWithChannels, { application, channel, windowId }) => {
5185
5420
  const window = this.windowsController.findById(windowId);
5186
5421
  return window ? [...windowsWithChannels, { application, channel, window }] : windowsWithChannels;
@@ -5190,7 +5425,7 @@ class ChannelsController {
5190
5425
  }
5191
5426
  }
5192
5427
 
5193
- const operations$2 = {
5428
+ const operations$3 = {
5194
5429
  getEnvironment: { name: "getEnvironment", resultDecoder: anyDecoder },
5195
5430
  getBase: { name: "getBase", resultDecoder: anyDecoder },
5196
5431
  platformShutdown: { name: "platformShutdown" }
@@ -5208,7 +5443,7 @@ class SystemController {
5208
5443
  handleBridgeMessage(args) {
5209
5444
  return __awaiter$1(this, void 0, void 0, function* () {
5210
5445
  const operationName = systemOperationTypesDecoder.runWithException(args.operation);
5211
- const operation = operations$2[operationName];
5446
+ const operation = operations$3[operationName];
5212
5447
  if (!operation.execute) {
5213
5448
  return;
5214
5449
  }
@@ -5229,8 +5464,8 @@ class SystemController {
5229
5464
  }
5230
5465
  setEnvironment() {
5231
5466
  return __awaiter$1(this, void 0, void 0, function* () {
5232
- const environment = yield this.bridge.send("system", operations$2.getEnvironment, undefined);
5233
- const base = yield this.bridge.send("system", operations$2.getBase, undefined);
5467
+ const environment = yield this.bridge.send("system", operations$3.getEnvironment, undefined);
5468
+ const base = yield this.bridge.send("system", operations$3.getBase, undefined);
5234
5469
  const globalNamespace = window.glue42core || window.iobrowser;
5235
5470
  const globalNamespaceName = window.glue42core ? "glue42core" : "iobrowser";
5236
5471
  const globalObj = Object.assign({}, globalNamespace, base, { environment });
@@ -5238,7 +5473,7 @@ class SystemController {
5238
5473
  });
5239
5474
  }
5240
5475
  addOperationsExecutors() {
5241
- operations$2.platformShutdown.execute = this.processPlatformShutdown.bind(this);
5476
+ operations$3.platformShutdown.execute = this.processPlatformShutdown.bind(this);
5242
5477
  }
5243
5478
  }
5244
5479
 
@@ -5267,6 +5502,7 @@ class Notification {
5267
5502
  this.severity = config.severity;
5268
5503
  this.showToast = config.showToast;
5269
5504
  this.showInPanel = config.showInPanel;
5505
+ this.state = config.state;
5270
5506
  }
5271
5507
  }
5272
5508
 
@@ -5277,7 +5513,7 @@ const extensionConfigDecoder = object$1({
5277
5513
  })
5278
5514
  });
5279
5515
 
5280
- const operations$1 = {
5516
+ const operations$2 = {
5281
5517
  clientHello: { name: "clientHello", resultDecoder: extensionConfigDecoder }
5282
5518
  };
5283
5519
 
@@ -5335,7 +5571,7 @@ class ExtController {
5335
5571
  registerWithPlatform() {
5336
5572
  return __awaiter$1(this, void 0, void 0, function* () {
5337
5573
  this.logger.trace("registering with the platform");
5338
- this.config = yield this.bridge.send("extension", operations$1.clientHello, { windowId: this.windowId });
5574
+ this.config = yield this.bridge.send("extension", operations$2.clientHello, { windowId: this.windowId });
5339
5575
  this.logger.trace("the platform responded to the hello message with a valid extension config");
5340
5576
  });
5341
5577
  }
@@ -5681,7 +5917,7 @@ class LegacyIntentsHelper {
5681
5917
  });
5682
5918
  }
5683
5919
  invokeRaiseIntent(requestObj) {
5684
- return this.bridge.send("intents", operations$4.raiseIntent, requestObj);
5920
+ return this.bridge.send("intents", operations$5.raiseIntent, requestObj);
5685
5921
  }
5686
5922
  registerResponseMethod() {
5687
5923
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -5841,7 +6077,7 @@ class LegacyIntentsHelper {
5841
6077
  }
5842
6078
  }
5843
6079
 
5844
- const operations = {
6080
+ const operations$1 = {
5845
6081
  getCurrent: { name: "getCurrent", resultDecoder: simpleThemeResponseDecoder },
5846
6082
  list: { name: "list", resultDecoder: allThemesResponseDecoder },
5847
6083
  select: { name: "select", dataDecoder: selectThemeConfigDecoder }
@@ -5884,20 +6120,20 @@ class ThemesController {
5884
6120
  }
5885
6121
  getCurrent() {
5886
6122
  return __awaiter$1(this, void 0, void 0, function* () {
5887
- const bridgeResponse = yield this.bridge.send("themes", operations.getCurrent, undefined, undefined, { includeOperationCheck: true });
6123
+ const bridgeResponse = yield this.bridge.send("themes", operations$1.getCurrent, undefined, undefined, { includeOperationCheck: true });
5888
6124
  return bridgeResponse.theme;
5889
6125
  });
5890
6126
  }
5891
6127
  list() {
5892
6128
  return __awaiter$1(this, void 0, void 0, function* () {
5893
- const bridgeResponse = yield this.bridge.send("themes", operations.list, undefined, undefined, { includeOperationCheck: true });
6129
+ const bridgeResponse = yield this.bridge.send("themes", operations$1.list, undefined, undefined, { includeOperationCheck: true });
5894
6130
  return bridgeResponse.themes;
5895
6131
  });
5896
6132
  }
5897
6133
  select(name) {
5898
6134
  return __awaiter$1(this, void 0, void 0, function* () {
5899
6135
  nonEmptyStringDecoder.runWithException(name);
5900
- yield this.bridge.send("themes", operations.select, { name }, undefined, { includeOperationCheck: true });
6136
+ yield this.bridge.send("themes", operations$1.select, { name }, undefined, { includeOperationCheck: true });
5901
6137
  });
5902
6138
  }
5903
6139
  onChanged(callback) {
@@ -5979,6 +6215,175 @@ class SessionStorageController {
5979
6215
  }
5980
6216
  }
5981
6217
 
6218
+ const operations = {
6219
+ clear: { name: "clear", dataDecoder: basePrefsConfigDecoder },
6220
+ clearAll: { name: "clearAll" },
6221
+ get: { name: "get", dataDecoder: basePrefsConfigDecoder, resultDecoder: getPrefsResultDecoder },
6222
+ getAll: { name: "getAll", resultDecoder: getAllPrefsResultDecoder },
6223
+ set: { name: "set", dataDecoder: changePrefsDataDecoder },
6224
+ update: { name: "update", dataDecoder: changePrefsDataDecoder },
6225
+ prefsChanged: { name: "prefsChanged", dataDecoder: getPrefsResultDecoder },
6226
+ prefsHello: { name: "prefsHello", resultDecoder: prefsHelloSuccessDecoder },
6227
+ };
6228
+
6229
+ class PrefsController {
6230
+ constructor() {
6231
+ this.registry = lib$3();
6232
+ }
6233
+ handlePlatformShutdown() {
6234
+ this.registry.clear();
6235
+ }
6236
+ start(coreGlue, ioc) {
6237
+ return __awaiter$1(this, void 0, void 0, function* () {
6238
+ this.logger = coreGlue.logger.subLogger("prefs.controller.web");
6239
+ this.logger.trace("starting the web prefs controller");
6240
+ this.addOperationsExecutors();
6241
+ this.bridge = ioc.bridge;
6242
+ this.config = ioc.config;
6243
+ this.appManagerController = ioc.appManagerController;
6244
+ try {
6245
+ const prefsHelloSuccess = yield this.bridge.send("prefs", operations.prefsHello, undefined, undefined, { includeOperationCheck: true });
6246
+ this.platformAppName = prefsHelloSuccess.platform.app;
6247
+ }
6248
+ catch (error) {
6249
+ this.logger.warn("The platform of this client is outdated and does not support Prefs API.");
6250
+ return;
6251
+ }
6252
+ this.logger.trace("no need for platform registration, attaching the prefs property to glue and returning");
6253
+ const api = this.toApi();
6254
+ coreGlue.prefs = api;
6255
+ });
6256
+ }
6257
+ handleBridgeMessage(args) {
6258
+ return __awaiter$1(this, void 0, void 0, function* () {
6259
+ const operationName = prefsOperationTypesDecoder.runWithException(args.operation);
6260
+ const operation = operations[operationName];
6261
+ if (!operation.execute) {
6262
+ return;
6263
+ }
6264
+ let operationData = args.data;
6265
+ if (operation.dataDecoder) {
6266
+ operationData = operation.dataDecoder.runWithException(args.data);
6267
+ }
6268
+ return yield operation.execute(operationData);
6269
+ });
6270
+ }
6271
+ addOperationsExecutors() {
6272
+ operations.prefsChanged.execute = this.handleOnChanged.bind(this);
6273
+ }
6274
+ toApi() {
6275
+ const api = {
6276
+ clear: this.clear.bind(this),
6277
+ clearAll: this.clearAll.bind(this),
6278
+ clearFor: this.clearFor.bind(this),
6279
+ get: this.get.bind(this),
6280
+ getAll: this.getAll.bind(this),
6281
+ set: this.set.bind(this),
6282
+ setFor: this.setFor.bind(this),
6283
+ subscribe: this.subscribe.bind(this),
6284
+ subscribeFor: this.subscribeFor.bind(this),
6285
+ update: this.update.bind(this),
6286
+ updateFor: this.updateFor.bind(this),
6287
+ };
6288
+ return api;
6289
+ }
6290
+ clear() {
6291
+ return __awaiter$1(this, void 0, void 0, function* () {
6292
+ const app = this.getMyAppName();
6293
+ yield this.clearFor(app);
6294
+ });
6295
+ }
6296
+ clearAll() {
6297
+ return __awaiter$1(this, void 0, void 0, function* () {
6298
+ yield this.bridge.send("prefs", operations.clearAll, undefined, undefined, { includeOperationCheck: true });
6299
+ });
6300
+ }
6301
+ clearFor(app) {
6302
+ return __awaiter$1(this, void 0, void 0, function* () {
6303
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6304
+ yield this.bridge.send("prefs", operations.clear, { app: verifiedApp }, undefined, { includeOperationCheck: true });
6305
+ });
6306
+ }
6307
+ get(app) {
6308
+ return __awaiter$1(this, void 0, void 0, function* () {
6309
+ const verifiedApp = app === undefined || app === null ? this.getMyAppName() : nonEmptyStringDecoder.runWithException(app);
6310
+ const { prefs } = yield this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
6311
+ return prefs;
6312
+ });
6313
+ }
6314
+ getAll() {
6315
+ return __awaiter$1(this, void 0, void 0, function* () {
6316
+ const result = yield this.bridge.send("prefs", operations.getAll, undefined, undefined, { includeOperationCheck: true });
6317
+ return result;
6318
+ });
6319
+ }
6320
+ set(data, options) {
6321
+ var _a;
6322
+ return __awaiter$1(this, void 0, void 0, function* () {
6323
+ const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
6324
+ const app = (_a = verifiedOptions === null || verifiedOptions === void 0 ? void 0 : verifiedOptions.app) !== null && _a !== void 0 ? _a : this.getMyAppName();
6325
+ yield this.setFor(app, data);
6326
+ });
6327
+ }
6328
+ setFor(app, data) {
6329
+ return __awaiter$1(this, void 0, void 0, function* () {
6330
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6331
+ const verifiedData = object$1().runWithException(data);
6332
+ yield this.bridge.send("prefs", operations.set, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
6333
+ });
6334
+ }
6335
+ subscribe(callback) {
6336
+ const app = this.getMyAppName();
6337
+ return this.subscribeFor(app, callback);
6338
+ }
6339
+ subscribeFor(app, callback) {
6340
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6341
+ const applications = this.appManagerController.getApplications();
6342
+ const isValidApp = verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp);
6343
+ if (!isValidApp) {
6344
+ throw new Error(`The provided app name "${app}" is not valid.`);
6345
+ }
6346
+ if (typeof callback !== "function") {
6347
+ throw new Error("Cannot subscribe to prefs, because the provided callback is not a function!");
6348
+ }
6349
+ const subscriptionKey = this.getSubscriptionKey(verifiedApp);
6350
+ this.get(verifiedApp).then(callback);
6351
+ return this.registry.add(subscriptionKey, callback);
6352
+ }
6353
+ update(data, options) {
6354
+ var _a;
6355
+ return __awaiter$1(this, void 0, void 0, function* () {
6356
+ const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
6357
+ const app = (_a = verifiedOptions === null || verifiedOptions === void 0 ? void 0 : verifiedOptions.app) !== null && _a !== void 0 ? _a : this.getMyAppName();
6358
+ yield this.updateFor(app, data);
6359
+ });
6360
+ }
6361
+ updateFor(app, data) {
6362
+ return __awaiter$1(this, void 0, void 0, function* () {
6363
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6364
+ const verifiedData = object$1().runWithException(data);
6365
+ yield this.bridge.send("prefs", operations.update, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
6366
+ });
6367
+ }
6368
+ getMyAppName() {
6369
+ var _a;
6370
+ const myAppName = this.config.isPlatformInternal ? this.platformAppName : (_a = this.appManagerController.me) === null || _a === void 0 ? void 0 : _a.application.name;
6371
+ if (!myAppName) {
6372
+ throw new Error("App Preferences operations can not be executed for windows that do not have app!");
6373
+ }
6374
+ return myAppName;
6375
+ }
6376
+ getSubscriptionKey(app) {
6377
+ return `prefs-changed-${app}`;
6378
+ }
6379
+ handleOnChanged({ prefs }) {
6380
+ return __awaiter$1(this, void 0, void 0, function* () {
6381
+ const subscriptionKey = this.getSubscriptionKey(prefs.app);
6382
+ this.registry.execute(subscriptionKey, prefs);
6383
+ });
6384
+ }
6385
+ }
6386
+
5982
6387
  class IoC {
5983
6388
  constructor() {
5984
6389
  this.controllers = {
@@ -5990,7 +6395,8 @@ class IoC {
5990
6395
  channels: this.channelsController,
5991
6396
  system: this.systemController,
5992
6397
  extension: this.extensionController,
5993
- themes: this.themesController
6398
+ themes: this.themesController,
6399
+ prefs: this.prefsController
5994
6400
  };
5995
6401
  }
5996
6402
  get communicationId() {
@@ -6053,6 +6459,12 @@ class IoC {
6053
6459
  }
6054
6460
  return this._channelsControllerInstance;
6055
6461
  }
6462
+ get prefsController() {
6463
+ if (!this._prefsControllerInstance) {
6464
+ this._prefsControllerInstance = new PrefsController();
6465
+ }
6466
+ return this._prefsControllerInstance;
6467
+ }
6056
6468
  get extensionController() {
6057
6469
  if (!this._extensionController) {
6058
6470
  this._extensionController = new ExtController();
@@ -6118,7 +6530,7 @@ class IoC {
6118
6530
  }
6119
6531
  }
6120
6532
 
6121
- var version$2 = "3.1.3";
6533
+ var version$2 = "3.2.1";
6122
6534
 
6123
6535
  const createFactoryFunction = (coreFactoryFunction) => {
6124
6536
  return (userConfig) => __awaiter$1(void 0, void 0, void 0, function* () {
@@ -7463,6 +7875,7 @@ var WS = (function () {
7463
7875
  return __generator(this, function (_b) {
7464
7876
  switch (_b.label) {
7465
7877
  case 0:
7878
+ this.logger.info("opening ws to ".concat(this.settings.ws, ", retryInterval: ").concat(retryInterval, ", retriesLeft: ").concat(retriesLeft, "..."));
7466
7879
  this.startupTimer.mark("opening-socket");
7467
7880
  if (retryInterval === undefined) {
7468
7881
  retryInterval = this.settings.reconnectInterval;
@@ -7500,9 +7913,10 @@ var WS = (function () {
7500
7913
  };
7501
7914
  WS.prototype.initiateSocket = function () {
7502
7915
  var _this = this;
7916
+ var _a;
7503
7917
  var pw = new PromiseWrapper();
7504
7918
  this.logger.debug("initiating ws to ".concat(this.settings.ws, "..."));
7505
- this.ws = new WebSocketConstructor(this.settings.ws || "");
7919
+ this.ws = new WebSocketConstructor((_a = this.settings.ws) !== null && _a !== void 0 ? _a : "");
7506
7920
  this.ws.onerror = function (err) {
7507
7921
  var reason = "";
7508
7922
  try {
@@ -7521,11 +7935,12 @@ var WS = (function () {
7521
7935
  };
7522
7936
  reason = JSON.stringify(err, replacer);
7523
7937
  }
7938
+ _this.logger.info("ws error - reason: ".concat(reason));
7524
7939
  pw.reject("error");
7525
7940
  _this.notifyStatusChanged(false, reason);
7526
7941
  };
7527
7942
  this.ws.onclose = function (err) {
7528
- _this.logger.info("ws closed ".concat(err));
7943
+ _this.logger.info("ws closed - code: ".concat(err === null || err === void 0 ? void 0 : err.code, " reason: ").concat(err === null || err === void 0 ? void 0 : err.reason));
7529
7944
  pw.reject("closed");
7530
7945
  _this.notifyStatusChanged(false);
7531
7946
  };
@@ -7560,47 +7975,121 @@ var WS = (function () {
7560
7975
  return WS;
7561
7976
  }());
7562
7977
 
7563
- var shortidExports = {};
7564
- var shortid$1 = {
7565
- get exports(){ return shortidExports; },
7566
- set exports(v){ shortidExports = v; },
7567
- };
7568
-
7569
- var libExports = {};
7570
- var lib = {
7571
- get exports(){ return libExports; },
7572
- set exports(v){ libExports = v; },
7573
- };
7574
-
7575
- // Found this seed-based random generator somewhere
7576
- // Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
7577
-
7578
- var seed = 1;
7579
-
7580
- /**
7581
- * return a random number based on a seed
7582
- * @param seed
7583
- * @returns {number}
7584
- */
7585
- function getNextValue() {
7586
- seed = (seed * 9301 + 49297) % 233280;
7587
- return seed/(233280.0);
7588
- }
7589
-
7590
- function setSeed$1(_seed_) {
7591
- seed = _seed_;
7592
- }
7593
-
7594
- var randomFromSeed$1 = {
7595
- nextValue: getNextValue,
7596
- seed: setSeed$1
7597
- };
7598
-
7599
- var randomFromSeed = randomFromSeed$1;
7600
-
7601
- var ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
7602
- var alphabet$2;
7603
- var previousSeed;
7978
+ var MessageReplayerImpl = (function () {
7979
+ function MessageReplayerImpl(specs) {
7980
+ this.specsNames = [];
7981
+ this.messages = {};
7982
+ this.subs = {};
7983
+ this.subsRefCount = {};
7984
+ this.specs = {};
7985
+ for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
7986
+ var spec = specs_1[_i];
7987
+ this.specs[spec.name] = spec;
7988
+ this.specsNames.push(spec.name);
7989
+ }
7990
+ }
7991
+ MessageReplayerImpl.prototype.init = function (connection) {
7992
+ var _this = this;
7993
+ this.connection = connection;
7994
+ for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
7995
+ var name_1 = _a[_i];
7996
+ var _loop_1 = function (type) {
7997
+ var refCount = this_1.subsRefCount[type];
7998
+ if (!refCount) {
7999
+ refCount = 0;
8000
+ }
8001
+ refCount += 1;
8002
+ this_1.subsRefCount[type] = refCount;
8003
+ if (refCount > 1) {
8004
+ return "continue";
8005
+ }
8006
+ var sub = connection.on(type, function (msg) { return _this.processMessage(type, msg); });
8007
+ this_1.subs[type] = sub;
8008
+ };
8009
+ var this_1 = this;
8010
+ for (var _b = 0, _c = this.specs[name_1].types; _b < _c.length; _b++) {
8011
+ var type = _c[_b];
8012
+ _loop_1(type);
8013
+ }
8014
+ }
8015
+ };
8016
+ MessageReplayerImpl.prototype.processMessage = function (type, msg) {
8017
+ if (this.isDone || !msg) {
8018
+ return;
8019
+ }
8020
+ for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
8021
+ var name_2 = _a[_i];
8022
+ if (this.specs[name_2].types.indexOf(type) !== -1) {
8023
+ var messages = this.messages[name_2] || [];
8024
+ this.messages[name_2] = messages;
8025
+ messages.push(msg);
8026
+ }
8027
+ }
8028
+ };
8029
+ MessageReplayerImpl.prototype.drain = function (name, callback) {
8030
+ var _a;
8031
+ if (callback) {
8032
+ (this.messages[name] || []).forEach(callback);
8033
+ }
8034
+ delete this.messages[name];
8035
+ for (var _i = 0, _b = this.specs[name].types; _i < _b.length; _i++) {
8036
+ var type = _b[_i];
8037
+ this.subsRefCount[type] -= 1;
8038
+ if (this.subsRefCount[type] <= 0) {
8039
+ (_a = this.connection) === null || _a === void 0 ? void 0 : _a.off(this.subs[type]);
8040
+ delete this.subs[type];
8041
+ delete this.subsRefCount[type];
8042
+ }
8043
+ }
8044
+ delete this.specs[name];
8045
+ if (!this.specs.length) {
8046
+ this.isDone = true;
8047
+ }
8048
+ };
8049
+ return MessageReplayerImpl;
8050
+ }());
8051
+
8052
+ var shortidExports = {};
8053
+ var shortid$1 = {
8054
+ get exports(){ return shortidExports; },
8055
+ set exports(v){ shortidExports = v; },
8056
+ };
8057
+
8058
+ var libExports = {};
8059
+ var lib = {
8060
+ get exports(){ return libExports; },
8061
+ set exports(v){ libExports = v; },
8062
+ };
8063
+
8064
+ // Found this seed-based random generator somewhere
8065
+ // Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
8066
+
8067
+ var seed = 1;
8068
+
8069
+ /**
8070
+ * return a random number based on a seed
8071
+ * @param seed
8072
+ * @returns {number}
8073
+ */
8074
+ function getNextValue() {
8075
+ seed = (seed * 9301 + 49297) % 233280;
8076
+ return seed/(233280.0);
8077
+ }
8078
+
8079
+ function setSeed$1(_seed_) {
8080
+ seed = _seed_;
8081
+ }
8082
+
8083
+ var randomFromSeed$1 = {
8084
+ nextValue: getNextValue,
8085
+ seed: setSeed$1
8086
+ };
8087
+
8088
+ var randomFromSeed = randomFromSeed$1;
8089
+
8090
+ var ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
8091
+ var alphabet$2;
8092
+ var previousSeed;
7604
8093
 
7605
8094
  var shuffled;
7606
8095
 
@@ -7896,633 +8385,17 @@ var isValid = isShortId;
7896
8385
  // Export all other functions as properties of the generate function
7897
8386
  module.exports = generate;
7898
8387
  module.exports.generate = generate;
7899
- module.exports.seed = seed;
7900
- module.exports.worker = worker;
7901
- module.exports.characters = characters;
7902
- module.exports.isValid = isValid$1;
7903
- } (lib));
7904
-
7905
- (function (module) {
7906
- module.exports = libExports;
7907
- } (shortid$1));
7908
-
7909
- var shortid = /*@__PURE__*/getDefaultExportFromCjs(shortidExports);
7910
-
7911
- function domainSession (domain, connection, logger, successMessages, errorMessages) {
7912
- if (domain == null) {
7913
- domain = "global";
7914
- }
7915
- successMessages = successMessages || ["success"];
7916
- errorMessages = errorMessages || ["error"];
7917
- var isJoined = false;
7918
- var tryReconnecting = false;
7919
- var _latestOptions;
7920
- var _connectionOn = false;
7921
- var callbacks = lib$1();
7922
- connection.disconnected(handleConnectionDisconnected);
7923
- connection.loggedIn(handleConnectionLoggedIn);
7924
- connection.on("success", function (msg) { return handleSuccessMessage(msg); });
7925
- connection.on("error", function (msg) { return handleErrorMessage(msg); });
7926
- connection.on("result", function (msg) { return handleSuccessMessage(msg); });
7927
- if (successMessages) {
7928
- successMessages.forEach(function (sm) {
7929
- connection.on(sm, function (msg) { return handleSuccessMessage(msg); });
7930
- });
7931
- }
7932
- if (errorMessages) {
7933
- errorMessages.forEach(function (sm) {
7934
- connection.on(sm, function (msg) { return handleErrorMessage(msg); });
7935
- });
7936
- }
7937
- var requestsMap = {};
7938
- function join(options) {
7939
- _latestOptions = options;
7940
- return new Promise(function (resolve, reject) {
7941
- if (isJoined) {
7942
- resolve({});
7943
- return;
7944
- }
7945
- var joinPromise;
7946
- if (domain === "global") {
7947
- joinPromise = _connectionOn ? Promise.resolve({}) : Promise.reject("not connected to gateway");
7948
- }
7949
- else {
7950
- logger.debug("joining domain ".concat(domain));
7951
- var joinMsg = {
7952
- type: "join",
7953
- destination: domain,
7954
- domain: "global",
7955
- options: options,
7956
- };
7957
- joinPromise = send(joinMsg);
7958
- }
7959
- joinPromise
7960
- .then(function () {
7961
- handleJoined();
7962
- resolve({});
7963
- })
7964
- .catch(function (err) {
7965
- logger.debug("error joining " + domain + " domain: " + JSON.stringify(err));
7966
- reject(err);
7967
- });
7968
- });
7969
- }
7970
- function leave() {
7971
- if (domain === "global") {
7972
- return Promise.resolve();
7973
- }
7974
- logger.debug("stopping session " + domain + "...");
7975
- var leaveMsg = {
7976
- type: "leave",
7977
- destination: domain,
7978
- domain: "global",
7979
- };
7980
- tryReconnecting = false;
7981
- return send(leaveMsg)
7982
- .then(function () {
7983
- isJoined = false;
7984
- callbacks.execute("onLeft");
7985
- })
7986
- .catch(function () {
7987
- isJoined = false;
7988
- callbacks.execute("onLeft");
7989
- });
7990
- }
7991
- function handleJoined() {
7992
- logger.debug("did join " + domain);
7993
- isJoined = true;
7994
- var wasReconnect = tryReconnecting;
7995
- tryReconnecting = false;
7996
- callbacks.execute("onJoined", wasReconnect);
7997
- }
7998
- function handleConnectionDisconnected() {
7999
- _connectionOn = false;
8000
- logger.debug("connection is down");
8001
- isJoined = false;
8002
- tryReconnecting = true;
8003
- callbacks.execute("onLeft", { disconnected: true });
8004
- }
8005
- function handleConnectionLoggedIn() {
8006
- _connectionOn = true;
8007
- if (tryReconnecting) {
8008
- logger.debug("connection is now up - trying to reconnect...");
8009
- join(_latestOptions);
8010
- }
8011
- }
8012
- function onJoined(callback) {
8013
- if (isJoined) {
8014
- callback(false);
8015
- }
8016
- return callbacks.add("onJoined", callback);
8017
- }
8018
- function onLeft(callback) {
8019
- if (!isJoined) {
8020
- callback();
8021
- }
8022
- return callbacks.add("onLeft", callback);
8023
- }
8024
- function handleErrorMessage(msg) {
8025
- if (domain !== msg.domain) {
8026
- return;
8027
- }
8028
- var requestId = msg.request_id;
8029
- if (!requestId) {
8030
- return;
8031
- }
8032
- var entry = requestsMap[requestId];
8033
- if (!entry) {
8034
- return;
8035
- }
8036
- entry.error(msg);
8037
- }
8038
- function handleSuccessMessage(msg) {
8039
- if (msg.domain !== domain) {
8040
- return;
8041
- }
8042
- var requestId = msg.request_id;
8043
- if (!requestId) {
8044
- return;
8045
- }
8046
- var entry = requestsMap[requestId];
8047
- if (!entry) {
8048
- return;
8049
- }
8050
- entry.success(msg);
8051
- }
8052
- function getNextRequestId() {
8053
- return shortid();
8054
- }
8055
- function send(msg, tag, options) {
8056
- options = options || {};
8057
- msg.request_id = msg.request_id || getNextRequestId();
8058
- msg.domain = msg.domain || domain;
8059
- if (!options.skipPeerId) {
8060
- msg.peer_id = connection.peerId;
8061
- }
8062
- var requestId = msg.request_id;
8063
- return new Promise(function (resolve, reject) {
8064
- requestsMap[requestId] = {
8065
- success: function (successMsg) {
8066
- delete requestsMap[requestId];
8067
- successMsg._tag = tag;
8068
- resolve(successMsg);
8069
- },
8070
- error: function (errorMsg) {
8071
- logger.warn("GW error - ".concat(JSON.stringify(errorMsg), " for request ").concat(JSON.stringify(msg)));
8072
- delete requestsMap[requestId];
8073
- errorMsg._tag = tag;
8074
- reject(errorMsg);
8075
- },
8076
- };
8077
- connection
8078
- .send(msg, options)
8079
- .catch(function (err) {
8080
- requestsMap[requestId].error({ err: err });
8081
- });
8082
- });
8083
- }
8084
- function sendFireAndForget(msg) {
8085
- msg.request_id = msg.request_id ? msg.request_id : getNextRequestId();
8086
- msg.domain = msg.domain || domain;
8087
- msg.peer_id = connection.peerId;
8088
- return connection.send(msg);
8089
- }
8090
- return {
8091
- join: join,
8092
- leave: leave,
8093
- onJoined: onJoined,
8094
- onLeft: onLeft,
8095
- send: send,
8096
- sendFireAndForget: sendFireAndForget,
8097
- on: function (type, callback) {
8098
- connection.on(type, function (msg) {
8099
- if (msg.domain !== domain) {
8100
- return;
8101
- }
8102
- try {
8103
- callback(msg);
8104
- }
8105
- catch (e) {
8106
- logger.error("Callback failed: ".concat(e, " \n ").concat(e.stack, " \n msg was: ").concat(JSON.stringify(msg)), e);
8107
- }
8108
- });
8109
- },
8110
- loggedIn: function (callback) { return connection.loggedIn(callback); },
8111
- connected: function (callback) { return connection.connected(callback); },
8112
- disconnected: function (callback) { return connection.disconnected(callback); },
8113
- get peerId() {
8114
- return connection.peerId;
8115
- },
8116
- get domain() {
8117
- return domain;
8118
- },
8119
- };
8120
- }
8121
-
8122
- var GW3ProtocolImpl = (function () {
8123
- function GW3ProtocolImpl(connection, settings, logger) {
8124
- var _this = this;
8125
- this.connection = connection;
8126
- this.settings = settings;
8127
- this.logger = logger;
8128
- this.protocolVersion = 3;
8129
- this.datePrefix = "#T42_DATE#";
8130
- this.datePrefixLen = this.datePrefix.length;
8131
- this.dateMinLen = this.datePrefixLen + 1;
8132
- this.datePrefixFirstChar = this.datePrefix[0];
8133
- this.registry = lib$1();
8134
- this._isLoggedIn = false;
8135
- this.shouldTryLogin = true;
8136
- this.initialLogin = true;
8137
- this.initialLoginAttempts = 3;
8138
- this.sessions = [];
8139
- connection.disconnected(function () {
8140
- _this.handleDisconnected();
8141
- });
8142
- this.ping();
8143
- }
8144
- Object.defineProperty(GW3ProtocolImpl.prototype, "isLoggedIn", {
8145
- get: function () {
8146
- return this._isLoggedIn;
8147
- },
8148
- enumerable: false,
8149
- configurable: true
8150
- });
8151
- GW3ProtocolImpl.prototype.processStringMessage = function (message) {
8152
- var _this = this;
8153
- var msg = JSON.parse(message, function (key, value) {
8154
- if (typeof value !== "string") {
8155
- return value;
8156
- }
8157
- if (value.length < _this.dateMinLen) {
8158
- return value;
8159
- }
8160
- if (value[0] !== _this.datePrefixFirstChar) {
8161
- return value;
8162
- }
8163
- if (value.substring(0, _this.datePrefixLen) !== _this.datePrefix) {
8164
- return value;
8165
- }
8166
- try {
8167
- var milliseconds = parseInt(value.substring(_this.datePrefixLen, value.length), 10);
8168
- if (isNaN(milliseconds)) {
8169
- return value;
8170
- }
8171
- return new Date(milliseconds);
8172
- }
8173
- catch (ex) {
8174
- return value;
8175
- }
8176
- });
8177
- return {
8178
- msg: msg,
8179
- msgType: msg.type,
8180
- };
8181
- };
8182
- GW3ProtocolImpl.prototype.createStringMessage = function (message) {
8183
- var oldToJson = Date.prototype.toJSON;
8184
- try {
8185
- var datePrefix_1 = this.datePrefix;
8186
- Date.prototype.toJSON = function () {
8187
- return datePrefix_1 + this.getTime();
8188
- };
8189
- var result = JSON.stringify(message);
8190
- return result;
8191
- }
8192
- finally {
8193
- Date.prototype.toJSON = oldToJson;
8194
- }
8195
- };
8196
- GW3ProtocolImpl.prototype.processObjectMessage = function (message) {
8197
- if (!message.type) {
8198
- throw new Error("Object should have type property");
8199
- }
8200
- return {
8201
- msg: message,
8202
- msgType: message.type,
8203
- };
8204
- };
8205
- GW3ProtocolImpl.prototype.createObjectMessage = function (message) {
8206
- return message;
8207
- };
8208
- GW3ProtocolImpl.prototype.login = function (config, reconnect) {
8209
- return __awaiter(this, void 0, void 0, function () {
8210
- var authentication, token, e_1, _a, helloMsg, sendOptions, welcomeMsg, msg, token, _b, err_1;
8211
- return __generator(this, function (_c) {
8212
- switch (_c.label) {
8213
- case 0:
8214
- this.logger.debug("logging in...");
8215
- this.loginConfig = config;
8216
- if (!this.loginConfig) {
8217
- this.loginConfig = { username: "", password: "" };
8218
- }
8219
- this.shouldTryLogin = true;
8220
- authentication = {};
8221
- this.connection.gatewayToken = config.gatewayToken;
8222
- if (!config.gatewayToken) return [3, 5];
8223
- if (!reconnect) return [3, 4];
8224
- _c.label = 1;
8225
- case 1:
8226
- _c.trys.push([1, 3, , 4]);
8227
- return [4, this.getNewGWToken()];
8228
- case 2:
8229
- token = _c.sent();
8230
- config.gatewayToken = token;
8231
- return [3, 4];
8232
- case 3:
8233
- e_1 = _c.sent();
8234
- this.logger.warn("failed to get GW token when reconnecting ".concat((e_1 === null || e_1 === void 0 ? void 0 : e_1.message) || e_1));
8235
- return [3, 4];
8236
- case 4:
8237
- authentication.method = "gateway-token";
8238
- authentication.token = config.gatewayToken;
8239
- this.connection.gatewayToken = config.gatewayToken;
8240
- return [3, 10];
8241
- case 5:
8242
- if (!(config.flowName === "sspi")) return [3, 9];
8243
- authentication.provider = "win";
8244
- authentication.method = "access-token";
8245
- if (!(config.flowCallback && config.sessionId)) return [3, 7];
8246
- _a = authentication;
8247
- return [4, config.flowCallback(config.sessionId, null)];
8248
- case 6:
8249
- _a.token =
8250
- (_c.sent())
8251
- .data
8252
- .toString("base64");
8253
- return [3, 8];
8254
- case 7: throw new Error("Invalid SSPI config");
8255
- case 8: return [3, 10];
8256
- case 9:
8257
- if (config.token) {
8258
- authentication.method = "access-token";
8259
- authentication.token = config.token;
8260
- }
8261
- else if (config.username) {
8262
- authentication.method = "secret";
8263
- authentication.login = config.username;
8264
- authentication.secret = config.password;
8265
- }
8266
- else if (config.provider) {
8267
- authentication.provider = config.provider;
8268
- authentication.providerContext = config.providerContext;
8269
- }
8270
- else {
8271
- throw new Error("invalid auth message" + JSON.stringify(config));
8272
- }
8273
- _c.label = 10;
8274
- case 10:
8275
- helloMsg = {
8276
- type: "hello",
8277
- identity: this.settings.identity,
8278
- authentication: authentication
8279
- };
8280
- if (config.sessionId) {
8281
- helloMsg.request_id = config.sessionId;
8282
- }
8283
- this.globalDomain = domainSession("global", this.connection, this.logger.subLogger("global-domain"), [
8284
- "welcome",
8285
- "token",
8286
- "authentication-request"
8287
- ]);
8288
- sendOptions = { skipPeerId: true };
8289
- if (this.initialLogin) {
8290
- sendOptions.retryInterval = this.settings.reconnectInterval;
8291
- sendOptions.maxRetries = this.settings.reconnectAttempts;
8292
- }
8293
- _c.label = 11;
8294
- case 11:
8295
- _c.trys.push([11, 19, 20, 21]);
8296
- welcomeMsg = void 0;
8297
- _c.label = 12;
8298
- case 12:
8299
- return [4, this.globalDomain.send(helloMsg, undefined, sendOptions)];
8300
- case 13:
8301
- msg = _c.sent();
8302
- if (!(msg.type === "authentication-request")) return [3, 16];
8303
- token = Buffer.from(msg.authentication.token, "base64");
8304
- if (!(config.flowCallback && config.sessionId)) return [3, 15];
8305
- _b = helloMsg.authentication;
8306
- return [4, config.flowCallback(config.sessionId, token)];
8307
- case 14:
8308
- _b.token =
8309
- (_c.sent())
8310
- .data
8311
- .toString("base64");
8312
- _c.label = 15;
8313
- case 15:
8314
- helloMsg.request_id = config.sessionId;
8315
- return [3, 12];
8316
- case 16:
8317
- if (msg.type === "welcome") {
8318
- welcomeMsg = msg;
8319
- return [3, 18];
8320
- }
8321
- else if (msg.type === "error") {
8322
- throw new Error("Authentication failed: " + msg.reason);
8323
- }
8324
- else {
8325
- throw new Error("Unexpected message type during authentication: " + msg.type);
8326
- }
8327
- case 17: return [3, 12];
8328
- case 18:
8329
- this.initialLogin = false;
8330
- this.logger.debug("login successful with peerId " + welcomeMsg.peer_id);
8331
- this.connection.peerId = welcomeMsg.peer_id;
8332
- this.connection.resolvedIdentity = welcomeMsg.resolved_identity;
8333
- this.connection.availableDomains = welcomeMsg.available_domains;
8334
- if (welcomeMsg.options) {
8335
- this.connection.token = welcomeMsg.options.access_token;
8336
- this.connection.info = welcomeMsg.options.info;
8337
- }
8338
- this.setLoggedIn(true);
8339
- return [2, welcomeMsg.resolved_identity];
8340
- case 19:
8341
- err_1 = _c.sent();
8342
- this.logger.error("error sending hello message - " + (err_1.message || err_1.msg || err_1.reason || err_1), err_1);
8343
- throw err_1;
8344
- case 20:
8345
- if (config && config.flowCallback && config.sessionId) {
8346
- config.flowCallback(config.sessionId, null);
8347
- }
8348
- return [7];
8349
- case 21: return [2];
8350
- }
8351
- });
8352
- });
8353
- };
8354
- GW3ProtocolImpl.prototype.logout = function () {
8355
- return __awaiter(this, void 0, void 0, function () {
8356
- var promises;
8357
- return __generator(this, function (_a) {
8358
- switch (_a.label) {
8359
- case 0:
8360
- this.logger.debug("logging out...");
8361
- this.shouldTryLogin = false;
8362
- if (this.pingTimer) {
8363
- clearTimeout(this.pingTimer);
8364
- }
8365
- promises = this.sessions.map(function (session) {
8366
- session.leave();
8367
- });
8368
- return [4, Promise.all(promises)];
8369
- case 1:
8370
- _a.sent();
8371
- return [2];
8372
- }
8373
- });
8374
- });
8375
- };
8376
- GW3ProtocolImpl.prototype.loggedIn = function (callback) {
8377
- if (this._isLoggedIn) {
8378
- callback();
8379
- }
8380
- return this.registry.add("onLoggedIn", callback);
8381
- };
8382
- GW3ProtocolImpl.prototype.domain = function (domainName, domainLogger, successMessages, errorMessages) {
8383
- var session = this.sessions.filter(function (s) { return s.domain === domainName; })[0];
8384
- if (!session) {
8385
- session = domainSession(domainName, this.connection, domainLogger, successMessages, errorMessages);
8386
- this.sessions.push(session);
8387
- }
8388
- return session;
8389
- };
8390
- GW3ProtocolImpl.prototype.handleDisconnected = function () {
8391
- var _this = this;
8392
- this.setLoggedIn(false);
8393
- var tryToLogin = this.shouldTryLogin;
8394
- if (tryToLogin && this.initialLogin) {
8395
- if (this.initialLoginAttempts <= 0) {
8396
- return;
8397
- }
8398
- this.initialLoginAttempts--;
8399
- }
8400
- this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
8401
- if (this.shouldTryLogin) {
8402
- if (!this.loginConfig) {
8403
- throw new Error("no login info");
8404
- }
8405
- this.connection.login(this.loginConfig, true)
8406
- .catch(function () {
8407
- setTimeout(_this.handleDisconnected.bind(_this), _this.settings.reconnectInterval || 1000);
8408
- });
8409
- }
8410
- };
8411
- GW3ProtocolImpl.prototype.setLoggedIn = function (value) {
8412
- this._isLoggedIn = value;
8413
- if (this._isLoggedIn) {
8414
- this.registry.execute("onLoggedIn");
8415
- }
8416
- };
8417
- GW3ProtocolImpl.prototype.ping = function () {
8418
- var _this = this;
8419
- if (!this.shouldTryLogin) {
8420
- return;
8421
- }
8422
- if (this._isLoggedIn) {
8423
- this.connection.send({ type: "ping" });
8424
- }
8425
- this.pingTimer = setTimeout(function () {
8426
- _this.ping();
8427
- }, 30 * 1000);
8428
- };
8429
- GW3ProtocolImpl.prototype.authToken = function () {
8430
- var createTokenReq = {
8431
- type: "create-token"
8432
- };
8433
- if (!this.globalDomain) {
8434
- return Promise.reject(new Error("no global domain session"));
8435
- }
8436
- return this.globalDomain.send(createTokenReq)
8437
- .then(function (res) {
8438
- return res.token;
8439
- });
8440
- };
8441
- GW3ProtocolImpl.prototype.getNewGWToken = function () {
8442
- if (typeof window !== "undefined") {
8443
- var glue42gd = window.glue42gd;
8444
- if (glue42gd) {
8445
- return glue42gd.getGWToken();
8446
- }
8447
- }
8448
- return Promise.reject(new Error("not running in GD"));
8449
- };
8450
- return GW3ProtocolImpl;
8451
- }());
8452
-
8453
- var MessageReplayerImpl = (function () {
8454
- function MessageReplayerImpl(specs) {
8455
- this.specsNames = [];
8456
- this.messages = {};
8457
- this.subs = {};
8458
- this.subsRefCount = {};
8459
- this.specs = {};
8460
- for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
8461
- var spec = specs_1[_i];
8462
- this.specs[spec.name] = spec;
8463
- this.specsNames.push(spec.name);
8464
- }
8465
- }
8466
- MessageReplayerImpl.prototype.init = function (connection) {
8467
- var _this = this;
8468
- this.connection = connection;
8469
- for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
8470
- var name_1 = _a[_i];
8471
- var _loop_1 = function (type) {
8472
- var refCount = this_1.subsRefCount[type];
8473
- if (!refCount) {
8474
- refCount = 0;
8475
- }
8476
- refCount += 1;
8477
- this_1.subsRefCount[type] = refCount;
8478
- if (refCount > 1) {
8479
- return "continue";
8480
- }
8481
- var sub = connection.on(type, function (msg) { return _this.processMessage(type, msg); });
8482
- this_1.subs[type] = sub;
8483
- };
8484
- var this_1 = this;
8485
- for (var _b = 0, _c = this.specs[name_1].types; _b < _c.length; _b++) {
8486
- var type = _c[_b];
8487
- _loop_1(type);
8488
- }
8489
- }
8490
- };
8491
- MessageReplayerImpl.prototype.processMessage = function (type, msg) {
8492
- if (this.isDone || !msg) {
8493
- return;
8494
- }
8495
- for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
8496
- var name_2 = _a[_i];
8497
- if (this.specs[name_2].types.indexOf(type) !== -1) {
8498
- var messages = this.messages[name_2] || [];
8499
- this.messages[name_2] = messages;
8500
- messages.push(msg);
8501
- }
8502
- }
8503
- };
8504
- MessageReplayerImpl.prototype.drain = function (name, callback) {
8505
- var _a;
8506
- if (callback) {
8507
- (this.messages[name] || []).forEach(callback);
8508
- }
8509
- delete this.messages[name];
8510
- for (var _i = 0, _b = this.specs[name].types; _i < _b.length; _i++) {
8511
- var type = _b[_i];
8512
- this.subsRefCount[type] -= 1;
8513
- if (this.subsRefCount[type] <= 0) {
8514
- (_a = this.connection) === null || _a === void 0 ? void 0 : _a.off(this.subs[type]);
8515
- delete this.subs[type];
8516
- delete this.subsRefCount[type];
8517
- }
8518
- }
8519
- delete this.specs[name];
8520
- if (!this.specs.length) {
8521
- this.isDone = true;
8522
- }
8523
- };
8524
- return MessageReplayerImpl;
8525
- }());
8388
+ module.exports.seed = seed;
8389
+ module.exports.worker = worker;
8390
+ module.exports.characters = characters;
8391
+ module.exports.isValid = isValid$1;
8392
+ } (lib));
8393
+
8394
+ (function (module) {
8395
+ module.exports = libExports;
8396
+ } (shortid$1));
8397
+
8398
+ var shortid = /*@__PURE__*/getDefaultExportFromCjs(shortidExports);
8526
8399
 
8527
8400
  var PromisePlus = function (executor, timeoutMilliseconds, timeoutMessage) {
8528
8401
  return new Promise(function (resolve, reject) {
@@ -9261,10 +9134,247 @@ var AsyncSequelizer = (function () {
9261
9134
  return AsyncSequelizer;
9262
9135
  }());
9263
9136
 
9137
+ function domainSession (domain, connection, logger, successMessages, errorMessages) {
9138
+ if (domain == null) {
9139
+ domain = "global";
9140
+ }
9141
+ successMessages = successMessages !== null && successMessages !== void 0 ? successMessages : ["success"];
9142
+ errorMessages = errorMessages !== null && errorMessages !== void 0 ? errorMessages : ["error"];
9143
+ var isJoined = domain === "global";
9144
+ var tryReconnecting = false;
9145
+ var _latestOptions;
9146
+ var _connectionOn = false;
9147
+ var callbacks = lib$1();
9148
+ connection.disconnected(handleConnectionDisconnected);
9149
+ connection.loggedIn(handleConnectionLoggedIn);
9150
+ connection.on("success", function (msg) { return handleSuccessMessage(msg); });
9151
+ connection.on("error", function (msg) { return handleErrorMessage(msg); });
9152
+ connection.on("result", function (msg) { return handleSuccessMessage(msg); });
9153
+ if (successMessages) {
9154
+ successMessages.forEach(function (sm) {
9155
+ connection.on(sm, function (msg) { return handleSuccessMessage(msg); });
9156
+ });
9157
+ }
9158
+ if (errorMessages) {
9159
+ errorMessages.forEach(function (sm) {
9160
+ connection.on(sm, function (msg) { return handleErrorMessage(msg); });
9161
+ });
9162
+ }
9163
+ var requestsMap = {};
9164
+ function join(options) {
9165
+ _latestOptions = options;
9166
+ return new Promise(function (resolve, reject) {
9167
+ if (isJoined) {
9168
+ resolve({});
9169
+ return;
9170
+ }
9171
+ var joinPromise;
9172
+ if (domain === "global") {
9173
+ joinPromise = _connectionOn ? Promise.resolve({}) : Promise.reject("not connected to gateway");
9174
+ }
9175
+ else {
9176
+ logger.debug("joining domain ".concat(domain));
9177
+ var joinMsg = {
9178
+ type: "join",
9179
+ destination: domain,
9180
+ domain: "global",
9181
+ options: options,
9182
+ };
9183
+ joinPromise = send(joinMsg);
9184
+ }
9185
+ joinPromise
9186
+ .then(function () {
9187
+ handleJoined();
9188
+ resolve({});
9189
+ })
9190
+ .catch(function (err) {
9191
+ logger.debug("error joining " + domain + " domain: " + JSON.stringify(err));
9192
+ reject(err);
9193
+ });
9194
+ });
9195
+ }
9196
+ function leave() {
9197
+ if (domain === "global") {
9198
+ return Promise.resolve();
9199
+ }
9200
+ logger.debug("stopping session " + domain + "...");
9201
+ var leaveMsg = {
9202
+ type: "leave",
9203
+ destination: domain,
9204
+ domain: "global",
9205
+ };
9206
+ tryReconnecting = false;
9207
+ return send(leaveMsg)
9208
+ .then(function () {
9209
+ isJoined = false;
9210
+ callbacks.execute("onLeft");
9211
+ })
9212
+ .catch(function () {
9213
+ isJoined = false;
9214
+ callbacks.execute("onLeft");
9215
+ });
9216
+ }
9217
+ function handleJoined() {
9218
+ logger.debug("did join " + domain);
9219
+ isJoined = true;
9220
+ var wasReconnect = tryReconnecting;
9221
+ tryReconnecting = false;
9222
+ callbacks.execute("onJoined", wasReconnect);
9223
+ }
9224
+ function handleConnectionDisconnected() {
9225
+ _connectionOn = false;
9226
+ logger.debug("connection is down");
9227
+ isJoined = false;
9228
+ tryReconnecting = true;
9229
+ callbacks.execute("onLeft", { disconnected: true });
9230
+ }
9231
+ function handleConnectionLoggedIn() {
9232
+ _connectionOn = true;
9233
+ if (tryReconnecting) {
9234
+ logger.debug("connection is now up - trying to reconnect...");
9235
+ join(_latestOptions);
9236
+ }
9237
+ }
9238
+ function onJoined(callback) {
9239
+ if (isJoined) {
9240
+ callback(false);
9241
+ }
9242
+ return callbacks.add("onJoined", callback);
9243
+ }
9244
+ function onLeft(callback) {
9245
+ if (!isJoined) {
9246
+ callback();
9247
+ }
9248
+ return callbacks.add("onLeft", callback);
9249
+ }
9250
+ function handleErrorMessage(msg) {
9251
+ if (domain !== msg.domain) {
9252
+ return;
9253
+ }
9254
+ var requestId = msg.request_id;
9255
+ if (!requestId) {
9256
+ return;
9257
+ }
9258
+ var entry = requestsMap[requestId];
9259
+ if (!entry) {
9260
+ return;
9261
+ }
9262
+ entry.error(msg);
9263
+ }
9264
+ function handleSuccessMessage(msg) {
9265
+ if (msg.domain !== domain) {
9266
+ return;
9267
+ }
9268
+ var requestId = msg.request_id;
9269
+ if (!requestId) {
9270
+ return;
9271
+ }
9272
+ var entry = requestsMap[requestId];
9273
+ if (!entry) {
9274
+ return;
9275
+ }
9276
+ entry.success(msg);
9277
+ }
9278
+ function getNextRequestId() {
9279
+ return shortid();
9280
+ }
9281
+ var queuedCalls = [];
9282
+ function send(msg, tag, options) {
9283
+ var _a, _b;
9284
+ var ignore = ["hello", "join"];
9285
+ if (msg.type && ignore.indexOf(msg.type) === -1) {
9286
+ if (!isJoined) {
9287
+ logger.warn("trying to send a message (".concat(msg.domain, " ").concat(msg.type, ") but not connected, will queue"));
9288
+ var pw = new PromiseWrapper();
9289
+ queuedCalls.push({ msg: msg, tag: tag, options: options, pw: pw });
9290
+ if (queuedCalls.length === 1) {
9291
+ var unsubscribe_1 = onJoined(function () {
9292
+ logger.info("joined - will now send queued messages (".concat(queuedCalls.length, " -> [").concat(queuedCalls.map(function (m) { return m.msg.type; }), "])"));
9293
+ queuedCalls.forEach(function (qm) {
9294
+ send(qm.msg, qm.tag, qm.options)
9295
+ .then(function (t) { return qm.pw.resolve(t); })
9296
+ .catch(function (e) { return qm.pw.reject(e); });
9297
+ });
9298
+ queuedCalls = [];
9299
+ unsubscribe_1();
9300
+ });
9301
+ }
9302
+ return pw.promise;
9303
+ }
9304
+ }
9305
+ options = options !== null && options !== void 0 ? options : {};
9306
+ msg.request_id = (_a = msg.request_id) !== null && _a !== void 0 ? _a : getNextRequestId();
9307
+ msg.domain = (_b = msg.domain) !== null && _b !== void 0 ? _b : domain;
9308
+ if (!options.skipPeerId) {
9309
+ msg.peer_id = connection.peerId;
9310
+ }
9311
+ var requestId = msg.request_id;
9312
+ return new Promise(function (resolve, reject) {
9313
+ requestsMap[requestId] = {
9314
+ success: function (successMsg) {
9315
+ delete requestsMap[requestId];
9316
+ successMsg._tag = tag;
9317
+ resolve(successMsg);
9318
+ },
9319
+ error: function (errorMsg) {
9320
+ logger.warn("GW error - ".concat(JSON.stringify(errorMsg), " for request ").concat(JSON.stringify(msg)));
9321
+ delete requestsMap[requestId];
9322
+ errorMsg._tag = tag;
9323
+ reject(errorMsg);
9324
+ },
9325
+ };
9326
+ connection
9327
+ .send(msg, options)
9328
+ .catch(function (err) {
9329
+ requestsMap[requestId].error({ err: err });
9330
+ });
9331
+ });
9332
+ }
9333
+ function sendFireAndForget(msg) {
9334
+ var _a;
9335
+ msg.request_id = msg.request_id ? msg.request_id : getNextRequestId();
9336
+ msg.domain = (_a = msg.domain) !== null && _a !== void 0 ? _a : domain;
9337
+ msg.peer_id = connection.peerId;
9338
+ return connection.send(msg);
9339
+ }
9340
+ return {
9341
+ join: join,
9342
+ leave: leave,
9343
+ onJoined: onJoined,
9344
+ onLeft: onLeft,
9345
+ send: send,
9346
+ sendFireAndForget: sendFireAndForget,
9347
+ on: function (type, callback) {
9348
+ connection.on(type, function (msg) {
9349
+ if (msg.domain !== domain) {
9350
+ return;
9351
+ }
9352
+ try {
9353
+ callback(msg);
9354
+ }
9355
+ catch (e) {
9356
+ logger.error("Callback failed: ".concat(e, " \n ").concat(e.stack, " \n msg was: ").concat(JSON.stringify(msg)), e);
9357
+ }
9358
+ });
9359
+ },
9360
+ loggedIn: function (callback) { return connection.loggedIn(callback); },
9361
+ connected: function (callback) { return connection.connected(callback); },
9362
+ disconnected: function (callback) { return connection.disconnected(callback); },
9363
+ get peerId() {
9364
+ return connection.peerId;
9365
+ },
9366
+ get domain() {
9367
+ return domain;
9368
+ },
9369
+ };
9370
+ }
9371
+
9264
9372
  var Connection = (function () {
9265
9373
  function Connection(settings, logger) {
9374
+ var _a, _b;
9266
9375
  this.settings = settings;
9267
9376
  this.logger = logger;
9377
+ this.protocolVersion = 3;
9268
9378
  this.messageHandlers = {};
9269
9379
  this.ids = 1;
9270
9380
  this.registry = lib$1();
@@ -9273,10 +9383,19 @@ var Connection = (function () {
9273
9383
  this._swapTransport = false;
9274
9384
  this._switchInProgress = false;
9275
9385
  this._transportSubscriptions = [];
9386
+ this.datePrefix = "#T42_DATE#";
9387
+ this.datePrefixLen = this.datePrefix.length;
9388
+ this.dateMinLen = this.datePrefixLen + 1;
9389
+ this.datePrefixFirstChar = this.datePrefix[0];
9276
9390
  this._sequelizer = new AsyncSequelizer();
9391
+ this._isLoggedIn = false;
9392
+ this.shouldTryLogin = true;
9393
+ this.sessions = [];
9394
+ this.initialLogin = true;
9395
+ this.initialLoginAttempts = 3;
9277
9396
  settings = settings || {};
9278
- settings.reconnectAttempts = settings.reconnectAttempts || 10;
9279
- settings.reconnectInterval = settings.reconnectInterval || 1000;
9397
+ settings.reconnectAttempts = (_a = settings.reconnectAttempts) !== null && _a !== void 0 ? _a : 10;
9398
+ settings.reconnectInterval = (_b = settings.reconnectInterval) !== null && _b !== void 0 ? _b : 1000;
9280
9399
  if (settings.inproc) {
9281
9400
  this.transport = new InProcTransport(settings.inproc, logger.subLogger("inMemory"));
9282
9401
  }
@@ -9294,21 +9413,13 @@ var Connection = (function () {
9294
9413
  }
9295
9414
  this.isTrace = logger.canPublish("trace");
9296
9415
  logger.debug("starting with ".concat(this.transport.name(), " transport"));
9297
- this.protocol = new GW3ProtocolImpl(this, settings, logger.subLogger("protocol"));
9298
9416
  var unsubConnectionChanged = this.transport.onConnectedChanged(this.handleConnectionChanged.bind(this));
9299
9417
  var unsubOnMessage = this.transport.onMessage(this.handleTransportMessage.bind(this));
9300
9418
  this._transportSubscriptions.push(unsubConnectionChanged);
9301
9419
  this._transportSubscriptions.push(unsubOnMessage);
9302
9420
  this._defaultTransport = this.transport;
9421
+ this.ping();
9303
9422
  }
9304
- Object.defineProperty(Connection.prototype, "protocolVersion", {
9305
- get: function () {
9306
- var _a;
9307
- return (_a = this.protocol) === null || _a === void 0 ? void 0 : _a.protocolVersion;
9308
- },
9309
- enumerable: false,
9310
- configurable: true
9311
- });
9312
9423
  Connection.prototype.switchTransport = function (settings) {
9313
9424
  return __awaiter(this, void 0, void 0, function () {
9314
9425
  var _this = this;
@@ -9367,14 +9478,14 @@ var Connection = (function () {
9367
9478
  Connection.prototype.send = function (message, options) {
9368
9479
  if (this.transport.sendObject &&
9369
9480
  this.transport.isObjectBasedTransport) {
9370
- var msg = this.protocol.createObjectMessage(message);
9481
+ var msg = this.createObjectMessage(message);
9371
9482
  if (this.isTrace) {
9372
9483
  this.logger.trace(">> ".concat(JSON.stringify(msg)));
9373
9484
  }
9374
9485
  return this.transport.sendObject(msg, options);
9375
9486
  }
9376
9487
  else {
9377
- var strMessage = this.protocol.createStringMessage(message);
9488
+ var strMessage = this.createStringMessage(message);
9378
9489
  if (this.isTrace) {
9379
9490
  this.logger.trace(">> ".concat(strMessage));
9380
9491
  }
@@ -9398,14 +9509,14 @@ var Connection = (function () {
9398
9509
  };
9399
9510
  Object.defineProperty(Connection.prototype, "isConnected", {
9400
9511
  get: function () {
9401
- return this.protocol.isLoggedIn;
9512
+ return this._isLoggedIn;
9402
9513
  },
9403
9514
  enumerable: false,
9404
9515
  configurable: true
9405
9516
  });
9406
9517
  Connection.prototype.connected = function (callback) {
9407
9518
  var _this = this;
9408
- return this.protocol.loggedIn(function () {
9519
+ return this.loggedIn(function () {
9409
9520
  var currentServer = _this.transport.name();
9410
9521
  callback(currentServer);
9411
9522
  });
@@ -9436,7 +9547,7 @@ var Connection = (function () {
9436
9547
  _a.sent();
9437
9548
  this.logger.trace("Transport: ".concat(this.transport.name(), " opened, logging in"));
9438
9549
  timer("connection").mark("transport-opened");
9439
- return [4, this.protocol.login(authRequest, reconnect)];
9550
+ return [4, this.loginCore(authRequest, reconnect)];
9440
9551
  case 3:
9441
9552
  identity = _a.sent();
9442
9553
  this.logger.trace("Logged in with identity: ".concat(JSON.stringify(identity)));
@@ -9458,7 +9569,7 @@ var Connection = (function () {
9458
9569
  return __awaiter(this, void 0, void 0, function () {
9459
9570
  return __generator(this, function (_a) {
9460
9571
  switch (_a.label) {
9461
- case 0: return [4, this.protocol.logout()];
9572
+ case 0: return [4, this.logoutCore()];
9462
9573
  case 1:
9463
9574
  _a.sent();
9464
9575
  return [4, this.transport.close()];
@@ -9470,17 +9581,41 @@ var Connection = (function () {
9470
9581
  });
9471
9582
  };
9472
9583
  Connection.prototype.loggedIn = function (callback) {
9473
- return this.protocol.loggedIn(callback);
9584
+ if (this._isLoggedIn) {
9585
+ callback();
9586
+ }
9587
+ return this.registry.add("onLoggedIn", callback);
9474
9588
  };
9475
9589
  Connection.prototype.domain = function (domain, successMessages, errorMessages) {
9476
- return this.protocol.domain(domain, this.logger.subLogger("domain=".concat(domain)), successMessages, errorMessages);
9590
+ var session = this.sessions.find(function (s) { return s.domain === domain; });
9591
+ if (!session) {
9592
+ session = domainSession(domain, this, this.logger.subLogger("domain=".concat(domain)), successMessages, errorMessages);
9593
+ this.sessions.push(session);
9594
+ }
9595
+ return session;
9477
9596
  };
9478
9597
  Connection.prototype.authToken = function () {
9479
- return this.protocol.authToken();
9598
+ var createTokenReq = {
9599
+ domain: "global",
9600
+ type: "create-token"
9601
+ };
9602
+ if (!this.globalDomain) {
9603
+ return Promise.reject(new Error("no global domain session"));
9604
+ }
9605
+ return this.globalDomain.send(createTokenReq)
9606
+ .then(function (res) {
9607
+ return res.token;
9608
+ });
9480
9609
  };
9481
9610
  Connection.prototype.reconnect = function () {
9482
9611
  return this.transport.reconnect();
9483
9612
  };
9613
+ Connection.prototype.setLoggedIn = function (value) {
9614
+ this._isLoggedIn = value;
9615
+ if (this._isLoggedIn) {
9616
+ this.registry.execute("onLoggedIn");
9617
+ }
9618
+ };
9484
9619
  Connection.prototype.distributeMessage = function (message, type) {
9485
9620
  var _this = this;
9486
9621
  var handlers = this.messageHandlers[type.toLowerCase()];
@@ -9504,28 +9639,51 @@ var Connection = (function () {
9504
9639
  }
9505
9640
  };
9506
9641
  Connection.prototype.handleConnectionChanged = function (connected) {
9642
+ var _a, _b;
9507
9643
  if (this._connected === connected) {
9508
9644
  return;
9509
9645
  }
9510
9646
  this._connected = connected;
9511
9647
  if (connected) {
9512
- if (this.settings.replaySpecs && this.settings.replaySpecs.length) {
9648
+ if ((_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.replaySpecs) === null || _b === void 0 ? void 0 : _b.length) {
9513
9649
  this.replayer = new MessageReplayerImpl(this.settings.replaySpecs);
9514
9650
  this.replayer.init(this);
9515
9651
  }
9516
9652
  this.registry.execute("connected");
9517
9653
  }
9518
9654
  else {
9655
+ this.handleDisconnected();
9519
9656
  this.registry.execute("disconnected");
9520
9657
  }
9521
9658
  };
9659
+ Connection.prototype.handleDisconnected = function () {
9660
+ var _this = this;
9661
+ this.setLoggedIn(false);
9662
+ var tryToLogin = this.shouldTryLogin;
9663
+ if (tryToLogin && this.initialLogin) {
9664
+ if (this.initialLoginAttempts <= 0) {
9665
+ return;
9666
+ }
9667
+ this.initialLoginAttempts--;
9668
+ }
9669
+ this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
9670
+ if (this.shouldTryLogin) {
9671
+ if (!this.loginConfig) {
9672
+ throw new Error("no login info");
9673
+ }
9674
+ this.login(this.loginConfig, true)
9675
+ .catch(function () {
9676
+ setTimeout(_this.handleDisconnected.bind(_this), _this.settings.reconnectInterval || 1000);
9677
+ });
9678
+ }
9679
+ };
9522
9680
  Connection.prototype.handleTransportMessage = function (msg) {
9523
9681
  var msgObj;
9524
9682
  if (typeof msg === "string") {
9525
- msgObj = this.protocol.processStringMessage(msg);
9683
+ msgObj = this.processStringMessage(msg);
9526
9684
  }
9527
9685
  else {
9528
- msgObj = this.protocol.processObjectMessage(msg);
9686
+ msgObj = this.processObjectMessage(msg);
9529
9687
  }
9530
9688
  if (this.isTrace) {
9531
9689
  this.logger.trace("<< ".concat(JSON.stringify(msgObj)));
@@ -9590,6 +9748,275 @@ var Connection = (function () {
9590
9748
  this._targetAuth = this._defaultAuth;
9591
9749
  this._swapTransport = true;
9592
9750
  };
9751
+ Connection.prototype.processStringMessage = function (message) {
9752
+ var _this = this;
9753
+ var msg = JSON.parse(message, function (key, value) {
9754
+ if (typeof value !== "string") {
9755
+ return value;
9756
+ }
9757
+ if (value.length < _this.dateMinLen) {
9758
+ return value;
9759
+ }
9760
+ if (!value.startsWith(_this.datePrefixFirstChar)) {
9761
+ return value;
9762
+ }
9763
+ if (value.substring(0, _this.datePrefixLen) !== _this.datePrefix) {
9764
+ return value;
9765
+ }
9766
+ try {
9767
+ var milliseconds = parseInt(value.substring(_this.datePrefixLen, value.length), 10);
9768
+ if (isNaN(milliseconds)) {
9769
+ return value;
9770
+ }
9771
+ return new Date(milliseconds);
9772
+ }
9773
+ catch (ex) {
9774
+ return value;
9775
+ }
9776
+ });
9777
+ return {
9778
+ msg: msg,
9779
+ msgType: msg.type,
9780
+ };
9781
+ };
9782
+ Connection.prototype.createStringMessage = function (message) {
9783
+ var oldToJson = Date.prototype.toJSON;
9784
+ try {
9785
+ var datePrefix_1 = this.datePrefix;
9786
+ Date.prototype.toJSON = function () {
9787
+ return datePrefix_1 + this.getTime();
9788
+ };
9789
+ var result = JSON.stringify(message);
9790
+ return result;
9791
+ }
9792
+ finally {
9793
+ Date.prototype.toJSON = oldToJson;
9794
+ }
9795
+ };
9796
+ Connection.prototype.processObjectMessage = function (message) {
9797
+ if (!message.type) {
9798
+ throw new Error("Object should have type property");
9799
+ }
9800
+ return {
9801
+ msg: message,
9802
+ msgType: message.type,
9803
+ };
9804
+ };
9805
+ Connection.prototype.createObjectMessage = function (message) {
9806
+ return message;
9807
+ };
9808
+ Connection.prototype.loginCore = function (config, reconnect) {
9809
+ return __awaiter(this, void 0, void 0, function () {
9810
+ var authentication, helloMsg, sendOptions, welcomeMsg, err_1;
9811
+ return __generator(this, function (_a) {
9812
+ switch (_a.label) {
9813
+ case 0:
9814
+ this.logger.info("logging in...");
9815
+ this.loginConfig = config;
9816
+ if (!this.loginConfig) {
9817
+ this.loginConfig = { username: "", password: "" };
9818
+ }
9819
+ this.shouldTryLogin = true;
9820
+ return [4, this.setupAuthConfig(config, reconnect)];
9821
+ case 1:
9822
+ authentication = _a.sent();
9823
+ helloMsg = {
9824
+ type: "hello",
9825
+ identity: this.settings.identity,
9826
+ authentication: authentication
9827
+ };
9828
+ if (config.sessionId) {
9829
+ helloMsg.request_id = config.sessionId;
9830
+ }
9831
+ this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
9832
+ "welcome",
9833
+ "token",
9834
+ "authentication-request"
9835
+ ]);
9836
+ sendOptions = { skipPeerId: true };
9837
+ if (this.initialLogin) {
9838
+ sendOptions.retryInterval = this.settings.reconnectInterval;
9839
+ sendOptions.maxRetries = this.settings.reconnectAttempts;
9840
+ }
9841
+ _a.label = 2;
9842
+ case 2:
9843
+ _a.trys.push([2, 4, 5, 6]);
9844
+ return [4, this.tryAuthenticate(this.globalDomain, helloMsg, sendOptions, config)];
9845
+ case 3:
9846
+ welcomeMsg = _a.sent();
9847
+ this.initialLogin = false;
9848
+ this.logger.info("login successful with peerId " + welcomeMsg.peer_id);
9849
+ this.peerId = welcomeMsg.peer_id;
9850
+ this.resolvedIdentity = welcomeMsg.resolved_identity;
9851
+ this.availableDomains = welcomeMsg.available_domains;
9852
+ if (welcomeMsg.options) {
9853
+ this.token = welcomeMsg.options.access_token;
9854
+ this.info = welcomeMsg.options.info;
9855
+ }
9856
+ this.setLoggedIn(true);
9857
+ return [2, welcomeMsg.resolved_identity];
9858
+ case 4:
9859
+ err_1 = _a.sent();
9860
+ this.logger.error("error sending hello message - " + (err_1.message || err_1.msg || err_1.reason || err_1), err_1);
9861
+ throw err_1;
9862
+ case 5:
9863
+ if ((config === null || config === void 0 ? void 0 : config.flowCallback) && config.sessionId) {
9864
+ config.flowCallback(config.sessionId, null);
9865
+ }
9866
+ return [7];
9867
+ case 6: return [2];
9868
+ }
9869
+ });
9870
+ });
9871
+ };
9872
+ Connection.prototype.tryAuthenticate = function (globalDomain, helloMsg, sendOptions, config) {
9873
+ return __awaiter(this, void 0, void 0, function () {
9874
+ var welcomeMsg, msg, token, _a;
9875
+ return __generator(this, function (_b) {
9876
+ switch (_b.label) {
9877
+ case 0:
9878
+ return [4, globalDomain.send(helloMsg, undefined, sendOptions)];
9879
+ case 1:
9880
+ msg = _b.sent();
9881
+ if (!(msg.type === "authentication-request")) return [3, 4];
9882
+ token = Buffer.from(msg.authentication.token, "base64");
9883
+ if (!(config.flowCallback && config.sessionId)) return [3, 3];
9884
+ _a = helloMsg.authentication;
9885
+ return [4, config.flowCallback(config.sessionId, token)];
9886
+ case 2:
9887
+ _a.token =
9888
+ (_b.sent())
9889
+ .data
9890
+ .toString("base64");
9891
+ _b.label = 3;
9892
+ case 3:
9893
+ helloMsg.request_id = config.sessionId;
9894
+ return [3, 5];
9895
+ case 4:
9896
+ if (msg.type === "welcome") {
9897
+ welcomeMsg = msg;
9898
+ return [3, 6];
9899
+ }
9900
+ else if (msg.type === "error") {
9901
+ throw new Error("Authentication failed: " + msg.reason);
9902
+ }
9903
+ else {
9904
+ throw new Error("Unexpected message type during authentication: " + msg.type);
9905
+ }
9906
+ case 5: return [3, 0];
9907
+ case 6: return [2, welcomeMsg];
9908
+ }
9909
+ });
9910
+ });
9911
+ };
9912
+ Connection.prototype.setupAuthConfig = function (config, reconnect) {
9913
+ return __awaiter(this, void 0, void 0, function () {
9914
+ var authentication, _a, e_1, _b;
9915
+ return __generator(this, function (_c) {
9916
+ switch (_c.label) {
9917
+ case 0:
9918
+ authentication = {};
9919
+ this.gatewayToken = config.gatewayToken;
9920
+ if (!config.gatewayToken) return [3, 5];
9921
+ if (!reconnect) return [3, 4];
9922
+ _c.label = 1;
9923
+ case 1:
9924
+ _c.trys.push([1, 3, , 4]);
9925
+ _a = config;
9926
+ return [4, this.getNewGWToken()];
9927
+ case 2:
9928
+ _a.gatewayToken = _c.sent();
9929
+ return [3, 4];
9930
+ case 3:
9931
+ e_1 = _c.sent();
9932
+ this.logger.warn("failed to get GW token when reconnecting ".concat((e_1 === null || e_1 === void 0 ? void 0 : e_1.message) || e_1));
9933
+ return [3, 4];
9934
+ case 4:
9935
+ authentication.method = "gateway-token";
9936
+ authentication.token = config.gatewayToken;
9937
+ this.gatewayToken = config.gatewayToken;
9938
+ return [3, 10];
9939
+ case 5:
9940
+ if (!(config.flowName === "sspi")) return [3, 9];
9941
+ authentication.provider = "win";
9942
+ authentication.method = "access-token";
9943
+ if (!(config.flowCallback && config.sessionId)) return [3, 7];
9944
+ _b = authentication;
9945
+ return [4, config.flowCallback(config.sessionId, null)];
9946
+ case 6:
9947
+ _b.token =
9948
+ (_c.sent())
9949
+ .data
9950
+ .toString("base64");
9951
+ return [3, 8];
9952
+ case 7: throw new Error("Invalid SSPI config");
9953
+ case 8: return [3, 10];
9954
+ case 9:
9955
+ if (config.token) {
9956
+ authentication.method = "access-token";
9957
+ authentication.token = config.token;
9958
+ }
9959
+ else if (config.username) {
9960
+ authentication.method = "secret";
9961
+ authentication.login = config.username;
9962
+ authentication.secret = config.password;
9963
+ }
9964
+ else if (config.provider) {
9965
+ authentication.provider = config.provider;
9966
+ authentication.providerContext = config.providerContext;
9967
+ }
9968
+ else {
9969
+ throw new Error("invalid auth message" + JSON.stringify(config));
9970
+ }
9971
+ _c.label = 10;
9972
+ case 10: return [2, authentication];
9973
+ }
9974
+ });
9975
+ });
9976
+ };
9977
+ Connection.prototype.logoutCore = function () {
9978
+ return __awaiter(this, void 0, void 0, function () {
9979
+ var promises;
9980
+ return __generator(this, function (_a) {
9981
+ switch (_a.label) {
9982
+ case 0:
9983
+ this.logger.debug("logging out...");
9984
+ this.shouldTryLogin = false;
9985
+ if (this.pingTimer) {
9986
+ clearTimeout(this.pingTimer);
9987
+ }
9988
+ promises = this.sessions.map(function (session) {
9989
+ session.leave();
9990
+ });
9991
+ return [4, Promise.all(promises)];
9992
+ case 1:
9993
+ _a.sent();
9994
+ return [2];
9995
+ }
9996
+ });
9997
+ });
9998
+ };
9999
+ Connection.prototype.getNewGWToken = function () {
10000
+ if (typeof window !== "undefined") {
10001
+ var glue42gd = window.glue42gd;
10002
+ if (glue42gd) {
10003
+ return glue42gd.getGWToken();
10004
+ }
10005
+ }
10006
+ return Promise.reject(new Error("not running in GD"));
10007
+ };
10008
+ Connection.prototype.ping = function () {
10009
+ var _this = this;
10010
+ if (!this.shouldTryLogin) {
10011
+ return;
10012
+ }
10013
+ if (this._isLoggedIn) {
10014
+ this.send({ type: "ping" });
10015
+ }
10016
+ this.pingTimer = setTimeout(function () {
10017
+ _this.ping();
10018
+ }, 30 * 1000);
10019
+ };
9593
10020
  return Connection;
9594
10021
  }());
9595
10022
 
@@ -9771,7 +10198,7 @@ var ContextMessageReplaySpec = {
9771
10198
  }
9772
10199
  };
9773
10200
 
9774
- var version = "6.1.1";
10201
+ var version = "6.2.1";
9775
10202
 
9776
10203
  function prepareConfig (configuration, ext, glue42gd) {
9777
10204
  var _a, _b, _c, _d;
@@ -12047,7 +12474,7 @@ var GW3Bridge = (function () {
12047
12474
  currentContext = _b.sent();
12048
12475
  _b.label = 4;
12049
12476
  case 4:
12050
- calculatedDelta = this.protocolVersion === 2 ?
12477
+ calculatedDelta = this.setPathSupported ?
12051
12478
  this.calculateContextDeltaV2(currentContext, delta) :
12052
12479
  this.calculateContextDeltaV1(currentContext, delta);
12053
12480
  if (!Object.keys(calculatedDelta.added).length
@@ -15032,10 +15459,11 @@ function gW3ProtocolFactory (instance, connection, clientRepository, serverRepos
15032
15459
  var server = new ServerProtocol(session, clientRepository, serverRepository, logger.subLogger("server"));
15033
15460
  var client = new ClientProtocol(session, clientRepository, logger.subLogger("client"));
15034
15461
  function handleReconnect() {
15462
+ var _a, _b;
15035
15463
  return __awaiter(this, void 0, void 0, function () {
15036
- var reconnectionPromises, existingSubscriptions, _loop_1, _i, existingSubscriptions_1, sub, registeredMethods, _loop_2, _a, registeredMethods_1, method;
15037
- return __generator(this, function (_b) {
15038
- switch (_b.label) {
15464
+ var reconnectionPromises, existingSubscriptions, _loop_1, _i, existingSubscriptions_1, sub, registeredMethods, _loop_2, _c, registeredMethods_1, method;
15465
+ return __generator(this, function (_d) {
15466
+ switch (_d.label) {
15039
15467
  case 0:
15040
15468
  logger.info("reconnected - will replay registered methods and subscriptions");
15041
15469
  client.drainSubscriptionsCache().forEach(function (sub) {
@@ -15060,25 +15488,29 @@ function gW3ProtocolFactory (instance, connection, clientRepository, serverRepos
15060
15488
  serverRepository.reset();
15061
15489
  _loop_2 = function (method) {
15062
15490
  var def = method.definition;
15063
- logger.info("re-publishing method ".concat(def.name));
15064
15491
  if (method.stream) {
15065
- reconnectionPromises.push(interop.server.createStream(def, method.streamCallbacks, undefined, undefined, method.stream).then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); }));
15492
+ reconnectionPromises.push(interop.server.createStream(def, method.streamCallbacks, undefined, undefined, method.stream)
15493
+ .then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); })
15494
+ .catch(function () { return logger.warn("subscribing to method ".concat(def.name, " FAILED")); }));
15066
15495
  }
15067
- else if (method.theFunction && method.theFunction.userCallback) {
15068
- reconnectionPromises.push(interop.register(def, method.theFunction.userCallback).then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); }));
15496
+ else if ((_a = method === null || method === void 0 ? void 0 : method.theFunction) === null || _a === void 0 ? void 0 : _a.userCallback) {
15497
+ reconnectionPromises.push(interop.register(def, method.theFunction.userCallback)
15498
+ .then(function () { return logger.info("registering method ".concat(def.name, " DONE")); })
15499
+ .catch(function () { return logger.warn("registering method ".concat(def.name, " FAILED")); }));
15069
15500
  }
15070
- else if (method.theFunction && method.theFunction.userCallbackAsync) {
15071
- reconnectionPromises.push(interop.registerAsync(def, method.theFunction.userCallbackAsync).then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); }));
15501
+ else if ((_b = method === null || method === void 0 ? void 0 : method.theFunction) === null || _b === void 0 ? void 0 : _b.userCallbackAsync) {
15502
+ reconnectionPromises.push(interop.registerAsync(def, method.theFunction.userCallbackAsync)
15503
+ .then(function () { return logger.info("registering method ".concat(def.name, " DONE")); })
15504
+ .catch(function () { return logger.warn("registering method ".concat(def.name, " FAILED")); }));
15072
15505
  }
15073
- logger.info("re-publishing method ".concat(def.name, " DONE"));
15074
15506
  };
15075
- for (_a = 0, registeredMethods_1 = registeredMethods; _a < registeredMethods_1.length; _a++) {
15076
- method = registeredMethods_1[_a];
15507
+ for (_c = 0, registeredMethods_1 = registeredMethods; _c < registeredMethods_1.length; _c++) {
15508
+ method = registeredMethods_1[_c];
15077
15509
  _loop_2(method);
15078
15510
  }
15079
15511
  return [4, Promise.all(reconnectionPromises)];
15080
15512
  case 1:
15081
- _b.sent();
15513
+ _d.sent();
15082
15514
  logger.info("Interop is re-announced");
15083
15515
  return [2];
15084
15516
  }