@factset/frontgate-js-sdk 7.1.3 → 7.1.5

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 (99) hide show
  1. package/CHANGELOG.md +56 -26
  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 +0 -4
  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 +0 -4
  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 +8 -24
  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/auth/FetchAuthenticationMixin.d.ts +2 -2
  79. package/dist/lib/types/mixins/auth/FetchAuthenticationWithOptionalCompressionMixin.d.ts +2 -2
  80. package/dist/lib/types/mixins/connection/index.d.ts +9 -3
  81. package/dist/lib/types/mixins/subscription/DataObserver.d.ts +2 -3
  82. package/dist/lib/umd/mdg2.client.min.umd.js +1 -1
  83. package/dist/lib/umd/mdg2.client.umd.js +114 -99
  84. package/package.json +2 -2
  85. package/dist/lib/esnext/common/interfaces/PtlMessage.js +0 -1
  86. package/dist/lib/esnext/message/response/AuthenticationResponse.js +0 -1
  87. package/dist/lib/esnext/message/response/ConfigurationResponse.js +0 -1
  88. package/dist/lib/esnext/message/response/DisconnectionMessage.js +0 -1
  89. package/dist/lib/esnext/message/response/ErrorResponse.js +0 -9
  90. package/dist/lib/node/common/interfaces/PtlMessage.js +0 -2
  91. package/dist/lib/node/message/response/AuthenticationResponse.js +0 -2
  92. package/dist/lib/node/message/response/ConfigurationResponse.js +0 -2
  93. package/dist/lib/node/message/response/DisconnectionMessage.js +0 -2
  94. package/dist/lib/node/message/response/ErrorResponse.js +0 -13
  95. package/dist/lib/types/common/interfaces/PtlMessage.d.ts +0 -5
  96. package/dist/lib/types/message/response/AuthenticationResponse.d.ts +0 -37
  97. package/dist/lib/types/message/response/ConfigurationResponse.d.ts +0 -44
  98. package/dist/lib/types/message/response/DisconnectionMessage.d.ts +0 -7
  99. package/dist/lib/types/message/response/ErrorResponse.d.ts +0 -5
package/CHANGELOG.md CHANGED
@@ -1,9 +1,27 @@
1
+ ## <small>7.1.5 (2026-07-06)</small>
2
+
3
+ * chore(deps): lock file maintenance [4f4410c]
4
+ * chore(deps): lock file maintenance [b5939a8]
5
+ * chore(deps): update actions/setup-python action to v6.3.0 [eb694db]
6
+ * chore(deps): update dependency conventional-changelog to v8 [1a83768]
7
+ * feat(client): remove dead code in PingResponse error handling [24d4d9b]
8
+ * feat(client): use actual Errors in DataObserver instead of faking ErrorResponses [5273791]
9
+ * feat(client): use properly types PtlMessage definitions [abeeca0]
10
+ * fix(client): correctly define AuthenticationRequestOptions [ddde3b3]
11
+ * fix(client): correctly type challenge [61e4a1c]
12
+ * docs(architecture): document mixins and hooks [08d9244]
13
+ * docs(contribution): add getting started guide [5791d47]
14
+
15
+ ## <small>7.1.4 (2026-06-25)</small>
16
+
17
+ * chore(release): reenable update commands after non-version-update release [d77a54e]
18
+ * chore(release): update changelog for v7.1.4 [78a1306]
19
+ * chore(review-app): lift stack to ubuntu-24 [43fbcbd]
20
+ * fix(client): using fetchAuth adds Connectable interface [2b442ee]
21
+ * fix(review-app): build as prod to reflect release [232a674]
22
+
1
23
  ## <small>7.1.3 (2026-06-24)</small>
2
24
 
3
- * fix(frontgate-ws-mixin): message lost between connected and authenticated [b20b034]
4
- * fix(frontgate-ws-mixin): prepare authentication details once available [b2cde24]
5
- * feat(repo): drop canary releases [3ce31b7]
6
- * feat(repo): replace lerna with workspaces [1a451d1]
7
25
  * chore(deps): lock file maintenance [f14e678]
8
26
  * chore(deps): lock file maintenance [2110b1b]
9
27
  * chore(deps): lock file maintenance [c48b42c]
@@ -18,6 +36,12 @@
18
36
  * chore(deps): update shared-actions-public/sonarsource_sonarqube-scan-action action to v8.2.0 [e47d8c3]
19
37
  * chore(deps): update yarn to v4.16.0 [f66761e]
20
38
  * chore(deps): update yarn to v4.17.0 [8c4a62b]
39
+ * chore(release): fix publish command [4fbb369]
40
+ * chore(release): update changelog for v7.1.3 [507cc8a]
41
+ * fix(frontgate-ws-mixin): message lost between connected and authenticated [b20b034]
42
+ * fix(frontgate-ws-mixin): prepare authentication details once available [b2cde24]
43
+ * feat(repo): drop canary releases [3ce31b7]
44
+ * feat(repo): replace lerna with workspaces [1a451d1]
21
45
 
22
46
  ## <small>7.1.2 (2026-05-26)</small>
23
47
 
@@ -146,7 +170,7 @@
146
170
  * chore(deps): update factset/waffle-actions action to v2.5.3 [ec62ef6]
147
171
  * chore(deps): update factset/waffle-actions action to v2.5.4 [015093c]
148
172
  * chore(deps): update lockfile [10360ec]
149
- * chore(deps): update softprops/action-gh-release action to v2.5.0 [8e0e10e], closes [softprops/action-#release]
173
+ * chore(deps): update softprops/action-gh-release action to v2.5.0 [8e0e10e], closes [softprops/action-gh-release]
150
174
  * chore(deps): update sonarsource/sonarqube-scan-action action to v7 [ec16d18]
151
175
  * chore(deps): update yarn to v4.12.0 [0d94944]
152
176
  * chore(release): update changelog for v7.0.6 [4f77be8]
@@ -175,7 +199,7 @@
175
199
  * chore(deps): update dependency node to v24 [272a875]
176
200
  * chore(deps): update dependency node to v24 [515f36c]
177
201
  * chore(deps): update dependency nx to v22 [62d9329]
178
- * chore(deps): update softprops/action-gh-release action to v2.4.1 [2b084a1], closes [softprops/action-#release]
202
+ * chore(deps): update softprops/action-gh-release action to v2.4.1 [2b084a1], closes [softprops/action-gh-release]
179
203
  * chore(deps): update vitest monorepo to v4 [cfbe7ce]
180
204
  * chore(release): update changelog for v7.0.3 [e60b73f]
181
205
  * chore(release): update changelog for v7.0.4 [e2c2c86]
@@ -210,9 +234,9 @@
210
234
  * chore(deps): update dependency @fds/lint-standards to v29 [90367f8]
211
235
  * chore(deps): update dependency happy-dom to v19 [32960ea]
212
236
  * chore(deps): update dependency vite to ^7.1.5 [security] [8879b32]
213
- * chore(deps): update softprops/action-gh-release action to v2.3.3 [00f18bb], closes [softprops/action-#release]
214
- * chore(deps): update softprops/action-gh-release action to v2.3.4 [1bf3bad], closes [softprops/action-#release]
215
- * chore(deps): update softprops/action-gh-release action to v2.4.0 [6fa1a5e], closes [softprops/action-#release]
237
+ * chore(deps): update softprops/action-gh-release action to v2.3.3 [00f18bb], closes [softprops/action-gh-release]
238
+ * chore(deps): update softprops/action-gh-release action to v2.3.4 [1bf3bad], closes [softprops/action-gh-release]
239
+ * chore(deps): update softprops/action-gh-release action to v2.4.0 [6fa1a5e], closes [softprops/action-gh-release]
216
240
  * chore(deps): update sonarsource/sonarqube-scan-action action to v6 [6efaefa]
217
241
  * chore(deps): update yarn to v4.10.0 [b47a139]
218
242
  * chore(deps): update yarn to v4.10.3 [7759d0a]
@@ -302,9 +326,9 @@
302
326
  * chore(deps): update dependency vite to v7 [ff16a47]
303
327
  * chore(deps): update dependency vite-tsconfig-paths to v5 [307fd61]
304
328
  * chore(deps): update factset/waffle-actions action to v2.5.2 [617d450]
305
- * chore(deps): update peaceiris/actions-gh-pages action to v3.9.3 [2070e37], closes [peaceiris/actions-#pages]
306
- * chore(deps): update peaceiris/actions-gh-pages action to v4 [6569746], closes [peaceiris/actions-#pages]
307
- * chore(deps): update softprops/action-gh-release action to v2 [cba8093], closes [softprops/action-#release]
329
+ * chore(deps): update peaceiris/actions-gh-pages action to v3.9.3 [2070e37], closes [peaceiris/actions-gh-pages]
330
+ * chore(deps): update peaceiris/actions-gh-pages action to v4 [6569746], closes [peaceiris/actions-gh-pages]
331
+ * chore(deps): update softprops/action-gh-release action to v2 [cba8093], closes [softprops/action-gh-release]
308
332
  * chore(deps): update sonarsource/sonarqube-scan-action action to v5 [5876377]
309
333
  * chore(deps): update yarn to v4.9.2 [750d175]
310
334
  * feat(auth): remove depracted auth interfaces [01da6bd]
@@ -550,7 +574,7 @@
550
574
 
551
575
  ## <small>6.2.5 (2024-04-29)</small>
552
576
 
553
- * chore(gh-actions): upgrade sonarcloud action [84b0aaa], closes [#actions]
577
+ * chore(gh-actions): upgrade sonarcloud action [84b0aaa], closes [gh-actions]
554
578
  * chore(repo): bump version.ts [b84a41c]
555
579
  * chore(repo): update changelog [b16b9a8]
556
580
  * feat(subscriptions): add request options [8703cc3]
@@ -810,9 +834,12 @@
810
834
 
811
835
  ## <small>5.6.4 (2023-09-14)</small>
812
836
 
813
- * v5.6.3 (#171) [224c1bd], closes [#171]
814
837
  * v5.6.4 (#182) [abfb313], closes [#182]
815
838
  * fix: refactor session handling code to make mdg2Client backward compatible (#179) [adfc5f0], closes [#179]
839
+
840
+ ## <small>5.6.3 (2023-07-17)</small>
841
+
842
+ * v5.6.3 (#171) [224c1bd], closes [#171]
816
843
  * Fix: fix undefined logger to endpointhandler from subscription Module (#167) [da440dd], closes [#167]
817
844
  * Fix: Prevent form from submitting (#168) [832ecae], closes [#168]
818
845
 
@@ -1000,7 +1027,7 @@
1000
1027
  ### BREAKING CHANGE
1001
1028
 
1002
1029
  * UserCredentialAuthentication constructor changed: idUser removed.
1003
- UserPasswordAuthentication constructor changed: idUser removed.
1030
+ UserPasswordAuthentication constructor changed: idUser removed.
1004
1031
 
1005
1032
  ## 4.2.0 (2021-07-23)
1006
1033
 
@@ -1023,29 +1050,32 @@ UserPasswordAuthentication constructor changed: idUser removed.
1023
1050
 
1024
1051
  ## 4.0.0 (2021-06-01)
1025
1052
 
1053
+ * Updated function to boolean [86623f0]
1054
+ * Updated Readme for flagPermissionDenied [2f69a09]
1055
+ * Updated readme with how to enable flag_permission_denied_response [1dc9653]
1056
+ * v4.0.0 [0f2343e]
1057
+ * feat(demo): replace local- with sessionStorage [e1642d4]
1058
+ * feat(low-level-messages): remove all lowlevel messages [c7d4c2a]
1059
+ * feat(request): configured flag_permission_denied_response globally [9c2b654]
1060
+ * feat(request): support for flag_permission_denied_response for HighLevelRequests [8112a05]
1061
+ * feat(sessionModule): delete session module [81d2252]
1062
+ * feat(sessionModule): remove from demos [c23b3a5]
1063
+
1064
+ ## <small>3.3.3 (2021-04-16)</small>
1065
+
1026
1066
  * fix:(subscription loss) removed void as return type [74d6195]
1027
1067
  * fix:(subscriptionloss) handling message from frontgate [4966cae]
1028
1068
  * fix:(subscriptionloss) updated unit tests [59f79f7]
1029
1069
  * fix:(subscriptionloss)Deleting lost job [043ca5c]
1030
1070
  * job deleted outside the loop [c3dcfc0]
1031
- * Updated function to boolean [86623f0]
1032
- * Updated Readme for flagPermissionDenied [2f69a09]
1033
- * Updated readme with how to enable flag_permission_denied_response [1dc9653]
1034
1071
  * v3.3.3 [7cb7671]
1035
- * v4.0.0 [0f2343e]
1036
1072
  * feat(authentication): enforce clientCredentials parameter [b62222b]
1037
- * feat(demo): replace local- with sessionStorage [e1642d4]
1038
1073
  * feat(documentation): add documentation on using a proxy [40910a4]
1039
1074
  * feat(FAS-491): implement client side ws timeout [da4860f]
1040
1075
  * feat(FAS-491): take timeout from server response [bc9727b]
1041
1076
  * feat(FAS-492): increase to 45sec [13c791a]
1042
1077
  * feat(logger): document logging [fdc138e]
1043
- * feat(low-level-messages): remove all lowlevel messages [c7d4c2a]
1044
1078
  * feat(request-timeout): document usage [be1425e]
1045
- * feat(request): configured flag_permission_denied_response globally [9c2b654]
1046
- * feat(request): support for flag_permission_denied_response for HighLevelRequests [8112a05]
1047
- * feat(sessionModule): delete session module [81d2252]
1048
- * feat(sessionModule): remove from demos [c23b3a5]
1049
1079
 
1050
1080
  ## <small>3.3.2 (2021-02-03)</small>
1051
1081
 
@@ -1381,7 +1411,7 @@ UserPasswordAuthentication constructor changed: idUser removed.
1381
1411
  * Update: release of version 0.1.2 [edd26cb]
1382
1412
  * Update: updated lint task to use lint-standards repo; updated release task to newer version. [1bebb60]
1383
1413
  * Update: updated Readme; fixed subscriptions [2950c68]
1384
- * Feature: removed observe() from Mdg2Client and created a PushClient; added fieldInstanceId cache to [00f88e1]
1414
+ * Feature: removed observe() from Mdg2Client and created a PushClient; added fieldInstanceId cache to [00f88e1]
1385
1415
  * Docs: update Readme [0a3ead8]
1386
1416
  * Fix: added babel-loader for Datamodel files, in order to uglify them [a46f007]
1387
1417
  * 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;
@@ -10,16 +10,12 @@ export class HTTPProxyResponse extends Mdg2Response {
10
10
  catch (error) {
11
11
  throw new Error(`Could not parse HTTPProxyResponse: ${error}`);
12
12
  }
13
- this.responseInfo = this.raw.info;
14
13
  this.statusReason = this.raw.response.status_reason;
15
14
  this.statusCode = this.raw.response.status_code.value;
16
15
  }
17
16
  get data() {
18
17
  return this.responseData;
19
18
  }
20
- get meta() {
21
- return this.responseData.meta;
22
- }
23
19
  get status() {
24
20
  return {
25
21
  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
  }