@factset/frontgate-js-sdk 7.1.4 → 7.1.6

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 (97) hide show
  1. package/CHANGELOG.md +50 -24
  2. package/dist/lib/esnext/common/errors.js +4 -5
  3. package/dist/lib/esnext/index.js +1 -0
  4. package/dist/lib/esnext/message/interfaces/PtlMessage.js +4 -0
  5. package/dist/lib/esnext/message/interfaces/index.js +1 -0
  6. package/dist/lib/esnext/message/request/AuthenticationByTokenRequest.js +2 -2
  7. package/dist/lib/esnext/message/request/AuthenticationRequest.js +2 -0
  8. package/dist/lib/esnext/message/request/ConfigurationRequest.js +3 -3
  9. package/dist/lib/esnext/message/response/AuthenticationTokenResponse.js +3 -11
  10. package/dist/lib/esnext/message/response/HTTPProxyResponse.js +3 -0
  11. package/dist/lib/esnext/message/response/Mdg2Response.js +4 -1
  12. package/dist/lib/esnext/message/response/PingResponse.js +0 -6
  13. package/dist/lib/esnext/message/response/index.js +0 -3
  14. package/dist/lib/esnext/mixins/AuthTokenRequestMixin.js +1 -1
  15. package/dist/lib/esnext/mixins/EndpointRequestMixin.js +7 -7
  16. package/dist/lib/esnext/mixins/HTTPProxyRequestMixin.js +1 -1
  17. package/dist/lib/esnext/mixins/OpenTelemetryMixin.js +2 -1
  18. package/dist/lib/esnext/mixins/PingMixin.js +5 -1
  19. package/dist/lib/esnext/mixins/RequestMixin.js +6 -1
  20. package/dist/lib/esnext/mixins/auth/AppAuthMixin.js +3 -3
  21. package/dist/lib/esnext/mixins/auth/SessionAuthMixin.js +4 -4
  22. package/dist/lib/esnext/mixins/auth/UserCredentialAuthMixin.js +3 -3
  23. package/dist/lib/esnext/mixins/auth/UserPasswordAuthMixin.js +3 -3
  24. package/dist/lib/esnext/mixins/connection/FrontgateWSMixin.js +11 -9
  25. package/dist/lib/esnext/mixins/subscription/DataObserver.js +1 -2
  26. package/dist/lib/esnext/mixins/subscription/EndpointSubscriptionMixin.js +13 -12
  27. package/dist/lib/esnext/mixins/subscription/RawSubscriptionMixin.js +28 -15
  28. package/dist/lib/esnext/version.js +1 -1
  29. package/dist/lib/node/common/errors.js +6 -7
  30. package/dist/lib/node/index.js +1 -0
  31. package/dist/lib/node/message/interfaces/PtlMessage.js +11 -0
  32. package/dist/lib/node/message/interfaces/index.js +1 -0
  33. package/dist/lib/node/message/request/AuthenticationByTokenRequest.js +2 -2
  34. package/dist/lib/node/message/request/AuthenticationRequest.js +2 -0
  35. package/dist/lib/node/message/request/ConfigurationRequest.js +3 -3
  36. package/dist/lib/node/message/response/AuthenticationTokenResponse.js +3 -11
  37. package/dist/lib/node/message/response/HTTPProxyResponse.js +3 -0
  38. package/dist/lib/node/message/response/Mdg2Response.js +4 -1
  39. package/dist/lib/node/message/response/PingResponse.js +0 -6
  40. package/dist/lib/node/message/response/index.js +0 -3
  41. package/dist/lib/node/mixins/AuthTokenRequestMixin.js +1 -1
  42. package/dist/lib/node/mixins/EndpointRequestMixin.js +7 -7
  43. package/dist/lib/node/mixins/HTTPProxyRequestMixin.js +1 -1
  44. package/dist/lib/node/mixins/OpenTelemetryMixin.js +2 -1
  45. package/dist/lib/node/mixins/PingMixin.js +5 -1
  46. package/dist/lib/node/mixins/RequestMixin.js +6 -1
  47. package/dist/lib/node/mixins/auth/AppAuthMixin.js +3 -3
  48. package/dist/lib/node/mixins/auth/SessionAuthMixin.js +4 -4
  49. package/dist/lib/node/mixins/auth/UserCredentialAuthMixin.js +3 -3
  50. package/dist/lib/node/mixins/auth/UserPasswordAuthMixin.js +3 -3
  51. package/dist/lib/node/mixins/connection/FrontgateWSMixin.js +11 -9
  52. package/dist/lib/node/mixins/subscription/DataObserver.js +1 -2
  53. package/dist/lib/node/mixins/subscription/EndpointSubscriptionMixin.js +12 -11
  54. package/dist/lib/node/mixins/subscription/RawSubscriptionMixin.js +27 -14
  55. package/dist/lib/node/version.js +1 -1
  56. package/dist/lib/types/common/errors.d.ts +4 -8
  57. package/dist/lib/types/common/interfaces/index.d.ts +0 -1
  58. package/dist/lib/types/index.d.ts +1 -0
  59. package/dist/lib/types/message/interfaces/PtlMessage.d.ts +486 -0
  60. package/dist/lib/types/message/interfaces/index.d.ts +1 -0
  61. package/dist/lib/types/message/request/AbstractMdg2Request.d.ts +3 -3
  62. package/dist/lib/types/message/request/AuthenticationByTokenRequest.d.ts +5 -2
  63. package/dist/lib/types/message/request/AuthenticationRequest.d.ts +10 -9
  64. package/dist/lib/types/message/request/AuthenticationTokenRequest.d.ts +2 -1
  65. package/dist/lib/types/message/request/CancelSubscriptionRequest.d.ts +2 -1
  66. package/dist/lib/types/message/request/ConfigurationRequest.d.ts +7 -2
  67. package/dist/lib/types/message/request/HTTPProxyRequest.d.ts +2 -2
  68. package/dist/lib/types/message/request/HighLevelRequest.d.ts +2 -2
  69. package/dist/lib/types/message/request/PingRequest.d.ts +2 -8
  70. package/dist/lib/types/message/request/TransportLayerClientRequestHeader.d.ts +3 -26
  71. package/dist/lib/types/message/response/AuthenticationTokenResponse.d.ts +3 -3
  72. package/dist/lib/types/message/response/HTTPProxyResponse.d.ts +6 -3
  73. package/dist/lib/types/message/response/HighLevelResponse.d.ts +3 -1
  74. package/dist/lib/types/message/response/Mdg2Response.d.ts +6 -4
  75. package/dist/lib/types/message/response/PingResponse.d.ts +2 -1
  76. package/dist/lib/types/message/response/index.d.ts +0 -3
  77. package/dist/lib/types/message/update/HighLevelUpdate.d.ts +3 -1
  78. package/dist/lib/types/mixins/connection/index.d.ts +9 -3
  79. package/dist/lib/types/mixins/subscription/DataObserver.d.ts +2 -3
  80. package/dist/lib/umd/mdg2.client.min.umd.js +1 -1
  81. package/dist/lib/umd/mdg2.client.umd.js +172 -150
  82. package/package.json +2 -2
  83. package/dist/lib/esnext/common/interfaces/PtlMessage.js +0 -1
  84. package/dist/lib/esnext/message/response/AuthenticationResponse.js +0 -1
  85. package/dist/lib/esnext/message/response/ConfigurationResponse.js +0 -1
  86. package/dist/lib/esnext/message/response/DisconnectionMessage.js +0 -1
  87. package/dist/lib/esnext/message/response/ErrorResponse.js +0 -9
  88. package/dist/lib/node/common/interfaces/PtlMessage.js +0 -2
  89. package/dist/lib/node/message/response/AuthenticationResponse.js +0 -2
  90. package/dist/lib/node/message/response/ConfigurationResponse.js +0 -2
  91. package/dist/lib/node/message/response/DisconnectionMessage.js +0 -2
  92. package/dist/lib/node/message/response/ErrorResponse.js +0 -13
  93. package/dist/lib/types/common/interfaces/PtlMessage.d.ts +0 -5
  94. package/dist/lib/types/message/response/AuthenticationResponse.d.ts +0 -37
  95. package/dist/lib/types/message/response/ConfigurationResponse.d.ts +0 -44
  96. package/dist/lib/types/message/response/DisconnectionMessage.d.ts +0 -7
  97. package/dist/lib/types/message/response/ErrorResponse.d.ts +0 -5
package/CHANGELOG.md CHANGED
@@ -1,9 +1,29 @@
1
+ ## <small>7.1.6 (2026-07-07)</small>
2
+
3
+ * fix(http-proxy-response): restore meta property [171fb76]
4
+
5
+ ## <small>7.1.5 (2026-07-06)</small>
6
+
7
+ * chore(deps): lock file maintenance [4f4410c]
8
+ * chore(deps): lock file maintenance [b5939a8]
9
+ * chore(deps): update actions/setup-python action to v6.3.0 [eb694db]
10
+ * chore(deps): update dependency conventional-changelog to v8 [1a83768]
11
+ * chore(release): update changelog for v7.1.5 [642560f]
12
+ * feat(client): remove dead code in PingResponse error handling [24d4d9b]
13
+ * feat(client): use actual Errors in DataObserver instead of faking ErrorResponses [5273791]
14
+ * feat(client): use properly types PtlMessage definitions [abeeca0]
15
+ * fix(client): correctly define AuthenticationRequestOptions [ddde3b3]
16
+ * fix(client): correctly type challenge [61e4a1c]
17
+ * docs(architecture): document mixins and hooks [08d9244]
18
+ * docs(contribution): add getting started guide [5791d47]
19
+
1
20
  ## <small>7.1.4 (2026-06-25)</small>
2
21
 
3
- * fix(client): using fetchAuth adds Connectable interface [2b442ee]
4
- * fix(review-app): build as prod to reflect release [232a674]
5
22
  * chore(release): reenable update commands after non-version-update release [d77a54e]
23
+ * chore(release): update changelog for v7.1.4 [78a1306]
6
24
  * chore(review-app): lift stack to ubuntu-24 [43fbcbd]
25
+ * fix(client): using fetchAuth adds Connectable interface [2b442ee]
26
+ * fix(review-app): build as prod to reflect release [232a674]
7
27
 
8
28
  ## <small>7.1.3 (2026-06-24)</small>
9
29
 
@@ -155,7 +175,7 @@
155
175
  * chore(deps): update factset/waffle-actions action to v2.5.3 [ec62ef6]
156
176
  * chore(deps): update factset/waffle-actions action to v2.5.4 [015093c]
157
177
  * chore(deps): update lockfile [10360ec]
158
- * chore(deps): update softprops/action-gh-release action to v2.5.0 [8e0e10e], closes [softprops/action-#release]
178
+ * chore(deps): update softprops/action-gh-release action to v2.5.0 [8e0e10e], closes [softprops/action-gh-release]
159
179
  * chore(deps): update sonarsource/sonarqube-scan-action action to v7 [ec16d18]
160
180
  * chore(deps): update yarn to v4.12.0 [0d94944]
161
181
  * chore(release): update changelog for v7.0.6 [4f77be8]
@@ -184,7 +204,7 @@
184
204
  * chore(deps): update dependency node to v24 [272a875]
185
205
  * chore(deps): update dependency node to v24 [515f36c]
186
206
  * chore(deps): update dependency nx to v22 [62d9329]
187
- * chore(deps): update softprops/action-gh-release action to v2.4.1 [2b084a1], closes [softprops/action-#release]
207
+ * chore(deps): update softprops/action-gh-release action to v2.4.1 [2b084a1], closes [softprops/action-gh-release]
188
208
  * chore(deps): update vitest monorepo to v4 [cfbe7ce]
189
209
  * chore(release): update changelog for v7.0.3 [e60b73f]
190
210
  * chore(release): update changelog for v7.0.4 [e2c2c86]
@@ -219,9 +239,9 @@
219
239
  * chore(deps): update dependency @fds/lint-standards to v29 [90367f8]
220
240
  * chore(deps): update dependency happy-dom to v19 [32960ea]
221
241
  * chore(deps): update dependency vite to ^7.1.5 [security] [8879b32]
222
- * chore(deps): update softprops/action-gh-release action to v2.3.3 [00f18bb], closes [softprops/action-#release]
223
- * chore(deps): update softprops/action-gh-release action to v2.3.4 [1bf3bad], closes [softprops/action-#release]
224
- * chore(deps): update softprops/action-gh-release action to v2.4.0 [6fa1a5e], closes [softprops/action-#release]
242
+ * chore(deps): update softprops/action-gh-release action to v2.3.3 [00f18bb], closes [softprops/action-gh-release]
243
+ * chore(deps): update softprops/action-gh-release action to v2.3.4 [1bf3bad], closes [softprops/action-gh-release]
244
+ * chore(deps): update softprops/action-gh-release action to v2.4.0 [6fa1a5e], closes [softprops/action-gh-release]
225
245
  * chore(deps): update sonarsource/sonarqube-scan-action action to v6 [6efaefa]
226
246
  * chore(deps): update yarn to v4.10.0 [b47a139]
227
247
  * chore(deps): update yarn to v4.10.3 [7759d0a]
@@ -311,9 +331,9 @@
311
331
  * chore(deps): update dependency vite to v7 [ff16a47]
312
332
  * chore(deps): update dependency vite-tsconfig-paths to v5 [307fd61]
313
333
  * chore(deps): update factset/waffle-actions action to v2.5.2 [617d450]
314
- * chore(deps): update peaceiris/actions-gh-pages action to v3.9.3 [2070e37], closes [peaceiris/actions-#pages]
315
- * chore(deps): update peaceiris/actions-gh-pages action to v4 [6569746], closes [peaceiris/actions-#pages]
316
- * chore(deps): update softprops/action-gh-release action to v2 [cba8093], closes [softprops/action-#release]
334
+ * chore(deps): update peaceiris/actions-gh-pages action to v3.9.3 [2070e37], closes [peaceiris/actions-gh-pages]
335
+ * chore(deps): update peaceiris/actions-gh-pages action to v4 [6569746], closes [peaceiris/actions-gh-pages]
336
+ * chore(deps): update softprops/action-gh-release action to v2 [cba8093], closes [softprops/action-gh-release]
317
337
  * chore(deps): update sonarsource/sonarqube-scan-action action to v5 [5876377]
318
338
  * chore(deps): update yarn to v4.9.2 [750d175]
319
339
  * feat(auth): remove depracted auth interfaces [01da6bd]
@@ -559,7 +579,7 @@
559
579
 
560
580
  ## <small>6.2.5 (2024-04-29)</small>
561
581
 
562
- * chore(gh-actions): upgrade sonarcloud action [84b0aaa], closes [#actions]
582
+ * chore(gh-actions): upgrade sonarcloud action [84b0aaa], closes [gh-actions]
563
583
  * chore(repo): bump version.ts [b84a41c]
564
584
  * chore(repo): update changelog [b16b9a8]
565
585
  * feat(subscriptions): add request options [8703cc3]
@@ -819,9 +839,12 @@
819
839
 
820
840
  ## <small>5.6.4 (2023-09-14)</small>
821
841
 
822
- * v5.6.3 (#171) [224c1bd], closes [#171]
823
842
  * v5.6.4 (#182) [abfb313], closes [#182]
824
843
  * fix: refactor session handling code to make mdg2Client backward compatible (#179) [adfc5f0], closes [#179]
844
+
845
+ ## <small>5.6.3 (2023-07-17)</small>
846
+
847
+ * v5.6.3 (#171) [224c1bd], closes [#171]
825
848
  * Fix: fix undefined logger to endpointhandler from subscription Module (#167) [da440dd], closes [#167]
826
849
  * Fix: Prevent form from submitting (#168) [832ecae], closes [#168]
827
850
 
@@ -1009,7 +1032,7 @@
1009
1032
  ### BREAKING CHANGE
1010
1033
 
1011
1034
  * UserCredentialAuthentication constructor changed: idUser removed.
1012
- UserPasswordAuthentication constructor changed: idUser removed.
1035
+ UserPasswordAuthentication constructor changed: idUser removed.
1013
1036
 
1014
1037
  ## 4.2.0 (2021-07-23)
1015
1038
 
@@ -1032,29 +1055,32 @@ UserPasswordAuthentication constructor changed: idUser removed.
1032
1055
 
1033
1056
  ## 4.0.0 (2021-06-01)
1034
1057
 
1058
+ * Updated function to boolean [86623f0]
1059
+ * Updated Readme for flagPermissionDenied [2f69a09]
1060
+ * Updated readme with how to enable flag_permission_denied_response [1dc9653]
1061
+ * v4.0.0 [0f2343e]
1062
+ * feat(demo): replace local- with sessionStorage [e1642d4]
1063
+ * feat(low-level-messages): remove all lowlevel messages [c7d4c2a]
1064
+ * feat(request): configured flag_permission_denied_response globally [9c2b654]
1065
+ * feat(request): support for flag_permission_denied_response for HighLevelRequests [8112a05]
1066
+ * feat(sessionModule): delete session module [81d2252]
1067
+ * feat(sessionModule): remove from demos [c23b3a5]
1068
+
1069
+ ## <small>3.3.3 (2021-04-16)</small>
1070
+
1035
1071
  * fix:(subscription loss) removed void as return type [74d6195]
1036
1072
  * fix:(subscriptionloss) handling message from frontgate [4966cae]
1037
1073
  * fix:(subscriptionloss) updated unit tests [59f79f7]
1038
1074
  * fix:(subscriptionloss)Deleting lost job [043ca5c]
1039
1075
  * job deleted outside the loop [c3dcfc0]
1040
- * Updated function to boolean [86623f0]
1041
- * Updated Readme for flagPermissionDenied [2f69a09]
1042
- * Updated readme with how to enable flag_permission_denied_response [1dc9653]
1043
1076
  * v3.3.3 [7cb7671]
1044
- * v4.0.0 [0f2343e]
1045
1077
  * feat(authentication): enforce clientCredentials parameter [b62222b]
1046
- * feat(demo): replace local- with sessionStorage [e1642d4]
1047
1078
  * feat(documentation): add documentation on using a proxy [40910a4]
1048
1079
  * feat(FAS-491): implement client side ws timeout [da4860f]
1049
1080
  * feat(FAS-491): take timeout from server response [bc9727b]
1050
1081
  * feat(FAS-492): increase to 45sec [13c791a]
1051
1082
  * feat(logger): document logging [fdc138e]
1052
- * feat(low-level-messages): remove all lowlevel messages [c7d4c2a]
1053
1083
  * feat(request-timeout): document usage [be1425e]
1054
- * feat(request): configured flag_permission_denied_response globally [9c2b654]
1055
- * feat(request): support for flag_permission_denied_response for HighLevelRequests [8112a05]
1056
- * feat(sessionModule): delete session module [81d2252]
1057
- * feat(sessionModule): remove from demos [c23b3a5]
1058
1084
 
1059
1085
  ## <small>3.3.2 (2021-02-03)</small>
1060
1086
 
@@ -1390,7 +1416,7 @@ UserPasswordAuthentication constructor changed: idUser removed.
1390
1416
  * Update: release of version 0.1.2 [edd26cb]
1391
1417
  * Update: updated lint task to use lint-standards repo; updated release task to newer version. [1bebb60]
1392
1418
  * Update: updated Readme; fixed subscriptions [2950c68]
1393
- * Feature: removed observe() from Mdg2Client and created a PushClient; added fieldInstanceId cache to [00f88e1]
1419
+ * Feature: removed observe() from Mdg2Client and created a PushClient; added fieldInstanceId cache to [00f88e1]
1394
1420
  * Docs: update Readme [0a3ead8]
1395
1421
  * Fix: added babel-loader for Datamodel files, in order to uglify them [a46f007]
1396
1422
  * Fix: creection of the repository reference [57b9823]
@@ -1,7 +1,6 @@
1
- export class TimeoutError extends Error {
2
- constructor(message = 'Timeout', error) {
3
- super(message, { cause: error });
4
- this.name = 'TimeoutError';
5
- this.code = 408;
1
+ export class UnexpectedResponseError extends Error {
2
+ constructor(response) {
3
+ super(`Unexpected response: ${response.Message}`);
4
+ this.response = response;
6
5
  }
7
6
  }
@@ -1,6 +1,7 @@
1
1
  export * from './authentication';
2
2
  export * from './connection';
3
3
  export * from './message';
4
+ export * from './message/interfaces';
4
5
  export * from './common/interfaces';
5
6
  export * from './common/types';
6
7
  export * from './logger';
@@ -0,0 +1,4 @@
1
+ export const hasJobIdInRoot = (msg) => typeof msg.id_job !== 'undefined';
2
+ export const hasJobIdInHeader = (msg) => typeof msg.header?.id_job !== 'undefined';
3
+ export const isServiceAndNotationBased = (msg) => typeof msg.header?.id_service !== 'undefined' && typeof msg.id_notation !== 'undefined';
4
+ export const isPtlMessageWithHeader = (msg) => msg.header !== undefined;
@@ -1,3 +1,4 @@
1
1
  export * from './HighLevelRequestMethod';
2
2
  export * from './HighLevelRequestOptions';
3
3
  export * from './HTTPProxyRequestOptions';
4
+ export * from './PtlMessage';
@@ -21,10 +21,10 @@ export class AuthenticationByTokenRequest {
21
21
  maximum_receivable_message_size: 1048576,
22
22
  flags: 0,
23
23
  cache_authentication_salt: {
24
- value: [],
24
+ value: { b64: '' },
25
25
  },
26
26
  cache_authentication_encrypted_secret: {
27
- encrypted_secret: [],
27
+ encrypted_secret: { b64: '' },
28
28
  },
29
29
  };
30
30
  }
@@ -26,4 +26,6 @@ AuthenticationRequest.DEFAULT_OPTIONS = {
26
26
  idPeer: 0,
27
27
  salt: [],
28
28
  username: '',
29
+ challenge: [],
30
+ idApplication: 0,
29
31
  };
@@ -67,9 +67,9 @@ export class ConfigurationRequest {
67
67
  if (typeof challenge === 'string') {
68
68
  return Buffer.from(challenge, 'utf-8');
69
69
  }
70
- if (typeof challenge.b64 !== 'undefined') {
71
- return Buffer.from(challenge.b64, 'base64');
70
+ if (Array.isArray(challenge)) {
71
+ return Buffer.from(challenge);
72
72
  }
73
- return Buffer.from(challenge);
73
+ return Buffer.from(challenge.b64, 'base64');
74
74
  }
75
75
  }
@@ -1,16 +1,8 @@
1
- import { Mdg2Response } from './Mdg2Response';
2
1
  import { timeToMilliseconds } from '../types';
3
- export class AuthenticationTokenResponse extends Mdg2Response {
2
+ export class AuthenticationTokenResponse {
4
3
  constructor(raw) {
5
- super(raw);
6
- if (!this.raw.token.value.b64) {
7
- throw new Error('Token not set in AuthenticationTokenResponse');
8
- }
9
- if (!this.raw.expiry.microseconds) {
10
- throw new Error('Expiry not set in AuthenticationTokenResponse');
11
- }
12
- this.token = this.raw.token.value.b64;
13
- this.expiry = parseInt(timeToMilliseconds(this.raw.expiry.microseconds), 10);
4
+ this.token = raw.token.value.b64;
5
+ this.expiry = parseInt(timeToMilliseconds(raw.expiry.microseconds), 10);
14
6
  }
15
7
  getToken() {
16
8
  return this.token;
@@ -20,6 +20,9 @@ export class HTTPProxyResponse extends Mdg2Response {
20
20
  get meta() {
21
21
  return this.responseData.meta;
22
22
  }
23
+ get info() {
24
+ return this.responseInfo;
25
+ }
23
26
  get status() {
24
27
  return {
25
28
  code: this.statusCode,
@@ -12,7 +12,10 @@ export class Mdg2Response {
12
12
  return this.raw.header.id_job;
13
13
  }
14
14
  get serviceId() {
15
- return this.raw.header.id_service;
15
+ if (this.raw.Message === 'Foundation::HTTPProxyResponse' || this.raw.Message === 'Foundation::HighLevelResponse') {
16
+ return this.raw.header.id_service;
17
+ }
18
+ throw new Error('Invalid message type');
16
19
  }
17
20
  isUpdateMessage() {
18
21
  if (!Object.hasOwnProperty.call(this.raw, 'header')) {
@@ -1,12 +1,6 @@
1
1
  import { timeToMilliseconds } from '../types';
2
2
  export class PingResponse {
3
3
  constructor(raw) {
4
- if (raw.Message !== PingResponse.NAME) {
5
- throw new Error(`Unsupported message=${raw.Message}`);
6
- }
7
- if (raw.Version !== PingResponse.VERSION) {
8
- throw new Error(`Unsupported version=${raw.Version} for message=${raw.Message}`);
9
- }
10
4
  this._timeReceivedResponse = Date.now();
11
5
  this._timeAtSender = Number(timeToMilliseconds(raw.time_at_sender.microseconds));
12
6
  this._timeFromRequest = Number(timeToMilliseconds(raw.time_from_request.microseconds));
@@ -1,7 +1,4 @@
1
1
  export * from './AuthenticationTokenResponse';
2
- export * from './ConfigurationResponse';
3
- export * from './DisconnectionMessage';
4
- export * from './ErrorResponse';
5
2
  export * from './HighLevelResponse';
6
3
  export * from './HTTPProxyResponse';
7
4
  export * from './Mdg2Response';
@@ -15,7 +15,7 @@ export const authTokenRequest = () => {
15
15
  await this.hooks.callHook('frontgateConnection:sendMessage', msg);
16
16
  const promise = new Promise((resolve, reject) => {
17
17
  this.hooks.hookOnce(`frontgateConnection:response:${msg.callbackId}`, (response) => {
18
- if (!response.Message.includes('AuthenticationTokenResponse')) {
18
+ if (response.Message !== 'Foundation::AuthenticationTokenResponse') {
19
19
  reject(JSON.stringify(response));
20
20
  return;
21
21
  }
@@ -35,19 +35,19 @@ export const endpointRequest = (config) => {
35
35
  const hookResponse = () => {
36
36
  this.hooks.hookOnce(`frontgateConnection:response:${msg.callbackId}`, (response) => {
37
37
  try {
38
- if (!response.Message.includes('HighLevelResponse')) {
38
+ if (response.Message !== 'Foundation::HighLevelResponse' && response.Message !== 'HighLevelResponse') {
39
39
  reject(JSON.stringify(response));
40
40
  return;
41
41
  }
42
42
  if (!__classPrivateFieldGet(this, _instances, "m", _hasNextChunk).call(this, response)) {
43
43
  chunkedData.push({
44
- body: response.body?.value ?? '',
45
- processingTime: response.header?.processingTime ?? 0,
44
+ body: response.body.value,
45
+ processingTime: response.header.processing_time,
46
46
  });
47
47
  const hlResponse = new HighLevelResponse({
48
48
  ...response,
49
49
  body: { value: chunkedData.map((chunk) => chunk.body).join('') },
50
- header: { ...response.header, processingTime: chunkedData.reduce((acc, chunk) => acc + chunk.processingTime, 0) },
50
+ header: { ...response.header, processing_time: chunkedData.reduce((acc, chunk) => acc + chunk.processingTime, 0) },
51
51
  });
52
52
  resolve({
53
53
  response: hlResponse,
@@ -56,8 +56,8 @@ export const endpointRequest = (config) => {
56
56
  }
57
57
  else {
58
58
  chunkedData.push({
59
- body: response.body?.value ?? '',
60
- processingTime: response.header?.processingTime ?? 0,
59
+ body: response.body.value,
60
+ processingTime: response.header.processing_time,
61
61
  });
62
62
  hookResponse();
63
63
  }
@@ -75,7 +75,7 @@ export const endpointRequest = (config) => {
75
75
  },
76
76
  _instances = new WeakSet(),
77
77
  _hasNextChunk = function _hasNextChunk(msg) {
78
- return ((msg.header?.flags ?? 0) & FLAG_HAS_NEXT_CHUNK) === FLAG_HAS_NEXT_CHUNK;
78
+ return (msg.header.flags & FLAG_HAS_NEXT_CHUNK) === FLAG_HAS_NEXT_CHUNK;
79
79
  },
80
80
  _a;
81
81
  };
@@ -19,7 +19,7 @@ export const httpProxyRequest = () => {
19
19
  const promise = new Promise((resolve, reject) => {
20
20
  this.hooks.hookOnce(`frontgateConnection:response:${msg.callbackId}`, (response) => {
21
21
  try {
22
- if (!response.Message.includes('HTTPProxyResponse')) {
22
+ if (response.Message !== 'Foundation::HTTPProxyResponse') {
23
23
  reject(JSON.stringify(response));
24
24
  return;
25
25
  }
@@ -5,6 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
5
5
  };
6
6
  import { trace } from '@opentelemetry/api';
7
7
  import { createExtendedMixinFactory } from '.';
8
+ import { isPtlMessageWithHeader } from '../message/interfaces';
8
9
  export const openTelemetry = () => {
9
10
  const mixinOpenTelemetry = (Base) => {
10
11
  var _instances, _createSpanHeader, _a;
@@ -13,7 +14,7 @@ export const openTelemetry = () => {
13
14
  super(...args);
14
15
  _instances.add(this);
15
16
  this.hooks.hook('frontgateConnection:beforeSerializeMessage', (msg) => {
16
- if (msg.header) {
17
+ if (isPtlMessageWithHeader(msg)) {
17
18
  trace.getTracer('frontgate-js-sdk').startActiveSpan('frontgateConnection:sendMessage', (span) => {
18
19
  const spanHeader = __classPrivateFieldGet(this, _instances, "m", _createSpanHeader).call(this, span.spanContext());
19
20
  if (spanHeader) {
@@ -12,8 +12,12 @@ export const pingRequests = () => {
12
12
  callbackId: 'PingResponse',
13
13
  };
14
14
  await this.hooks.callHook('frontgateConnection:sendMessage', msg);
15
- const promise = new Promise((resolve) => {
15
+ const promise = new Promise((resolve, reject) => {
16
16
  this.hooks.hookOnce(`frontgateConnection:response:${msg.callbackId}`, (response) => {
17
+ if (response.Message !== 'Foundation::PingResponse') {
18
+ reject(JSON.stringify(response));
19
+ return;
20
+ }
17
21
  const pong = new PingResponse(response);
18
22
  resolve(pong);
19
23
  });
@@ -1,4 +1,5 @@
1
1
  import { createExtendedMixinFactory } from '.';
2
+ import { UnexpectedResponseError } from '../common/errors';
2
3
  import { Mdg2Response } from '../message';
3
4
  import { useTimeout } from '../util/functions';
4
5
  export const requests = () => {
@@ -12,8 +13,12 @@ export const requests = () => {
12
13
  callbackId: '',
13
14
  };
14
15
  await this.hooks.callHook('frontgateConnection:sendMessage', msg);
15
- const promise = new Promise((resolve) => {
16
+ const promise = new Promise((resolve, reject) => {
16
17
  this.hooks.hookOnce(`frontgateConnection:response:${msg.callbackId}`, (response) => {
18
+ if (response.Message !== 'Foundation::HighLevelResponse' && response.Message !== 'HighLevelResponse') {
19
+ reject(new UnexpectedResponseError(response));
20
+ return;
21
+ }
17
22
  const mdg2Response = new Mdg2Response(response);
18
23
  resolve(mdg2Response);
19
24
  });
@@ -10,6 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  import { createExtendedMixinFactory } from '../.';
13
+ import { UnexpectedResponseError } from '../../common/errors';
13
14
  import { SecretGenerator, AuthenticationRequest, ConfigurationRequest } from '../../compat';
14
15
  import { getBytesFromBuffer } from '../../connection';
15
16
  import { LogLevel } from '../../logger';
@@ -59,9 +60,8 @@ export const appAuth = (idApplication, idUser, clientCredentials, deploymentStag
59
60
  return new AuthenticationRequest(options);
60
61
  },
61
62
  _createConfigurationRequest = function _createConfigurationRequest(msg, conf) {
62
- const expectedMessage = 'Foundation::AuthenticationResponse';
63
- if (msg.Message !== expectedMessage) {
64
- throw new Error(`Expected message "${expectedMessage}" but received "${msg.Message}"`);
63
+ if (msg.Message !== 'Foundation::AuthenticationResponse') {
64
+ throw new UnexpectedResponseError(msg);
65
65
  }
66
66
  const { challenge } = msg.challenge;
67
67
  const options = {
@@ -18,6 +18,7 @@ import { LogLevel } from '../../logger';
18
18
  import { AuthenticationByTokenRequest, AuthenticationTokenRequest, AuthenticationTokenResponse } from '../../message';
19
19
  import { randomBytes } from 'crypto';
20
20
  import { useTimeout } from '../../util/functions';
21
+ import { UnexpectedResponseError } from '../../common/errors';
21
22
  export const sessionAuth = (config, idApplication, username, password, deploymentStage) => {
22
23
  const mixinSessionAuth = (Base) => {
23
24
  var _instances, _tokenConnectionAttempt, _logOut, _mdg2wstoken, _sharedSecret, _clientSecret, _requestOtpAuthenticationTokenForSessionHandling, _toUrlBase64, _createAuthenticationRequest, _createConfigurationRequest, _createTransportLayerRequestHeaderConfigurationRequest, _submit, _a;
@@ -134,7 +135,7 @@ export const sessionAuth = (config, idApplication, username, password, deploymen
134
135
  await this.hooks.callHook('frontgateConnection:sendMessage', msg);
135
136
  const promise = new Promise((resolve, reject) => {
136
137
  this.hooks.hookOnce(`frontgateConnection:response:${msg.callbackId}`, (response) => {
137
- if (!response.Message.includes('AuthenticationTokenResponse')) {
138
+ if (response.Message !== 'Foundation::AuthenticationTokenResponse') {
138
139
  reject(JSON.stringify(response));
139
140
  return;
140
141
  }
@@ -163,9 +164,8 @@ export const sessionAuth = (config, idApplication, username, password, deploymen
163
164
  return new AuthenticationRequest(options);
164
165
  },
165
166
  _createConfigurationRequest = function _createConfigurationRequest(msg, conf) {
166
- const expectedMessage = 'Foundation::AuthenticationResponse';
167
- if (msg.Message !== expectedMessage) {
168
- throw new Error(`Expected message "${expectedMessage}" but received "${msg.Message}"`);
167
+ if (msg.Message !== 'Foundation::AuthenticationResponse') {
168
+ throw new UnexpectedResponseError(msg);
169
169
  }
170
170
  if (msg.id_user === ID_USER_AUTHENTICATED) {
171
171
  void this.hooks.callHook('frontgateConnection:setIdApp', ID_APP_AUTHENTICATED);
@@ -15,6 +15,7 @@ import { AuthenticationRequest, ConfigurationRequest, SecretGenerator } from '..
15
15
  import { ID_APP_AUTHENTICATED, ID_USER_AUTHENTICATED } from '../../authentication';
16
16
  import { randomBytes } from 'crypto';
17
17
  import { LogLevel } from '../../logger';
18
+ import { UnexpectedResponseError } from '../../common/errors';
18
19
  export const userCredentialAuth = (idApplication, username, credentials, deploymentStage) => {
19
20
  const mixinUserCredentialAuth = (Base) => {
20
21
  var _instances, _sharedSecret, _clientSecret, _createAuthenticationRequest, _createConfigurationRequest, _createTransportLayerRequestHeaderConfigurationRequest, _submit, _a;
@@ -58,9 +59,8 @@ export const userCredentialAuth = (idApplication, username, credentials, deploym
58
59
  return new AuthenticationRequest(options);
59
60
  },
60
61
  _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}"`);
62
+ if (msg.Message !== 'Foundation::AuthenticationResponse') {
63
+ throw new UnexpectedResponseError(msg);
64
64
  }
65
65
  if (msg.id_user === ID_USER_AUTHENTICATED) {
66
66
  void this.hooks.callHook('frontgateConnection:setIdApp', ID_APP_AUTHENTICATED);
@@ -15,6 +15,7 @@ import { ID_APP_AUTHENTICATED, ID_USER_AUTHENTICATED } from '../../authenticatio
15
15
  import { AuthenticationRequest, ConfigurationRequest, SecretGenerator } from '../../compat';
16
16
  import { LogLevel } from '../../logger';
17
17
  import { randomBytes } from 'crypto';
18
+ import { UnexpectedResponseError } from '../../common/errors';
18
19
  export const userPasswordAuth = (idApplication, username, password, deploymentStage) => {
19
20
  const mixinUserPasswordAuth = (Base) => {
20
21
  var _instances, _sharedSecret, _clientSecret, _createAuthenticationRequest, _createConfigurationRequest, _createTransportLayerRequestHeaderConfigurationRequest, _submit, _a;
@@ -53,9 +54,8 @@ export const userPasswordAuth = (idApplication, username, password, deploymentSt
53
54
  return new AuthenticationRequest(options);
54
55
  },
55
56
  _createConfigurationRequest = function _createConfigurationRequest(msg, conf) {
56
- const expectedMessage = 'Foundation::AuthenticationResponse';
57
- if (msg.Message !== expectedMessage) {
58
- throw new Error(`Expected message "${expectedMessage}" but received "${msg.Message}"`);
57
+ if (msg.Message !== 'Foundation::AuthenticationResponse') {
58
+ throw new UnexpectedResponseError(msg);
59
59
  }
60
60
  if (msg.id_user === ID_USER_AUTHENTICATED) {
61
61
  void this.hooks.callHook('frontgateConnection:setIdApp', ID_APP_AUTHENTICATED);
@@ -12,8 +12,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
12
12
  import { createExtendedMixinFactory, } from '../';
13
13
  import WebSocket from 'isomorphic-ws';
14
14
  import { LogLevel } from '../../logger';
15
+ import { hasJobIdInRoot, hasJobIdInHeader, isServiceAndNotationBased } from '../../message/interfaces';
15
16
  import { ID_APP_AUTHENTICATED, ID_USER_NONE } from '../../authentication';
16
- import { ErrorResponse } from '../../message';
17
17
  import { useTimeout } from '../../util/functions';
18
18
  export const wsConnection = (conf) => {
19
19
  const mixinConnectableWS = (Base) => {
@@ -259,19 +259,19 @@ export const wsConnection = (conf) => {
259
259
  }
260
260
  catch (e) {
261
261
  const errorResponse = __classPrivateFieldGet(this, _instances, "m", _createErrorMessage).call(this, e, msg);
262
- __classPrivateFieldGet(this, _instances, "m", _respondToMessage).call(this, errorResponse.msg);
262
+ __classPrivateFieldGet(this, _instances, "m", _respondToMessage).call(this, errorResponse);
263
263
  }
264
264
  },
265
265
  _respondToMessage = function _respondToMessage(msgObj) {
266
- if (typeof msgObj.header?.id_job !== 'undefined') {
266
+ if (hasJobIdInHeader(msgObj)) {
267
267
  void this.hooks.callHook(`frontgateConnection:response:${msgObj.header.id_job}`, msgObj);
268
268
  return;
269
269
  }
270
- if (typeof msgObj.header?.id_service !== 'undefined' && typeof msgObj.id_notation !== 'undefined') {
270
+ if (isServiceAndNotationBased(msgObj)) {
271
271
  void this.hooks.callHook(`frontgateConnection:response:${msgObj.header.id_service}-${msgObj.id_notation}`, msgObj);
272
272
  return;
273
273
  }
274
- if (typeof msgObj.id_job !== 'undefined') {
274
+ if (hasJobIdInRoot(msgObj)) {
275
275
  void this.hooks.callHook(`frontgateConnection:response:${msgObj.id_job}`, msgObj);
276
276
  return;
277
277
  }
@@ -308,13 +308,15 @@ export const wsConnection = (conf) => {
308
308
  (_c = msg.header.authentication_identifiers).id_user || (_c.id_user = __classPrivateFieldGet(this, _idUser, "f"));
309
309
  },
310
310
  _createErrorMessage = function _createErrorMessage(error, msg) {
311
- return new ErrorResponse({
311
+ return {
312
312
  Message: 'Foundation::ErrorResponse',
313
313
  Version: 1,
314
- id_job: msg.header?.id_job,
315
- reason: 8,
314
+ header: {},
315
+ id_job: msg.header?.id_job ?? -1,
316
+ processing_time: 0,
317
+ reason: { value: 8 },
316
318
  details: error,
317
- });
319
+ };
318
320
  },
319
321
  _applyDefaultsToConfig = function _applyDefaultsToConfig(oldConf) {
320
322
  const maxIdleIntervalInS = oldConf.maximumIdleIntervalInS ?? 60;
@@ -10,7 +10,6 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
12
  var _FrontgateClientDataObserver_data, _FrontgateClientDataObserver_nextFn, _FrontgateClientDataObserver_errorFn;
13
- import { ErrorResponse } from '../../message/response';
14
13
  const getParentAndKey = (obj, path) => {
15
14
  const parts = path.split('/').slice(1);
16
15
  let parent = obj;
@@ -110,7 +109,7 @@ export class FrontgateClientEndpointDataObserver extends FrontgateClientDataObse
110
109
  super.pushData(data);
111
110
  }
112
111
  catch (e) {
113
- super.pushError(new ErrorResponse(e.message));
112
+ super.pushError(new Error('Failed to apply patch', { cause: e }));
114
113
  }
115
114
  }
116
115
  }