@factset/frontgate-js-sdk 6.11.1 → 7.0.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.
Files changed (196) hide show
  1. package/CHANGELOG.md +97 -40
  2. package/dist/lib/esnext/FrontgateClient.js +0 -3
  3. package/dist/lib/esnext/authentication/index.js +3 -4
  4. package/dist/lib/esnext/common/errors.js +0 -35
  5. package/dist/lib/esnext/common/functions.js +0 -84
  6. package/dist/lib/esnext/common/interfaces/index.js +0 -1
  7. package/dist/lib/esnext/compat/index.js +0 -3
  8. package/dist/lib/esnext/connection/index.js +19 -6
  9. package/dist/lib/esnext/connection/util/functions.js +0 -56
  10. package/dist/lib/esnext/index.js +0 -1
  11. package/dist/lib/esnext/message/index.js +1 -1
  12. package/dist/lib/esnext/message/interfaces/index.js +0 -1
  13. package/dist/lib/esnext/message/request/TransportLayerClientRequestHeader.js +1 -1
  14. package/dist/lib/esnext/message/request/raw/example/CreateNotationSearchRequest.js +1 -1
  15. package/dist/lib/esnext/message/request/raw/index.js +0 -1
  16. package/dist/lib/esnext/message/response/index.js +0 -5
  17. package/dist/lib/esnext/message/update/index.js +0 -1
  18. package/dist/lib/esnext/mixins/EndpointRequestMixin.js +1 -1
  19. package/dist/lib/esnext/mixins/RemoteLoggerMixin.js +29 -0
  20. package/dist/lib/esnext/mixins/auth/AppAuthMixin.js +79 -11
  21. package/dist/lib/esnext/mixins/auth/SessionAuthMixin.js +76 -36
  22. package/dist/lib/esnext/mixins/auth/UserCredentialAuthMixin.js +82 -12
  23. package/dist/lib/esnext/mixins/auth/UserPasswordAuthMixin.js +80 -13
  24. package/dist/lib/esnext/mixins/auth/index.js +0 -31
  25. package/dist/lib/esnext/mixins/index.js +1 -0
  26. package/dist/lib/esnext/mixins/subscription/EndpointSubscriptionMixin.js +149 -122
  27. package/dist/lib/esnext/version.js +1 -1
  28. package/dist/lib/node/FrontgateClient.js +0 -3
  29. package/dist/lib/node/authentication/index.js +4 -4
  30. package/dist/lib/node/common/errors.js +1 -41
  31. package/dist/lib/node/common/functions.js +0 -92
  32. package/dist/lib/node/common/interfaces/index.js +0 -1
  33. package/dist/lib/node/compat/index.js +0 -3
  34. package/dist/lib/node/connection/index.js +20 -6
  35. package/dist/lib/node/connection/util/functions.js +0 -63
  36. package/dist/lib/node/index.js +1 -3
  37. package/dist/lib/node/message/index.js +2 -1
  38. package/dist/lib/node/message/interfaces/index.js +0 -1
  39. package/dist/lib/node/message/request/TransportLayerClientRequestHeader.js +3 -3
  40. package/dist/lib/node/message/request/raw/example/CreateNotationSearchRequest.js +3 -3
  41. package/dist/lib/node/message/request/raw/index.js +0 -1
  42. package/dist/lib/node/message/response/index.js +0 -5
  43. package/dist/lib/node/message/update/index.js +0 -1
  44. package/dist/lib/node/mixins/EndpointRequestMixin.js +2 -2
  45. package/dist/lib/node/mixins/RemoteLoggerMixin.js +33 -0
  46. package/dist/lib/node/mixins/auth/AppAuthMixin.js +78 -10
  47. package/dist/lib/node/mixins/auth/SessionAuthMixin.js +75 -35
  48. package/dist/lib/node/mixins/auth/UserCredentialAuthMixin.js +80 -10
  49. package/dist/lib/node/mixins/auth/UserPasswordAuthMixin.js +78 -11
  50. package/dist/lib/node/mixins/auth/index.js +0 -33
  51. package/dist/lib/node/mixins/index.js +1 -0
  52. package/dist/lib/node/mixins/subscription/EndpointSubscriptionMixin.js +149 -122
  53. package/dist/lib/node/version.js +1 -1
  54. package/dist/lib/types/FrontgateClient.d.ts +0 -1
  55. package/dist/lib/types/authentication/index.d.ts +3 -4
  56. package/dist/lib/types/authentication/util/ChallengeResolver.d.ts +2 -1
  57. package/dist/lib/types/common/errors.d.ts +0 -21
  58. package/dist/lib/types/common/functions.d.ts +0 -8
  59. package/dist/lib/types/common/interfaces/index.d.ts +0 -1
  60. package/dist/lib/types/compat/index.d.ts +0 -3
  61. package/dist/lib/types/connection/index.d.ts +16 -6
  62. package/dist/lib/types/connection/util/functions.d.ts +0 -18
  63. package/dist/lib/types/index.d.ts +0 -1
  64. package/dist/lib/types/message/index.d.ts +1 -1
  65. package/dist/lib/types/message/interfaces/index.d.ts +0 -1
  66. package/dist/lib/types/message/request/TransportLayerClientRequestHeader.d.ts +1 -0
  67. package/dist/lib/types/message/request/raw/index.d.ts +0 -1
  68. package/dist/lib/types/message/response/index.d.ts +0 -5
  69. package/dist/lib/types/message/update/index.d.ts +0 -1
  70. package/dist/lib/types/mixins/AuthTokenRequestMixin.d.ts +1 -2
  71. package/dist/lib/types/mixins/EndpointRequestMixin.d.ts +1 -2
  72. package/dist/lib/types/mixins/HTTPProxyRequestMixin.d.ts +1 -4
  73. package/dist/lib/types/mixins/LoggerMixin.d.ts +1 -2
  74. package/dist/lib/types/mixins/MessageCompressorMixin.d.ts +1 -2
  75. package/dist/lib/types/mixins/OpenTelemetryMixin.d.ts +1 -2
  76. package/dist/lib/types/mixins/PingMixin.d.ts +1 -2
  77. package/dist/lib/types/mixins/ReconnectMixin.d.ts +1 -2
  78. package/dist/lib/types/mixins/RemoteLoggerMixin.d.ts +16 -0
  79. package/dist/lib/types/mixins/RequestMixin.d.ts +1 -2
  80. package/dist/lib/types/mixins/auth/AppAuthMixin.d.ts +15 -8
  81. package/dist/lib/types/mixins/auth/CookieTokenAuthMixin.d.ts +1 -2
  82. package/dist/lib/types/mixins/auth/FetchAuthenticationMixin.d.ts +1 -2
  83. package/dist/lib/types/mixins/auth/SessionAuthMixin.d.ts +10 -5
  84. package/dist/lib/types/mixins/auth/TokenAuthMixin.d.ts +1 -2
  85. package/dist/lib/types/mixins/auth/UserCredentialAuthMixin.d.ts +15 -8
  86. package/dist/lib/types/mixins/auth/UserPasswordAuthMixin.d.ts +15 -8
  87. package/dist/lib/types/mixins/auth/index.d.ts +0 -8
  88. package/dist/lib/types/mixins/connection/FrontgateWSMixin.d.ts +1 -2
  89. package/dist/lib/types/mixins/index.d.ts +2 -1
  90. package/dist/lib/types/mixins/subscription/EndpointSubscriptionMixin.d.ts +4 -6
  91. package/dist/lib/types/mixins/subscription/RawSubscriptionMixin.d.ts +1 -2
  92. package/dist/lib/umd/mdg2.client.min.umd.js +1 -12
  93. package/dist/lib/umd/mdg2.client.umd.js +4061 -8138
  94. package/package.json +25 -28
  95. package/dist/lib/esnext/Mdg2Client.js +0 -185
  96. package/dist/lib/esnext/authentication/AbstractAuthentication.js +0 -49
  97. package/dist/lib/esnext/authentication/AppAuthentication.js +0 -70
  98. package/dist/lib/esnext/authentication/AuthenticationInterface.js +0 -1
  99. package/dist/lib/esnext/authentication/CookieTokenAuthentication.js +0 -18
  100. package/dist/lib/esnext/authentication/TokenAuthentication.js +0 -42
  101. package/dist/lib/esnext/authentication/UserCredentialAuthentication.js +0 -73
  102. package/dist/lib/esnext/authentication/UserPasswordAuthentication.js +0 -71
  103. package/dist/lib/esnext/common/Mdg2ClientOptions.js +0 -1
  104. package/dist/lib/esnext/common/constants.js +0 -10
  105. package/dist/lib/esnext/common/interfaces/observe/ObserveOptions.js +0 -1
  106. package/dist/lib/esnext/connection/AbstractFrontgateConnection.js +0 -324
  107. package/dist/lib/esnext/connection/ConnectionInterface.js +0 -1
  108. package/dist/lib/esnext/connection/FrontgateWSConnection.js +0 -281
  109. package/dist/lib/esnext/connection/JobPromise.js +0 -2
  110. package/dist/lib/esnext/connection/LatencyHandler.js +0 -1
  111. package/dist/lib/esnext/connection/LatencyTracker.js +0 -47
  112. package/dist/lib/esnext/connection/MessageProcessor.js +0 -1
  113. package/dist/lib/esnext/connection/util/Encoding.js +0 -14
  114. package/dist/lib/esnext/core/RequestModule.js +0 -349
  115. package/dist/lib/esnext/core/SubscriptionModule.js +0 -104
  116. package/dist/lib/esnext/core/subscription/EndpointHandler.js +0 -121
  117. package/dist/lib/esnext/core/subscription/SubjectManager.js +0 -39
  118. package/dist/lib/esnext/message/MessageFactory.js +0 -36
  119. package/dist/lib/esnext/message/guards.js +0 -21
  120. package/dist/lib/esnext/message/interfaces/JobObservable.js +0 -1
  121. package/dist/lib/esnext/message/request/raw/RawRequestFactory.js +0 -18
  122. package/dist/lib/esnext/message/response/AuthenticationByTokenResponse.js +0 -1
  123. package/dist/lib/esnext/message/response/CancelSubscriptionResponse.js +0 -3
  124. package/dist/lib/esnext/message/response/LoadNotificationMessage.js +0 -1
  125. package/dist/lib/esnext/message/response/PermissionDeniedResponse.js +0 -6
  126. package/dist/lib/esnext/message/response/RejectResponse.js +0 -9
  127. package/dist/lib/esnext/message/update/SubscriptionLossMessage.js +0 -10
  128. package/dist/lib/esnext/util/TimeOutWrapper.js +0 -51
  129. package/dist/lib/node/Mdg2Client.js +0 -189
  130. package/dist/lib/node/authentication/AbstractAuthentication.js +0 -53
  131. package/dist/lib/node/authentication/AppAuthentication.js +0 -74
  132. package/dist/lib/node/authentication/AuthenticationInterface.js +0 -2
  133. package/dist/lib/node/authentication/CookieTokenAuthentication.js +0 -22
  134. package/dist/lib/node/authentication/TokenAuthentication.js +0 -46
  135. package/dist/lib/node/authentication/UserCredentialAuthentication.js +0 -77
  136. package/dist/lib/node/authentication/UserPasswordAuthentication.js +0 -75
  137. package/dist/lib/node/common/Mdg2ClientOptions.js +0 -2
  138. package/dist/lib/node/common/constants.js +0 -13
  139. package/dist/lib/node/common/interfaces/observe/ObserveOptions.js +0 -2
  140. package/dist/lib/node/connection/AbstractFrontgateConnection.js +0 -328
  141. package/dist/lib/node/connection/ConnectionInterface.js +0 -2
  142. package/dist/lib/node/connection/FrontgateWSConnection.js +0 -288
  143. package/dist/lib/node/connection/JobPromise.js +0 -6
  144. package/dist/lib/node/connection/LatencyHandler.js +0 -2
  145. package/dist/lib/node/connection/LatencyTracker.js +0 -51
  146. package/dist/lib/node/connection/MessageProcessor.js +0 -2
  147. package/dist/lib/node/connection/util/Encoding.js +0 -18
  148. package/dist/lib/node/core/RequestModule.js +0 -353
  149. package/dist/lib/node/core/SubscriptionModule.js +0 -108
  150. package/dist/lib/node/core/subscription/EndpointHandler.js +0 -125
  151. package/dist/lib/node/core/subscription/SubjectManager.js +0 -43
  152. package/dist/lib/node/message/MessageFactory.js +0 -73
  153. package/dist/lib/node/message/guards.js +0 -30
  154. package/dist/lib/node/message/interfaces/JobObservable.js +0 -2
  155. package/dist/lib/node/message/request/raw/RawRequestFactory.js +0 -22
  156. package/dist/lib/node/message/response/AuthenticationByTokenResponse.js +0 -2
  157. package/dist/lib/node/message/response/CancelSubscriptionResponse.js +0 -7
  158. package/dist/lib/node/message/response/LoadNotificationMessage.js +0 -2
  159. package/dist/lib/node/message/response/PermissionDeniedResponse.js +0 -10
  160. package/dist/lib/node/message/response/RejectResponse.js +0 -13
  161. package/dist/lib/node/message/update/SubscriptionLossMessage.js +0 -14
  162. package/dist/lib/node/util/TimeOutWrapper.js +0 -55
  163. package/dist/lib/types/Mdg2Client.d.ts +0 -52
  164. package/dist/lib/types/authentication/AbstractAuthentication.d.ts +0 -17
  165. package/dist/lib/types/authentication/AppAuthentication.d.ts +0 -12
  166. package/dist/lib/types/authentication/AuthenticationInterface.d.ts +0 -9
  167. package/dist/lib/types/authentication/CookieTokenAuthentication.d.ts +0 -6
  168. package/dist/lib/types/authentication/TokenAuthentication.d.ts +0 -14
  169. package/dist/lib/types/authentication/UserCredentialAuthentication.d.ts +0 -13
  170. package/dist/lib/types/authentication/UserPasswordAuthentication.d.ts +0 -14
  171. package/dist/lib/types/common/Mdg2ClientOptions.d.ts +0 -12
  172. package/dist/lib/types/common/constants.d.ts +0 -11
  173. package/dist/lib/types/common/interfaces/observe/ObserveOptions.d.ts +0 -5
  174. package/dist/lib/types/connection/AbstractFrontgateConnection.d.ts +0 -116
  175. package/dist/lib/types/connection/ConnectionInterface.d.ts +0 -53
  176. package/dist/lib/types/connection/FrontgateWSConnection.d.ts +0 -23
  177. package/dist/lib/types/connection/JobPromise.d.ts +0 -3
  178. package/dist/lib/types/connection/LatencyHandler.d.ts +0 -1
  179. package/dist/lib/types/connection/LatencyTracker.d.ts +0 -13
  180. package/dist/lib/types/connection/MessageProcessor.d.ts +0 -2
  181. package/dist/lib/types/connection/util/Encoding.d.ts +0 -9
  182. package/dist/lib/types/core/RequestModule.d.ts +0 -78
  183. package/dist/lib/types/core/SubscriptionModule.d.ts +0 -24
  184. package/dist/lib/types/core/subscription/EndpointHandler.d.ts +0 -37
  185. package/dist/lib/types/core/subscription/SubjectManager.d.ts +0 -21
  186. package/dist/lib/types/message/MessageFactory.d.ts +0 -29
  187. package/dist/lib/types/message/guards.d.ts +0 -11
  188. package/dist/lib/types/message/interfaces/JobObservable.d.ts +0 -4
  189. package/dist/lib/types/message/request/raw/RawRequestFactory.d.ts +0 -4
  190. package/dist/lib/types/message/response/AuthenticationByTokenResponse.d.ts +0 -20
  191. package/dist/lib/types/message/response/CancelSubscriptionResponse.d.ts +0 -3
  192. package/dist/lib/types/message/response/LoadNotificationMessage.d.ts +0 -8
  193. package/dist/lib/types/message/response/PermissionDeniedResponse.d.ts +0 -4
  194. package/dist/lib/types/message/response/RejectResponse.d.ts +0 -5
  195. package/dist/lib/types/message/update/SubscriptionLossMessage.d.ts +0 -17
  196. package/dist/lib/types/util/TimeOutWrapper.d.ts +0 -12
@@ -13,29 +13,96 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.userPasswordAuth = void 0;
15
15
  const _1 = require("../.");
16
- const compat_1 = require("../../compat");
16
+ const connection_1 = require("../../connection");
17
17
  const authentication_1 = require("../../authentication");
18
+ const compat_1 = require("../../compat");
19
+ const logger_1 = require("../../logger");
20
+ const crypto_1 = require("crypto");
18
21
  const userPasswordAuth = (idApplication, username, password, deploymentStage) => {
19
22
  const mixinUserPasswordAuth = (Base) => {
20
- var _auth, _a;
23
+ var _instances, _sharedSecret, _clientSecret, _createAuthenticationRequest, _createConfigurationRequest, _createTransportLayerRequestHeaderConfigurationRequest, _submit, _a;
21
24
  return _a = class extends Base {
22
25
  constructor(...args) {
23
26
  super(...args);
24
- _auth.set(this, void 0);
25
- __classPrivateFieldSet(this, _auth, new compat_1.UserPasswordAuthentication(idApplication, username, password), "f");
27
+ _instances.add(this);
28
+ _sharedSecret.set(this, void 0);
29
+ _clientSecret.set(this, void 0);
30
+ const plainSharedSecret = compat_1.SecretGenerator.generateSharedSecret(username, password);
31
+ const plainClientSecret = compat_1.SecretGenerator.generateClientSecret(username, password);
32
+ if (plainSharedSecret && plainClientSecret) {
33
+ __classPrivateFieldSet(this, _sharedSecret, Buffer.from(plainSharedSecret), "f");
34
+ __classPrivateFieldSet(this, _clientSecret, Buffer.from(plainClientSecret), "f");
35
+ }
26
36
  this.hooks.hook('frontgateConnection:connected', async (conf) => {
27
37
  void this.hooks.callHook('frontgateConnection:setIdApp', idApplication);
28
- void this.hooks.callHook('frontgateConnection:setIdUser', authentication_1.ID_USER_NONE);
29
- await __classPrivateFieldGet(this, _auth, "f").authenticate((0, _1.createConnectionInterface)({
30
- payload_content: conf.payloadContent,
31
- deployment_stage: deploymentStage,
32
- maximum_idle_interval: conf.maximumIdleInterval,
33
- }, this));
38
+ void this.hooks.callHook('frontgateConnection:setIdUser', authentication_1.ID_USER_AUTHENTICATED);
39
+ const authResponse = await __classPrivateFieldGet(this, _instances, "m", _submit).call(this, __classPrivateFieldGet(this, _instances, "m", _createAuthenticationRequest).call(this).toJson());
40
+ await __classPrivateFieldGet(this, _instances, "m", _submit).call(this, __classPrivateFieldGet(this, _instances, "m", _createConfigurationRequest).call(this, authResponse, conf).toJson());
41
+ await __classPrivateFieldGet(this, _instances, "m", _submit).call(this, __classPrivateFieldGet(this, _instances, "m", _createTransportLayerRequestHeaderConfigurationRequest).call(this));
34
42
  await this.hooks.callHook('frontgateConnection:authenticated');
35
43
  });
36
44
  }
37
45
  },
38
- _auth = new WeakMap(),
46
+ _sharedSecret = new WeakMap(),
47
+ _clientSecret = new WeakMap(),
48
+ _instances = new WeakSet(),
49
+ _createAuthenticationRequest = function _createAuthenticationRequest() {
50
+ const salt = (0, crypto_1.randomBytes)(16);
51
+ const options = {
52
+ idApplication,
53
+ username,
54
+ salt: (0, connection_1.getBytesFromBuffer)(salt),
55
+ challenge: (0, connection_1.getBytesFromBuffer)((0, crypto_1.randomBytes)(16)),
56
+ encryptedSecrets: [{ encrypted_secret: compat_1.SecretGenerator.createEncryptedSecret(salt, __classPrivateFieldGet(this, _sharedSecret, "f"), __classPrivateFieldGet(this, _clientSecret, "f")) }],
57
+ };
58
+ return new compat_1.AuthenticationRequest(options);
59
+ },
60
+ _createConfigurationRequest = function _createConfigurationRequest(msg, conf) {
61
+ const expectedMessage = 'Foundation::AuthenticationResponse';
62
+ if (msg.Message !== expectedMessage) {
63
+ throw new Error(`Expected message "${expectedMessage}" but received "${msg.Message}"`);
64
+ }
65
+ if (msg.id_user === authentication_1.ID_USER_AUTHENTICATED) {
66
+ void this.hooks.callHook('frontgateConnection:setIdApp', authentication_1.ID_APP_AUTHENTICATED);
67
+ void this.hooks.callHook('frontgateConnection:setIdUser', authentication_1.ID_USER_AUTHENTICATED);
68
+ }
69
+ const { challenge } = msg.challenge;
70
+ const options = {
71
+ shared_secret: __classPrivateFieldGet(this, _sharedSecret, "f"),
72
+ payload_content: conf.payloadContent,
73
+ deployment_stage: deploymentStage,
74
+ maximum_idle_interval: conf.maximumIdleInterval,
75
+ };
76
+ return new compat_1.ConfigurationRequest(challenge, options);
77
+ },
78
+ _createTransportLayerRequestHeaderConfigurationRequest = function _createTransportLayerRequestHeaderConfigurationRequest() {
79
+ return {
80
+ Message: 'TransportLayerClientConfigurationRequest',
81
+ Version: 1,
82
+ flags: 0,
83
+ };
84
+ },
85
+ _submit = async function _submit(message) {
86
+ this.log(logger_1.LogLevel.INFO, 'Sending message', message);
87
+ const msg = {
88
+ message,
89
+ callbackType: 'response',
90
+ callbackId: message.Message.replace('Request', 'Response'),
91
+ };
92
+ await this.hooks.callHook('frontgateConnection:sendMessage', msg);
93
+ let timeout;
94
+ return new Promise((resolve, reject) => {
95
+ const unsubMessage = this.hooks.hookOnce(`frontgateConnection:response:${msg.callbackId}`, (response) => {
96
+ clearTimeout(timeout);
97
+ this.log(logger_1.LogLevel.INFO, 'Received response', response);
98
+ resolve(response);
99
+ });
100
+ timeout = setTimeout(() => {
101
+ unsubMessage();
102
+ reject(new Error('Authentication message timeout'));
103
+ }, 3000);
104
+ });
105
+ },
39
106
  _a;
40
107
  };
41
108
  return (0, _1.createExtendedMixinFactory)(mixinUserPasswordAuth, {
@@ -14,39 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.createConnectionInterface = void 0;
18
- const logger_1 = require("../../logger");
19
17
  __exportStar(require("./CookieTokenAuthMixin"), exports);
20
18
  __exportStar(require("./TokenAuthMixin"), exports);
21
19
  __exportStar(require("./FetchAuthenticationMixin"), exports);
22
- const createConnectionInterface = (options, base) => {
23
- return {
24
- options,
25
- submit: async (message) => {
26
- base.log(logger_1.LogLevel.INFO, 'Sending message', message);
27
- const msg = {
28
- message,
29
- callbackType: 'response',
30
- callbackId: message.Message.replace('Request', 'Response'),
31
- };
32
- await base.hooks.callHook('frontgateConnection:sendMessage', msg);
33
- let timeout;
34
- return new Promise((resolve, reject) => {
35
- const unsubMessage = base.hooks.hookOnce(`frontgateConnection:response:${msg.callbackId}`, (response) => {
36
- clearTimeout(timeout);
37
- base.log(logger_1.LogLevel.INFO, 'Received response', response);
38
- resolve(response);
39
- });
40
- timeout = setTimeout(() => {
41
- unsubMessage();
42
- reject(new Error('Authentication message timeout'));
43
- }, 3000);
44
- });
45
- },
46
- setPeerInfo: (peerInfo) => {
47
- base.log(logger_1.LogLevel.INFO, 'Peer info:', peerInfo);
48
- },
49
- auth: {},
50
- };
51
- };
52
- exports.createConnectionInterface = createConnectionInterface;
@@ -27,6 +27,7 @@ __exportStar(require("./ReconnectMixin"), exports);
27
27
  __exportStar(require("./OpenTelemetryMixin"), exports);
28
28
  __exportStar(require("./HTTPProxyRequestMixin"), exports);
29
29
  __exportStar(require("./PingMixin"), exports);
30
+ __exportStar(require("./RemoteLoggerMixin"), exports);
30
31
  const createExtendedMixinFactory = (mixinFactory, options) => {
31
32
  const extendedMixinFactory = mixinFactory;
32
33
  extendedMixinFactory.featureName = options.featureName;
@@ -12,23 +12,33 @@ const message_1 = require("../../message");
12
12
  const functions_1 = require("../../util/functions");
13
13
  const endpointSubscriptions = (originalConfig) => {
14
14
  const mixinEndpointSubscribable = (Base) => {
15
- var _subscriptions, _a;
15
+ var _subscriptions, _subscriptionCounts, _inFlights, _a;
16
16
  const config = { ...originalConfig };
17
17
  return _a = class extends Base {
18
18
  constructor() {
19
19
  super(...arguments);
20
20
  _subscriptions.set(this, new Map());
21
+ _subscriptionCounts.set(this, new Map());
22
+ _inFlights.set(this, new Map());
21
23
  }
22
24
  async observeEndpoint(method, path, data, requestOptions) {
23
25
  const key = `${method}:${path}:${JSON.stringify(data)}:${JSON.stringify(requestOptions ?? {})}`;
26
+ if (__classPrivateFieldGet(this, _inFlights, "f").has(key)) {
27
+ const inFlightPromise = __classPrivateFieldGet(this, _inFlights, "f").get(key);
28
+ this.log(logger_1.LogLevel.INFO, `Catching inflight subscription for ${key}`);
29
+ const subscriptionCount = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
30
+ __classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, subscriptionCount + 1);
31
+ return inFlightPromise;
32
+ }
24
33
  const timeOutInMs = config.timeout ?? this.defaultTimeoutInMs;
25
34
  const resubscribeTimeout = config.subscriptionResubscribeTimeout ?? 1000;
26
35
  if (__classPrivateFieldGet(this, _subscriptions, "f").has(key)) {
27
36
  const subscription = __classPrivateFieldGet(this, _subscriptions, "f").get(key);
37
+ const subscriptionCount = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
28
38
  if (subscription) {
29
- subscription.count++;
39
+ __classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, subscriptionCount + 1);
30
40
  this.log(logger_1.LogLevel.INFO, `Reusing existing subscription for ${key}`);
31
- return subscription.observer;
41
+ return subscription;
32
42
  }
33
43
  }
34
44
  this.log(logger_1.LogLevel.INFO, `Creating new subscription for ${key}`);
@@ -39,153 +49,170 @@ const endpointSubscriptions = (originalConfig) => {
39
49
  callbackType: 'job',
40
50
  callbackId: '',
41
51
  };
42
- await this.hooks.callHook('frontgateConnection:sendMessage', subscriptionMsg);
43
52
  const promise = new Promise((resolve, reject) => {
44
- this.hooks.hookOnce(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (response) => {
45
- if (!response.Message.includes('HighLevelResponse')) {
46
- this.log(logger_1.LogLevel.ERROR, `Unexpected response: ${response.Message}`);
47
- reject(new message_1.ErrorResponse(JSON.stringify(response)));
48
- return;
49
- }
50
- let hlResponseData;
51
- try {
52
- hlResponseData = JSON.parse(response.body.value);
53
- }
54
- catch (e) {
55
- this.log(logger_1.LogLevel.ERROR, `Failed to parse response: ${response.body.value}`);
56
- this.log(logger_1.LogLevel.ERROR, e);
57
- reject(e);
58
- return;
59
- }
60
- const observer = new __1.FrontgateClientEndpointDataObserver(response.header.id_job, hlResponseData);
61
- let removeMessageUpdateHook = this.hooks.hook(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (update) => {
62
- if (!update.Message.includes('HighLevelUpdate')) {
63
- if (update.Message.includes('SubscriptionLoss')) {
64
- this.log(logger_1.LogLevel.DEBUG, `Received: ${update.Message}`);
65
- setTimeout(() => {
66
- void resubscribe();
67
- }, (0, functions_1.addRandomnessToTime)(resubscribeTimeout));
68
- removeMessageUpdateHook();
69
- return;
70
- }
53
+ this.hooks
54
+ .callHook('frontgateConnection:sendMessage', subscriptionMsg)
55
+ .then(() => {
56
+ this.hooks.hookOnce(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (response) => {
57
+ if (!response.Message.includes('HighLevelResponse')) {
71
58
  this.log(logger_1.LogLevel.ERROR, `Unexpected response: ${response.Message}`);
72
- observer.pushError(new message_1.ErrorResponse(JSON.stringify(update)));
73
- removeMessageUpdateHook();
59
+ reject(new message_1.ErrorResponse(JSON.stringify(response)));
74
60
  return;
75
61
  }
76
- let hlUpdate;
62
+ let hlResponseData;
77
63
  try {
78
- hlUpdate = new message_1.HighLevelUpdate(update);
64
+ hlResponseData = JSON.parse(response.body.value);
79
65
  }
80
66
  catch (e) {
81
- this.log(logger_1.LogLevel.ERROR, `Failed to parse response: ${update.body.value}`);
82
- observer.pushError(e);
67
+ this.log(logger_1.LogLevel.ERROR, `Failed to parse response: ${response.body.value}`);
68
+ this.log(logger_1.LogLevel.ERROR, e);
69
+ reject(e);
83
70
  return;
84
71
  }
85
- observer.pushPatchData(hlUpdate.data);
86
- });
87
- const resubscribe = async () => {
88
- removeMessageUpdateHook();
89
- this.log(logger_1.LogLevel.INFO, `Resubscribing to ${key} due to reconnect`);
90
- await this.hooks.callHook('frontgateConnection:sendMessage', subscriptionMsg);
91
- const resubscribePromise = new Promise((res, rej) => {
92
- this.hooks.hookOnce(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (resp) => {
93
- if (!response.Message.includes('HighLevelResponse')) {
94
- const err = new message_1.ErrorResponse(resp);
95
- this.log(logger_1.LogLevel.ERROR, `Unexpected response: ${resp.Message}`);
72
+ const observer = new __1.FrontgateClientEndpointDataObserver(response.header.id_job, hlResponseData);
73
+ let removeMessageUpdateHook = this.hooks.hook(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (update) => {
74
+ if (!update.Message.includes('HighLevelUpdate')) {
75
+ if (update.Message.includes('SubscriptionLoss')) {
76
+ this.log(logger_1.LogLevel.DEBUG, `Received: ${update.Message}`);
77
+ setTimeout(() => {
78
+ void resubscribe();
79
+ }, (0, functions_1.addRandomnessToTime)(resubscribeTimeout));
96
80
  removeMessageUpdateHook();
97
- rej(err);
98
81
  return;
99
82
  }
100
- this.log(logger_1.LogLevel.INFO, `Resubscribed to ${key} with ${resp.header.id_job}`);
101
- observer.idJob = resp.header.id_job;
102
- removeMessageUpdateHook = this.hooks.hook(`frontgateConnection:response:${resp.header.id_job}`, (update) => {
103
- if (!update.Message.includes('HighLevelUpdate')) {
104
- if (update.Message.includes('SubscriptionLoss')) {
105
- this.log(logger_1.LogLevel.DEBUG, `Received: ${update.Message}`);
106
- setTimeout(() => {
107
- void resubscribe();
108
- }, (0, functions_1.addRandomnessToTime)(resubscribeTimeout));
109
- return;
110
- }
111
- this.log(logger_1.LogLevel.ERROR, `Unexpected response: ${update.Message}`);
112
- const err = new message_1.ErrorResponse(update);
113
- observer.pushError(err);
114
- return;
115
- }
116
- let hlUpdate;
117
- try {
118
- hlUpdate = new message_1.HighLevelUpdate(update);
119
- }
120
- catch (e) {
121
- this.log(logger_1.LogLevel.ERROR, `Failed to parse response: ${update.body.value}`);
122
- observer.pushError(e);
83
+ this.log(logger_1.LogLevel.ERROR, `Unexpected response: ${response.Message}`);
84
+ observer.pushError(new message_1.ErrorResponse(JSON.stringify(update)));
85
+ removeMessageUpdateHook();
86
+ return;
87
+ }
88
+ let hlUpdate;
89
+ try {
90
+ hlUpdate = new message_1.HighLevelUpdate(update);
91
+ }
92
+ catch (e) {
93
+ this.log(logger_1.LogLevel.ERROR, `Failed to parse response: ${update.body.value}`);
94
+ observer.pushError(e);
95
+ return;
96
+ }
97
+ observer.pushPatchData(hlUpdate.data);
98
+ });
99
+ const resubscribe = async () => {
100
+ removeMessageUpdateHook();
101
+ this.log(logger_1.LogLevel.INFO, `Resubscribing to ${key} due to reconnect`);
102
+ await this.hooks.callHook('frontgateConnection:sendMessage', subscriptionMsg);
103
+ const resubscribePromise = new Promise((res, rej) => {
104
+ this.hooks.hookOnce(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (resp) => {
105
+ if (!response.Message.includes('HighLevelResponse')) {
106
+ const err = new message_1.ErrorResponse(resp);
107
+ this.log(logger_1.LogLevel.ERROR, `Unexpected response: ${resp.Message}`);
108
+ removeMessageUpdateHook();
109
+ rej(err);
123
110
  return;
124
111
  }
125
- observer.unsubscribe = () => {
126
- const subscription = __classPrivateFieldGet(this, _subscriptions, "f").get(key);
127
- if (subscription) {
128
- subscription.count--;
129
- if (subscription.count > 0) {
130
- this.log(logger_1.LogLevel.INFO, `Not unsubscribing from ${key} as there are still ${subscription.count} subscribers`);
112
+ this.log(logger_1.LogLevel.INFO, `Resubscribed to ${key} with ${resp.header.id_job}`);
113
+ observer.idJob = resp.header.id_job;
114
+ removeMessageUpdateHook = this.hooks.hook(`frontgateConnection:response:${resp.header.id_job}`, (update) => {
115
+ if (!update.Message.includes('HighLevelUpdate')) {
116
+ if (update.Message.includes('SubscriptionLoss')) {
117
+ this.log(logger_1.LogLevel.DEBUG, `Received: ${update.Message}`);
118
+ setTimeout(() => {
119
+ void resubscribe();
120
+ }, (0, functions_1.addRandomnessToTime)(resubscribeTimeout));
131
121
  return;
132
122
  }
133
- __classPrivateFieldGet(this, _subscriptions, "f").delete(key);
123
+ this.log(logger_1.LogLevel.ERROR, `Unexpected response: ${update.Message}`);
124
+ const err = new message_1.ErrorResponse(update);
125
+ observer.pushError(err);
126
+ return;
127
+ }
128
+ let hlUpdate;
129
+ try {
130
+ hlUpdate = new message_1.HighLevelUpdate(update);
134
131
  }
135
- this.log(logger_1.LogLevel.INFO, `Unsubscribing from ${key}`);
136
- const cancelationRequest = new message_1.CancelSubscriptionRequest(observer.idJob);
137
- const unsubscribeMsg = {
138
- message: cancelationRequest.getPtlMessage(),
139
- callbackType: 'job',
140
- callbackId: '',
132
+ catch (e) {
133
+ this.log(logger_1.LogLevel.ERROR, `Failed to parse response: ${update.body.value}`);
134
+ observer.pushError(e);
135
+ return;
136
+ }
137
+ observer.unsubscribe = () => {
138
+ const subscription = __classPrivateFieldGet(this, _subscriptions, "f").get(key);
139
+ if (subscription) {
140
+ const subcounts = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
141
+ __classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, subcounts - 1);
142
+ if (subcounts - 1 > 0) {
143
+ this.log(logger_1.LogLevel.INFO, `Not unsubscribing from ${key} as there are still ${subcounts} subscribers`);
144
+ return;
145
+ }
146
+ __classPrivateFieldGet(this, _subscriptions, "f").delete(key);
147
+ __classPrivateFieldGet(this, _subscriptionCounts, "f").delete(key);
148
+ }
149
+ this.log(logger_1.LogLevel.INFO, `Unsubscribing from ${key}`);
150
+ const cancelationRequest = new message_1.CancelSubscriptionRequest(observer.idJob);
151
+ const unsubscribeMsg = {
152
+ message: cancelationRequest.getPtlMessage(),
153
+ callbackType: 'job',
154
+ callbackId: '',
155
+ };
156
+ void this.hooks.callHook('frontgateConnection:sendMessage', unsubscribeMsg);
157
+ removeMessageUpdateHook();
158
+ removeReconnectHook();
141
159
  };
142
- void this.hooks.callHook('frontgateConnection:sendMessage', unsubscribeMsg);
143
- removeMessageUpdateHook();
144
- removeReconnectHook();
145
- };
146
- observer.pushPatchData(hlUpdate.data);
160
+ observer.pushPatchData(hlUpdate.data);
161
+ });
162
+ res();
147
163
  });
148
- res();
149
164
  });
150
- });
151
- try {
152
- await (0, functions_1.useTimeout)(timeOutInMs, 'Request timeout reached', resubscribePromise);
153
- }
154
- catch (e) {
155
- observer.pushError(new message_1.ErrorResponse({ Message: 'Reconnect failed', Error: e }));
156
- }
157
- };
158
- const removeReconnectHook = this.hooks.hook('reconnect:success', resubscribe);
159
- observer.unsubscribe = () => {
160
- const subscription = __classPrivateFieldGet(this, _subscriptions, "f").get(key);
161
- if (subscription) {
162
- subscription.count--;
163
- if (subscription.count > 0) {
164
- this.log(logger_1.LogLevel.INFO, `Not unsubscribing from ${key} as there are still ${subscription.count} subscribers`);
165
- return;
165
+ try {
166
+ await (0, functions_1.useTimeout)(timeOutInMs, 'Request timeout reached', resubscribePromise);
166
167
  }
167
- __classPrivateFieldGet(this, _subscriptions, "f").delete(key);
168
- }
169
- this.log(logger_1.LogLevel.INFO, `Unsubscribing from ${key}`);
170
- const cancelationRequest = new message_1.CancelSubscriptionRequest(observer.idJob);
171
- const unsubscribeMsg = {
172
- message: cancelationRequest.getPtlMessage(),
173
- callbackType: 'job',
174
- callbackId: '',
168
+ catch (e) {
169
+ observer.pushError(new message_1.ErrorResponse({ Message: 'Reconnect failed', Error: e }));
170
+ }
171
+ };
172
+ const removeReconnectHook = this.hooks.hook('reconnect:success', resubscribe);
173
+ observer.unsubscribe = () => {
174
+ const subscription = __classPrivateFieldGet(this, _subscriptions, "f").get(key);
175
+ if (subscription) {
176
+ const subcounts = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
177
+ __classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, subcounts - 1);
178
+ if (subcounts - 1 > 0) {
179
+ this.log(logger_1.LogLevel.INFO, `Not unsubscribing from ${key} as there are still ${subcounts} subscribers`);
180
+ return;
181
+ }
182
+ __classPrivateFieldGet(this, _subscriptions, "f").delete(key);
183
+ __classPrivateFieldGet(this, _subscriptionCounts, "f").delete(key);
184
+ }
185
+ this.log(logger_1.LogLevel.INFO, `Unsubscribing from ${key}`);
186
+ const cancelationRequest = new message_1.CancelSubscriptionRequest(observer.idJob);
187
+ const unsubscribeMsg = {
188
+ message: cancelationRequest.getPtlMessage(),
189
+ callbackType: 'job',
190
+ callbackId: '',
191
+ };
192
+ void this.hooks.callHook('frontgateConnection:sendMessage', unsubscribeMsg);
193
+ removeMessageUpdateHook();
194
+ removeReconnectHook();
175
195
  };
176
- void this.hooks.callHook('frontgateConnection:sendMessage', unsubscribeMsg);
177
- removeMessageUpdateHook();
178
- removeReconnectHook();
179
- };
180
- __classPrivateFieldGet(this, _subscriptions, "f").set(key, { observer, count: 1 });
181
- resolve(observer);
196
+ __classPrivateFieldGet(this, _subscriptions, "f").set(key, observer);
197
+ const currentSubscounts = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
198
+ __classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, currentSubscounts + 1);
199
+ __classPrivateFieldGet(this, _inFlights, "f").delete(key);
200
+ resolve(observer);
201
+ });
202
+ })
203
+ .catch((e) => {
204
+ reject(e);
182
205
  });
183
206
  });
184
207
  const rejectReason = `Request timeout reached (${timeOutInMs} ms) for ${subscriptionMsg.message.Message}`;
185
- return (0, functions_1.useTimeout)(timeOutInMs, rejectReason, promise);
208
+ const wrappedTimeoutPromise = (0, functions_1.useTimeout)(timeOutInMs, rejectReason, promise);
209
+ __classPrivateFieldGet(this, _inFlights, "f").set(key, wrappedTimeoutPromise);
210
+ return wrappedTimeoutPromise;
186
211
  }
187
212
  },
188
213
  _subscriptions = new WeakMap(),
214
+ _subscriptionCounts = new WeakMap(),
215
+ _inFlights = new WeakMap(),
189
216
  _a;
190
217
  };
191
218
  return (0, __1.createExtendedMixinFactory)(mixinEndpointSubscribable, {
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_JSON = void 0;
4
- exports.PACKAGE_JSON = { version: '6.11.1', package: '@factset/frontgate-js-sdk' };
4
+ exports.PACKAGE_JSON = { version: '7.0.1', package: '@factset/frontgate-js-sdk' };
@@ -19,7 +19,6 @@ export declare class FrontgateClient<hookable extends DefaultFrontgateClientHook
19
19
  logger: LoggerInterface | undefined;
20
20
  hooks: Hookable<hookable>;
21
21
  get defaultTimeoutInMs(): number;
22
- set defaultTimeoutInMs(value: number);
23
22
  constructor(conf?: Partial<FrontgateClientConfig>);
24
23
  log(level: LogLevel, ...args: unknown[]): void;
25
24
  }
@@ -1,5 +1,4 @@
1
- export * from './AbstractAuthentication';
2
- export * from './AuthenticationInterface';
3
- export * from './CookieTokenAuthentication';
4
1
  export * from './CookieTokenAuthenticationFactors';
5
- export * from './TokenAuthentication';
2
+ export declare const ID_APP_AUTHENTICATED = -2;
3
+ export declare const ID_USER_AUTHENTICATED = -2;
4
+ export declare const ID_USER_NONE = -1;
@@ -1,5 +1,5 @@
1
1
  import bigInt from 'big-integer';
2
- export interface SaltedHash {
2
+ interface SaltedHash {
3
3
  salt: number[];
4
4
  hash1: bigInt.BigInteger;
5
5
  hash2: bigInt.BigInteger;
@@ -13,3 +13,4 @@ export declare class ChallengeResolver {
13
13
  private static createSaltedHash;
14
14
  private static hexToInt64LE;
15
15
  }
16
+ export {};
@@ -1,30 +1,9 @@
1
- import type { ErrorResponse } from '../message';
2
1
  export interface CustomError {
3
2
  message: string;
4
3
  name: string;
5
4
  code: number;
6
5
  }
7
- export declare class ServiceUnavailableError extends Error implements CustomError {
8
- code: number;
9
- constructor(message?: string, error?: Error);
10
- }
11
- export declare class InternalServerError extends Error implements CustomError {
12
- code: number;
13
- constructor(message?: string, error?: Error);
14
- }
15
6
  export declare class TimeoutError extends Error implements CustomError {
16
7
  code: number;
17
8
  constructor(message?: string, error?: Error);
18
9
  }
19
- export declare class UnauthorizedError extends Error implements CustomError {
20
- code: number;
21
- constructor(message?: string, error?: Error);
22
- }
23
- export declare class BadRequestError extends Error implements CustomError {
24
- code: number;
25
- constructor(message?: string, error?: Error);
26
- }
27
- export declare class ResponseError extends Error {
28
- response: ErrorResponse;
29
- constructor(message: string, response: ErrorResponse);
30
- }
@@ -1,11 +1,3 @@
1
- import type { ErrorResponse, PermissionDeniedResponse } from '../message';
2
1
  export declare function isObject(obj: unknown): obj is object;
3
2
  export declare function deepmerge(...args: unknown[]): object;
4
- export declare function provideAsArray<T>(subject: T | T[]): T[];
5
- export declare function unsignedArrayToBase64(data: number[] | Uint8Array): string;
6
3
  export declare function toUrlBase64(strInBase64: string): string;
7
- export declare function isBase64Url(tokenStr: string): boolean;
8
- export declare function base64UrlToBase64(base64Url: string): string;
9
- export declare const errorHandler: (response: ErrorResponse | PermissionDeniedResponse) => Error;
10
- export declare const delay: (delayInMs: number) => Promise<unknown>;
11
- export declare const isNodeEnvironment: () => boolean;
@@ -1,4 +1,3 @@
1
- export * from './observe/ObserveOptions';
2
1
  export * from './result/RequestResult';
3
2
  export * from './result/HighLevelRequestResult';
4
3
  export * from './result/HTTPProxyRequestResult';
@@ -1,7 +1,4 @@
1
1
  export * from '../authentication/util';
2
- export * from '../authentication/AppAuthentication';
3
- export * from '../authentication/UserCredentialAuthentication';
4
- export * from '../authentication/UserPasswordAuthentication';
5
2
  export * from '../message/request/AuthenticationRequest';
6
3
  export * from '../message/request/ConfigurationRequest';
7
4
  export * from '../mixins/auth/AppAuthMixin';
@@ -1,7 +1,17 @@
1
- export * from './ConnectionInterface';
2
- export * from './AbstractFrontgateConnection';
3
- export * from './FrontgateWSConnection';
4
- export * from './util/Encoding';
5
1
  export * from './util/functions';
6
- export * from './LatencyHandler';
7
- export * from './LatencyTracker';
2
+ export declare enum ConnectionState {
3
+ DISCONNECTED = 0,
4
+ CONNECTING = 1,
5
+ AUTHENTICATED = 2,
6
+ RECONNECTING = 3
7
+ }
8
+ export declare enum DeploymentStage {
9
+ production = 40,
10
+ preproduction = 35,
11
+ show = 30,
12
+ testing = 20
13
+ }
14
+ export declare enum DefaultHosts {
15
+ production = "frontgate-eu.factsetdigitalsolutions.com",
16
+ show = "frontgate-eu.show.factsetdigitalsolutions.com"
17
+ }