perimeterx-js-core 0.25.0 → 0.26.0

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 (255) hide show
  1. package/lib/cjs/action/Action.js +15 -0
  2. package/lib/cjs/action/ActionPriorityOrder.js +4 -0
  3. package/lib/cjs/action/utils.js +20 -0
  4. package/lib/cjs/activities/HttpActivityClient.js +61 -1
  5. package/lib/cjs/activities/HttpBatchedActivityClient.js +7 -0
  6. package/lib/cjs/activities/utils.js +128 -62
  7. package/lib/cjs/additional_activity_handler/AdditionalActivityHandlerUtils.js +6 -0
  8. package/lib/cjs/blocker/BlockerBase.js +14 -0
  9. package/lib/cjs/blocker/JsonBlockerBase.js +5 -0
  10. package/lib/cjs/blocker/utils.js +13 -0
  11. package/lib/cjs/config/ConfigurationBase.js +17 -0
  12. package/lib/cjs/context/DefaultContext.js +4 -0
  13. package/lib/cjs/context/SerializedContext.js +5 -0
  14. package/lib/cjs/enforcer/EnforcerBase.js +61 -22
  15. package/lib/cjs/enforcer/index.js +1 -0
  16. package/lib/cjs/{phase/flow → flow}/EndEnforcerFlow.js +11 -7
  17. package/lib/cjs/{phase/flow → flow}/EnforceFlow.js +10 -15
  18. package/lib/cjs/{phase/flow → flow}/FilterFlow.js +10 -9
  19. package/lib/cjs/flow/Flow.js +60 -0
  20. package/lib/cjs/flow/IFlow.js +2 -0
  21. package/lib/cjs/{phase/flow → flow}/PostEnforceFlow.js +6 -6
  22. package/lib/cjs/{phase/flow → flow}/index.js +2 -0
  23. package/lib/cjs/index.js +1 -0
  24. package/lib/cjs/phase/impl/AdditionalActivityHandlerPhase.js +3 -0
  25. package/lib/cjs/phase/impl/ClearLogsPhase.js +3 -0
  26. package/lib/cjs/phase/impl/CompositePhase.js +9 -0
  27. package/lib/cjs/phase/impl/CreateBlockResponsePhase.js +16 -0
  28. package/lib/cjs/phase/impl/DecideActionPhase.js +11 -0
  29. package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +13 -9
  30. package/lib/cjs/phase/impl/EnrichContextFromResponsePhase.js +4 -0
  31. package/lib/cjs/phase/impl/FilterPhase.js +4 -0
  32. package/lib/cjs/phase/impl/FirstPartyPhase.js +5 -0
  33. package/lib/cjs/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.js +5 -0
  34. package/lib/cjs/phase/impl/IdentifyTelemetryRequestPhase.js +5 -0
  35. package/lib/cjs/phase/impl/ModifyIncomingRequestPhase.js +5 -0
  36. package/lib/cjs/phase/impl/ModifyOutgoingResponsePhase.js +5 -0
  37. package/lib/cjs/phase/impl/ParseTokenPhase.js +14 -7
  38. package/lib/cjs/phase/impl/PreflightPhase.js +4 -0
  39. package/lib/cjs/phase/impl/RiskApiPhase.js +18 -7
  40. package/lib/cjs/phase/impl/{SendAsyncActivitiesOnResponsePhase.js → SendAsyncActivitiesPhase.js} +15 -8
  41. package/lib/cjs/phase/impl/SendLogsPhase.js +3 -0
  42. package/lib/cjs/phase/impl/SendTelemetryActivityPhase.js +3 -0
  43. package/lib/cjs/phase/impl/UpdateRemoteConfigPhase.js +3 -0
  44. package/lib/cjs/phase/impl/index.js +1 -2
  45. package/lib/cjs/phase/index.js +0 -1
  46. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +1 -1
  47. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +5 -2
  48. package/lib/cjs/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.js +3 -1
  49. package/lib/cjs/risk_api/client/GetRiskApiClientV2.js +80 -0
  50. package/lib/cjs/risk_api/client/PostRiskApiClientV2.js +3 -3
  51. package/lib/cjs/risk_api/client/PostRiskApiClientV3.js +3 -3
  52. package/lib/cjs/risk_api/client/abstract/IRiskApiClient.js +2 -0
  53. package/lib/cjs/risk_api/client/abstract/PostRiskApiClientBase.js +43 -0
  54. package/lib/cjs/risk_api/client/{PostRiskApiClientBase.js → abstract/RiskApiClientBase.js} +22 -69
  55. package/lib/cjs/risk_api/client/abstract/index.js +19 -0
  56. package/lib/cjs/risk_api/client/index.js +2 -2
  57. package/lib/cjs/risk_api/index.js +1 -0
  58. package/lib/cjs/risk_api/model/GetRiskRequestHeaders.js +185 -0
  59. package/lib/cjs/risk_api/model/GetRiskResponseHeaders.js +16 -0
  60. package/lib/cjs/risk_api/model/index.js +2 -0
  61. package/lib/cjs/{phase/impl/SendAsyncActivitiesOnRequestPhase.js → risk_api/risk_response/PostRiskResponseBase.js} +26 -30
  62. package/lib/cjs/risk_api/risk_response/RiskResponseBase.js +11 -8
  63. package/lib/cjs/risk_api/risk_response/index.js +1 -0
  64. package/lib/cjs/risk_api/risk_response/serialize/SerializedRiskResponse.js +5 -1
  65. package/lib/cjs/risk_api/risk_response/v2/GetRiskResponseV2.js +80 -0
  66. package/lib/cjs/risk_api/risk_response/v2/{DefaultRiskResponseV2.js → PostRiskResponseV2.js} +10 -10
  67. package/lib/cjs/risk_api/risk_response/v2/index.js +2 -1
  68. package/lib/cjs/risk_api/risk_response/v3/{DefaultRiskResponseV3.js → PostRiskResponseV3.js} +10 -10
  69. package/lib/cjs/risk_api/risk_response/v3/index.js +1 -1
  70. package/lib/cjs/risk_api/utils.js +36 -0
  71. package/lib/cjs/telemetry/DefaultTelemetry.js +12 -9
  72. package/lib/cjs/utils/constants.js +1 -1
  73. package/lib/cjs/utils/utils.js +1 -19
  74. package/lib/esm/action/Action.js +15 -0
  75. package/lib/esm/action/ActionPriorityOrder.js +4 -0
  76. package/lib/esm/action/utils.js +20 -0
  77. package/lib/esm/activities/HttpActivityClient.js +61 -1
  78. package/lib/esm/activities/HttpBatchedActivityClient.js +7 -0
  79. package/lib/esm/activities/utils.js +128 -63
  80. package/lib/esm/additional_activity_handler/AdditionalActivityHandlerUtils.js +6 -0
  81. package/lib/esm/blocker/BlockerBase.js +14 -0
  82. package/lib/esm/blocker/JsonBlockerBase.js +5 -0
  83. package/lib/esm/blocker/utils.js +13 -0
  84. package/lib/esm/config/ConfigurationBase.js +13 -0
  85. package/lib/esm/context/DefaultContext.js +4 -0
  86. package/lib/esm/context/SerializedContext.js +5 -0
  87. package/lib/esm/enforcer/EnforcerBase.js +43 -6
  88. package/lib/esm/enforcer/index.js +1 -0
  89. package/lib/esm/flow/EndEnforcerFlow.js +18 -0
  90. package/lib/esm/flow/EnforceFlow.js +14 -0
  91. package/lib/esm/{phase/flow → flow}/FilterFlow.js +5 -4
  92. package/lib/esm/flow/Flow.js +56 -0
  93. package/lib/esm/flow/IFlow.js +1 -0
  94. package/lib/esm/flow/PostEnforceFlow.js +10 -0
  95. package/lib/esm/{phase/flow → flow}/index.js +2 -0
  96. package/lib/esm/index.js +1 -0
  97. package/lib/esm/phase/impl/AdditionalActivityHandlerPhase.js +3 -0
  98. package/lib/esm/phase/impl/ClearLogsPhase.js +3 -0
  99. package/lib/esm/phase/impl/CompositePhase.js +9 -0
  100. package/lib/esm/phase/impl/CreateBlockResponsePhase.js +16 -1
  101. package/lib/esm/phase/impl/DecideActionPhase.js +11 -0
  102. package/lib/esm/phase/impl/EnrichContextFromRequestPhase.js +9 -0
  103. package/lib/esm/phase/impl/EnrichContextFromResponsePhase.js +4 -0
  104. package/lib/esm/phase/impl/FilterPhase.js +4 -0
  105. package/lib/esm/phase/impl/FirstPartyPhase.js +5 -0
  106. package/lib/esm/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.js +5 -0
  107. package/lib/esm/phase/impl/IdentifyTelemetryRequestPhase.js +5 -0
  108. package/lib/esm/phase/impl/ModifyIncomingRequestPhase.js +5 -0
  109. package/lib/esm/phase/impl/ModifyOutgoingResponsePhase.js +5 -0
  110. package/lib/esm/phase/impl/ParseTokenPhase.js +15 -8
  111. package/lib/esm/phase/impl/PreflightPhase.js +4 -0
  112. package/lib/esm/phase/impl/RiskApiPhase.js +19 -8
  113. package/lib/esm/phase/impl/SendAsyncActivitiesPhase.js +16 -0
  114. package/lib/esm/phase/impl/SendLogsPhase.js +3 -0
  115. package/lib/esm/phase/impl/SendTelemetryActivityPhase.js +3 -0
  116. package/lib/esm/phase/impl/UpdateRemoteConfigPhase.js +3 -0
  117. package/lib/esm/phase/impl/index.js +1 -2
  118. package/lib/esm/phase/index.js +0 -1
  119. package/lib/esm/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +1 -1
  120. package/lib/esm/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +5 -2
  121. package/lib/esm/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.js +2 -1
  122. package/lib/esm/risk_api/client/GetRiskApiClientV2.js +57 -0
  123. package/lib/esm/risk_api/client/PostRiskApiClientV2.js +3 -3
  124. package/lib/esm/risk_api/client/PostRiskApiClientV3.js +3 -3
  125. package/lib/esm/risk_api/client/abstract/IRiskApiClient.js +1 -0
  126. package/lib/esm/risk_api/client/abstract/PostRiskApiClientBase.js +18 -0
  127. package/lib/esm/risk_api/client/{PostRiskApiClientBase.js → abstract/RiskApiClientBase.js} +10 -49
  128. package/lib/esm/risk_api/client/abstract/index.js +3 -0
  129. package/lib/esm/risk_api/client/index.js +2 -2
  130. package/lib/esm/risk_api/index.js +1 -0
  131. package/lib/esm/risk_api/model/GetRiskRequestHeaders.js +182 -0
  132. package/lib/esm/risk_api/model/GetRiskResponseHeaders.js +13 -0
  133. package/lib/esm/risk_api/model/index.js +2 -0
  134. package/lib/esm/risk_api/risk_response/PostRiskResponseBase.js +6 -0
  135. package/lib/esm/risk_api/risk_response/RiskResponseBase.js +5 -1
  136. package/lib/esm/risk_api/risk_response/index.js +1 -0
  137. package/lib/esm/risk_api/risk_response/serialize/SerializedRiskResponse.js +5 -1
  138. package/lib/esm/risk_api/risk_response/v2/GetRiskResponseV2.js +52 -0
  139. package/lib/esm/risk_api/risk_response/v2/{DefaultRiskResponseV2.js → PostRiskResponseV2.js} +2 -2
  140. package/lib/esm/risk_api/risk_response/v2/index.js +2 -1
  141. package/lib/esm/risk_api/risk_response/v3/{DefaultRiskResponseV3.js → PostRiskResponseV3.js} +2 -2
  142. package/lib/esm/risk_api/risk_response/v3/index.js +1 -1
  143. package/lib/esm/risk_api/utils.js +23 -0
  144. package/lib/esm/telemetry/DefaultTelemetry.js +13 -10
  145. package/lib/esm/utils/constants.js +1 -1
  146. package/lib/esm/utils/utils.js +0 -16
  147. package/lib/types/action/Action.d.ts +15 -0
  148. package/lib/types/action/ActionData.d.ts +3 -0
  149. package/lib/types/action/ActionPriorityOrder.d.ts +4 -0
  150. package/lib/types/action/Decision.d.ts +9 -0
  151. package/lib/types/action/ProductAction.d.ts +3 -0
  152. package/lib/types/action/utils.d.ts +20 -0
  153. package/lib/types/activities/HttpActivityClient.d.ts +57 -1
  154. package/lib/types/activities/HttpBatchedActivityClient.d.ts +7 -0
  155. package/lib/types/activities/IActivityClient.d.ts +4 -1
  156. package/lib/types/activities/model/AsyncActivity.d.ts +3 -0
  157. package/lib/types/activities/model/AsyncActivityDetails.d.ts +12 -0
  158. package/lib/types/activities/model/CommonActivityDetails.d.ts +3 -0
  159. package/lib/types/activities/utils.d.ts +14 -0
  160. package/lib/types/additional_activity_handler/AdditionalActivityHandlerUtils.d.ts +6 -0
  161. package/lib/types/blocker/BlockerBase.d.ts +21 -0
  162. package/lib/types/blocker/IBlocker.d.ts +8 -0
  163. package/lib/types/blocker/IConditionalBlocker.d.ts +4 -0
  164. package/lib/types/blocker/JsonBlockerBase.d.ts +12 -0
  165. package/lib/types/blocker/model/BlockData.d.ts +3 -0
  166. package/lib/types/blocker/utils.d.ts +13 -0
  167. package/lib/types/config/ConfigurationBase.d.ts +22 -0
  168. package/lib/types/config/IConfiguration.d.ts +4 -0
  169. package/lib/types/config/params/CoreConfigurationParams.d.ts +21 -0
  170. package/lib/types/config/params/RemoteConfigurationParams.d.ts +3 -0
  171. package/lib/types/config/params/StaticConfigurationParams.d.ts +3 -0
  172. package/lib/types/context/ContextJson.d.ts +4 -0
  173. package/lib/types/context/DefaultContext.d.ts +4 -0
  174. package/lib/types/context/SerializedContext.d.ts +5 -0
  175. package/lib/types/custom_parameters/CustomParameters.d.ts +3 -0
  176. package/lib/types/enforcer/EnforcerBase.d.ts +48 -12
  177. package/lib/types/enforcer/IEnforcer.d.ts +1 -2
  178. package/lib/types/enforcer/IPostEnforcer.d.ts +3 -0
  179. package/lib/types/enforcer/index.d.ts +1 -0
  180. package/lib/types/first_party/IFirstParty.d.ts +1 -1
  181. package/lib/types/flow/EndEnforcerFlow.d.ts +8 -0
  182. package/lib/types/flow/EnforceFlow.d.ts +8 -0
  183. package/lib/types/{phase/flow → flow}/FilterFlow.d.ts +7 -7
  184. package/lib/types/flow/Flow.d.ts +13 -0
  185. package/lib/types/flow/IFlow.d.ts +57 -0
  186. package/lib/types/flow/PostEnforceFlow.d.ts +6 -0
  187. package/lib/types/{phase/flow → flow}/index.d.ts +2 -0
  188. package/lib/types/index.d.ts +1 -0
  189. package/lib/types/phase/IPhase.d.ts +9 -0
  190. package/lib/types/phase/PhaseResult.d.ts +11 -0
  191. package/lib/types/phase/impl/AdditionalActivityHandlerPhase.d.ts +3 -0
  192. package/lib/types/phase/impl/ClearLogsPhase.d.ts +3 -0
  193. package/lib/types/phase/impl/CompositePhase.d.ts +9 -0
  194. package/lib/types/phase/impl/CreateBlockResponsePhase.d.ts +11 -1
  195. package/lib/types/phase/impl/DecideActionPhase.d.ts +11 -0
  196. package/lib/types/phase/impl/EnrichContextFromRequestPhase.d.ts +9 -0
  197. package/lib/types/phase/impl/EnrichContextFromResponsePhase.d.ts +4 -0
  198. package/lib/types/phase/impl/FilterPhase.d.ts +4 -0
  199. package/lib/types/phase/impl/FirstPartyPhase.d.ts +5 -0
  200. package/lib/types/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.d.ts +5 -0
  201. package/lib/types/phase/impl/IdentifyTelemetryRequestPhase.d.ts +5 -0
  202. package/lib/types/phase/impl/ModifyIncomingRequestPhase.d.ts +5 -0
  203. package/lib/types/phase/impl/ModifyOutgoingResponsePhase.d.ts +5 -0
  204. package/lib/types/phase/impl/ParseTokenPhase.d.ts +3 -0
  205. package/lib/types/phase/impl/PreflightPhase.d.ts +4 -0
  206. package/lib/types/phase/impl/RiskApiPhase.d.ts +5 -0
  207. package/lib/types/phase/impl/{SendAsyncActivitiesOnResponsePhase.d.ts → SendAsyncActivitiesPhase.d.ts} +5 -2
  208. package/lib/types/phase/impl/SendLogsPhase.d.ts +3 -0
  209. package/lib/types/phase/impl/SendTelemetryActivityPhase.d.ts +3 -0
  210. package/lib/types/phase/impl/UpdateRemoteConfigPhase.d.ts +3 -0
  211. package/lib/types/phase/impl/index.d.ts +1 -2
  212. package/lib/types/phase/index.d.ts +0 -1
  213. package/lib/types/products/credential_intelligence/endpoint/CredentialEndpointConfiguration.d.ts +1 -1
  214. package/lib/types/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.d.ts +1 -1
  215. package/lib/types/products/interfaces/IProduct.d.ts +28 -0
  216. package/lib/types/products/interfaces/ProductDataType.d.ts +1 -1
  217. package/lib/types/risk_api/client/GetRiskApiClientV2.d.ts +15 -0
  218. package/lib/types/risk_api/client/PostRiskApiClientV2.d.ts +1 -1
  219. package/lib/types/risk_api/client/PostRiskApiClientV3.d.ts +2 -2
  220. package/lib/types/risk_api/client/{IRiskApiClient.d.ts → abstract/IRiskApiClient.d.ts} +1 -1
  221. package/lib/types/risk_api/client/abstract/PostRiskApiClientBase.d.ts +8 -0
  222. package/lib/types/risk_api/client/abstract/RiskApiClientBase.d.ts +26 -0
  223. package/lib/types/risk_api/client/abstract/index.d.ts +3 -0
  224. package/lib/types/risk_api/client/index.d.ts +2 -2
  225. package/lib/types/risk_api/index.d.ts +1 -0
  226. package/lib/types/risk_api/model/GetRiskRequestHeaders.d.ts +17 -0
  227. package/lib/types/risk_api/model/GetRiskResponseHeaders.d.ts +3 -0
  228. package/lib/types/risk_api/model/index.d.ts +2 -0
  229. package/lib/types/risk_api/risk_response/IRiskResponse.d.ts +2 -0
  230. package/lib/types/risk_api/risk_response/PostRiskResponseBase.d.ts +7 -0
  231. package/lib/types/risk_api/risk_response/RiskResponseBase.d.ts +3 -1
  232. package/lib/types/risk_api/risk_response/index.d.ts +1 -0
  233. package/lib/types/risk_api/risk_response/serialize/SerializedRiskResponse.d.ts +1 -0
  234. package/lib/types/risk_api/risk_response/v2/GetRiskResponseV2.d.ts +11 -0
  235. package/lib/types/risk_api/risk_response/{v3/DefaultRiskResponseV3.d.ts → v2/PostRiskResponseV2.d.ts} +2 -2
  236. package/lib/types/risk_api/risk_response/v2/index.d.ts +2 -1
  237. package/lib/types/risk_api/risk_response/{v2/DefaultRiskResponseV2.d.ts → v3/PostRiskResponseV3.d.ts} +2 -2
  238. package/lib/types/risk_api/risk_response/v3/index.d.ts +1 -1
  239. package/lib/types/risk_api/utils.d.ts +69 -0
  240. package/lib/types/telemetry/model/TelemetryActivity.d.ts +1 -1
  241. package/lib/types/utils/constants.d.ts +1 -1
  242. package/lib/types/utils/utils.d.ts +0 -5
  243. package/package.json +1 -1
  244. package/lib/esm/phase/flow/EndEnforcerFlow.js +0 -14
  245. package/lib/esm/phase/flow/EnforceFlow.js +0 -18
  246. package/lib/esm/phase/flow/PostEnforceFlow.js +0 -10
  247. package/lib/esm/phase/impl/SendAsyncActivitiesOnRequestPhase.js +0 -16
  248. package/lib/esm/phase/impl/SendAsyncActivitiesOnResponsePhase.js +0 -10
  249. package/lib/types/phase/flow/EndEnforcerFlow.d.ts +0 -8
  250. package/lib/types/phase/flow/EnforceFlow.d.ts +0 -8
  251. package/lib/types/phase/flow/PostEnforceFlow.d.ts +0 -6
  252. package/lib/types/phase/impl/SendAsyncActivitiesOnRequestPhase.d.ts +0 -10
  253. package/lib/types/risk_api/client/PostRiskApiClientBase.d.ts +0 -40
  254. /package/lib/cjs/{risk_api/client/IRiskApiClient.js → enforcer/IPostEnforcer.js} +0 -0
  255. /package/lib/esm/{risk_api/client/IRiskApiClient.js → enforcer/IPostEnforcer.js} +0 -0
@@ -1,9 +1,9 @@
1
- import { AUTHORIZATION_HEADER_NAME, CONTENT_TYPE_HEADER_NAME, ContentType, HttpMethod, OutgoingRequestImpl, } from '../../http/index.js';
2
- import { EnforcerErrorName, getAuthorizationHeader, removeSensitiveHeaders } from '../../utils/index.js';
3
- import { createCommonActivityDetails, toHeaderEntryArray } from '../../activities/index.js';
4
- import { RISK_API_ENDPOINT } from '../constants.js';
5
- import { RiskApiCallResult, RiskStatus, S2SErrorReason } from '../model/index.js';
6
- export class PostRiskApiClientBase {
1
+ import { AUTHORIZATION_HEADER_NAME, } from '../../../http/index.js';
2
+ import { EnforcerErrorName, getAuthorizationHeader, removeSensitiveHeaders } from '../../../utils/index.js';
3
+ import { toHeaderEntryArray } from '../../../activities/index.js';
4
+ import { RISK_API_ENDPOINT } from '../../constants.js';
5
+ import { RiskApiCallResult, RiskStatus, S2SErrorReason } from '../../model/index.js';
6
+ export class RiskApiClientBase {
7
7
  config;
8
8
  httpClient;
9
9
  constructor(config, httpClient) {
@@ -20,8 +20,8 @@ export class PostRiskApiClientBase {
20
20
  let riskResponse;
21
21
  const riskApiData = { riskApiCallResult: RiskApiCallResult.NONE };
22
22
  try {
23
- const riskActivity = this.createRiskActivity(context);
24
- response = await this.sendRiskActivity(riskActivity, riskApiData, context);
23
+ const riskRequest = this.createRiskRequest(context);
24
+ response = await this.sendRiskActivity(riskRequest, riskApiData, context);
25
25
  if (response?.status !== 200) {
26
26
  return await this.handleS2SError(riskApiData, context, response);
27
27
  }
@@ -41,50 +41,12 @@ export class PostRiskApiClientBase {
41
41
  return await this.handleS2SError(riskApiData, context, response, err);
42
42
  }
43
43
  }
44
- /**
45
- * Creates the RiskActivity payload
46
- * @param context
47
- * @returns RiskActivity
48
- * @protected
49
- */
50
- createRiskActivity(context) {
51
- const riskActivity = {
52
- vid: context.vid,
53
- client_uuid: context.uuid,
54
- pxhd: context.pxhd?.value,
55
- request: {
56
- socket_ip: context.requestData.ip,
57
- headers: this.formatRiskHeadersField(context.requestData.headers),
58
- url: context.requestData.url.href,
59
- },
60
- additional: {
61
- ...createCommonActivityDetails(this.config, context),
62
- s2s_call_reason: context.riskApiData.s2sCallReason ?? 'unknown_reason',
63
- risk_start_time: context.riskApiData.riskStartTime ?? Date.now(),
64
- },
65
- };
66
- return this.finalizeRiskActivity(riskActivity);
67
- }
68
- /**
69
- * Protected function in case expansions or alterations to the risk activity are needed for certain platforms.
70
- * @param riskActivity
71
- * @returns RiskActivity
72
- * @protected
73
- */
74
- finalizeRiskActivity(riskActivity) {
75
- return riskActivity;
76
- }
77
44
  formatRiskHeadersField(headers) {
78
45
  const headersWithoutSensitive = removeSensitiveHeaders(headers, this.config.sensitiveHeaders);
79
46
  return toHeaderEntryArray(headersWithoutSensitive);
80
47
  }
81
- async sendRiskActivity(riskActivity, riskApiData, context) {
82
- const url = this.getRiskUrl();
83
- const headers = this.getRiskHeaders();
84
- const body = JSON.stringify(riskActivity);
85
- const method = HttpMethod.POST;
86
- const riskRequest = new OutgoingRequestImpl({ url, method, headers, body });
87
- context.logger.debug(`sending risk api to ${url}`);
48
+ async sendRiskActivity(riskRequest, riskApiData, context) {
49
+ context.logger.debug(`sending risk api to ${riskRequest.url}`);
88
50
  const startTime = Date.now();
89
51
  const response = await this.httpClient.send(riskRequest, { timeoutMs: this.config.s2sTimeout });
90
52
  const endTime = Date.now();
@@ -97,7 +59,6 @@ export class PostRiskApiClientBase {
97
59
  }
98
60
  getRiskHeaders() {
99
61
  return {
100
- [CONTENT_TYPE_HEADER_NAME]: [ContentType.APPLICATION_JSON],
101
62
  [AUTHORIZATION_HEADER_NAME]: [getAuthorizationHeader(this.config.authToken)],
102
63
  };
103
64
  }
@@ -0,0 +1,3 @@
1
+ export * from './PostRiskApiClientBase.js';
2
+ export * from './RiskApiClientBase.js';
3
+ export * from './IRiskApiClient.js';
@@ -1,4 +1,4 @@
1
- export * from './IRiskApiClient.js';
2
- export * from './PostRiskApiClientBase.js';
3
1
  export * from './PostRiskApiClientV2.js';
4
2
  export * from './PostRiskApiClientV3.js';
3
+ export * from './abstract/index.js';
4
+ export * from './GetRiskApiClientV2.js';
@@ -2,3 +2,4 @@ export * from './model/index.js';
2
2
  export * from './risk_response/index.js';
3
3
  export * from './client/index.js';
4
4
  export * from './constants.js';
5
+ export * from './utils.js';
@@ -0,0 +1,182 @@
1
+ export const RISK_ACTIVITY_FIELDS_TO_HEADER_NAMES = {
2
+ vid: {
3
+ header: 'x-px-vid',
4
+ },
5
+ client_uuid: {
6
+ header: 'x-px-client-uuid',
7
+ },
8
+ pxhd: {
9
+ header: 'x-px-pxhd',
10
+ },
11
+ };
12
+ export const RISK_ACTIVITY_REQUEST_FIELDS_TO_HEADER_NAMES = {
13
+ socket_ip: {
14
+ header: 'x-px-socket-ip',
15
+ },
16
+ url: {
17
+ header: 'x-px-url',
18
+ },
19
+ };
20
+ export const RISK_ACTIVITY_ADDITIONAL_FIELDS_TO_HEADER_NAMES = {
21
+ cpa: {
22
+ header: 'x-px-add-cpa',
23
+ convertToString: (value) => `${value}`,
24
+ },
25
+ enforcer_start_time: {
26
+ header: 'x-px-add-enforcer-start-time',
27
+ convertToString: (value) => `${value}`,
28
+ },
29
+ is_hype_sale: {
30
+ header: 'x-px-add-is-hype-sale',
31
+ convertToString: (value) => `${value}`,
32
+ },
33
+ px_cookie_hmac: {
34
+ header: 'x-px-add-cookie-hmac',
35
+ },
36
+ raw_url: {
37
+ header: 'x-px-add-raw-url',
38
+ },
39
+ tls_ja3_fingerprint: {
40
+ header: 'x-px-add-tls-ja3-fingerprint',
41
+ },
42
+ tls_preferred_ciphers: {
43
+ header: 'x-px-add-tls-preferred-ciphers',
44
+ },
45
+ used_cookie_secret: {
46
+ header: 'x-px-add-used-cookie-secret',
47
+ },
48
+ risk_start_time: {
49
+ header: 'x-px-add-risk-start-time',
50
+ convertToString: (value) => `${value}`,
51
+ },
52
+ app_user_id: {
53
+ header: 'x-px-add-app-user-id',
54
+ },
55
+ ci_version: {
56
+ header: 'x-px-add-ci-version',
57
+ },
58
+ cookie_origin: {
59
+ header: 'x-px-add-cookie-origin',
60
+ },
61
+ cross_tab_session: {
62
+ header: 'x-px-add-cross-tab-session',
63
+ },
64
+ custom_param1: {
65
+ header: 'x-px-custom-param1',
66
+ },
67
+ custom_param10: {
68
+ header: 'x-px-custom-param10',
69
+ },
70
+ custom_param2: {
71
+ header: 'x-px-custom-param2',
72
+ },
73
+ custom_param3: {
74
+ header: 'x-px-custom-param3',
75
+ },
76
+ custom_param4: {
77
+ header: 'x-px-custom-param4',
78
+ },
79
+ custom_param5: {
80
+ header: 'x-px-custom-param5',
81
+ },
82
+ custom_param6: {
83
+ header: 'x-px-custom-param6',
84
+ },
85
+ custom_param7: {
86
+ header: 'x-px-custom-param7',
87
+ },
88
+ custom_param8: {
89
+ header: 'x-px-custom-param8',
90
+ },
91
+ custom_param9: {
92
+ header: 'x-px-custom-param9',
93
+ },
94
+ enforcer_vid_source: {
95
+ header: 'x-px-add-enforcer-vid-source',
96
+ },
97
+ server_info_datacenter: {
98
+ header: 'x-px-add-server-info-datacenter',
99
+ },
100
+ server_info_region: {
101
+ header: 'x-px-add-server-info-region',
102
+ },
103
+ graphql_operations: {
104
+ header: 'x-px-add-graphql-operations',
105
+ convertToString: (value) => JSON.stringify(value),
106
+ },
107
+ http_method: {
108
+ header: 'x-px-add-http-method',
109
+ },
110
+ http_version: {
111
+ header: 'x-px-add-http-version',
112
+ },
113
+ jwt_additional_fields: {
114
+ header: 'x-px-add-jwt-additional-fields',
115
+ convertToString: (value) => JSON.stringify(value),
116
+ },
117
+ module_version: {
118
+ header: 'x-px-add-module-version',
119
+ },
120
+ original_token: {
121
+ header: 'x-px-add-original-token',
122
+ },
123
+ original_token_error: {
124
+ header: 'x-px-add-original-token-error',
125
+ },
126
+ original_uuid: {
127
+ header: 'x-px-add-original-uuid',
128
+ },
129
+ pass: {
130
+ header: 'x-px-add-pass',
131
+ },
132
+ px_cookie: {
133
+ header: 'x-px-add-px-cookie',
134
+ },
135
+ px_decoded_original_token: {
136
+ header: 'x-px-decoded-original-token',
137
+ },
138
+ px_orig_cookie: {
139
+ header: 'x-px-add-px-orig-cookie',
140
+ },
141
+ request_cookie_names: {
142
+ header: 'x-px-add-request-cookie-names',
143
+ convertToString: (value) => value.join(','),
144
+ },
145
+ request_id: {
146
+ header: 'x-px-add-request-id',
147
+ },
148
+ risk_mode: {
149
+ header: 'x-px-add-risk-mode',
150
+ },
151
+ sso_step: {
152
+ header: 'x-px-add-sso-step',
153
+ },
154
+ tls_cipher: {
155
+ header: 'x-px-add-tls-cipher',
156
+ },
157
+ tls_ciphers_sha: {
158
+ header: 'x-px-add-tls-ciphers-sha',
159
+ },
160
+ tls_extension_sha: {
161
+ header: 'x-px-add-tls-extension-sha',
162
+ },
163
+ tls_protocol: {
164
+ header: 'x-px-add-tls-protocol',
165
+ },
166
+ tls_server: {
167
+ header: 'x-px-add-tls-server',
168
+ },
169
+ user: {
170
+ header: 'x-px-add-user',
171
+ },
172
+ remote_config_id: {
173
+ header: 'x-px-add-remote-config-id',
174
+ },
175
+ remote_config_version: {
176
+ header: 'x-px-add-remote-config-version',
177
+ convertToString: (value) => `${value}`,
178
+ },
179
+ s2s_call_reason: {
180
+ header: 'x-px-add-s2s-call-reason',
181
+ },
182
+ };
@@ -0,0 +1,13 @@
1
+ export const GetRiskResponseHeaders = {
2
+ Action: 'x-px-action',
3
+ AdditionalRiskInfo: 'x-px-additional-risk-info',
4
+ CookieCfgBlockResult: 'x-px-cookie-cfg-block-result',
5
+ DataEnrichment: 'x-px-data-enrichment',
6
+ Drc: 'x-px-drc',
7
+ Message: 'x-px-message',
8
+ Pxhd: 'x-px-pxhd',
9
+ PxhdDomain: 'x-px-pxhddomain',
10
+ Status: 'x-px-status',
11
+ TelemetryRequested: 'x-px-telemetry-requested',
12
+ Uuid: 'x-px-uuid',
13
+ };
@@ -2,3 +2,5 @@ export * from './RiskActivity.js';
2
2
  export * from './RiskStatus.js';
3
3
  export * from './RiskApiCallResult.js';
4
4
  export * from './S2SErrorReason.js';
5
+ export * from './GetRiskResponseHeaders.js';
6
+ export * from './GetRiskRequestHeaders.js';
@@ -0,0 +1,6 @@
1
+ import { RiskResponseBase } from './RiskResponseBase.js';
2
+ export class PostRiskResponseBase extends RiskResponseBase {
3
+ async parseRiskResponse(response) {
4
+ return response.json();
5
+ }
6
+ }
@@ -7,7 +7,11 @@ export class RiskResponseBase {
7
7
  }
8
8
  async validate() {
9
9
  try {
10
- this.riskResponse = (await this.response.json());
10
+ const riskResponse = await this.parseRiskResponse(this.response);
11
+ if (!riskResponse) {
12
+ return false;
13
+ }
14
+ this.riskResponse = riskResponse;
11
15
  return this.status === RiskStatus.SUCCESS && this.validateRiskResponseScore();
12
16
  }
13
17
  catch (e) {
@@ -1,5 +1,6 @@
1
1
  export * from './IRiskResponse.js';
2
2
  export * from './RiskResponseBase.js';
3
+ export * from './PostRiskResponseBase.js';
3
4
  export * from './CommonRiskResponsePayload.js';
4
5
  export * from './v2/index.js';
5
6
  export * from './v3/index.js';
@@ -1,3 +1,4 @@
1
+ import { EnforcerError } from '../../../utils/index.js';
1
2
  export class SerializedRiskResponse {
2
3
  action;
3
4
  additionalRiskInfo;
@@ -24,6 +25,9 @@ export class SerializedRiskResponse {
24
25
  this.uuid = riskResponseJson.uuid;
25
26
  }
26
27
  validate() {
27
- return true;
28
+ throw new EnforcerError('SerializedRiskResponse.validate() should not be invoked');
29
+ }
30
+ toJSON() {
31
+ return this;
28
32
  }
29
33
  }
@@ -0,0 +1,52 @@
1
+ import { RiskResponseBase } from '../RiskResponseBase.js';
2
+ import { GetRiskResponseHeaders } from '../../model/index.js';
3
+ export class GetRiskResponseV2 extends RiskResponseBase {
4
+ constructor(response) {
5
+ super(response);
6
+ }
7
+ parseRiskResponse(response) {
8
+ const riskStatus = this.getHeader(response, GetRiskResponseHeaders.Status);
9
+ if (!riskStatus) {
10
+ return null;
11
+ }
12
+ const status = parseInt(riskStatus);
13
+ const blockResult = this.getHeader(response, GetRiskResponseHeaders.CookieCfgBlockResult);
14
+ const additionalRiskInfo = this.getHeader(response, GetRiskResponseHeaders.AdditionalRiskInfo);
15
+ const dataEnrichment = this.getHeader(response, GetRiskResponseHeaders.DataEnrichment);
16
+ const drc = this.getHeader(response, GetRiskResponseHeaders.Drc);
17
+ const message = this.getHeader(response, GetRiskResponseHeaders.Message);
18
+ const pxhd = this.getHeader(response, GetRiskResponseHeaders.Pxhd);
19
+ const pxhdDomain = this.getHeader(response, GetRiskResponseHeaders.PxhdDomain);
20
+ const telemetryRequested = this.getHeader(response, GetRiskResponseHeaders.TelemetryRequested);
21
+ const uuid = this.getHeader(response, GetRiskResponseHeaders.Uuid);
22
+ const action = this.getHeader(response, GetRiskResponseHeaders.Action);
23
+ return {
24
+ status,
25
+ action,
26
+ uuid,
27
+ pxhd,
28
+ message,
29
+ data_enrichment: dataEnrichment ? JSON.parse(dataEnrichment) : undefined,
30
+ pxhdDomain,
31
+ additional_risk_info: additionalRiskInfo,
32
+ telemetry_requested: !!telemetryRequested,
33
+ drc: drc ? parseInt(drc) : undefined,
34
+ cookie_cfg_block_result: blockResult,
35
+ };
36
+ }
37
+ getHeader(response, header) {
38
+ return response.headers[header.toLowerCase()]?.[0];
39
+ }
40
+ // TODO: This is the same as in PostRiskResponseV2. We should deduplicate this.
41
+ get score() {
42
+ return typeof this.riskResponse?.cookie_cfg_block_result === 'undefined'
43
+ ? undefined
44
+ : this.riskResponse.cookie_cfg_block_result === '1'
45
+ ? 100
46
+ : 0;
47
+ }
48
+ validateRiskResponseScore() {
49
+ const blockResult = this.riskResponse?.cookie_cfg_block_result;
50
+ return typeof blockResult === 'string' && ['0', '1'].includes(blockResult);
51
+ }
52
+ }
@@ -1,5 +1,5 @@
1
- import { RiskResponseBase } from '../RiskResponseBase.js';
2
- export class DefaultRiskResponseV2 extends RiskResponseBase {
1
+ import { PostRiskResponseBase } from '../PostRiskResponseBase.js';
2
+ export class PostRiskResponseV2 extends PostRiskResponseBase {
3
3
  constructor(response) {
4
4
  super(response);
5
5
  }
@@ -1,2 +1,3 @@
1
- export * from './DefaultRiskResponseV2.js';
1
+ export * from './GetRiskResponseV2.js';
2
+ export * from './PostRiskResponseV2.js';
2
3
  export * from './RiskResponseV2Payload.js';
@@ -1,5 +1,5 @@
1
- import { RiskResponseBase } from '../RiskResponseBase.js';
2
- export class DefaultRiskResponseV3 extends RiskResponseBase {
1
+ import { PostRiskResponseBase } from '../PostRiskResponseBase.js';
2
+ export class PostRiskResponseV3 extends PostRiskResponseBase {
3
3
  constructor(response) {
4
4
  super(response);
5
5
  }
@@ -1,2 +1,2 @@
1
- export * from './DefaultRiskResponseV3.js';
1
+ export * from './PostRiskResponseV3.js';
2
2
  export * from './RiskResponseV3Payload.js';
@@ -0,0 +1,23 @@
1
+ import { createCommonActivityDetails, toHeaderEntryArray } from '../activities/index.js';
2
+ import { removeSensitiveHeaders } from '../utils/index.js';
3
+ export const createRiskApiActivity = (config, context) => {
4
+ return {
5
+ vid: context.vid,
6
+ client_uuid: context.uuid,
7
+ pxhd: context.pxhd?.value,
8
+ request: {
9
+ socket_ip: context.requestData.ip,
10
+ headers: formatRiskHeadersField(context.requestData.headers, config),
11
+ url: context.requestData.url.href,
12
+ },
13
+ additional: {
14
+ ...createCommonActivityDetails(config, context),
15
+ s2s_call_reason: context.riskApiData.s2sCallReason ?? 'unknown_reason',
16
+ risk_start_time: context.riskApiData.riskStartTime ?? Date.now(),
17
+ },
18
+ };
19
+ };
20
+ export const formatRiskHeadersField = (headers, config) => {
21
+ const headersWithoutSensitive = removeSensitiveHeaders(headers, config.sensitiveHeaders);
22
+ return toHeaderEntryArray(headersWithoutSensitive);
23
+ };
@@ -1,6 +1,6 @@
1
1
  import { AUTHORIZATION_HEADER_NAME, CONTENT_TYPE_HEADER_NAME, ContentType, HttpMethod, OutgoingRequestImpl, } from '../http/index.js';
2
2
  import { ActivityType } from '../activities/index.js';
3
- import { getAuthorizationHeader, transferExistingProperties, DefaultTimestampHmacHeaderValidator, telemetryConfigReplacer, redactSensitiveFields, } from '../utils/index.js';
3
+ import { getAuthorizationHeader, DefaultTimestampHmacHeaderValidator, telemetryConfigReplacer, redactSensitiveFields, } from '../utils/index.js';
4
4
  import { TELEMETRY_ENDPOINT, TELEMETRY_HEADER_NAME, TELEMETRY_UPDATE_REASON } from './constants.js';
5
5
  export class DefaultTelemetry {
6
6
  config;
@@ -49,7 +49,6 @@ export class DefaultTelemetry {
49
49
  [AUTHORIZATION_HEADER_NAME]: [getAuthorizationHeader(this.config.authToken)],
50
50
  };
51
51
  const activity = this.createTelemetryActivity(context);
52
- context.logger.debug(`created telemetry activity config - ${JSON.stringify(activity.details.enforcer_configs, telemetryConfigReplacer)}`);
53
52
  return new OutgoingRequestImpl({
54
53
  url: url,
55
54
  method: method,
@@ -79,14 +78,18 @@ export class DefaultTelemetry {
79
78
  enforcer_configs: telemetryConfig,
80
79
  },
81
80
  };
82
- transferExistingProperties(context.serverData, activity.details, {
83
- osName: 'os_name',
84
- nodeName: 'node_name',
85
- });
86
- transferExistingProperties(this.config, activity.details, {
87
- remoteConfigId: 'remote_config_id',
88
- remoteConfigVersion: 'remote_config_version',
89
- });
81
+ if (context.serverData.osName) {
82
+ activity.details.os_name = context.serverData.osName;
83
+ }
84
+ if (context.serverData.nodeName) {
85
+ activity.details.node_name = context.serverData.nodeName;
86
+ }
87
+ if (this.config.remoteConfigId) {
88
+ activity.details.remote_config_id = this.config.remoteConfigId;
89
+ }
90
+ if (this.config.remoteConfigVersion) {
91
+ activity.details.remote_config_version = this.config.remoteConfigVersion;
92
+ }
90
93
  return activity;
91
94
  }
92
95
  }
@@ -11,4 +11,4 @@ export const PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
11
11
  export const EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
12
12
  export const URL_REGEX = /^(https?:)\/\/(([^@\s:\/]+):?([^@\s\/]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)(\/?[^?#]*)(\?[^#]*|)(#.*|)$/;
13
13
  export const REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/;
14
- export const CORE_MODULE_VERSION = 'JS Core 0.25.0';
14
+ export const CORE_MODULE_VERSION = 'JS Core 0.26.0';
@@ -85,22 +85,6 @@ export const isStringMatch = (str, pattern) => {
85
85
  }
86
86
  return false;
87
87
  };
88
- /**
89
- * @deprecated this method is not typesafe. Copy the fields manually instead,
90
- * unsafe - ignores compilerOptions.strictNullChecks
91
- */
92
- export const transferExistingProperties = (fromObj, toObj, propertyMappings) => {
93
- if (!toObj || !fromObj) {
94
- return;
95
- }
96
- Object.entries(propertyMappings).forEach(([fromObjKey, toObjKey]) => {
97
- if ((typeof fromObj[fromObjKey] !== 'string' && fromObj[fromObjKey] != null) ||
98
- (typeof fromObj[fromObjKey] === 'string' && fromObj[fromObjKey] !== '')) {
99
- // @ts-ignore
100
- toObj[toObjKey] = fromObj[fromObjKey];
101
- }
102
- });
103
- };
104
88
  export const rejectOnTimeout = async (promise, ms) => {
105
89
  let id;
106
90
  const timeout = new Promise((_resolve, reject) => {
@@ -1,6 +1,21 @@
1
+ /**
2
+ * The action that should be taken by the enforcer.
3
+ */
1
4
  export declare enum Action {
5
+ /**
6
+ * Indicates that the request should be allowed to pass.
7
+ */
2
8
  PASS_REQUEST = "pass_request",
9
+ /**
10
+ * Indicates that there is not enough information to make a decision and a Risk API request should be made.
11
+ */
3
12
  TRIGGER_RISK_API = "trigger_risk_api",
13
+ /**
14
+ * Indicates that the request should be blocked, but no block response will be returned.
15
+ */
4
16
  SIMULATED_BLOCK = "simulated_block",
17
+ /**
18
+ * Indicates that the request should be blocked and a block response should be returned.
19
+ */
5
20
  BLOCK = "block"
6
21
  }
@@ -1,4 +1,7 @@
1
1
  import { Action } from './Action';
2
+ /**
3
+ * The action and reason provided by each product that influences the enforcer's behavior.
4
+ */
2
5
  export type ActionData = {
3
6
  /**
4
7
  * The recommended action that should be taken by the enforcer.
@@ -1,2 +1,6 @@
1
1
  import { Action } from './Action';
2
+ /**
3
+ * The priority order of actions that the enforcer should take. The array will be traversed in order,
4
+ * and the first action that matches a product recommendation will be taken.
5
+ */
2
6
  export declare const ACTION_PRIORITY_ORDER: Action[];
@@ -1,6 +1,15 @@
1
1
  import { Action } from './index';
2
2
  import { ProductName } from '../products';
3
+ /**
4
+ * The decision made by the enforcer based on the action and reason provided by each product.
5
+ */
3
6
  export type Decision = {
7
+ /**
8
+ * The action that will be taken by the enforcer.
9
+ */
4
10
  action: Action;
11
+ /**
12
+ * A mapping of the product name to the reason for the action.
13
+ */
5
14
  reasons: Partial<Record<ProductName, string>>;
6
15
  };
@@ -1,5 +1,8 @@
1
1
  import { ActionData } from './ActionData';
2
2
  import { ProductName } from '../products';
3
+ /**
4
+ * An object that includes the productName and its associated recommended action and reason.
5
+ */
3
6
  export type ProductAction = ActionData & {
4
7
  productName: ProductName;
5
8
  };
@@ -2,7 +2,27 @@ import { ProductName } from '../products';
2
2
  import { Decision } from './Decision';
3
3
  import { IContext } from '../context';
4
4
  import { ProductAction } from './ProductAction';
5
+ /**
6
+ * Determines the final decision from the context.
7
+ * @param context - The request context.
8
+ * @returns Decision - The final action that should be taken and the associated products and reasons responsible for the decision.
9
+ */
5
10
  export declare const getDecisionFromContext: <Req, Res>(context: IContext<Req, Res>) => Decision;
11
+ /**
12
+ * Determines all product recommended actions from the context.
13
+ * @param context - The request context.
14
+ * @returns ProductAction[] - An array of objects, representing the recommended action and reason of all relevant products.
15
+ */
6
16
  export declare const getProductActions: <Req, Res>(context: IContext<Req, Res>) => ProductAction[];
17
+ /**
18
+ * Reduces a list of ProductActions to a single Decision, taking into consideration the ACTION_PRIORITY_ORDER.
19
+ * @param productActions - All possible actions from all products.
20
+ * @returns Decision - The final action that should be taken and the associated products and reasons responsible for the decision.
21
+ */
7
22
  export declare const getDecisionFromActions: (productActions: ProductAction[]) => Decision;
23
+ /**
24
+ * Provided a mapping of product names to reasons, returns the reason associated with the highest priority product in the mapping.
25
+ * @param reasons - An object mapping any product names to their associated reasons.
26
+ * @returns string - The reason for the highest priority product, or 'unknown_reason' if none is found.
27
+ */
8
28
  export declare const getReasonForHighestPriorityProduct: (reasons: Partial<Record<ProductName, string>>) => string;