@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.
@@ -79,10 +79,8 @@
79
79
  libraries: (_a = config === null || config === void 0 ? void 0 : config.libraries) !== null && _a !== void 0 ? _a : [],
80
80
  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"
81
81
  };
82
- if (window.glue42gd) {
83
- return window.Glue(enterpriseConfig);
84
- }
85
- return window.Glue(enterpriseConfig);
82
+ const injectedFactory = window.IODesktop || window.Glue;
83
+ return injectedFactory(enterpriseConfig);
86
84
  };
87
85
 
88
86
  /**
@@ -1806,7 +1804,7 @@
1806
1804
  isFdc3Definition(definition) {
1807
1805
  const decodeRes = allDefinitionsDecoder.run(definition);
1808
1806
  if (!decodeRes.ok) {
1809
- return { isFdc3: false };
1807
+ return { isFdc3: false, reason: parseDecoderErrorToStringMessage(decodeRes.error) };
1810
1808
  }
1811
1809
  if (definition.appId && definition.details) {
1812
1810
  return { isFdc3: true, version: "2.0" };
@@ -1814,7 +1812,7 @@
1814
1812
  if (definition.manifest) {
1815
1813
  return { isFdc3: true, version: "1.2" };
1816
1814
  }
1817
- return { isFdc3: false };
1815
+ return { isFdc3: false, reason: "The passed definition is not FDC3" };
1818
1816
  }
1819
1817
  parseToBrowserBaseAppData(definition) {
1820
1818
  var _a;
@@ -1985,9 +1983,27 @@
1985
1983
  }
1986
1984
  };
1987
1985
 
1986
+ var INTENTS_ERRORS;
1987
+ (function (INTENTS_ERRORS) {
1988
+ INTENTS_ERRORS["USER_CANCELLED"] = "User Closed Intents Resolver UI without choosing a handler";
1989
+ INTENTS_ERRORS["CALLER_NOT_DEFINED"] = "Caller Id is not defined";
1990
+ INTENTS_ERRORS["TIMEOUT_HIT"] = "Timeout hit";
1991
+ INTENTS_ERRORS["INTENT_NOT_FOUND"] = "Cannot find Intent";
1992
+ INTENTS_ERRORS["HANDLER_NOT_FOUND"] = "Cannot find Intent Handler";
1993
+ INTENTS_ERRORS["TARGET_INSTANCE_UNAVAILABLE"] = "Cannot start Target Instance";
1994
+ INTENTS_ERRORS["INTENT_DELIVERY_FAILED"] = "Target Instance did not add a listener";
1995
+ INTENTS_ERRORS["RESOLVER_UNAVAILABLE"] = "Intents Resolver UI unavailable";
1996
+ INTENTS_ERRORS["RESOLVER_TIMEOUT"] = "User did not choose a handler";
1997
+ INTENTS_ERRORS["INVALID_RESOLVER_RESPONSE"] = "Intents Resolver UI returned invalid response";
1998
+ INTENTS_ERRORS["INTENT_HANDLER_REJECTION"] = "Intent Handler function processing the raised intent threw an error or rejected the promise it returned";
1999
+ })(INTENTS_ERRORS || (INTENTS_ERRORS = {}));
2000
+
1988
2001
  let IoC$1 = class IoC {
1989
2002
  constructor() {
1990
2003
  this._decoders = decoders$1;
2004
+ this._errors = {
2005
+ intents: INTENTS_ERRORS
2006
+ };
1991
2007
  }
1992
2008
  get fdc3() {
1993
2009
  if (!this._fdc3) {
@@ -1998,20 +2014,24 @@
1998
2014
  get decoders() {
1999
2015
  return this._decoders;
2000
2016
  }
2017
+ get errors() {
2018
+ return this._errors;
2019
+ }
2001
2020
  };
2002
2021
 
2003
2022
  const ioc = new IoC$1();
2004
2023
  ioc.fdc3;
2005
2024
  const decoders = ioc.decoders;
2025
+ ioc.errors;
2006
2026
 
2007
2027
  const nonEmptyStringDecoder = string$1().where((s) => s.length > 0, "Expected a non-empty string");
2008
2028
  const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
2009
2029
  const optionalNonEmptyStringDecoder = optional$1(nonEmptyStringDecoder);
2010
- 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"));
2030
+ 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"));
2011
2031
  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"));
2012
2032
  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"));
2013
2033
  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"));
2014
- 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"));
2034
+ 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"));
2015
2035
  const systemOperationTypesDecoder = oneOf$1(constant$1("getEnvironment"), constant$1("getBase"), constant$1("platformShutdown"));
2016
2036
  const windowRelativeDirectionDecoder = oneOf$1(constant$1("top"), constant$1("left"), constant$1("right"), constant$1("bottom"));
2017
2037
  const windowBoundsDecoder = object$1({
@@ -2338,7 +2358,7 @@
2338
2358
  const setDefaultGlobalConfigDecoder = object$1({
2339
2359
  name: nonEmptyStringDecoder
2340
2360
  });
2341
- const intentsOperationTypesDecoder = oneOf$1(constant$1("findIntent"), constant$1("getIntents"), constant$1("raiseIntent"), constant$1("raise"));
2361
+ const intentsOperationTypesDecoder = oneOf$1(constant$1("findIntent"), constant$1("getIntents"), constant$1("raiseIntent"), constant$1("raise"), constant$1("filterHandlers"));
2342
2362
  const intentHandlerDecoder = object$1({
2343
2363
  applicationName: nonEmptyStringDecoder,
2344
2364
  applicationTitle: optional$1(string$1()),
@@ -2395,20 +2415,36 @@
2395
2415
  waitUserResponseIndefinitely: optional$1(boolean$1())
2396
2416
  });
2397
2417
  const raiseRequestDecoder = oneOf$1(nonEmptyStringDecoder, intentRequestDecoder);
2398
- const intentRequestResolverConfigDecoder = object$1({
2418
+ const resolverConfigDecoder = object$1({
2399
2419
  enabled: boolean$1(),
2400
2420
  appName: nonEmptyStringDecoder,
2401
2421
  waitResponseTimeout: number$1()
2402
2422
  });
2403
2423
  const raiseIntentRequestDecoder = object$1({
2404
2424
  intentRequest: intentRequestDecoder,
2405
- resolverConfig: intentRequestResolverConfigDecoder
2425
+ resolverConfig: resolverConfigDecoder
2406
2426
  });
2407
2427
  const intentResultDecoder = object$1({
2408
2428
  request: intentRequestDecoder,
2409
2429
  handler: intentHandlerDecoder,
2410
2430
  result: anyJson$1()
2411
2431
  });
2432
+ const handlersFilterDecoder = object$1({
2433
+ title: optional$1(nonEmptyStringDecoder),
2434
+ openResolver: optional$1(boolean$1()),
2435
+ timeout: optional$1(nonNegativeNumberDecoder),
2436
+ intent: optional$1(nonEmptyStringDecoder),
2437
+ contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
2438
+ resultType: optional$1(nonEmptyStringDecoder),
2439
+ applicationNames: optional$1(array$1(nonEmptyStringDecoder))
2440
+ });
2441
+ const filterHandlersResultDecoder = object$1({
2442
+ handlers: array$1(intentHandlerDecoder)
2443
+ });
2444
+ const filterHandlersWithResolverConfigDecoder = object$1({
2445
+ filterHandlersRequest: handlersFilterDecoder,
2446
+ resolverConfig: resolverConfigDecoder
2447
+ });
2412
2448
  const AddIntentListenerRequestDecoder = object$1({
2413
2449
  intent: nonEmptyStringDecoder,
2414
2450
  contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
@@ -2418,6 +2454,17 @@
2418
2454
  resultType: optional$1(string$1())
2419
2455
  });
2420
2456
  const AddIntentListenerDecoder = oneOf$1(nonEmptyStringDecoder, AddIntentListenerRequestDecoder);
2457
+ const intentInfoDecoder = object$1({
2458
+ intent: nonEmptyStringDecoder,
2459
+ contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
2460
+ description: optional$1(nonEmptyStringDecoder),
2461
+ displayName: optional$1(nonEmptyStringDecoder),
2462
+ icon: optional$1(nonEmptyStringDecoder),
2463
+ resultType: optional$1(nonEmptyStringDecoder)
2464
+ });
2465
+ const getIntentsResultDecoder = object$1({
2466
+ intents: array$1(intentInfoDecoder)
2467
+ });
2421
2468
  const channelNameDecoder = (channelNames) => {
2422
2469
  return nonEmptyStringDecoder.where(s => channelNames.includes(s), "Expected a valid channel name");
2423
2470
  };
@@ -2432,6 +2479,10 @@
2432
2479
  icon: optional$1(string$1()),
2433
2480
  interop: optional$1(interopActionSettingsDecoder)
2434
2481
  });
2482
+ 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"));
2483
+ const activeNotificationsCountChangeDecoder = object$1({
2484
+ count: number$1()
2485
+ });
2435
2486
  const notificationDefinitionDecoder = object$1({
2436
2487
  badge: optional$1(string$1()),
2437
2488
  body: optional$1(string$1()),
@@ -2467,7 +2518,12 @@
2467
2518
  vibrate: optional$1(array$1(number$1())),
2468
2519
  severity: optional$1(oneOf$1(constant$1("Low"), constant$1("None"), constant$1("Medium"), constant$1("High"), constant$1("Critical"))),
2469
2520
  showToast: optional$1(boolean$1()),
2470
- showInPanel: optional$1(boolean$1())
2521
+ showInPanel: optional$1(boolean$1()),
2522
+ state: optional$1(notificationStateDecoder)
2523
+ });
2524
+ const notificationSetStateRequestDecoder = object$1({
2525
+ id: nonEmptyStringDecoder,
2526
+ state: notificationStateDecoder
2471
2527
  });
2472
2528
  const channelContextDecoder = object$1({
2473
2529
  name: nonEmptyStringDecoder,
@@ -2494,6 +2550,28 @@
2494
2550
  action: optional$1(string$1()),
2495
2551
  id: optional$1(nonEmptyStringDecoder)
2496
2552
  });
2553
+ const notificationFilterDecoder = object$1({
2554
+ allowed: optional$1(array$1(nonEmptyStringDecoder)),
2555
+ blocked: optional$1(array$1(nonEmptyStringDecoder))
2556
+ });
2557
+ const notificationsConfigurationDecoder = object$1({
2558
+ enable: optional$1(boolean$1()),
2559
+ enableToasts: optional$1(boolean$1()),
2560
+ sourceFilter: optional$1(notificationFilterDecoder),
2561
+ });
2562
+ const notificationsConfigurationProtocolDecoder = object$1({
2563
+ configuration: notificationsConfigurationDecoder
2564
+ });
2565
+ const strictNotificationsConfigurationProtocolDecoder = object$1({
2566
+ configuration: object$1({
2567
+ enable: boolean$1(),
2568
+ enableToasts: boolean$1(),
2569
+ sourceFilter: object$1({
2570
+ allowed: array$1(nonEmptyStringDecoder),
2571
+ blocked: array$1(nonEmptyStringDecoder)
2572
+ })
2573
+ })
2574
+ });
2497
2575
  const platformSaveRequestConfigDecoder = object$1({
2498
2576
  layoutType: oneOf$1(constant$1("Global"), constant$1("Workspace")),
2499
2577
  layoutName: nonEmptyStringDecoder,
@@ -2554,7 +2632,8 @@
2554
2632
  vibrate: optional$1(array$1(number$1())),
2555
2633
  severity: optional$1(oneOf$1(constant$1("Low"), constant$1("None"), constant$1("Medium"), constant$1("High"), constant$1("Critical"))),
2556
2634
  showToast: optional$1(boolean$1()),
2557
- showInPanel: optional$1(boolean$1())
2635
+ showInPanel: optional$1(boolean$1()),
2636
+ state: optional$1(notificationStateDecoder)
2558
2637
  });
2559
2638
  const simpleNotificationDataDecoder = object$1({
2560
2639
  notification: notificationsDataDecoder
@@ -2608,9 +2687,33 @@
2608
2687
  });
2609
2688
  const windowChannelResultDecoder = object$1({
2610
2689
  channel: optional$1(nonEmptyStringDecoder),
2690
+ });
2691
+ 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"));
2692
+ const appPreferencesDecoder = object$1({
2693
+ app: nonEmptyStringDecoder,
2694
+ data: object$1(),
2695
+ lastUpdate: optional$1(nonEmptyStringDecoder),
2696
+ });
2697
+ const basePrefsConfigDecoder = object$1({
2698
+ app: nonEmptyStringDecoder,
2699
+ });
2700
+ const getPrefsResultDecoder = object$1({
2701
+ prefs: appPreferencesDecoder,
2702
+ });
2703
+ const getAllPrefsResultDecoder = object$1({
2704
+ all: array$1(appPreferencesDecoder),
2705
+ });
2706
+ const changePrefsDataDecoder = object$1({
2707
+ app: nonEmptyStringDecoder,
2708
+ data: object$1(),
2709
+ });
2710
+ const prefsHelloSuccessDecoder = object$1({
2711
+ platform: object$1({
2712
+ app: nonEmptyStringDecoder,
2713
+ }),
2611
2714
  });
2612
2715
 
2613
- const operations$8 = {
2716
+ const operations$9 = {
2614
2717
  openWindow: { name: "openWindow", dataDecoder: openWindowConfigDecoder, resultDecoder: coreWindowDataDecoder },
2615
2718
  windowHello: { name: "windowHello", dataDecoder: windowHelloDecoder, resultDecoder: helloSuccessDecoder },
2616
2719
  windowAdded: { name: "windowAdded", dataDecoder: coreWindowDataDecoder },
@@ -2799,7 +2902,7 @@
2799
2902
  }
2800
2903
  getURL() {
2801
2904
  return __awaiter$1(this, void 0, void 0, function* () {
2802
- const result = yield this._bridge.send("windows", operations$8.getUrl, { windowId: this.id });
2905
+ const result = yield this._bridge.send("windows", operations$9.getUrl, { windowId: this.id });
2803
2906
  return result.url;
2804
2907
  });
2805
2908
  }
@@ -2813,7 +2916,7 @@
2813
2916
  return __awaiter$1(this, void 0, void 0, function* () {
2814
2917
  const targetBounds = boundsDecoder.runWithException(dimension);
2815
2918
  const commandArgs = Object.assign({}, targetBounds, { windowId: this.id, relative: false });
2816
- yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
2919
+ yield this._bridge.send("windows", operations$9.moveResize, commandArgs);
2817
2920
  return this.me;
2818
2921
  });
2819
2922
  }
@@ -2829,7 +2932,7 @@
2829
2932
  nonNegativeNumberDecoder.runWithException(height);
2830
2933
  }
2831
2934
  const commandArgs = Object.assign({}, { width, height }, { windowId: this.id, relative: true });
2832
- yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
2935
+ yield this._bridge.send("windows", operations$9.moveResize, commandArgs);
2833
2936
  return this.me;
2834
2937
  });
2835
2938
  }
@@ -2845,7 +2948,7 @@
2845
2948
  number$1().runWithException(left);
2846
2949
  }
2847
2950
  const commandArgs = Object.assign({}, { top, left }, { windowId: this.id, relative: true });
2848
- yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
2951
+ yield this._bridge.send("windows", operations$9.moveResize, commandArgs);
2849
2952
  return this.me;
2850
2953
  });
2851
2954
  }
@@ -2855,33 +2958,33 @@
2855
2958
  window.open(undefined, this.id);
2856
2959
  }
2857
2960
  else {
2858
- yield this._bridge.send("windows", operations$8.focus, { windowId: this.id });
2961
+ yield this._bridge.send("windows", operations$9.focus, { windowId: this.id });
2859
2962
  }
2860
2963
  return this.me;
2861
2964
  });
2862
2965
  }
2863
2966
  close() {
2864
2967
  return __awaiter$1(this, void 0, void 0, function* () {
2865
- yield this._bridge.send("windows", operations$8.close, { windowId: this.id });
2968
+ yield this._bridge.send("windows", operations$9.close, { windowId: this.id });
2866
2969
  return this.me;
2867
2970
  });
2868
2971
  }
2869
2972
  getTitle() {
2870
2973
  return __awaiter$1(this, void 0, void 0, function* () {
2871
- const result = yield this._bridge.send("windows", operations$8.getTitle, { windowId: this.id });
2974
+ const result = yield this._bridge.send("windows", operations$9.getTitle, { windowId: this.id });
2872
2975
  return result.title;
2873
2976
  });
2874
2977
  }
2875
2978
  setTitle(title) {
2876
2979
  return __awaiter$1(this, void 0, void 0, function* () {
2877
2980
  const ttl = nonEmptyStringDecoder.runWithException(title);
2878
- yield this._bridge.send("windows", operations$8.setTitle, { windowId: this.id, title: ttl });
2981
+ yield this._bridge.send("windows", operations$9.setTitle, { windowId: this.id, title: ttl });
2879
2982
  return this.me;
2880
2983
  });
2881
2984
  }
2882
2985
  getBounds() {
2883
2986
  return __awaiter$1(this, void 0, void 0, function* () {
2884
- const result = yield this._bridge.send("windows", operations$8.getBounds, { windowId: this.id });
2987
+ const result = yield this._bridge.send("windows", operations$9.getBounds, { windowId: this.id });
2885
2988
  return result.bounds;
2886
2989
  });
2887
2990
  }
@@ -2916,7 +3019,7 @@
2916
3019
  }
2917
3020
  getChannel() {
2918
3021
  return __awaiter$1(this, void 0, void 0, function* () {
2919
- const result = yield this._bridge.send("windows", operations$8.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
3022
+ const result = yield this._bridge.send("windows", operations$9.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
2920
3023
  return result.channel;
2921
3024
  });
2922
3025
  }
@@ -3014,7 +3117,7 @@
3014
3117
  return __awaiter$1(this, void 0, void 0, function* () {
3015
3118
  yield this.platformRegistration;
3016
3119
  const operationName = windowOperationTypesDecoder.runWithException(args.operation);
3017
- const operation = operations$8[operationName];
3120
+ const operation = operations$9[operationName];
3018
3121
  if (!operation.execute) {
3019
3122
  return;
3020
3123
  }
@@ -3030,7 +3133,7 @@
3030
3133
  nonEmptyStringDecoder.runWithException(name);
3031
3134
  nonEmptyStringDecoder.runWithException(url);
3032
3135
  const settings = windowOpenSettingsDecoder.runWithException(options);
3033
- const windowSuccess = yield this.bridge.send("windows", operations$8.openWindow, { name, url, options: settings });
3136
+ const windowSuccess = yield this.bridge.send("windows", operations$9.openWindow, { name, url, options: settings });
3034
3137
  return this.waitForWindowAdded(windowSuccess.windowId);
3035
3138
  });
3036
3139
  }
@@ -3055,16 +3158,16 @@
3055
3158
  };
3056
3159
  }
3057
3160
  addWindowOperationExecutors() {
3058
- operations$8.focusChange.execute = this.handleFocusChangeEvent.bind(this);
3059
- operations$8.windowAdded.execute = this.handleWindowAdded.bind(this);
3060
- operations$8.windowRemoved.execute = this.handleWindowRemoved.bind(this);
3061
- operations$8.getBounds.execute = this.handleGetBounds.bind(this);
3062
- operations$8.getFrameBounds.execute = this.handleGetBounds.bind(this);
3063
- operations$8.getTitle.execute = this.handleGetTitle.bind(this);
3064
- operations$8.getUrl.execute = this.handleGetUrl.bind(this);
3065
- operations$8.moveResize.execute = this.handleMoveResize.bind(this);
3066
- operations$8.setTitle.execute = this.handleSetTitle.bind(this);
3067
- operations$8.getChannel.execute = this.handleGetChannel.bind(this);
3161
+ operations$9.focusChange.execute = this.handleFocusChangeEvent.bind(this);
3162
+ operations$9.windowAdded.execute = this.handleWindowAdded.bind(this);
3163
+ operations$9.windowRemoved.execute = this.handleWindowRemoved.bind(this);
3164
+ operations$9.getBounds.execute = this.handleGetBounds.bind(this);
3165
+ operations$9.getFrameBounds.execute = this.handleGetBounds.bind(this);
3166
+ operations$9.getTitle.execute = this.handleGetTitle.bind(this);
3167
+ operations$9.getUrl.execute = this.handleGetUrl.bind(this);
3168
+ operations$9.moveResize.execute = this.handleMoveResize.bind(this);
3169
+ operations$9.setTitle.execute = this.handleSetTitle.bind(this);
3170
+ operations$9.getChannel.execute = this.handleGetChannel.bind(this);
3068
3171
  }
3069
3172
  my() {
3070
3173
  return Object.assign({}, this.me);
@@ -3095,7 +3198,7 @@
3095
3198
  }
3096
3199
  sayHello() {
3097
3200
  return __awaiter$1(this, void 0, void 0, function* () {
3098
- const helloSuccess = yield this.bridge.send("windows", operations$8.windowHello, { windowId: this.publicWindowId });
3201
+ const helloSuccess = yield this.bridge.send("windows", operations$9.windowHello, { windowId: this.publicWindowId });
3099
3202
  return helloSuccess;
3100
3203
  });
3101
3204
  }
@@ -3261,7 +3364,7 @@
3261
3364
  if (this.me) {
3262
3365
  this.me.isFocused = hasFocus;
3263
3366
  }
3264
- yield this.bridge.send("windows", operations$8.focusChange, eventData);
3367
+ yield this.bridge.send("windows", operations$9.focusChange, eventData);
3265
3368
  });
3266
3369
  }
3267
3370
  defineEventListeners() {
@@ -3461,7 +3564,7 @@
3461
3564
  }
3462
3565
  }
3463
3566
 
3464
- const operations$7 = {
3567
+ const operations$8 = {
3465
3568
  appHello: { name: "appHello", dataDecoder: windowHelloDecoder, resultDecoder: appHelloSuccessDecoder },
3466
3569
  appDirectoryStateChange: { name: "appDirectoryStateChange", dataDecoder: appDirectoryStateChangeDecoder },
3467
3570
  instanceStarted: { name: "instanceStarted", dataDecoder: instanceDataDecoder },
@@ -3509,7 +3612,7 @@
3509
3612
  return __awaiter$1(this, void 0, void 0, function* () {
3510
3613
  yield this.platformRegistration;
3511
3614
  const operationName = appManagerOperationTypesDecoder.runWithException(args.operation);
3512
- const operation = operations$7[operationName];
3615
+ const operation = operations$8[operationName];
3513
3616
  if (!operation.execute) {
3514
3617
  return;
3515
3618
  }
@@ -3554,7 +3657,7 @@
3554
3657
  layoutComponentId: options === null || options === void 0 ? void 0 : options.layoutComponentId,
3555
3658
  channelId: options === null || options === void 0 ? void 0 : options.channelId
3556
3659
  };
3557
- const openResult = yield this.bridge.send("appManager", operations$7.applicationStart, startOptions);
3660
+ const openResult = yield this.bridge.send("appManager", operations$8.applicationStart, startOptions);
3558
3661
  const app = this.applications.find((a) => a.name === openResult.applicationName);
3559
3662
  return this.ioc.buildInstance(openResult, app);
3560
3663
  });
@@ -3587,9 +3690,9 @@
3587
3690
  return api;
3588
3691
  }
3589
3692
  addOperationsExecutors() {
3590
- operations$7.appDirectoryStateChange.execute = this.handleAppDirectoryStateChange.bind(this);
3591
- operations$7.instanceStarted.execute = this.handleInstanceStartedMessage.bind(this);
3592
- operations$7.instanceStopped.execute = this.handleInstanceStoppedMessage.bind(this);
3693
+ operations$8.appDirectoryStateChange.execute = this.handleAppDirectoryStateChange.bind(this);
3694
+ operations$8.instanceStarted.execute = this.handleInstanceStartedMessage.bind(this);
3695
+ operations$8.instanceStopped.execute = this.handleInstanceStoppedMessage.bind(this);
3593
3696
  }
3594
3697
  handleAppDirectoryStateChange(data) {
3595
3698
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -3706,7 +3809,7 @@
3706
3809
  return soFar;
3707
3810
  }, { valid: [], invalid: [] });
3708
3811
  const responseTimeout = this.baseApplicationsTimeoutMS + this.appImportTimeoutMS * parseResult.valid.length;
3709
- yield this.bridge.send("appManager", operations$7.import, { definitions: parseResult.valid, mode }, { methodResponseTimeoutMs: responseTimeout });
3812
+ yield this.bridge.send("appManager", operations$8.import, { definitions: parseResult.valid, mode }, { methodResponseTimeoutMs: responseTimeout });
3710
3813
  return {
3711
3814
  imported: parseResult.valid.map((valid) => valid.name),
3712
3815
  errors: parseResult.invalid
@@ -3716,17 +3819,17 @@
3716
3819
  remove(name) {
3717
3820
  return __awaiter$1(this, void 0, void 0, function* () {
3718
3821
  nonEmptyStringDecoder.runWithException(name);
3719
- yield this.bridge.send("appManager", operations$7.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3822
+ yield this.bridge.send("appManager", operations$8.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3720
3823
  });
3721
3824
  }
3722
3825
  clear() {
3723
3826
  return __awaiter$1(this, void 0, void 0, function* () {
3724
- yield this.bridge.send("appManager", operations$7.clear, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3827
+ yield this.bridge.send("appManager", operations$8.clear, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3725
3828
  });
3726
3829
  }
3727
3830
  export() {
3728
3831
  return __awaiter$1(this, void 0, void 0, function* () {
3729
- const response = yield this.bridge.send("appManager", operations$7.export, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3832
+ const response = yield this.bridge.send("appManager", operations$8.export, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3730
3833
  return response.definitions;
3731
3834
  });
3732
3835
  }
@@ -3745,7 +3848,7 @@
3745
3848
  }
3746
3849
  registerWithPlatform() {
3747
3850
  return __awaiter$1(this, void 0, void 0, function* () {
3748
- const result = yield this.bridge.send("appManager", operations$7.appHello, { windowId: this.publicWindowId }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3851
+ const result = yield this.bridge.send("appManager", operations$8.appHello, { windowId: this.publicWindowId }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3749
3852
  this.logger.trace("the platform responded to the hello message with a full list of apps");
3750
3853
  this.applications = yield Promise.all(result.apps.map((app) => this.ioc.buildApplication(app, app.instances)));
3751
3854
  this.instances = this.applications.reduce((instancesSoFar, app) => {
@@ -3798,7 +3901,7 @@
3798
3901
  }
3799
3902
  stop() {
3800
3903
  return __awaiter$1(this, void 0, void 0, function* () {
3801
- yield this.bridge.send("appManager", operations$7.instanceStop, { id: this.data.id });
3904
+ yield this.bridge.send("appManager", operations$8.instanceStop, { id: this.data.id });
3802
3905
  });
3803
3906
  }
3804
3907
  }
@@ -3854,7 +3957,7 @@
3854
3957
  }
3855
3958
  }
3856
3959
 
3857
- const operations$6 = {
3960
+ const operations$7 = {
3858
3961
  layoutAdded: { name: "layoutAdded", dataDecoder: glueLayoutDecoder },
3859
3962
  layoutChanged: { name: "layoutChanged", dataDecoder: glueLayoutDecoder },
3860
3963
  layoutRemoved: { name: "layoutRemoved", dataDecoder: glueLayoutDecoder },
@@ -3897,7 +4000,7 @@
3897
4000
  handleBridgeMessage(args) {
3898
4001
  return __awaiter$1(this, void 0, void 0, function* () {
3899
4002
  const operationName = layoutsOperationTypesDecoder.runWithException(args.operation);
3900
- const operation = operations$6[operationName];
4003
+ const operation = operations$7[operationName];
3901
4004
  if (!operation.execute) {
3902
4005
  return;
3903
4006
  }
@@ -3931,30 +4034,30 @@
3931
4034
  return Object.freeze(api);
3932
4035
  }
3933
4036
  addOperationsExecutors() {
3934
- operations$6.layoutAdded.execute = this.handleOnAdded.bind(this);
3935
- operations$6.layoutChanged.execute = this.handleOnChanged.bind(this);
3936
- operations$6.layoutRemoved.execute = this.handleOnRemoved.bind(this);
3937
- operations$6.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
4037
+ operations$7.layoutAdded.execute = this.handleOnAdded.bind(this);
4038
+ operations$7.layoutChanged.execute = this.handleOnChanged.bind(this);
4039
+ operations$7.layoutRemoved.execute = this.handleOnRemoved.bind(this);
4040
+ operations$7.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
3938
4041
  }
3939
4042
  get(name, type) {
3940
4043
  return __awaiter$1(this, void 0, void 0, function* () {
3941
4044
  nonEmptyStringDecoder.runWithException(name);
3942
4045
  layoutTypeDecoder.runWithException(type);
3943
- const result = yield this.bridge.send("layouts", operations$6.get, { name, type });
4046
+ const result = yield this.bridge.send("layouts", operations$7.get, { name, type });
3944
4047
  return result.layout;
3945
4048
  });
3946
4049
  }
3947
4050
  getAll(type) {
3948
4051
  return __awaiter$1(this, void 0, void 0, function* () {
3949
4052
  layoutTypeDecoder.runWithException(type);
3950
- const result = yield this.bridge.send("layouts", operations$6.getAll, { type });
4053
+ const result = yield this.bridge.send("layouts", operations$7.getAll, { type });
3951
4054
  return result.summaries;
3952
4055
  });
3953
4056
  }
3954
4057
  export(type) {
3955
4058
  return __awaiter$1(this, void 0, void 0, function* () {
3956
4059
  layoutTypeDecoder.runWithException(type);
3957
- const result = yield this.bridge.send("layouts", operations$6.export, { type });
4060
+ const result = yield this.bridge.send("layouts", operations$7.export, { type });
3958
4061
  return result.layouts;
3959
4062
  });
3960
4063
  }
@@ -3978,13 +4081,13 @@
3978
4081
  return soFar;
3979
4082
  }, { valid: [] });
3980
4083
  const layoutsToImport = layouts.filter((layout) => parseResult.valid.some((validLayout) => validLayout.name === layout.name));
3981
- yield this.bridge.send("layouts", operations$6.import, { layouts: layoutsToImport, mode });
4084
+ yield this.bridge.send("layouts", operations$7.import, { layouts: layoutsToImport, mode });
3982
4085
  });
3983
4086
  }
3984
4087
  save(layout) {
3985
4088
  return __awaiter$1(this, void 0, void 0, function* () {
3986
4089
  newLayoutOptionsDecoder.runWithException(layout);
3987
- const saveResult = yield this.bridge.send("layouts", operations$6.save, { layout });
4090
+ const saveResult = yield this.bridge.send("layouts", operations$7.save, { layout });
3988
4091
  return saveResult.layout;
3989
4092
  });
3990
4093
  }
@@ -3992,14 +4095,14 @@
3992
4095
  return __awaiter$1(this, void 0, void 0, function* () {
3993
4096
  restoreOptionsDecoder.runWithException(options);
3994
4097
  const invocationTimeout = options.timeout ? options.timeout * 2 : this.defaultLayoutRestoreTimeoutMS;
3995
- yield this.bridge.send("layouts", operations$6.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
4098
+ yield this.bridge.send("layouts", operations$7.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
3996
4099
  });
3997
4100
  }
3998
4101
  remove(type, name) {
3999
4102
  return __awaiter$1(this, void 0, void 0, function* () {
4000
4103
  layoutTypeDecoder.runWithException(type);
4001
4104
  nonEmptyStringDecoder.runWithException(name);
4002
- yield this.bridge.send("layouts", operations$6.remove, { type, name });
4105
+ yield this.bridge.send("layouts", operations$7.remove, { type, name });
4003
4106
  });
4004
4107
  }
4005
4108
  handleSaveRequest(config) {
@@ -4019,7 +4122,7 @@
4019
4122
  }
4020
4123
  getGlobalPermissionState() {
4021
4124
  return __awaiter$1(this, void 0, void 0, function* () {
4022
- const requestResult = yield this.bridge.send("layouts", operations$6.getGlobalPermissionState, undefined);
4125
+ const requestResult = yield this.bridge.send("layouts", operations$7.getGlobalPermissionState, undefined);
4023
4126
  return requestResult;
4024
4127
  });
4025
4128
  }
@@ -4038,43 +4141,43 @@
4038
4141
  if (myWindow.name !== "Platform" && !amIWorkspaceFrame) {
4039
4142
  throw new Error("Cannot request permission for multi-window placement from any app other than the Platform.");
4040
4143
  }
4041
- const requestResult = yield this.bridge.send("layouts", operations$6.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
4144
+ const requestResult = yield this.bridge.send("layouts", operations$7.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
4042
4145
  return { permissionGranted: requestResult.isAvailable };
4043
4146
  });
4044
4147
  }
4045
4148
  checkGlobalActivated() {
4046
4149
  return __awaiter$1(this, void 0, void 0, function* () {
4047
- const requestResult = yield this.bridge.send("layouts", operations$6.checkGlobalActivated, undefined);
4150
+ const requestResult = yield this.bridge.send("layouts", operations$7.checkGlobalActivated, undefined);
4048
4151
  return { activated: requestResult.isAvailable };
4049
4152
  });
4050
4153
  }
4051
4154
  getDefaultGlobal() {
4052
4155
  return __awaiter$1(this, void 0, void 0, function* () {
4053
- const requestResult = yield this.bridge.send("layouts", operations$6.getDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4156
+ const requestResult = yield this.bridge.send("layouts", operations$7.getDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4054
4157
  return requestResult.layout;
4055
4158
  });
4056
4159
  }
4057
4160
  setDefaultGlobal(name) {
4058
4161
  return __awaiter$1(this, void 0, void 0, function* () {
4059
4162
  nonEmptyStringDecoder.runWithException(name);
4060
- yield this.bridge.send("layouts", operations$6.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
4163
+ yield this.bridge.send("layouts", operations$7.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
4061
4164
  });
4062
4165
  }
4063
4166
  clearDefaultGlobal() {
4064
4167
  return __awaiter$1(this, void 0, void 0, function* () {
4065
- yield this.bridge.send("layouts", operations$6.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4168
+ yield this.bridge.send("layouts", operations$7.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4066
4169
  });
4067
4170
  }
4068
4171
  onAdded(callback) {
4069
4172
  this.export("Global").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
4070
4173
  this.export("Workspace").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
4071
- return this.registry.add(operations$6.layoutAdded.name, callback);
4174
+ return this.registry.add(operations$7.layoutAdded.name, callback);
4072
4175
  }
4073
4176
  onChanged(callback) {
4074
- return this.registry.add(operations$6.layoutChanged.name, callback);
4177
+ return this.registry.add(operations$7.layoutChanged.name, callback);
4075
4178
  }
4076
4179
  onRemoved(callback) {
4077
- return this.registry.add(operations$6.layoutRemoved.name, callback);
4180
+ return this.registry.add(operations$7.layoutRemoved.name, callback);
4078
4181
  }
4079
4182
  subscribeOnSaveRequested(callback) {
4080
4183
  if (typeof callback !== "function") {
@@ -4090,22 +4193,22 @@
4090
4193
  }
4091
4194
  handleOnAdded(layout) {
4092
4195
  return __awaiter$1(this, void 0, void 0, function* () {
4093
- this.registry.execute(operations$6.layoutAdded.name, layout);
4196
+ this.registry.execute(operations$7.layoutAdded.name, layout);
4094
4197
  });
4095
4198
  }
4096
4199
  handleOnChanged(layout) {
4097
4200
  return __awaiter$1(this, void 0, void 0, function* () {
4098
- this.registry.execute(operations$6.layoutChanged.name, layout);
4201
+ this.registry.execute(operations$7.layoutChanged.name, layout);
4099
4202
  });
4100
4203
  }
4101
4204
  handleOnRemoved(layout) {
4102
4205
  return __awaiter$1(this, void 0, void 0, function* () {
4103
- this.registry.execute(operations$6.layoutRemoved.name, layout);
4206
+ this.registry.execute(operations$7.layoutRemoved.name, layout);
4104
4207
  });
4105
4208
  }
4106
4209
  }
4107
4210
 
4108
- const operations$5 = {
4211
+ const operations$6 = {
4109
4212
  raiseNotification: { name: "raiseNotification", dataDecoder: raiseNotificationDecoder, resultDecoder: raiseNotificationResultDecoder },
4110
4213
  requestPermission: { name: "requestPermission", resultDecoder: permissionRequestResultDecoder },
4111
4214
  notificationShow: { name: "notificationShow", dataDecoder: notificationEventPayloadDecoder },
@@ -4116,7 +4219,14 @@
4116
4219
  notificationClosed: { name: "notificationClosed", dataDecoder: simpleNotificationSelectDecoder },
4117
4220
  click: { name: "click" },
4118
4221
  clear: { name: "clear" },
4119
- clearAll: { name: "clearAll" }
4222
+ clearAll: { name: "clearAll" },
4223
+ clearOld: { name: "clearOld" },
4224
+ configure: { name: "configure", dataDecoder: notificationsConfigurationProtocolDecoder },
4225
+ getConfiguration: { name: "getConfiguration", resultDecoder: strictNotificationsConfigurationProtocolDecoder },
4226
+ configurationChanged: { name: "configurationChanged", resultDecoder: strictNotificationsConfigurationProtocolDecoder },
4227
+ setState: { name: "setState", dataDecoder: notificationSetStateRequestDecoder },
4228
+ activeCountChange: { name: "activeCountChange", resultDecoder: activeNotificationsCountChangeDecoder },
4229
+ stateChange: { name: "stateChange", resultDecoder: notificationSetStateRequestDecoder }
4120
4230
  };
4121
4231
 
4122
4232
  var shortidExports$1 = {};
@@ -4493,7 +4603,7 @@
4493
4603
  handleBridgeMessage(args) {
4494
4604
  return __awaiter$1(this, void 0, void 0, function* () {
4495
4605
  const operationName = notificationsOperationTypesDecoder.runWithException(args.operation);
4496
- const operation = operations$5[operationName];
4606
+ const operation = operations$6[operationName];
4497
4607
  if (!operation.execute) {
4498
4608
  return;
4499
4609
  }
@@ -4514,19 +4624,28 @@
4514
4624
  onClosed: this.onClosed.bind(this),
4515
4625
  click: this.click.bind(this),
4516
4626
  clear: this.clear.bind(this),
4517
- clearAll: this.clearAll.bind(this)
4627
+ clearAll: this.clearAll.bind(this),
4628
+ clearOld: this.clearOld.bind(this),
4629
+ configure: this.configure.bind(this),
4630
+ getConfiguration: this.getConfiguration.bind(this),
4631
+ getFilter: this.getFilter.bind(this),
4632
+ setFilter: this.setFilter.bind(this),
4633
+ setState: this.setState.bind(this),
4634
+ onConfigurationChanged: this.onConfigurationChanged.bind(this),
4635
+ onActiveCountChanged: this.onActiveCountChanged.bind(this),
4636
+ onStateChanged: this.onStateChanged.bind(this)
4518
4637
  };
4519
4638
  return Object.freeze(api);
4520
4639
  }
4521
4640
  getPermission() {
4522
4641
  return __awaiter$1(this, void 0, void 0, function* () {
4523
- const queryResult = yield this.bridge.send("notifications", operations$5.getPermission, undefined);
4642
+ const queryResult = yield this.bridge.send("notifications", operations$6.getPermission, undefined);
4524
4643
  return queryResult.permission;
4525
4644
  });
4526
4645
  }
4527
4646
  requestPermission() {
4528
4647
  return __awaiter$1(this, void 0, void 0, function* () {
4529
- const permissionResult = yield this.bridge.send("notifications", operations$5.requestPermission, undefined);
4648
+ const permissionResult = yield this.bridge.send("notifications", operations$6.requestPermission, undefined);
4530
4649
  return permissionResult.permissionGranted;
4531
4650
  });
4532
4651
  }
@@ -4540,7 +4659,7 @@
4540
4659
  throw new Error("Cannot raise the notification, because the user has declined the permission request");
4541
4660
  }
4542
4661
  const id = shortidExports$1.generate();
4543
- const raiseResult = yield this.bridge.send("notifications", operations$5.raiseNotification, { settings, id });
4662
+ const raiseResult = yield this.bridge.send("notifications", operations$6.raiseNotification, { settings, id });
4544
4663
  const notification = this.buildNotificationFunc(raiseResult.settings, id);
4545
4664
  this.notifications[id] = notification;
4546
4665
  return notification;
@@ -4548,7 +4667,7 @@
4548
4667
  }
4549
4668
  list() {
4550
4669
  return __awaiter$1(this, void 0, void 0, function* () {
4551
- const bridgeResponse = yield this.bridge.send("notifications", operations$5.list, undefined, undefined, { includeOperationCheck: true });
4670
+ const bridgeResponse = yield this.bridge.send("notifications", operations$6.list, undefined, undefined, { includeOperationCheck: true });
4552
4671
  return bridgeResponse.notifications;
4553
4672
  });
4554
4673
  }
@@ -4570,25 +4689,98 @@
4570
4689
  if (action) {
4571
4690
  nonEmptyStringDecoder.runWithException(action);
4572
4691
  }
4573
- yield this.bridge.send("notifications", operations$5.click, { id, action }, undefined, { includeOperationCheck: true });
4692
+ yield this.bridge.send("notifications", operations$6.click, { id, action }, undefined, { includeOperationCheck: true });
4574
4693
  });
4575
4694
  }
4576
4695
  clear(id) {
4577
4696
  return __awaiter$1(this, void 0, void 0, function* () {
4578
4697
  nonEmptyStringDecoder.runWithException(id);
4579
- yield this.bridge.send("notifications", operations$5.clear, { id }, undefined, { includeOperationCheck: true });
4698
+ yield this.bridge.send("notifications", operations$6.clear, { id }, undefined, { includeOperationCheck: true });
4580
4699
  });
4581
4700
  }
4582
4701
  clearAll() {
4583
4702
  return __awaiter$1(this, void 0, void 0, function* () {
4584
- yield this.bridge.send("notifications", operations$5.clearAll, undefined, undefined, { includeOperationCheck: true });
4703
+ yield this.bridge.send("notifications", operations$6.clearAll, undefined, undefined, { includeOperationCheck: true });
4704
+ });
4705
+ }
4706
+ clearOld() {
4707
+ return __awaiter$1(this, void 0, void 0, function* () {
4708
+ yield this.bridge.send("notifications", operations$6.clearOld, undefined, undefined, { includeOperationCheck: true });
4709
+ });
4710
+ }
4711
+ configure(config) {
4712
+ return __awaiter$1(this, void 0, void 0, function* () {
4713
+ const verifiedConfig = notificationsConfigurationDecoder.runWithException(config);
4714
+ yield this.bridge.send("notifications", operations$6.configure, { configuration: verifiedConfig }, undefined, { includeOperationCheck: true });
4715
+ });
4716
+ }
4717
+ getConfiguration() {
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;
4721
+ });
4722
+ }
4723
+ getFilter() {
4724
+ return __awaiter$1(this, void 0, void 0, function* () {
4725
+ const response = yield this.bridge.send("notifications", operations$6.getConfiguration, undefined, undefined, { includeOperationCheck: true });
4726
+ return response.configuration.sourceFilter;
4727
+ });
4728
+ }
4729
+ setFilter(filter) {
4730
+ return __awaiter$1(this, void 0, void 0, function* () {
4731
+ const verifiedFilter = notificationFilterDecoder.runWithException(filter);
4732
+ yield this.bridge.send("notifications", operations$6.configure, { configuration: { sourceFilter: verifiedFilter } }, undefined, { includeOperationCheck: true });
4733
+ return verifiedFilter;
4585
4734
  });
4586
4735
  }
4736
+ setState(id, state) {
4737
+ return __awaiter$1(this, void 0, void 0, function* () {
4738
+ nonEmptyStringDecoder.runWithException(id);
4739
+ notificationStateDecoder.runWithException(state);
4740
+ yield this.bridge.send("notifications", operations$6.setState, { id, state }, undefined, { includeOperationCheck: true });
4741
+ });
4742
+ }
4743
+ onConfigurationChanged(callback) {
4744
+ if (typeof callback !== "function") {
4745
+ throw new Error("Cannot subscribe to configuration changed, because the provided callback is not a function!");
4746
+ }
4747
+ return this.registry.add("notifications-config-changed", callback);
4748
+ }
4749
+ onActiveCountChanged(callback) {
4750
+ if (typeof callback !== "function") {
4751
+ throw new Error("Cannot subscribe to onActiveCountChanged changed, because the provided callback is not a function!");
4752
+ }
4753
+ return this.registry.add("notifications-active-count-changed", callback);
4754
+ }
4755
+ onStateChanged(callback) {
4756
+ if (typeof callback !== "function") {
4757
+ throw new Error("Cannot subscribe to onStateChanged changed, because the provided callback is not a function!");
4758
+ }
4759
+ return this.registry.add("notification-state-changed", callback);
4760
+ }
4587
4761
  addOperationExecutors() {
4588
- operations$5.notificationShow.execute = this.handleNotificationShow.bind(this);
4589
- operations$5.notificationClick.execute = this.handleNotificationClick.bind(this);
4590
- operations$5.notificationRaised.execute = this.handleNotificationRaised.bind(this);
4591
- operations$5.notificationClosed.execute = this.handleNotificationClosed.bind(this);
4762
+ operations$6.notificationShow.execute = this.handleNotificationShow.bind(this);
4763
+ operations$6.notificationClick.execute = this.handleNotificationClick.bind(this);
4764
+ operations$6.notificationRaised.execute = this.handleNotificationRaised.bind(this);
4765
+ operations$6.notificationClosed.execute = this.handleNotificationClosed.bind(this);
4766
+ operations$6.configurationChanged.execute = this.handleConfigurationChanged.bind(this);
4767
+ operations$6.activeCountChange.execute = this.handleActiveCountChanged.bind(this);
4768
+ operations$6.stateChange.execute = this.handleNotificationStateChanged.bind(this);
4769
+ }
4770
+ handleConfigurationChanged(data) {
4771
+ return __awaiter$1(this, void 0, void 0, function* () {
4772
+ this.registry.execute("notifications-config-changed", data.configuration);
4773
+ });
4774
+ }
4775
+ handleActiveCountChanged(data) {
4776
+ return __awaiter$1(this, void 0, void 0, function* () {
4777
+ this.registry.execute("notifications-active-count-changed", data);
4778
+ });
4779
+ }
4780
+ handleNotificationStateChanged(data) {
4781
+ return __awaiter$1(this, void 0, void 0, function* () {
4782
+ this.registry.execute("notification-state-changed", { id: data.id }, data.state);
4783
+ });
4592
4784
  }
4593
4785
  handleNotificationShow(data) {
4594
4786
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -4633,21 +4825,24 @@
4633
4825
  }
4634
4826
  }
4635
4827
 
4636
- const operations$4 = {
4828
+ const operations$5 = {
4637
4829
  getIntents: { name: "getIntents", resultDecoder: wrappedIntentsDecoder },
4638
4830
  findIntent: { name: "findIntent", dataDecoder: wrappedIntentFilterDecoder, resultDecoder: wrappedIntentsDecoder },
4639
4831
  raiseIntent: { name: "raiseIntent", dataDecoder: intentRequestDecoder, resultDecoder: intentResultDecoder },
4640
4832
  raise: { name: "raise", dataDecoder: raiseIntentRequestDecoder, resultDecoder: intentResultDecoder },
4833
+ filterHandlers: { name: "filterHandlers", dataDecoder: filterHandlersWithResolverConfigDecoder, resultDecoder: filterHandlersResultDecoder },
4834
+ getIntentsByHandler: { name: "getIntentsByHandler", dataDecoder: intentHandlerDecoder, resultDecoder: getIntentsResultDecoder }
4641
4835
  };
4642
4836
 
4643
4837
  const GLUE42_FDC3_INTENTS_METHOD_PREFIX = "Tick42.FDC3.Intents.";
4644
4838
  const INTENTS_RESOLVER_INTEROP_PREFIX = "T42.Intents.Resolver.Control.";
4645
4839
  const INTENTS_RESOLVER_APP_NAME = "intentsResolver";
4646
- const DEFAULT_RESOLVER_RESPONSE_TIMEOUT = 60000;
4647
- const ADDITIONAL_BRIDGE_OPERATION_TIMEOUT = 30000;
4840
+ const DEFAULT_RESOLVER_RESPONSE_TIMEOUT = 60 * 1000;
4841
+ const ADDITIONAL_BRIDGE_OPERATION_TIMEOUT = 30 * 1000;
4648
4842
  const INTENTS_RESOLVER_WIDTH = 400;
4649
4843
  const INTENTS_RESOLVER_HEIGHT = 440;
4650
- const MAX_SET_TIMEOUT_DELAY = 2147483647;
4844
+ const MAX_SET_TIMEOUT_DELAY = 2147483647;
4845
+ const DEFAULT_PICK_HANDLER_BY_TIMEOUT = 90 * 1000;
4651
4846
 
4652
4847
  class IntentsController {
4653
4848
  constructor() {
@@ -4675,7 +4870,7 @@
4675
4870
  handleBridgeMessage(args) {
4676
4871
  return __awaiter$1(this, void 0, void 0, function* () {
4677
4872
  const operationName = intentsOperationTypesDecoder.runWithException(args.operation);
4678
- const operation = operations$4[operationName];
4873
+ const operation = operations$5[operationName];
4679
4874
  if (!operation.execute) {
4680
4875
  return;
4681
4876
  }
@@ -4692,7 +4887,9 @@
4692
4887
  all: this.all.bind(this),
4693
4888
  addIntentListener: this.addIntentListener.bind(this),
4694
4889
  register: this.register.bind(this),
4695
- find: this.find.bind(this)
4890
+ find: this.find.bind(this),
4891
+ filterHandlers: this.filterHandlers.bind(this),
4892
+ getIntents: this.getIntentsByHandler.bind(this)
4696
4893
  };
4697
4894
  return api;
4698
4895
  }
@@ -4703,7 +4900,7 @@
4703
4900
  ? { intent: validatedIntentRequest }
4704
4901
  : validatedIntentRequest;
4705
4902
  yield Promise.all(this.unregisterIntentPromises);
4706
- const requestWithResolverInfo = this.buildIntentRequestWithResolverInfo(intentRequest);
4903
+ const requestWithResolverInfo = { intentRequest, resolverConfig: this.getResolverConfigByRequest({ intentRequest }) };
4707
4904
  const isRaiseOperationSupported = yield this.isRaiseOperationSupported();
4708
4905
  if (!isRaiseOperationSupported.supported) {
4709
4906
  this.logger.warn(`${isRaiseOperationSupported.reason}. Invoking legacy raise method`);
@@ -4713,18 +4910,24 @@
4713
4910
  const methodResponseTimeoutMs = intentRequest.waitUserResponseIndefinitely
4714
4911
  ? MAX_SET_TIMEOUT_DELAY
4715
4912
  : (intentRequest.timeout || this.intentResolverResponseTimeout) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
4716
- const response = yield this.bridge.send("intents", operations$4.raise, requestWithResolverInfo, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs });
4913
+ const response = yield this.bridge.send("intents", operations$5.raise, requestWithResolverInfo, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs });
4717
4914
  return response;
4718
4915
  });
4719
4916
  }
4720
- buildIntentRequestWithResolverInfo(request) {
4721
- return {
4722
- intentRequest: request,
4723
- resolverConfig: {
4724
- enabled: this.useIntentsResolverUI,
4917
+ getResolverConfigByRequest(filter) {
4918
+ var _a, _b, _c, _d;
4919
+ if (filter.handlerFilter) {
4920
+ return {
4921
+ 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,
4725
4922
  appName: this.intentsResolverAppName,
4726
- waitResponseTimeout: request.waitUserResponseIndefinitely ? MAX_SET_TIMEOUT_DELAY : this.intentResolverResponseTimeout
4727
- }
4923
+ waitResponseTimeout: ((_c = filter.handlerFilter) === null || _c === void 0 ? void 0 : _c.timeout) || DEFAULT_PICK_HANDLER_BY_TIMEOUT
4924
+ };
4925
+ }
4926
+ const waitResponseTimeout = ((_d = filter.intentRequest) === null || _d === void 0 ? void 0 : _d.waitUserResponseIndefinitely) ? MAX_SET_TIMEOUT_DELAY : this.intentResolverResponseTimeout;
4927
+ return {
4928
+ enabled: this.useIntentsResolverUI,
4929
+ appName: this.intentsResolverAppName,
4930
+ waitResponseTimeout
4728
4931
  };
4729
4932
  }
4730
4933
  isRaiseOperationSupported() {
@@ -4747,7 +4950,7 @@
4747
4950
  all() {
4748
4951
  return __awaiter$1(this, void 0, void 0, function* () {
4749
4952
  yield Promise.all(this.unregisterIntentPromises);
4750
- const result = yield this.bridge.send("intents", operations$4.getIntents, undefined);
4953
+ const result = yield this.bridge.send("intents", operations$5.getIntents, undefined);
4751
4954
  return result.intents;
4752
4955
  });
4753
4956
  }
@@ -4845,7 +5048,7 @@
4845
5048
  }
4846
5049
  }
4847
5050
  yield Promise.all(this.unregisterIntentPromises);
4848
- const result = yield this.bridge.send("intents", operations$4.findIntent, data);
5051
+ const result = yield this.bridge.send("intents", operations$5.findIntent, data);
4849
5052
  return result.intents;
4850
5053
  });
4851
5054
  }
@@ -4877,6 +5080,38 @@
4877
5080
  this.clearUnregistrationPromise(unregisterPromise);
4878
5081
  });
4879
5082
  }
5083
+ filterHandlers(handlerFilter) {
5084
+ return __awaiter$1(this, void 0, void 0, function* () {
5085
+ handlersFilterDecoder.runWithException(handlerFilter);
5086
+ this.checkIfAtLeastOneFilterIsPresent(handlerFilter);
5087
+ if (handlerFilter.openResolver && !this.useIntentsResolverUI) {
5088
+ throw new Error("Cannot resolve 'filterHandlers' request using Intents Resolver UI because it's globally disabled");
5089
+ }
5090
+ const methodResponseTimeoutMs = (handlerFilter.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
5091
+ const filterHandlersRequestWithResolverConfig = { filterHandlersRequest: handlerFilter, resolverConfig: this.getResolverConfigByRequest({ handlerFilter }) };
5092
+ const result = yield this.bridge.send("intents", operations$5.filterHandlers, filterHandlersRequestWithResolverConfig, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs }, { includeOperationCheck: true });
5093
+ return result;
5094
+ });
5095
+ }
5096
+ checkIfAtLeastOneFilterIsPresent(filter) {
5097
+ const errorMsg = "Provide at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'";
5098
+ if (!Object.keys(filter).length) {
5099
+ throw new Error(errorMsg);
5100
+ }
5101
+ const { intent, resultType, contextTypes, applicationNames } = filter;
5102
+ const existingValidContextTypes = contextTypes === null || contextTypes === void 0 ? void 0 : contextTypes.length;
5103
+ const existingValidApplicationNames = applicationNames === null || applicationNames === void 0 ? void 0 : applicationNames.length;
5104
+ if (!intent && !resultType && !existingValidContextTypes && !existingValidApplicationNames) {
5105
+ throw new Error(errorMsg);
5106
+ }
5107
+ }
5108
+ getIntentsByHandler(handler) {
5109
+ return __awaiter$1(this, void 0, void 0, function* () {
5110
+ intentHandlerDecoder.runWithException(handler);
5111
+ const result = yield this.bridge.send("intents", operations$5.getIntentsByHandler, handler, undefined, { includeOperationCheck: true });
5112
+ return result;
5113
+ });
5114
+ }
4880
5115
  }
4881
5116
 
4882
5117
  const Glue42CoreMessageTypes = {
@@ -4893,7 +5128,7 @@
4893
5128
  const webPlatformTransportName = "web-platform";
4894
5129
  const latestFDC3Type = "latest_fdc3_type";
4895
5130
 
4896
- const operations$3 = {
5131
+ const operations$4 = {
4897
5132
  addChannel: { name: "addChannel", dataDecoder: channelContextDecoder },
4898
5133
  getMyChannel: { name: "getMyChannel", resultDecoder: getMyChanelResultDecoder },
4899
5134
  getWindowIdsOnChannel: { name: "getWindowIdsOnChannel", dataDecoder: getWindowIdsOnChannelDataDecoder, resultDecoder: getWindowIdsOnChannelResultDecoder },
@@ -4930,8 +5165,8 @@
4930
5165
  this.registry.clear();
4931
5166
  }
4932
5167
  addOperationsExecutors() {
4933
- operations$3.getMyChannel.execute = this.handleGetMyChannel.bind(this);
4934
- operations$3.joinChannel.execute = this.handleJoinChannel.bind(this);
5168
+ operations$4.getMyChannel.execute = this.handleGetMyChannel.bind(this);
5169
+ operations$4.joinChannel.execute = this.handleJoinChannel.bind(this);
4935
5170
  }
4936
5171
  start(coreGlue, ioc) {
4937
5172
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -4950,7 +5185,7 @@
4950
5185
  handleBridgeMessage(args) {
4951
5186
  return __awaiter$1(this, void 0, void 0, function* () {
4952
5187
  const operationName = channelsOperationTypesDecoder.runWithException(args.operation);
4953
- const operation = operations$3[operationName];
5188
+ const operation = operations$4[operationName];
4954
5189
  if (!operation.execute) {
4955
5190
  return;
4956
5191
  }
@@ -4986,7 +5221,7 @@
4986
5221
  yield this.switchToChannel(name);
4987
5222
  }
4988
5223
  else {
4989
- yield this.bridge.send("channels", operations$3.joinChannel, { channel: name, windowId }, undefined, { includeOperationCheck: true });
5224
+ yield this.bridge.send("channels", operations$4.joinChannel, { channel: name, windowId }, undefined, { includeOperationCheck: true });
4990
5225
  }
4991
5226
  });
4992
5227
  }
@@ -5157,7 +5392,7 @@
5157
5392
  if (channelWithSuchNameExists) {
5158
5393
  throw new Error("There's an already existing channel with such name");
5159
5394
  }
5160
- yield this.bridge.send("channels", operations$3.addChannel, channelContext);
5395
+ yield this.bridge.send("channels", operations$4.addChannel, channelContext);
5161
5396
  return channelContext;
5162
5397
  });
5163
5398
  }
@@ -5173,7 +5408,7 @@
5173
5408
  return __awaiter$1(this, void 0, void 0, function* () {
5174
5409
  const channelNames = this.getAllChannelNames();
5175
5410
  channelNameDecoder(channelNames).runWithException(channel);
5176
- const { windowIds } = yield this.bridge.send("channels", operations$3.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
5411
+ const { windowIds } = yield this.bridge.send("channels", operations$4.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
5177
5412
  const result = windowIds.reduce((windows, windowId) => {
5178
5413
  const window = this.windowsController.findById(windowId);
5179
5414
  return window ? [...windows, window] : windows;
@@ -5186,7 +5421,7 @@
5186
5421
  const operationData = filter !== undefined
5187
5422
  ? { filter: windowWithChannelFilterDecoder.runWithException(filter) }
5188
5423
  : {};
5189
- const { windowIdsWithChannels } = yield this.bridge.send("channels", operations$3.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
5424
+ const { windowIdsWithChannels } = yield this.bridge.send("channels", operations$4.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
5190
5425
  const result = windowIdsWithChannels.reduce((windowsWithChannels, { application, channel, windowId }) => {
5191
5426
  const window = this.windowsController.findById(windowId);
5192
5427
  return window ? [...windowsWithChannels, { application, channel, window }] : windowsWithChannels;
@@ -5196,7 +5431,7 @@
5196
5431
  }
5197
5432
  }
5198
5433
 
5199
- const operations$2 = {
5434
+ const operations$3 = {
5200
5435
  getEnvironment: { name: "getEnvironment", resultDecoder: anyDecoder },
5201
5436
  getBase: { name: "getBase", resultDecoder: anyDecoder },
5202
5437
  platformShutdown: { name: "platformShutdown" }
@@ -5214,7 +5449,7 @@
5214
5449
  handleBridgeMessage(args) {
5215
5450
  return __awaiter$1(this, void 0, void 0, function* () {
5216
5451
  const operationName = systemOperationTypesDecoder.runWithException(args.operation);
5217
- const operation = operations$2[operationName];
5452
+ const operation = operations$3[operationName];
5218
5453
  if (!operation.execute) {
5219
5454
  return;
5220
5455
  }
@@ -5235,8 +5470,8 @@
5235
5470
  }
5236
5471
  setEnvironment() {
5237
5472
  return __awaiter$1(this, void 0, void 0, function* () {
5238
- const environment = yield this.bridge.send("system", operations$2.getEnvironment, undefined);
5239
- const base = yield this.bridge.send("system", operations$2.getBase, undefined);
5473
+ const environment = yield this.bridge.send("system", operations$3.getEnvironment, undefined);
5474
+ const base = yield this.bridge.send("system", operations$3.getBase, undefined);
5240
5475
  const globalNamespace = window.glue42core || window.iobrowser;
5241
5476
  const globalNamespaceName = window.glue42core ? "glue42core" : "iobrowser";
5242
5477
  const globalObj = Object.assign({}, globalNamespace, base, { environment });
@@ -5244,7 +5479,7 @@
5244
5479
  });
5245
5480
  }
5246
5481
  addOperationsExecutors() {
5247
- operations$2.platformShutdown.execute = this.processPlatformShutdown.bind(this);
5482
+ operations$3.platformShutdown.execute = this.processPlatformShutdown.bind(this);
5248
5483
  }
5249
5484
  }
5250
5485
 
@@ -5273,6 +5508,7 @@
5273
5508
  this.severity = config.severity;
5274
5509
  this.showToast = config.showToast;
5275
5510
  this.showInPanel = config.showInPanel;
5511
+ this.state = config.state;
5276
5512
  }
5277
5513
  }
5278
5514
 
@@ -5283,7 +5519,7 @@
5283
5519
  })
5284
5520
  });
5285
5521
 
5286
- const operations$1 = {
5522
+ const operations$2 = {
5287
5523
  clientHello: { name: "clientHello", resultDecoder: extensionConfigDecoder }
5288
5524
  };
5289
5525
 
@@ -5341,7 +5577,7 @@
5341
5577
  registerWithPlatform() {
5342
5578
  return __awaiter$1(this, void 0, void 0, function* () {
5343
5579
  this.logger.trace("registering with the platform");
5344
- this.config = yield this.bridge.send("extension", operations$1.clientHello, { windowId: this.windowId });
5580
+ this.config = yield this.bridge.send("extension", operations$2.clientHello, { windowId: this.windowId });
5345
5581
  this.logger.trace("the platform responded to the hello message with a valid extension config");
5346
5582
  });
5347
5583
  }
@@ -5687,7 +5923,7 @@
5687
5923
  });
5688
5924
  }
5689
5925
  invokeRaiseIntent(requestObj) {
5690
- return this.bridge.send("intents", operations$4.raiseIntent, requestObj);
5926
+ return this.bridge.send("intents", operations$5.raiseIntent, requestObj);
5691
5927
  }
5692
5928
  registerResponseMethod() {
5693
5929
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -5847,7 +6083,7 @@
5847
6083
  }
5848
6084
  }
5849
6085
 
5850
- const operations = {
6086
+ const operations$1 = {
5851
6087
  getCurrent: { name: "getCurrent", resultDecoder: simpleThemeResponseDecoder },
5852
6088
  list: { name: "list", resultDecoder: allThemesResponseDecoder },
5853
6089
  select: { name: "select", dataDecoder: selectThemeConfigDecoder }
@@ -5890,20 +6126,20 @@
5890
6126
  }
5891
6127
  getCurrent() {
5892
6128
  return __awaiter$1(this, void 0, void 0, function* () {
5893
- const bridgeResponse = yield this.bridge.send("themes", operations.getCurrent, undefined, undefined, { includeOperationCheck: true });
6129
+ const bridgeResponse = yield this.bridge.send("themes", operations$1.getCurrent, undefined, undefined, { includeOperationCheck: true });
5894
6130
  return bridgeResponse.theme;
5895
6131
  });
5896
6132
  }
5897
6133
  list() {
5898
6134
  return __awaiter$1(this, void 0, void 0, function* () {
5899
- const bridgeResponse = yield this.bridge.send("themes", operations.list, undefined, undefined, { includeOperationCheck: true });
6135
+ const bridgeResponse = yield this.bridge.send("themes", operations$1.list, undefined, undefined, { includeOperationCheck: true });
5900
6136
  return bridgeResponse.themes;
5901
6137
  });
5902
6138
  }
5903
6139
  select(name) {
5904
6140
  return __awaiter$1(this, void 0, void 0, function* () {
5905
6141
  nonEmptyStringDecoder.runWithException(name);
5906
- yield this.bridge.send("themes", operations.select, { name }, undefined, { includeOperationCheck: true });
6142
+ yield this.bridge.send("themes", operations$1.select, { name }, undefined, { includeOperationCheck: true });
5907
6143
  });
5908
6144
  }
5909
6145
  onChanged(callback) {
@@ -5985,6 +6221,175 @@
5985
6221
  }
5986
6222
  }
5987
6223
 
6224
+ const operations = {
6225
+ clear: { name: "clear", dataDecoder: basePrefsConfigDecoder },
6226
+ clearAll: { name: "clearAll" },
6227
+ get: { name: "get", dataDecoder: basePrefsConfigDecoder, resultDecoder: getPrefsResultDecoder },
6228
+ getAll: { name: "getAll", resultDecoder: getAllPrefsResultDecoder },
6229
+ set: { name: "set", dataDecoder: changePrefsDataDecoder },
6230
+ update: { name: "update", dataDecoder: changePrefsDataDecoder },
6231
+ prefsChanged: { name: "prefsChanged", dataDecoder: getPrefsResultDecoder },
6232
+ prefsHello: { name: "prefsHello", resultDecoder: prefsHelloSuccessDecoder },
6233
+ };
6234
+
6235
+ class PrefsController {
6236
+ constructor() {
6237
+ this.registry = lib$3();
6238
+ }
6239
+ handlePlatformShutdown() {
6240
+ this.registry.clear();
6241
+ }
6242
+ start(coreGlue, ioc) {
6243
+ return __awaiter$1(this, void 0, void 0, function* () {
6244
+ this.logger = coreGlue.logger.subLogger("prefs.controller.web");
6245
+ this.logger.trace("starting the web prefs controller");
6246
+ this.addOperationsExecutors();
6247
+ this.bridge = ioc.bridge;
6248
+ this.config = ioc.config;
6249
+ this.appManagerController = ioc.appManagerController;
6250
+ try {
6251
+ const prefsHelloSuccess = yield this.bridge.send("prefs", operations.prefsHello, undefined, undefined, { includeOperationCheck: true });
6252
+ this.platformAppName = prefsHelloSuccess.platform.app;
6253
+ }
6254
+ catch (error) {
6255
+ this.logger.warn("The platform of this client is outdated and does not support Prefs API.");
6256
+ return;
6257
+ }
6258
+ this.logger.trace("no need for platform registration, attaching the prefs property to glue and returning");
6259
+ const api = this.toApi();
6260
+ coreGlue.prefs = api;
6261
+ });
6262
+ }
6263
+ handleBridgeMessage(args) {
6264
+ return __awaiter$1(this, void 0, void 0, function* () {
6265
+ const operationName = prefsOperationTypesDecoder.runWithException(args.operation);
6266
+ const operation = operations[operationName];
6267
+ if (!operation.execute) {
6268
+ return;
6269
+ }
6270
+ let operationData = args.data;
6271
+ if (operation.dataDecoder) {
6272
+ operationData = operation.dataDecoder.runWithException(args.data);
6273
+ }
6274
+ return yield operation.execute(operationData);
6275
+ });
6276
+ }
6277
+ addOperationsExecutors() {
6278
+ operations.prefsChanged.execute = this.handleOnChanged.bind(this);
6279
+ }
6280
+ toApi() {
6281
+ const api = {
6282
+ clear: this.clear.bind(this),
6283
+ clearAll: this.clearAll.bind(this),
6284
+ clearFor: this.clearFor.bind(this),
6285
+ get: this.get.bind(this),
6286
+ getAll: this.getAll.bind(this),
6287
+ set: this.set.bind(this),
6288
+ setFor: this.setFor.bind(this),
6289
+ subscribe: this.subscribe.bind(this),
6290
+ subscribeFor: this.subscribeFor.bind(this),
6291
+ update: this.update.bind(this),
6292
+ updateFor: this.updateFor.bind(this),
6293
+ };
6294
+ return api;
6295
+ }
6296
+ clear() {
6297
+ return __awaiter$1(this, void 0, void 0, function* () {
6298
+ const app = this.getMyAppName();
6299
+ yield this.clearFor(app);
6300
+ });
6301
+ }
6302
+ clearAll() {
6303
+ return __awaiter$1(this, void 0, void 0, function* () {
6304
+ yield this.bridge.send("prefs", operations.clearAll, undefined, undefined, { includeOperationCheck: true });
6305
+ });
6306
+ }
6307
+ clearFor(app) {
6308
+ return __awaiter$1(this, void 0, void 0, function* () {
6309
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6310
+ yield this.bridge.send("prefs", operations.clear, { app: verifiedApp }, undefined, { includeOperationCheck: true });
6311
+ });
6312
+ }
6313
+ get(app) {
6314
+ return __awaiter$1(this, void 0, void 0, function* () {
6315
+ const verifiedApp = app === undefined || app === null ? this.getMyAppName() : nonEmptyStringDecoder.runWithException(app);
6316
+ const { prefs } = yield this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
6317
+ return prefs;
6318
+ });
6319
+ }
6320
+ getAll() {
6321
+ return __awaiter$1(this, void 0, void 0, function* () {
6322
+ const result = yield this.bridge.send("prefs", operations.getAll, undefined, undefined, { includeOperationCheck: true });
6323
+ return result;
6324
+ });
6325
+ }
6326
+ set(data, options) {
6327
+ var _a;
6328
+ return __awaiter$1(this, void 0, void 0, function* () {
6329
+ const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
6330
+ const app = (_a = verifiedOptions === null || verifiedOptions === void 0 ? void 0 : verifiedOptions.app) !== null && _a !== void 0 ? _a : this.getMyAppName();
6331
+ yield this.setFor(app, data);
6332
+ });
6333
+ }
6334
+ setFor(app, data) {
6335
+ return __awaiter$1(this, void 0, void 0, function* () {
6336
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6337
+ const verifiedData = object$1().runWithException(data);
6338
+ yield this.bridge.send("prefs", operations.set, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
6339
+ });
6340
+ }
6341
+ subscribe(callback) {
6342
+ const app = this.getMyAppName();
6343
+ return this.subscribeFor(app, callback);
6344
+ }
6345
+ subscribeFor(app, callback) {
6346
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6347
+ const applications = this.appManagerController.getApplications();
6348
+ const isValidApp = verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp);
6349
+ if (!isValidApp) {
6350
+ throw new Error(`The provided app name "${app}" is not valid.`);
6351
+ }
6352
+ if (typeof callback !== "function") {
6353
+ throw new Error("Cannot subscribe to prefs, because the provided callback is not a function!");
6354
+ }
6355
+ const subscriptionKey = this.getSubscriptionKey(verifiedApp);
6356
+ this.get(verifiedApp).then(callback);
6357
+ return this.registry.add(subscriptionKey, callback);
6358
+ }
6359
+ update(data, options) {
6360
+ var _a;
6361
+ return __awaiter$1(this, void 0, void 0, function* () {
6362
+ const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
6363
+ const app = (_a = verifiedOptions === null || verifiedOptions === void 0 ? void 0 : verifiedOptions.app) !== null && _a !== void 0 ? _a : this.getMyAppName();
6364
+ yield this.updateFor(app, data);
6365
+ });
6366
+ }
6367
+ updateFor(app, data) {
6368
+ return __awaiter$1(this, void 0, void 0, function* () {
6369
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6370
+ const verifiedData = object$1().runWithException(data);
6371
+ yield this.bridge.send("prefs", operations.update, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
6372
+ });
6373
+ }
6374
+ getMyAppName() {
6375
+ var _a;
6376
+ const myAppName = this.config.isPlatformInternal ? this.platformAppName : (_a = this.appManagerController.me) === null || _a === void 0 ? void 0 : _a.application.name;
6377
+ if (!myAppName) {
6378
+ throw new Error("App Preferences operations can not be executed for windows that do not have app!");
6379
+ }
6380
+ return myAppName;
6381
+ }
6382
+ getSubscriptionKey(app) {
6383
+ return `prefs-changed-${app}`;
6384
+ }
6385
+ handleOnChanged({ prefs }) {
6386
+ return __awaiter$1(this, void 0, void 0, function* () {
6387
+ const subscriptionKey = this.getSubscriptionKey(prefs.app);
6388
+ this.registry.execute(subscriptionKey, prefs);
6389
+ });
6390
+ }
6391
+ }
6392
+
5988
6393
  class IoC {
5989
6394
  constructor() {
5990
6395
  this.controllers = {
@@ -5996,7 +6401,8 @@
5996
6401
  channels: this.channelsController,
5997
6402
  system: this.systemController,
5998
6403
  extension: this.extensionController,
5999
- themes: this.themesController
6404
+ themes: this.themesController,
6405
+ prefs: this.prefsController
6000
6406
  };
6001
6407
  }
6002
6408
  get communicationId() {
@@ -6059,6 +6465,12 @@
6059
6465
  }
6060
6466
  return this._channelsControllerInstance;
6061
6467
  }
6468
+ get prefsController() {
6469
+ if (!this._prefsControllerInstance) {
6470
+ this._prefsControllerInstance = new PrefsController();
6471
+ }
6472
+ return this._prefsControllerInstance;
6473
+ }
6062
6474
  get extensionController() {
6063
6475
  if (!this._extensionController) {
6064
6476
  this._extensionController = new ExtController();
@@ -6124,7 +6536,7 @@
6124
6536
  }
6125
6537
  }
6126
6538
 
6127
- var version$2 = "3.1.3";
6539
+ var version$2 = "3.2.1";
6128
6540
 
6129
6541
  const createFactoryFunction = (coreFactoryFunction) => {
6130
6542
  return (userConfig) => __awaiter$1(void 0, void 0, void 0, function* () {
@@ -7469,6 +7881,7 @@
7469
7881
  return __generator(this, function (_b) {
7470
7882
  switch (_b.label) {
7471
7883
  case 0:
7884
+ this.logger.info("opening ws to ".concat(this.settings.ws, ", retryInterval: ").concat(retryInterval, ", retriesLeft: ").concat(retriesLeft, "..."));
7472
7885
  this.startupTimer.mark("opening-socket");
7473
7886
  if (retryInterval === undefined) {
7474
7887
  retryInterval = this.settings.reconnectInterval;
@@ -7506,9 +7919,10 @@
7506
7919
  };
7507
7920
  WS.prototype.initiateSocket = function () {
7508
7921
  var _this = this;
7922
+ var _a;
7509
7923
  var pw = new PromiseWrapper();
7510
7924
  this.logger.debug("initiating ws to ".concat(this.settings.ws, "..."));
7511
- this.ws = new WebSocketConstructor(this.settings.ws || "");
7925
+ this.ws = new WebSocketConstructor((_a = this.settings.ws) !== null && _a !== void 0 ? _a : "");
7512
7926
  this.ws.onerror = function (err) {
7513
7927
  var reason = "";
7514
7928
  try {
@@ -7527,11 +7941,12 @@
7527
7941
  };
7528
7942
  reason = JSON.stringify(err, replacer);
7529
7943
  }
7944
+ _this.logger.info("ws error - reason: ".concat(reason));
7530
7945
  pw.reject("error");
7531
7946
  _this.notifyStatusChanged(false, reason);
7532
7947
  };
7533
7948
  this.ws.onclose = function (err) {
7534
- _this.logger.info("ws closed ".concat(err));
7949
+ _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));
7535
7950
  pw.reject("closed");
7536
7951
  _this.notifyStatusChanged(false);
7537
7952
  };
@@ -7566,47 +7981,121 @@
7566
7981
  return WS;
7567
7982
  }());
7568
7983
 
7569
- var shortidExports = {};
7570
- var shortid$1 = {
7571
- get exports(){ return shortidExports; },
7572
- set exports(v){ shortidExports = v; },
7573
- };
7574
-
7575
- var libExports = {};
7576
- var lib = {
7577
- get exports(){ return libExports; },
7578
- set exports(v){ libExports = v; },
7579
- };
7580
-
7581
- // Found this seed-based random generator somewhere
7582
- // Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
7583
-
7584
- var seed = 1;
7585
-
7586
- /**
7587
- * return a random number based on a seed
7588
- * @param seed
7589
- * @returns {number}
7590
- */
7591
- function getNextValue() {
7592
- seed = (seed * 9301 + 49297) % 233280;
7593
- return seed/(233280.0);
7594
- }
7595
-
7596
- function setSeed$1(_seed_) {
7597
- seed = _seed_;
7598
- }
7599
-
7600
- var randomFromSeed$1 = {
7601
- nextValue: getNextValue,
7602
- seed: setSeed$1
7603
- };
7604
-
7605
- var randomFromSeed = randomFromSeed$1;
7606
-
7607
- var ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
7608
- var alphabet$2;
7609
- var previousSeed;
7984
+ var MessageReplayerImpl = (function () {
7985
+ function MessageReplayerImpl(specs) {
7986
+ this.specsNames = [];
7987
+ this.messages = {};
7988
+ this.subs = {};
7989
+ this.subsRefCount = {};
7990
+ this.specs = {};
7991
+ for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
7992
+ var spec = specs_1[_i];
7993
+ this.specs[spec.name] = spec;
7994
+ this.specsNames.push(spec.name);
7995
+ }
7996
+ }
7997
+ MessageReplayerImpl.prototype.init = function (connection) {
7998
+ var _this = this;
7999
+ this.connection = connection;
8000
+ for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
8001
+ var name_1 = _a[_i];
8002
+ var _loop_1 = function (type) {
8003
+ var refCount = this_1.subsRefCount[type];
8004
+ if (!refCount) {
8005
+ refCount = 0;
8006
+ }
8007
+ refCount += 1;
8008
+ this_1.subsRefCount[type] = refCount;
8009
+ if (refCount > 1) {
8010
+ return "continue";
8011
+ }
8012
+ var sub = connection.on(type, function (msg) { return _this.processMessage(type, msg); });
8013
+ this_1.subs[type] = sub;
8014
+ };
8015
+ var this_1 = this;
8016
+ for (var _b = 0, _c = this.specs[name_1].types; _b < _c.length; _b++) {
8017
+ var type = _c[_b];
8018
+ _loop_1(type);
8019
+ }
8020
+ }
8021
+ };
8022
+ MessageReplayerImpl.prototype.processMessage = function (type, msg) {
8023
+ if (this.isDone || !msg) {
8024
+ return;
8025
+ }
8026
+ for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
8027
+ var name_2 = _a[_i];
8028
+ if (this.specs[name_2].types.indexOf(type) !== -1) {
8029
+ var messages = this.messages[name_2] || [];
8030
+ this.messages[name_2] = messages;
8031
+ messages.push(msg);
8032
+ }
8033
+ }
8034
+ };
8035
+ MessageReplayerImpl.prototype.drain = function (name, callback) {
8036
+ var _a;
8037
+ if (callback) {
8038
+ (this.messages[name] || []).forEach(callback);
8039
+ }
8040
+ delete this.messages[name];
8041
+ for (var _i = 0, _b = this.specs[name].types; _i < _b.length; _i++) {
8042
+ var type = _b[_i];
8043
+ this.subsRefCount[type] -= 1;
8044
+ if (this.subsRefCount[type] <= 0) {
8045
+ (_a = this.connection) === null || _a === void 0 ? void 0 : _a.off(this.subs[type]);
8046
+ delete this.subs[type];
8047
+ delete this.subsRefCount[type];
8048
+ }
8049
+ }
8050
+ delete this.specs[name];
8051
+ if (!this.specs.length) {
8052
+ this.isDone = true;
8053
+ }
8054
+ };
8055
+ return MessageReplayerImpl;
8056
+ }());
8057
+
8058
+ var shortidExports = {};
8059
+ var shortid$1 = {
8060
+ get exports(){ return shortidExports; },
8061
+ set exports(v){ shortidExports = v; },
8062
+ };
8063
+
8064
+ var libExports = {};
8065
+ var lib = {
8066
+ get exports(){ return libExports; },
8067
+ set exports(v){ libExports = v; },
8068
+ };
8069
+
8070
+ // Found this seed-based random generator somewhere
8071
+ // Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
8072
+
8073
+ var seed = 1;
8074
+
8075
+ /**
8076
+ * return a random number based on a seed
8077
+ * @param seed
8078
+ * @returns {number}
8079
+ */
8080
+ function getNextValue() {
8081
+ seed = (seed * 9301 + 49297) % 233280;
8082
+ return seed/(233280.0);
8083
+ }
8084
+
8085
+ function setSeed$1(_seed_) {
8086
+ seed = _seed_;
8087
+ }
8088
+
8089
+ var randomFromSeed$1 = {
8090
+ nextValue: getNextValue,
8091
+ seed: setSeed$1
8092
+ };
8093
+
8094
+ var randomFromSeed = randomFromSeed$1;
8095
+
8096
+ var ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
8097
+ var alphabet$2;
8098
+ var previousSeed;
7610
8099
 
7611
8100
  var shuffled;
7612
8101
 
@@ -7902,633 +8391,17 @@
7902
8391
  // Export all other functions as properties of the generate function
7903
8392
  module.exports = generate;
7904
8393
  module.exports.generate = generate;
7905
- module.exports.seed = seed;
7906
- module.exports.worker = worker;
7907
- module.exports.characters = characters;
7908
- module.exports.isValid = isValid$1;
7909
- } (lib));
7910
-
7911
- (function (module) {
7912
- module.exports = libExports;
7913
- } (shortid$1));
7914
-
7915
- var shortid = /*@__PURE__*/getDefaultExportFromCjs(shortidExports);
7916
-
7917
- function domainSession (domain, connection, logger, successMessages, errorMessages) {
7918
- if (domain == null) {
7919
- domain = "global";
7920
- }
7921
- successMessages = successMessages || ["success"];
7922
- errorMessages = errorMessages || ["error"];
7923
- var isJoined = false;
7924
- var tryReconnecting = false;
7925
- var _latestOptions;
7926
- var _connectionOn = false;
7927
- var callbacks = lib$1();
7928
- connection.disconnected(handleConnectionDisconnected);
7929
- connection.loggedIn(handleConnectionLoggedIn);
7930
- connection.on("success", function (msg) { return handleSuccessMessage(msg); });
7931
- connection.on("error", function (msg) { return handleErrorMessage(msg); });
7932
- connection.on("result", function (msg) { return handleSuccessMessage(msg); });
7933
- if (successMessages) {
7934
- successMessages.forEach(function (sm) {
7935
- connection.on(sm, function (msg) { return handleSuccessMessage(msg); });
7936
- });
7937
- }
7938
- if (errorMessages) {
7939
- errorMessages.forEach(function (sm) {
7940
- connection.on(sm, function (msg) { return handleErrorMessage(msg); });
7941
- });
7942
- }
7943
- var requestsMap = {};
7944
- function join(options) {
7945
- _latestOptions = options;
7946
- return new Promise(function (resolve, reject) {
7947
- if (isJoined) {
7948
- resolve({});
7949
- return;
7950
- }
7951
- var joinPromise;
7952
- if (domain === "global") {
7953
- joinPromise = _connectionOn ? Promise.resolve({}) : Promise.reject("not connected to gateway");
7954
- }
7955
- else {
7956
- logger.debug("joining domain ".concat(domain));
7957
- var joinMsg = {
7958
- type: "join",
7959
- destination: domain,
7960
- domain: "global",
7961
- options: options,
7962
- };
7963
- joinPromise = send(joinMsg);
7964
- }
7965
- joinPromise
7966
- .then(function () {
7967
- handleJoined();
7968
- resolve({});
7969
- })
7970
- .catch(function (err) {
7971
- logger.debug("error joining " + domain + " domain: " + JSON.stringify(err));
7972
- reject(err);
7973
- });
7974
- });
7975
- }
7976
- function leave() {
7977
- if (domain === "global") {
7978
- return Promise.resolve();
7979
- }
7980
- logger.debug("stopping session " + domain + "...");
7981
- var leaveMsg = {
7982
- type: "leave",
7983
- destination: domain,
7984
- domain: "global",
7985
- };
7986
- tryReconnecting = false;
7987
- return send(leaveMsg)
7988
- .then(function () {
7989
- isJoined = false;
7990
- callbacks.execute("onLeft");
7991
- })
7992
- .catch(function () {
7993
- isJoined = false;
7994
- callbacks.execute("onLeft");
7995
- });
7996
- }
7997
- function handleJoined() {
7998
- logger.debug("did join " + domain);
7999
- isJoined = true;
8000
- var wasReconnect = tryReconnecting;
8001
- tryReconnecting = false;
8002
- callbacks.execute("onJoined", wasReconnect);
8003
- }
8004
- function handleConnectionDisconnected() {
8005
- _connectionOn = false;
8006
- logger.debug("connection is down");
8007
- isJoined = false;
8008
- tryReconnecting = true;
8009
- callbacks.execute("onLeft", { disconnected: true });
8010
- }
8011
- function handleConnectionLoggedIn() {
8012
- _connectionOn = true;
8013
- if (tryReconnecting) {
8014
- logger.debug("connection is now up - trying to reconnect...");
8015
- join(_latestOptions);
8016
- }
8017
- }
8018
- function onJoined(callback) {
8019
- if (isJoined) {
8020
- callback(false);
8021
- }
8022
- return callbacks.add("onJoined", callback);
8023
- }
8024
- function onLeft(callback) {
8025
- if (!isJoined) {
8026
- callback();
8027
- }
8028
- return callbacks.add("onLeft", callback);
8029
- }
8030
- function handleErrorMessage(msg) {
8031
- if (domain !== msg.domain) {
8032
- return;
8033
- }
8034
- var requestId = msg.request_id;
8035
- if (!requestId) {
8036
- return;
8037
- }
8038
- var entry = requestsMap[requestId];
8039
- if (!entry) {
8040
- return;
8041
- }
8042
- entry.error(msg);
8043
- }
8044
- function handleSuccessMessage(msg) {
8045
- if (msg.domain !== domain) {
8046
- return;
8047
- }
8048
- var requestId = msg.request_id;
8049
- if (!requestId) {
8050
- return;
8051
- }
8052
- var entry = requestsMap[requestId];
8053
- if (!entry) {
8054
- return;
8055
- }
8056
- entry.success(msg);
8057
- }
8058
- function getNextRequestId() {
8059
- return shortid();
8060
- }
8061
- function send(msg, tag, options) {
8062
- options = options || {};
8063
- msg.request_id = msg.request_id || getNextRequestId();
8064
- msg.domain = msg.domain || domain;
8065
- if (!options.skipPeerId) {
8066
- msg.peer_id = connection.peerId;
8067
- }
8068
- var requestId = msg.request_id;
8069
- return new Promise(function (resolve, reject) {
8070
- requestsMap[requestId] = {
8071
- success: function (successMsg) {
8072
- delete requestsMap[requestId];
8073
- successMsg._tag = tag;
8074
- resolve(successMsg);
8075
- },
8076
- error: function (errorMsg) {
8077
- logger.warn("GW error - ".concat(JSON.stringify(errorMsg), " for request ").concat(JSON.stringify(msg)));
8078
- delete requestsMap[requestId];
8079
- errorMsg._tag = tag;
8080
- reject(errorMsg);
8081
- },
8082
- };
8083
- connection
8084
- .send(msg, options)
8085
- .catch(function (err) {
8086
- requestsMap[requestId].error({ err: err });
8087
- });
8088
- });
8089
- }
8090
- function sendFireAndForget(msg) {
8091
- msg.request_id = msg.request_id ? msg.request_id : getNextRequestId();
8092
- msg.domain = msg.domain || domain;
8093
- msg.peer_id = connection.peerId;
8094
- return connection.send(msg);
8095
- }
8096
- return {
8097
- join: join,
8098
- leave: leave,
8099
- onJoined: onJoined,
8100
- onLeft: onLeft,
8101
- send: send,
8102
- sendFireAndForget: sendFireAndForget,
8103
- on: function (type, callback) {
8104
- connection.on(type, function (msg) {
8105
- if (msg.domain !== domain) {
8106
- return;
8107
- }
8108
- try {
8109
- callback(msg);
8110
- }
8111
- catch (e) {
8112
- logger.error("Callback failed: ".concat(e, " \n ").concat(e.stack, " \n msg was: ").concat(JSON.stringify(msg)), e);
8113
- }
8114
- });
8115
- },
8116
- loggedIn: function (callback) { return connection.loggedIn(callback); },
8117
- connected: function (callback) { return connection.connected(callback); },
8118
- disconnected: function (callback) { return connection.disconnected(callback); },
8119
- get peerId() {
8120
- return connection.peerId;
8121
- },
8122
- get domain() {
8123
- return domain;
8124
- },
8125
- };
8126
- }
8127
-
8128
- var GW3ProtocolImpl = (function () {
8129
- function GW3ProtocolImpl(connection, settings, logger) {
8130
- var _this = this;
8131
- this.connection = connection;
8132
- this.settings = settings;
8133
- this.logger = logger;
8134
- this.protocolVersion = 3;
8135
- this.datePrefix = "#T42_DATE#";
8136
- this.datePrefixLen = this.datePrefix.length;
8137
- this.dateMinLen = this.datePrefixLen + 1;
8138
- this.datePrefixFirstChar = this.datePrefix[0];
8139
- this.registry = lib$1();
8140
- this._isLoggedIn = false;
8141
- this.shouldTryLogin = true;
8142
- this.initialLogin = true;
8143
- this.initialLoginAttempts = 3;
8144
- this.sessions = [];
8145
- connection.disconnected(function () {
8146
- _this.handleDisconnected();
8147
- });
8148
- this.ping();
8149
- }
8150
- Object.defineProperty(GW3ProtocolImpl.prototype, "isLoggedIn", {
8151
- get: function () {
8152
- return this._isLoggedIn;
8153
- },
8154
- enumerable: false,
8155
- configurable: true
8156
- });
8157
- GW3ProtocolImpl.prototype.processStringMessage = function (message) {
8158
- var _this = this;
8159
- var msg = JSON.parse(message, function (key, value) {
8160
- if (typeof value !== "string") {
8161
- return value;
8162
- }
8163
- if (value.length < _this.dateMinLen) {
8164
- return value;
8165
- }
8166
- if (value[0] !== _this.datePrefixFirstChar) {
8167
- return value;
8168
- }
8169
- if (value.substring(0, _this.datePrefixLen) !== _this.datePrefix) {
8170
- return value;
8171
- }
8172
- try {
8173
- var milliseconds = parseInt(value.substring(_this.datePrefixLen, value.length), 10);
8174
- if (isNaN(milliseconds)) {
8175
- return value;
8176
- }
8177
- return new Date(milliseconds);
8178
- }
8179
- catch (ex) {
8180
- return value;
8181
- }
8182
- });
8183
- return {
8184
- msg: msg,
8185
- msgType: msg.type,
8186
- };
8187
- };
8188
- GW3ProtocolImpl.prototype.createStringMessage = function (message) {
8189
- var oldToJson = Date.prototype.toJSON;
8190
- try {
8191
- var datePrefix_1 = this.datePrefix;
8192
- Date.prototype.toJSON = function () {
8193
- return datePrefix_1 + this.getTime();
8194
- };
8195
- var result = JSON.stringify(message);
8196
- return result;
8197
- }
8198
- finally {
8199
- Date.prototype.toJSON = oldToJson;
8200
- }
8201
- };
8202
- GW3ProtocolImpl.prototype.processObjectMessage = function (message) {
8203
- if (!message.type) {
8204
- throw new Error("Object should have type property");
8205
- }
8206
- return {
8207
- msg: message,
8208
- msgType: message.type,
8209
- };
8210
- };
8211
- GW3ProtocolImpl.prototype.createObjectMessage = function (message) {
8212
- return message;
8213
- };
8214
- GW3ProtocolImpl.prototype.login = function (config, reconnect) {
8215
- return __awaiter(this, void 0, void 0, function () {
8216
- var authentication, token, e_1, _a, helloMsg, sendOptions, welcomeMsg, msg, token, _b, err_1;
8217
- return __generator(this, function (_c) {
8218
- switch (_c.label) {
8219
- case 0:
8220
- this.logger.debug("logging in...");
8221
- this.loginConfig = config;
8222
- if (!this.loginConfig) {
8223
- this.loginConfig = { username: "", password: "" };
8224
- }
8225
- this.shouldTryLogin = true;
8226
- authentication = {};
8227
- this.connection.gatewayToken = config.gatewayToken;
8228
- if (!config.gatewayToken) return [3, 5];
8229
- if (!reconnect) return [3, 4];
8230
- _c.label = 1;
8231
- case 1:
8232
- _c.trys.push([1, 3, , 4]);
8233
- return [4, this.getNewGWToken()];
8234
- case 2:
8235
- token = _c.sent();
8236
- config.gatewayToken = token;
8237
- return [3, 4];
8238
- case 3:
8239
- e_1 = _c.sent();
8240
- 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));
8241
- return [3, 4];
8242
- case 4:
8243
- authentication.method = "gateway-token";
8244
- authentication.token = config.gatewayToken;
8245
- this.connection.gatewayToken = config.gatewayToken;
8246
- return [3, 10];
8247
- case 5:
8248
- if (!(config.flowName === "sspi")) return [3, 9];
8249
- authentication.provider = "win";
8250
- authentication.method = "access-token";
8251
- if (!(config.flowCallback && config.sessionId)) return [3, 7];
8252
- _a = authentication;
8253
- return [4, config.flowCallback(config.sessionId, null)];
8254
- case 6:
8255
- _a.token =
8256
- (_c.sent())
8257
- .data
8258
- .toString("base64");
8259
- return [3, 8];
8260
- case 7: throw new Error("Invalid SSPI config");
8261
- case 8: return [3, 10];
8262
- case 9:
8263
- if (config.token) {
8264
- authentication.method = "access-token";
8265
- authentication.token = config.token;
8266
- }
8267
- else if (config.username) {
8268
- authentication.method = "secret";
8269
- authentication.login = config.username;
8270
- authentication.secret = config.password;
8271
- }
8272
- else if (config.provider) {
8273
- authentication.provider = config.provider;
8274
- authentication.providerContext = config.providerContext;
8275
- }
8276
- else {
8277
- throw new Error("invalid auth message" + JSON.stringify(config));
8278
- }
8279
- _c.label = 10;
8280
- case 10:
8281
- helloMsg = {
8282
- type: "hello",
8283
- identity: this.settings.identity,
8284
- authentication: authentication
8285
- };
8286
- if (config.sessionId) {
8287
- helloMsg.request_id = config.sessionId;
8288
- }
8289
- this.globalDomain = domainSession("global", this.connection, this.logger.subLogger("global-domain"), [
8290
- "welcome",
8291
- "token",
8292
- "authentication-request"
8293
- ]);
8294
- sendOptions = { skipPeerId: true };
8295
- if (this.initialLogin) {
8296
- sendOptions.retryInterval = this.settings.reconnectInterval;
8297
- sendOptions.maxRetries = this.settings.reconnectAttempts;
8298
- }
8299
- _c.label = 11;
8300
- case 11:
8301
- _c.trys.push([11, 19, 20, 21]);
8302
- welcomeMsg = void 0;
8303
- _c.label = 12;
8304
- case 12:
8305
- return [4, this.globalDomain.send(helloMsg, undefined, sendOptions)];
8306
- case 13:
8307
- msg = _c.sent();
8308
- if (!(msg.type === "authentication-request")) return [3, 16];
8309
- token = Buffer.from(msg.authentication.token, "base64");
8310
- if (!(config.flowCallback && config.sessionId)) return [3, 15];
8311
- _b = helloMsg.authentication;
8312
- return [4, config.flowCallback(config.sessionId, token)];
8313
- case 14:
8314
- _b.token =
8315
- (_c.sent())
8316
- .data
8317
- .toString("base64");
8318
- _c.label = 15;
8319
- case 15:
8320
- helloMsg.request_id = config.sessionId;
8321
- return [3, 12];
8322
- case 16:
8323
- if (msg.type === "welcome") {
8324
- welcomeMsg = msg;
8325
- return [3, 18];
8326
- }
8327
- else if (msg.type === "error") {
8328
- throw new Error("Authentication failed: " + msg.reason);
8329
- }
8330
- else {
8331
- throw new Error("Unexpected message type during authentication: " + msg.type);
8332
- }
8333
- case 17: return [3, 12];
8334
- case 18:
8335
- this.initialLogin = false;
8336
- this.logger.debug("login successful with peerId " + welcomeMsg.peer_id);
8337
- this.connection.peerId = welcomeMsg.peer_id;
8338
- this.connection.resolvedIdentity = welcomeMsg.resolved_identity;
8339
- this.connection.availableDomains = welcomeMsg.available_domains;
8340
- if (welcomeMsg.options) {
8341
- this.connection.token = welcomeMsg.options.access_token;
8342
- this.connection.info = welcomeMsg.options.info;
8343
- }
8344
- this.setLoggedIn(true);
8345
- return [2, welcomeMsg.resolved_identity];
8346
- case 19:
8347
- err_1 = _c.sent();
8348
- this.logger.error("error sending hello message - " + (err_1.message || err_1.msg || err_1.reason || err_1), err_1);
8349
- throw err_1;
8350
- case 20:
8351
- if (config && config.flowCallback && config.sessionId) {
8352
- config.flowCallback(config.sessionId, null);
8353
- }
8354
- return [7];
8355
- case 21: return [2];
8356
- }
8357
- });
8358
- });
8359
- };
8360
- GW3ProtocolImpl.prototype.logout = function () {
8361
- return __awaiter(this, void 0, void 0, function () {
8362
- var promises;
8363
- return __generator(this, function (_a) {
8364
- switch (_a.label) {
8365
- case 0:
8366
- this.logger.debug("logging out...");
8367
- this.shouldTryLogin = false;
8368
- if (this.pingTimer) {
8369
- clearTimeout(this.pingTimer);
8370
- }
8371
- promises = this.sessions.map(function (session) {
8372
- session.leave();
8373
- });
8374
- return [4, Promise.all(promises)];
8375
- case 1:
8376
- _a.sent();
8377
- return [2];
8378
- }
8379
- });
8380
- });
8381
- };
8382
- GW3ProtocolImpl.prototype.loggedIn = function (callback) {
8383
- if (this._isLoggedIn) {
8384
- callback();
8385
- }
8386
- return this.registry.add("onLoggedIn", callback);
8387
- };
8388
- GW3ProtocolImpl.prototype.domain = function (domainName, domainLogger, successMessages, errorMessages) {
8389
- var session = this.sessions.filter(function (s) { return s.domain === domainName; })[0];
8390
- if (!session) {
8391
- session = domainSession(domainName, this.connection, domainLogger, successMessages, errorMessages);
8392
- this.sessions.push(session);
8393
- }
8394
- return session;
8395
- };
8396
- GW3ProtocolImpl.prototype.handleDisconnected = function () {
8397
- var _this = this;
8398
- this.setLoggedIn(false);
8399
- var tryToLogin = this.shouldTryLogin;
8400
- if (tryToLogin && this.initialLogin) {
8401
- if (this.initialLoginAttempts <= 0) {
8402
- return;
8403
- }
8404
- this.initialLoginAttempts--;
8405
- }
8406
- this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
8407
- if (this.shouldTryLogin) {
8408
- if (!this.loginConfig) {
8409
- throw new Error("no login info");
8410
- }
8411
- this.connection.login(this.loginConfig, true)
8412
- .catch(function () {
8413
- setTimeout(_this.handleDisconnected.bind(_this), _this.settings.reconnectInterval || 1000);
8414
- });
8415
- }
8416
- };
8417
- GW3ProtocolImpl.prototype.setLoggedIn = function (value) {
8418
- this._isLoggedIn = value;
8419
- if (this._isLoggedIn) {
8420
- this.registry.execute("onLoggedIn");
8421
- }
8422
- };
8423
- GW3ProtocolImpl.prototype.ping = function () {
8424
- var _this = this;
8425
- if (!this.shouldTryLogin) {
8426
- return;
8427
- }
8428
- if (this._isLoggedIn) {
8429
- this.connection.send({ type: "ping" });
8430
- }
8431
- this.pingTimer = setTimeout(function () {
8432
- _this.ping();
8433
- }, 30 * 1000);
8434
- };
8435
- GW3ProtocolImpl.prototype.authToken = function () {
8436
- var createTokenReq = {
8437
- type: "create-token"
8438
- };
8439
- if (!this.globalDomain) {
8440
- return Promise.reject(new Error("no global domain session"));
8441
- }
8442
- return this.globalDomain.send(createTokenReq)
8443
- .then(function (res) {
8444
- return res.token;
8445
- });
8446
- };
8447
- GW3ProtocolImpl.prototype.getNewGWToken = function () {
8448
- if (typeof window !== "undefined") {
8449
- var glue42gd = window.glue42gd;
8450
- if (glue42gd) {
8451
- return glue42gd.getGWToken();
8452
- }
8453
- }
8454
- return Promise.reject(new Error("not running in GD"));
8455
- };
8456
- return GW3ProtocolImpl;
8457
- }());
8458
-
8459
- var MessageReplayerImpl = (function () {
8460
- function MessageReplayerImpl(specs) {
8461
- this.specsNames = [];
8462
- this.messages = {};
8463
- this.subs = {};
8464
- this.subsRefCount = {};
8465
- this.specs = {};
8466
- for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
8467
- var spec = specs_1[_i];
8468
- this.specs[spec.name] = spec;
8469
- this.specsNames.push(spec.name);
8470
- }
8471
- }
8472
- MessageReplayerImpl.prototype.init = function (connection) {
8473
- var _this = this;
8474
- this.connection = connection;
8475
- for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
8476
- var name_1 = _a[_i];
8477
- var _loop_1 = function (type) {
8478
- var refCount = this_1.subsRefCount[type];
8479
- if (!refCount) {
8480
- refCount = 0;
8481
- }
8482
- refCount += 1;
8483
- this_1.subsRefCount[type] = refCount;
8484
- if (refCount > 1) {
8485
- return "continue";
8486
- }
8487
- var sub = connection.on(type, function (msg) { return _this.processMessage(type, msg); });
8488
- this_1.subs[type] = sub;
8489
- };
8490
- var this_1 = this;
8491
- for (var _b = 0, _c = this.specs[name_1].types; _b < _c.length; _b++) {
8492
- var type = _c[_b];
8493
- _loop_1(type);
8494
- }
8495
- }
8496
- };
8497
- MessageReplayerImpl.prototype.processMessage = function (type, msg) {
8498
- if (this.isDone || !msg) {
8499
- return;
8500
- }
8501
- for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
8502
- var name_2 = _a[_i];
8503
- if (this.specs[name_2].types.indexOf(type) !== -1) {
8504
- var messages = this.messages[name_2] || [];
8505
- this.messages[name_2] = messages;
8506
- messages.push(msg);
8507
- }
8508
- }
8509
- };
8510
- MessageReplayerImpl.prototype.drain = function (name, callback) {
8511
- var _a;
8512
- if (callback) {
8513
- (this.messages[name] || []).forEach(callback);
8514
- }
8515
- delete this.messages[name];
8516
- for (var _i = 0, _b = this.specs[name].types; _i < _b.length; _i++) {
8517
- var type = _b[_i];
8518
- this.subsRefCount[type] -= 1;
8519
- if (this.subsRefCount[type] <= 0) {
8520
- (_a = this.connection) === null || _a === void 0 ? void 0 : _a.off(this.subs[type]);
8521
- delete this.subs[type];
8522
- delete this.subsRefCount[type];
8523
- }
8524
- }
8525
- delete this.specs[name];
8526
- if (!this.specs.length) {
8527
- this.isDone = true;
8528
- }
8529
- };
8530
- return MessageReplayerImpl;
8531
- }());
8394
+ module.exports.seed = seed;
8395
+ module.exports.worker = worker;
8396
+ module.exports.characters = characters;
8397
+ module.exports.isValid = isValid$1;
8398
+ } (lib));
8399
+
8400
+ (function (module) {
8401
+ module.exports = libExports;
8402
+ } (shortid$1));
8403
+
8404
+ var shortid = /*@__PURE__*/getDefaultExportFromCjs(shortidExports);
8532
8405
 
8533
8406
  var PromisePlus = function (executor, timeoutMilliseconds, timeoutMessage) {
8534
8407
  return new Promise(function (resolve, reject) {
@@ -9267,10 +9140,247 @@
9267
9140
  return AsyncSequelizer;
9268
9141
  }());
9269
9142
 
9143
+ function domainSession (domain, connection, logger, successMessages, errorMessages) {
9144
+ if (domain == null) {
9145
+ domain = "global";
9146
+ }
9147
+ successMessages = successMessages !== null && successMessages !== void 0 ? successMessages : ["success"];
9148
+ errorMessages = errorMessages !== null && errorMessages !== void 0 ? errorMessages : ["error"];
9149
+ var isJoined = domain === "global";
9150
+ var tryReconnecting = false;
9151
+ var _latestOptions;
9152
+ var _connectionOn = false;
9153
+ var callbacks = lib$1();
9154
+ connection.disconnected(handleConnectionDisconnected);
9155
+ connection.loggedIn(handleConnectionLoggedIn);
9156
+ connection.on("success", function (msg) { return handleSuccessMessage(msg); });
9157
+ connection.on("error", function (msg) { return handleErrorMessage(msg); });
9158
+ connection.on("result", function (msg) { return handleSuccessMessage(msg); });
9159
+ if (successMessages) {
9160
+ successMessages.forEach(function (sm) {
9161
+ connection.on(sm, function (msg) { return handleSuccessMessage(msg); });
9162
+ });
9163
+ }
9164
+ if (errorMessages) {
9165
+ errorMessages.forEach(function (sm) {
9166
+ connection.on(sm, function (msg) { return handleErrorMessage(msg); });
9167
+ });
9168
+ }
9169
+ var requestsMap = {};
9170
+ function join(options) {
9171
+ _latestOptions = options;
9172
+ return new Promise(function (resolve, reject) {
9173
+ if (isJoined) {
9174
+ resolve({});
9175
+ return;
9176
+ }
9177
+ var joinPromise;
9178
+ if (domain === "global") {
9179
+ joinPromise = _connectionOn ? Promise.resolve({}) : Promise.reject("not connected to gateway");
9180
+ }
9181
+ else {
9182
+ logger.debug("joining domain ".concat(domain));
9183
+ var joinMsg = {
9184
+ type: "join",
9185
+ destination: domain,
9186
+ domain: "global",
9187
+ options: options,
9188
+ };
9189
+ joinPromise = send(joinMsg);
9190
+ }
9191
+ joinPromise
9192
+ .then(function () {
9193
+ handleJoined();
9194
+ resolve({});
9195
+ })
9196
+ .catch(function (err) {
9197
+ logger.debug("error joining " + domain + " domain: " + JSON.stringify(err));
9198
+ reject(err);
9199
+ });
9200
+ });
9201
+ }
9202
+ function leave() {
9203
+ if (domain === "global") {
9204
+ return Promise.resolve();
9205
+ }
9206
+ logger.debug("stopping session " + domain + "...");
9207
+ var leaveMsg = {
9208
+ type: "leave",
9209
+ destination: domain,
9210
+ domain: "global",
9211
+ };
9212
+ tryReconnecting = false;
9213
+ return send(leaveMsg)
9214
+ .then(function () {
9215
+ isJoined = false;
9216
+ callbacks.execute("onLeft");
9217
+ })
9218
+ .catch(function () {
9219
+ isJoined = false;
9220
+ callbacks.execute("onLeft");
9221
+ });
9222
+ }
9223
+ function handleJoined() {
9224
+ logger.debug("did join " + domain);
9225
+ isJoined = true;
9226
+ var wasReconnect = tryReconnecting;
9227
+ tryReconnecting = false;
9228
+ callbacks.execute("onJoined", wasReconnect);
9229
+ }
9230
+ function handleConnectionDisconnected() {
9231
+ _connectionOn = false;
9232
+ logger.debug("connection is down");
9233
+ isJoined = false;
9234
+ tryReconnecting = true;
9235
+ callbacks.execute("onLeft", { disconnected: true });
9236
+ }
9237
+ function handleConnectionLoggedIn() {
9238
+ _connectionOn = true;
9239
+ if (tryReconnecting) {
9240
+ logger.debug("connection is now up - trying to reconnect...");
9241
+ join(_latestOptions);
9242
+ }
9243
+ }
9244
+ function onJoined(callback) {
9245
+ if (isJoined) {
9246
+ callback(false);
9247
+ }
9248
+ return callbacks.add("onJoined", callback);
9249
+ }
9250
+ function onLeft(callback) {
9251
+ if (!isJoined) {
9252
+ callback();
9253
+ }
9254
+ return callbacks.add("onLeft", callback);
9255
+ }
9256
+ function handleErrorMessage(msg) {
9257
+ if (domain !== msg.domain) {
9258
+ return;
9259
+ }
9260
+ var requestId = msg.request_id;
9261
+ if (!requestId) {
9262
+ return;
9263
+ }
9264
+ var entry = requestsMap[requestId];
9265
+ if (!entry) {
9266
+ return;
9267
+ }
9268
+ entry.error(msg);
9269
+ }
9270
+ function handleSuccessMessage(msg) {
9271
+ if (msg.domain !== domain) {
9272
+ return;
9273
+ }
9274
+ var requestId = msg.request_id;
9275
+ if (!requestId) {
9276
+ return;
9277
+ }
9278
+ var entry = requestsMap[requestId];
9279
+ if (!entry) {
9280
+ return;
9281
+ }
9282
+ entry.success(msg);
9283
+ }
9284
+ function getNextRequestId() {
9285
+ return shortid();
9286
+ }
9287
+ var queuedCalls = [];
9288
+ function send(msg, tag, options) {
9289
+ var _a, _b;
9290
+ var ignore = ["hello", "join"];
9291
+ if (msg.type && ignore.indexOf(msg.type) === -1) {
9292
+ if (!isJoined) {
9293
+ logger.warn("trying to send a message (".concat(msg.domain, " ").concat(msg.type, ") but not connected, will queue"));
9294
+ var pw = new PromiseWrapper();
9295
+ queuedCalls.push({ msg: msg, tag: tag, options: options, pw: pw });
9296
+ if (queuedCalls.length === 1) {
9297
+ var unsubscribe_1 = onJoined(function () {
9298
+ logger.info("joined - will now send queued messages (".concat(queuedCalls.length, " -> [").concat(queuedCalls.map(function (m) { return m.msg.type; }), "])"));
9299
+ queuedCalls.forEach(function (qm) {
9300
+ send(qm.msg, qm.tag, qm.options)
9301
+ .then(function (t) { return qm.pw.resolve(t); })
9302
+ .catch(function (e) { return qm.pw.reject(e); });
9303
+ });
9304
+ queuedCalls = [];
9305
+ unsubscribe_1();
9306
+ });
9307
+ }
9308
+ return pw.promise;
9309
+ }
9310
+ }
9311
+ options = options !== null && options !== void 0 ? options : {};
9312
+ msg.request_id = (_a = msg.request_id) !== null && _a !== void 0 ? _a : getNextRequestId();
9313
+ msg.domain = (_b = msg.domain) !== null && _b !== void 0 ? _b : domain;
9314
+ if (!options.skipPeerId) {
9315
+ msg.peer_id = connection.peerId;
9316
+ }
9317
+ var requestId = msg.request_id;
9318
+ return new Promise(function (resolve, reject) {
9319
+ requestsMap[requestId] = {
9320
+ success: function (successMsg) {
9321
+ delete requestsMap[requestId];
9322
+ successMsg._tag = tag;
9323
+ resolve(successMsg);
9324
+ },
9325
+ error: function (errorMsg) {
9326
+ logger.warn("GW error - ".concat(JSON.stringify(errorMsg), " for request ").concat(JSON.stringify(msg)));
9327
+ delete requestsMap[requestId];
9328
+ errorMsg._tag = tag;
9329
+ reject(errorMsg);
9330
+ },
9331
+ };
9332
+ connection
9333
+ .send(msg, options)
9334
+ .catch(function (err) {
9335
+ requestsMap[requestId].error({ err: err });
9336
+ });
9337
+ });
9338
+ }
9339
+ function sendFireAndForget(msg) {
9340
+ var _a;
9341
+ msg.request_id = msg.request_id ? msg.request_id : getNextRequestId();
9342
+ msg.domain = (_a = msg.domain) !== null && _a !== void 0 ? _a : domain;
9343
+ msg.peer_id = connection.peerId;
9344
+ return connection.send(msg);
9345
+ }
9346
+ return {
9347
+ join: join,
9348
+ leave: leave,
9349
+ onJoined: onJoined,
9350
+ onLeft: onLeft,
9351
+ send: send,
9352
+ sendFireAndForget: sendFireAndForget,
9353
+ on: function (type, callback) {
9354
+ connection.on(type, function (msg) {
9355
+ if (msg.domain !== domain) {
9356
+ return;
9357
+ }
9358
+ try {
9359
+ callback(msg);
9360
+ }
9361
+ catch (e) {
9362
+ logger.error("Callback failed: ".concat(e, " \n ").concat(e.stack, " \n msg was: ").concat(JSON.stringify(msg)), e);
9363
+ }
9364
+ });
9365
+ },
9366
+ loggedIn: function (callback) { return connection.loggedIn(callback); },
9367
+ connected: function (callback) { return connection.connected(callback); },
9368
+ disconnected: function (callback) { return connection.disconnected(callback); },
9369
+ get peerId() {
9370
+ return connection.peerId;
9371
+ },
9372
+ get domain() {
9373
+ return domain;
9374
+ },
9375
+ };
9376
+ }
9377
+
9270
9378
  var Connection = (function () {
9271
9379
  function Connection(settings, logger) {
9380
+ var _a, _b;
9272
9381
  this.settings = settings;
9273
9382
  this.logger = logger;
9383
+ this.protocolVersion = 3;
9274
9384
  this.messageHandlers = {};
9275
9385
  this.ids = 1;
9276
9386
  this.registry = lib$1();
@@ -9279,10 +9389,19 @@
9279
9389
  this._swapTransport = false;
9280
9390
  this._switchInProgress = false;
9281
9391
  this._transportSubscriptions = [];
9392
+ this.datePrefix = "#T42_DATE#";
9393
+ this.datePrefixLen = this.datePrefix.length;
9394
+ this.dateMinLen = this.datePrefixLen + 1;
9395
+ this.datePrefixFirstChar = this.datePrefix[0];
9282
9396
  this._sequelizer = new AsyncSequelizer();
9397
+ this._isLoggedIn = false;
9398
+ this.shouldTryLogin = true;
9399
+ this.sessions = [];
9400
+ this.initialLogin = true;
9401
+ this.initialLoginAttempts = 3;
9283
9402
  settings = settings || {};
9284
- settings.reconnectAttempts = settings.reconnectAttempts || 10;
9285
- settings.reconnectInterval = settings.reconnectInterval || 1000;
9403
+ settings.reconnectAttempts = (_a = settings.reconnectAttempts) !== null && _a !== void 0 ? _a : 10;
9404
+ settings.reconnectInterval = (_b = settings.reconnectInterval) !== null && _b !== void 0 ? _b : 1000;
9286
9405
  if (settings.inproc) {
9287
9406
  this.transport = new InProcTransport(settings.inproc, logger.subLogger("inMemory"));
9288
9407
  }
@@ -9300,21 +9419,13 @@
9300
9419
  }
9301
9420
  this.isTrace = logger.canPublish("trace");
9302
9421
  logger.debug("starting with ".concat(this.transport.name(), " transport"));
9303
- this.protocol = new GW3ProtocolImpl(this, settings, logger.subLogger("protocol"));
9304
9422
  var unsubConnectionChanged = this.transport.onConnectedChanged(this.handleConnectionChanged.bind(this));
9305
9423
  var unsubOnMessage = this.transport.onMessage(this.handleTransportMessage.bind(this));
9306
9424
  this._transportSubscriptions.push(unsubConnectionChanged);
9307
9425
  this._transportSubscriptions.push(unsubOnMessage);
9308
9426
  this._defaultTransport = this.transport;
9427
+ this.ping();
9309
9428
  }
9310
- Object.defineProperty(Connection.prototype, "protocolVersion", {
9311
- get: function () {
9312
- var _a;
9313
- return (_a = this.protocol) === null || _a === void 0 ? void 0 : _a.protocolVersion;
9314
- },
9315
- enumerable: false,
9316
- configurable: true
9317
- });
9318
9429
  Connection.prototype.switchTransport = function (settings) {
9319
9430
  return __awaiter(this, void 0, void 0, function () {
9320
9431
  var _this = this;
@@ -9373,14 +9484,14 @@
9373
9484
  Connection.prototype.send = function (message, options) {
9374
9485
  if (this.transport.sendObject &&
9375
9486
  this.transport.isObjectBasedTransport) {
9376
- var msg = this.protocol.createObjectMessage(message);
9487
+ var msg = this.createObjectMessage(message);
9377
9488
  if (this.isTrace) {
9378
9489
  this.logger.trace(">> ".concat(JSON.stringify(msg)));
9379
9490
  }
9380
9491
  return this.transport.sendObject(msg, options);
9381
9492
  }
9382
9493
  else {
9383
- var strMessage = this.protocol.createStringMessage(message);
9494
+ var strMessage = this.createStringMessage(message);
9384
9495
  if (this.isTrace) {
9385
9496
  this.logger.trace(">> ".concat(strMessage));
9386
9497
  }
@@ -9404,14 +9515,14 @@
9404
9515
  };
9405
9516
  Object.defineProperty(Connection.prototype, "isConnected", {
9406
9517
  get: function () {
9407
- return this.protocol.isLoggedIn;
9518
+ return this._isLoggedIn;
9408
9519
  },
9409
9520
  enumerable: false,
9410
9521
  configurable: true
9411
9522
  });
9412
9523
  Connection.prototype.connected = function (callback) {
9413
9524
  var _this = this;
9414
- return this.protocol.loggedIn(function () {
9525
+ return this.loggedIn(function () {
9415
9526
  var currentServer = _this.transport.name();
9416
9527
  callback(currentServer);
9417
9528
  });
@@ -9442,7 +9553,7 @@
9442
9553
  _a.sent();
9443
9554
  this.logger.trace("Transport: ".concat(this.transport.name(), " opened, logging in"));
9444
9555
  timer("connection").mark("transport-opened");
9445
- return [4, this.protocol.login(authRequest, reconnect)];
9556
+ return [4, this.loginCore(authRequest, reconnect)];
9446
9557
  case 3:
9447
9558
  identity = _a.sent();
9448
9559
  this.logger.trace("Logged in with identity: ".concat(JSON.stringify(identity)));
@@ -9464,7 +9575,7 @@
9464
9575
  return __awaiter(this, void 0, void 0, function () {
9465
9576
  return __generator(this, function (_a) {
9466
9577
  switch (_a.label) {
9467
- case 0: return [4, this.protocol.logout()];
9578
+ case 0: return [4, this.logoutCore()];
9468
9579
  case 1:
9469
9580
  _a.sent();
9470
9581
  return [4, this.transport.close()];
@@ -9476,17 +9587,41 @@
9476
9587
  });
9477
9588
  };
9478
9589
  Connection.prototype.loggedIn = function (callback) {
9479
- return this.protocol.loggedIn(callback);
9590
+ if (this._isLoggedIn) {
9591
+ callback();
9592
+ }
9593
+ return this.registry.add("onLoggedIn", callback);
9480
9594
  };
9481
9595
  Connection.prototype.domain = function (domain, successMessages, errorMessages) {
9482
- return this.protocol.domain(domain, this.logger.subLogger("domain=".concat(domain)), successMessages, errorMessages);
9596
+ var session = this.sessions.find(function (s) { return s.domain === domain; });
9597
+ if (!session) {
9598
+ session = domainSession(domain, this, this.logger.subLogger("domain=".concat(domain)), successMessages, errorMessages);
9599
+ this.sessions.push(session);
9600
+ }
9601
+ return session;
9483
9602
  };
9484
9603
  Connection.prototype.authToken = function () {
9485
- return this.protocol.authToken();
9604
+ var createTokenReq = {
9605
+ domain: "global",
9606
+ type: "create-token"
9607
+ };
9608
+ if (!this.globalDomain) {
9609
+ return Promise.reject(new Error("no global domain session"));
9610
+ }
9611
+ return this.globalDomain.send(createTokenReq)
9612
+ .then(function (res) {
9613
+ return res.token;
9614
+ });
9486
9615
  };
9487
9616
  Connection.prototype.reconnect = function () {
9488
9617
  return this.transport.reconnect();
9489
9618
  };
9619
+ Connection.prototype.setLoggedIn = function (value) {
9620
+ this._isLoggedIn = value;
9621
+ if (this._isLoggedIn) {
9622
+ this.registry.execute("onLoggedIn");
9623
+ }
9624
+ };
9490
9625
  Connection.prototype.distributeMessage = function (message, type) {
9491
9626
  var _this = this;
9492
9627
  var handlers = this.messageHandlers[type.toLowerCase()];
@@ -9510,28 +9645,51 @@
9510
9645
  }
9511
9646
  };
9512
9647
  Connection.prototype.handleConnectionChanged = function (connected) {
9648
+ var _a, _b;
9513
9649
  if (this._connected === connected) {
9514
9650
  return;
9515
9651
  }
9516
9652
  this._connected = connected;
9517
9653
  if (connected) {
9518
- if (this.settings.replaySpecs && this.settings.replaySpecs.length) {
9654
+ if ((_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.replaySpecs) === null || _b === void 0 ? void 0 : _b.length) {
9519
9655
  this.replayer = new MessageReplayerImpl(this.settings.replaySpecs);
9520
9656
  this.replayer.init(this);
9521
9657
  }
9522
9658
  this.registry.execute("connected");
9523
9659
  }
9524
9660
  else {
9661
+ this.handleDisconnected();
9525
9662
  this.registry.execute("disconnected");
9526
9663
  }
9527
9664
  };
9665
+ Connection.prototype.handleDisconnected = function () {
9666
+ var _this = this;
9667
+ this.setLoggedIn(false);
9668
+ var tryToLogin = this.shouldTryLogin;
9669
+ if (tryToLogin && this.initialLogin) {
9670
+ if (this.initialLoginAttempts <= 0) {
9671
+ return;
9672
+ }
9673
+ this.initialLoginAttempts--;
9674
+ }
9675
+ this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
9676
+ if (this.shouldTryLogin) {
9677
+ if (!this.loginConfig) {
9678
+ throw new Error("no login info");
9679
+ }
9680
+ this.login(this.loginConfig, true)
9681
+ .catch(function () {
9682
+ setTimeout(_this.handleDisconnected.bind(_this), _this.settings.reconnectInterval || 1000);
9683
+ });
9684
+ }
9685
+ };
9528
9686
  Connection.prototype.handleTransportMessage = function (msg) {
9529
9687
  var msgObj;
9530
9688
  if (typeof msg === "string") {
9531
- msgObj = this.protocol.processStringMessage(msg);
9689
+ msgObj = this.processStringMessage(msg);
9532
9690
  }
9533
9691
  else {
9534
- msgObj = this.protocol.processObjectMessage(msg);
9692
+ msgObj = this.processObjectMessage(msg);
9535
9693
  }
9536
9694
  if (this.isTrace) {
9537
9695
  this.logger.trace("<< ".concat(JSON.stringify(msgObj)));
@@ -9596,6 +9754,275 @@
9596
9754
  this._targetAuth = this._defaultAuth;
9597
9755
  this._swapTransport = true;
9598
9756
  };
9757
+ Connection.prototype.processStringMessage = function (message) {
9758
+ var _this = this;
9759
+ var msg = JSON.parse(message, function (key, value) {
9760
+ if (typeof value !== "string") {
9761
+ return value;
9762
+ }
9763
+ if (value.length < _this.dateMinLen) {
9764
+ return value;
9765
+ }
9766
+ if (!value.startsWith(_this.datePrefixFirstChar)) {
9767
+ return value;
9768
+ }
9769
+ if (value.substring(0, _this.datePrefixLen) !== _this.datePrefix) {
9770
+ return value;
9771
+ }
9772
+ try {
9773
+ var milliseconds = parseInt(value.substring(_this.datePrefixLen, value.length), 10);
9774
+ if (isNaN(milliseconds)) {
9775
+ return value;
9776
+ }
9777
+ return new Date(milliseconds);
9778
+ }
9779
+ catch (ex) {
9780
+ return value;
9781
+ }
9782
+ });
9783
+ return {
9784
+ msg: msg,
9785
+ msgType: msg.type,
9786
+ };
9787
+ };
9788
+ Connection.prototype.createStringMessage = function (message) {
9789
+ var oldToJson = Date.prototype.toJSON;
9790
+ try {
9791
+ var datePrefix_1 = this.datePrefix;
9792
+ Date.prototype.toJSON = function () {
9793
+ return datePrefix_1 + this.getTime();
9794
+ };
9795
+ var result = JSON.stringify(message);
9796
+ return result;
9797
+ }
9798
+ finally {
9799
+ Date.prototype.toJSON = oldToJson;
9800
+ }
9801
+ };
9802
+ Connection.prototype.processObjectMessage = function (message) {
9803
+ if (!message.type) {
9804
+ throw new Error("Object should have type property");
9805
+ }
9806
+ return {
9807
+ msg: message,
9808
+ msgType: message.type,
9809
+ };
9810
+ };
9811
+ Connection.prototype.createObjectMessage = function (message) {
9812
+ return message;
9813
+ };
9814
+ Connection.prototype.loginCore = function (config, reconnect) {
9815
+ return __awaiter(this, void 0, void 0, function () {
9816
+ var authentication, helloMsg, sendOptions, welcomeMsg, err_1;
9817
+ return __generator(this, function (_a) {
9818
+ switch (_a.label) {
9819
+ case 0:
9820
+ this.logger.info("logging in...");
9821
+ this.loginConfig = config;
9822
+ if (!this.loginConfig) {
9823
+ this.loginConfig = { username: "", password: "" };
9824
+ }
9825
+ this.shouldTryLogin = true;
9826
+ return [4, this.setupAuthConfig(config, reconnect)];
9827
+ case 1:
9828
+ authentication = _a.sent();
9829
+ helloMsg = {
9830
+ type: "hello",
9831
+ identity: this.settings.identity,
9832
+ authentication: authentication
9833
+ };
9834
+ if (config.sessionId) {
9835
+ helloMsg.request_id = config.sessionId;
9836
+ }
9837
+ this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
9838
+ "welcome",
9839
+ "token",
9840
+ "authentication-request"
9841
+ ]);
9842
+ sendOptions = { skipPeerId: true };
9843
+ if (this.initialLogin) {
9844
+ sendOptions.retryInterval = this.settings.reconnectInterval;
9845
+ sendOptions.maxRetries = this.settings.reconnectAttempts;
9846
+ }
9847
+ _a.label = 2;
9848
+ case 2:
9849
+ _a.trys.push([2, 4, 5, 6]);
9850
+ return [4, this.tryAuthenticate(this.globalDomain, helloMsg, sendOptions, config)];
9851
+ case 3:
9852
+ welcomeMsg = _a.sent();
9853
+ this.initialLogin = false;
9854
+ this.logger.info("login successful with peerId " + welcomeMsg.peer_id);
9855
+ this.peerId = welcomeMsg.peer_id;
9856
+ this.resolvedIdentity = welcomeMsg.resolved_identity;
9857
+ this.availableDomains = welcomeMsg.available_domains;
9858
+ if (welcomeMsg.options) {
9859
+ this.token = welcomeMsg.options.access_token;
9860
+ this.info = welcomeMsg.options.info;
9861
+ }
9862
+ this.setLoggedIn(true);
9863
+ return [2, welcomeMsg.resolved_identity];
9864
+ case 4:
9865
+ err_1 = _a.sent();
9866
+ this.logger.error("error sending hello message - " + (err_1.message || err_1.msg || err_1.reason || err_1), err_1);
9867
+ throw err_1;
9868
+ case 5:
9869
+ if ((config === null || config === void 0 ? void 0 : config.flowCallback) && config.sessionId) {
9870
+ config.flowCallback(config.sessionId, null);
9871
+ }
9872
+ return [7];
9873
+ case 6: return [2];
9874
+ }
9875
+ });
9876
+ });
9877
+ };
9878
+ Connection.prototype.tryAuthenticate = function (globalDomain, helloMsg, sendOptions, config) {
9879
+ return __awaiter(this, void 0, void 0, function () {
9880
+ var welcomeMsg, msg, token, _a;
9881
+ return __generator(this, function (_b) {
9882
+ switch (_b.label) {
9883
+ case 0:
9884
+ return [4, globalDomain.send(helloMsg, undefined, sendOptions)];
9885
+ case 1:
9886
+ msg = _b.sent();
9887
+ if (!(msg.type === "authentication-request")) return [3, 4];
9888
+ token = Buffer.from(msg.authentication.token, "base64");
9889
+ if (!(config.flowCallback && config.sessionId)) return [3, 3];
9890
+ _a = helloMsg.authentication;
9891
+ return [4, config.flowCallback(config.sessionId, token)];
9892
+ case 2:
9893
+ _a.token =
9894
+ (_b.sent())
9895
+ .data
9896
+ .toString("base64");
9897
+ _b.label = 3;
9898
+ case 3:
9899
+ helloMsg.request_id = config.sessionId;
9900
+ return [3, 5];
9901
+ case 4:
9902
+ if (msg.type === "welcome") {
9903
+ welcomeMsg = msg;
9904
+ return [3, 6];
9905
+ }
9906
+ else if (msg.type === "error") {
9907
+ throw new Error("Authentication failed: " + msg.reason);
9908
+ }
9909
+ else {
9910
+ throw new Error("Unexpected message type during authentication: " + msg.type);
9911
+ }
9912
+ case 5: return [3, 0];
9913
+ case 6: return [2, welcomeMsg];
9914
+ }
9915
+ });
9916
+ });
9917
+ };
9918
+ Connection.prototype.setupAuthConfig = function (config, reconnect) {
9919
+ return __awaiter(this, void 0, void 0, function () {
9920
+ var authentication, _a, e_1, _b;
9921
+ return __generator(this, function (_c) {
9922
+ switch (_c.label) {
9923
+ case 0:
9924
+ authentication = {};
9925
+ this.gatewayToken = config.gatewayToken;
9926
+ if (!config.gatewayToken) return [3, 5];
9927
+ if (!reconnect) return [3, 4];
9928
+ _c.label = 1;
9929
+ case 1:
9930
+ _c.trys.push([1, 3, , 4]);
9931
+ _a = config;
9932
+ return [4, this.getNewGWToken()];
9933
+ case 2:
9934
+ _a.gatewayToken = _c.sent();
9935
+ return [3, 4];
9936
+ case 3:
9937
+ e_1 = _c.sent();
9938
+ 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));
9939
+ return [3, 4];
9940
+ case 4:
9941
+ authentication.method = "gateway-token";
9942
+ authentication.token = config.gatewayToken;
9943
+ this.gatewayToken = config.gatewayToken;
9944
+ return [3, 10];
9945
+ case 5:
9946
+ if (!(config.flowName === "sspi")) return [3, 9];
9947
+ authentication.provider = "win";
9948
+ authentication.method = "access-token";
9949
+ if (!(config.flowCallback && config.sessionId)) return [3, 7];
9950
+ _b = authentication;
9951
+ return [4, config.flowCallback(config.sessionId, null)];
9952
+ case 6:
9953
+ _b.token =
9954
+ (_c.sent())
9955
+ .data
9956
+ .toString("base64");
9957
+ return [3, 8];
9958
+ case 7: throw new Error("Invalid SSPI config");
9959
+ case 8: return [3, 10];
9960
+ case 9:
9961
+ if (config.token) {
9962
+ authentication.method = "access-token";
9963
+ authentication.token = config.token;
9964
+ }
9965
+ else if (config.username) {
9966
+ authentication.method = "secret";
9967
+ authentication.login = config.username;
9968
+ authentication.secret = config.password;
9969
+ }
9970
+ else if (config.provider) {
9971
+ authentication.provider = config.provider;
9972
+ authentication.providerContext = config.providerContext;
9973
+ }
9974
+ else {
9975
+ throw new Error("invalid auth message" + JSON.stringify(config));
9976
+ }
9977
+ _c.label = 10;
9978
+ case 10: return [2, authentication];
9979
+ }
9980
+ });
9981
+ });
9982
+ };
9983
+ Connection.prototype.logoutCore = function () {
9984
+ return __awaiter(this, void 0, void 0, function () {
9985
+ var promises;
9986
+ return __generator(this, function (_a) {
9987
+ switch (_a.label) {
9988
+ case 0:
9989
+ this.logger.debug("logging out...");
9990
+ this.shouldTryLogin = false;
9991
+ if (this.pingTimer) {
9992
+ clearTimeout(this.pingTimer);
9993
+ }
9994
+ promises = this.sessions.map(function (session) {
9995
+ session.leave();
9996
+ });
9997
+ return [4, Promise.all(promises)];
9998
+ case 1:
9999
+ _a.sent();
10000
+ return [2];
10001
+ }
10002
+ });
10003
+ });
10004
+ };
10005
+ Connection.prototype.getNewGWToken = function () {
10006
+ if (typeof window !== "undefined") {
10007
+ var glue42gd = window.glue42gd;
10008
+ if (glue42gd) {
10009
+ return glue42gd.getGWToken();
10010
+ }
10011
+ }
10012
+ return Promise.reject(new Error("not running in GD"));
10013
+ };
10014
+ Connection.prototype.ping = function () {
10015
+ var _this = this;
10016
+ if (!this.shouldTryLogin) {
10017
+ return;
10018
+ }
10019
+ if (this._isLoggedIn) {
10020
+ this.send({ type: "ping" });
10021
+ }
10022
+ this.pingTimer = setTimeout(function () {
10023
+ _this.ping();
10024
+ }, 30 * 1000);
10025
+ };
9599
10026
  return Connection;
9600
10027
  }());
9601
10028
 
@@ -9777,7 +10204,7 @@
9777
10204
  }
9778
10205
  };
9779
10206
 
9780
- var version = "6.1.1";
10207
+ var version = "6.2.1";
9781
10208
 
9782
10209
  function prepareConfig (configuration, ext, glue42gd) {
9783
10210
  var _a, _b, _c, _d;
@@ -12053,7 +12480,7 @@
12053
12480
  currentContext = _b.sent();
12054
12481
  _b.label = 4;
12055
12482
  case 4:
12056
- calculatedDelta = this.protocolVersion === 2 ?
12483
+ calculatedDelta = this.setPathSupported ?
12057
12484
  this.calculateContextDeltaV2(currentContext, delta) :
12058
12485
  this.calculateContextDeltaV1(currentContext, delta);
12059
12486
  if (!Object.keys(calculatedDelta.added).length
@@ -15038,10 +15465,11 @@
15038
15465
  var server = new ServerProtocol(session, clientRepository, serverRepository, logger.subLogger("server"));
15039
15466
  var client = new ClientProtocol(session, clientRepository, logger.subLogger("client"));
15040
15467
  function handleReconnect() {
15468
+ var _a, _b;
15041
15469
  return __awaiter(this, void 0, void 0, function () {
15042
- var reconnectionPromises, existingSubscriptions, _loop_1, _i, existingSubscriptions_1, sub, registeredMethods, _loop_2, _a, registeredMethods_1, method;
15043
- return __generator(this, function (_b) {
15044
- switch (_b.label) {
15470
+ var reconnectionPromises, existingSubscriptions, _loop_1, _i, existingSubscriptions_1, sub, registeredMethods, _loop_2, _c, registeredMethods_1, method;
15471
+ return __generator(this, function (_d) {
15472
+ switch (_d.label) {
15045
15473
  case 0:
15046
15474
  logger.info("reconnected - will replay registered methods and subscriptions");
15047
15475
  client.drainSubscriptionsCache().forEach(function (sub) {
@@ -15066,25 +15494,29 @@
15066
15494
  serverRepository.reset();
15067
15495
  _loop_2 = function (method) {
15068
15496
  var def = method.definition;
15069
- logger.info("re-publishing method ".concat(def.name));
15070
15497
  if (method.stream) {
15071
- reconnectionPromises.push(interop.server.createStream(def, method.streamCallbacks, undefined, undefined, method.stream).then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); }));
15498
+ reconnectionPromises.push(interop.server.createStream(def, method.streamCallbacks, undefined, undefined, method.stream)
15499
+ .then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); })
15500
+ .catch(function () { return logger.warn("subscribing to method ".concat(def.name, " FAILED")); }));
15072
15501
  }
15073
- else if (method.theFunction && method.theFunction.userCallback) {
15074
- reconnectionPromises.push(interop.register(def, method.theFunction.userCallback).then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); }));
15502
+ else if ((_a = method === null || method === void 0 ? void 0 : method.theFunction) === null || _a === void 0 ? void 0 : _a.userCallback) {
15503
+ reconnectionPromises.push(interop.register(def, method.theFunction.userCallback)
15504
+ .then(function () { return logger.info("registering method ".concat(def.name, " DONE")); })
15505
+ .catch(function () { return logger.warn("registering method ".concat(def.name, " FAILED")); }));
15075
15506
  }
15076
- else if (method.theFunction && method.theFunction.userCallbackAsync) {
15077
- reconnectionPromises.push(interop.registerAsync(def, method.theFunction.userCallbackAsync).then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); }));
15507
+ else if ((_b = method === null || method === void 0 ? void 0 : method.theFunction) === null || _b === void 0 ? void 0 : _b.userCallbackAsync) {
15508
+ reconnectionPromises.push(interop.registerAsync(def, method.theFunction.userCallbackAsync)
15509
+ .then(function () { return logger.info("registering method ".concat(def.name, " DONE")); })
15510
+ .catch(function () { return logger.warn("registering method ".concat(def.name, " FAILED")); }));
15078
15511
  }
15079
- logger.info("re-publishing method ".concat(def.name, " DONE"));
15080
15512
  };
15081
- for (_a = 0, registeredMethods_1 = registeredMethods; _a < registeredMethods_1.length; _a++) {
15082
- method = registeredMethods_1[_a];
15513
+ for (_c = 0, registeredMethods_1 = registeredMethods; _c < registeredMethods_1.length; _c++) {
15514
+ method = registeredMethods_1[_c];
15083
15515
  _loop_2(method);
15084
15516
  }
15085
15517
  return [4, Promise.all(reconnectionPromises)];
15086
15518
  case 1:
15087
- _b.sent();
15519
+ _d.sent();
15088
15520
  logger.info("Interop is re-announced");
15089
15521
  return [2];
15090
15522
  }