@openora/core 0.4.1-canary.39 → 0.4.1-canary.41

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 (248) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/admin-console/contract/index.d.ts +2 -0
  3. package/dist/admin-console/contract/index.d.ts.map +1 -1
  4. package/dist/admin-console/router/index.d.ts +1 -0
  5. package/dist/admin-console/router/index.d.ts.map +1 -1
  6. package/dist/admin-console/service/backoffice.service.d.ts +1 -1
  7. package/dist/audit/plugin.d.ts.map +1 -1
  8. package/dist/audit/plugin.js +48 -1
  9. package/dist/audit/plugin.js.map +1 -1
  10. package/dist/common/errors/errors.classes.js +3 -3
  11. package/dist/common/errors/errors.classes.js.map +1 -1
  12. package/dist/common/errors/errors.mapper.js +1 -1
  13. package/dist/common/errors/errors.mapper.js.map +1 -1
  14. package/dist/compliance/__tests__/hmac-kyc-webhook-verifier.test.js +66 -12
  15. package/dist/compliance/__tests__/hmac-kyc-webhook-verifier.test.js.map +1 -1
  16. package/dist/compliance/__tests__/kyc-admin.router.test.d.ts +2 -0
  17. package/dist/compliance/__tests__/kyc-admin.router.test.d.ts.map +1 -0
  18. package/dist/compliance/__tests__/kyc-admin.router.test.js +191 -0
  19. package/dist/compliance/__tests__/kyc-admin.router.test.js.map +1 -0
  20. package/dist/compliance/__tests__/kyc-webhook.router.test.d.ts +2 -0
  21. package/dist/compliance/__tests__/kyc-webhook.router.test.d.ts.map +1 -0
  22. package/dist/compliance/__tests__/kyc-webhook.router.test.js +148 -0
  23. package/dist/compliance/__tests__/kyc-webhook.router.test.js.map +1 -0
  24. package/dist/compliance/__tests__/kyc.service.test.js +16 -10
  25. package/dist/compliance/__tests__/kyc.service.test.js.map +1 -1
  26. package/dist/compliance/__tests__/rg.router.test.js +5 -1
  27. package/dist/compliance/__tests__/rg.router.test.js.map +1 -1
  28. package/dist/compliance/adapters/hmac-kyc-webhook-verifier.d.ts +16 -3
  29. package/dist/compliance/adapters/hmac-kyc-webhook-verifier.d.ts.map +1 -1
  30. package/dist/compliance/adapters/hmac-kyc-webhook-verifier.js +47 -5
  31. package/dist/compliance/adapters/hmac-kyc-webhook-verifier.js.map +1 -1
  32. package/dist/compliance/contract/index.d.ts +312 -0
  33. package/dist/compliance/contract/index.d.ts.map +1 -1
  34. package/dist/compliance/contract/index.js +50 -1
  35. package/dist/compliance/contract/index.js.map +1 -1
  36. package/dist/compliance/drizzle/migrations/0002_condemned_monster_badoon.sql +3 -0
  37. package/dist/compliance/drizzle/migrations/0003_public_spirit.sql +1 -0
  38. package/dist/compliance/drizzle/migrations/meta/0002_snapshot.json +673 -0
  39. package/dist/compliance/drizzle/migrations/meta/0003_snapshot.json +679 -0
  40. package/dist/compliance/drizzle/migrations/meta/_journal.json +14 -0
  41. package/dist/compliance/plugin.d.ts.map +1 -1
  42. package/dist/compliance/plugin.js +23 -3
  43. package/dist/compliance/plugin.js.map +1 -1
  44. package/dist/compliance/router/index.d.ts +186 -2
  45. package/dist/compliance/router/index.d.ts.map +1 -1
  46. package/dist/compliance/router/index.js +52 -3
  47. package/dist/compliance/router/index.js.map +1 -1
  48. package/dist/compliance/schema/index.d.ts +65 -3
  49. package/dist/compliance/schema/index.d.ts.map +1 -1
  50. package/dist/compliance/schema/index.js +8 -0
  51. package/dist/compliance/schema/index.js.map +1 -1
  52. package/dist/compliance/service/kyc.service.d.ts +153 -8
  53. package/dist/compliance/service/kyc.service.d.ts.map +1 -1
  54. package/dist/compliance/service/kyc.service.js +264 -32
  55. package/dist/compliance/service/kyc.service.js.map +1 -1
  56. package/dist/contracts/adapters/audit.d.ts +1 -1
  57. package/dist/contracts/adapters/audit.d.ts.map +1 -1
  58. package/dist/contracts/adapters/audit.js.map +1 -1
  59. package/dist/contracts/adapters/identity-reader.d.ts +9 -3
  60. package/dist/contracts/adapters/identity-reader.d.ts.map +1 -1
  61. package/dist/contracts/adapters/identity-reader.js.map +1 -1
  62. package/dist/contracts/adapters/index.d.ts +4 -2
  63. package/dist/contracts/adapters/index.d.ts.map +1 -1
  64. package/dist/contracts/adapters/index.js +2 -1
  65. package/dist/contracts/adapters/index.js.map +1 -1
  66. package/dist/contracts/adapters/kyc.d.ts +90 -5
  67. package/dist/contracts/adapters/kyc.d.ts.map +1 -1
  68. package/dist/contracts/adapters/kyc.js +23 -0
  69. package/dist/contracts/adapters/kyc.js.map +1 -1
  70. package/dist/contracts/adapters/tag-evaluation-commands.d.ts +10 -0
  71. package/dist/contracts/adapters/tag-evaluation-commands.d.ts.map +1 -0
  72. package/dist/contracts/adapters/tag-evaluation-commands.js +11 -0
  73. package/dist/contracts/adapters/tag-evaluation-commands.js.map +1 -0
  74. package/dist/contracts/adapters/wallet-reader.d.ts +8 -0
  75. package/dist/contracts/adapters/wallet-reader.d.ts.map +1 -1
  76. package/dist/contracts/adapters/wallet-reader.js.map +1 -1
  77. package/dist/contracts/schemas/__tests__/events.test.js +1 -1
  78. package/dist/contracts/schemas/__tests__/player-schemas.test.d.ts +2 -0
  79. package/dist/contracts/schemas/__tests__/player-schemas.test.d.ts.map +1 -0
  80. package/dist/contracts/schemas/__tests__/player-schemas.test.js +30 -0
  81. package/dist/contracts/schemas/__tests__/player-schemas.test.js.map +1 -0
  82. package/dist/contracts/schemas/events.d.ts +84 -0
  83. package/dist/contracts/schemas/events.d.ts.map +1 -1
  84. package/dist/contracts/schemas/events.js +24 -2
  85. package/dist/contracts/schemas/events.js.map +1 -1
  86. package/dist/contracts/schemas/platform-config.d.ts +13 -1
  87. package/dist/contracts/schemas/platform-config.d.ts.map +1 -1
  88. package/dist/contracts/schemas/player.d.ts +36 -3
  89. package/dist/contracts/schemas/player.d.ts.map +1 -1
  90. package/dist/contracts/schemas/player.js +14 -0
  91. package/dist/contracts/schemas/player.js.map +1 -1
  92. package/dist/contracts/schemas/tag.d.ts +85 -1
  93. package/dist/contracts/schemas/tag.d.ts.map +1 -1
  94. package/dist/contracts/schemas/tag.js +12 -0
  95. package/dist/contracts/schemas/tag.js.map +1 -1
  96. package/dist/engagement/notifications/contract/index.d.ts +5 -1
  97. package/dist/engagement/notifications/contract/index.d.ts.map +1 -1
  98. package/dist/engagement/notifications/contract/index.js +5 -1
  99. package/dist/engagement/notifications/contract/index.js.map +1 -1
  100. package/dist/engagement/notifications/plugin.d.ts.map +1 -1
  101. package/dist/engagement/notifications/plugin.js +43 -3
  102. package/dist/engagement/notifications/plugin.js.map +1 -1
  103. package/dist/engagement/notifications/router/index.d.ts +1 -0
  104. package/dist/engagement/notifications/router/index.d.ts.map +1 -1
  105. package/dist/iam/service/iam.service.d.ts +1 -1
  106. package/dist/pam/identity/__tests__/admin-user-directory.test.js +1 -1
  107. package/dist/pam/identity/adapters/identity-reader.service.d.ts +6 -4
  108. package/dist/pam/identity/adapters/identity-reader.service.d.ts.map +1 -1
  109. package/dist/pam/identity/adapters/identity-reader.service.js +19 -1
  110. package/dist/pam/identity/adapters/identity-reader.service.js.map +1 -1
  111. package/dist/pam/identity/admin-user-directory.d.ts +1 -1
  112. package/dist/pam/identity/admin-user-directory.d.ts.map +1 -1
  113. package/dist/pam/identity/admin-user-directory.js +6 -3
  114. package/dist/pam/identity/admin-user-directory.js.map +1 -1
  115. package/dist/pam/identity/service/identity.service.d.ts.map +1 -1
  116. package/dist/pam/identity/service/identity.service.js +4 -0
  117. package/dist/pam/identity/service/identity.service.js.map +1 -1
  118. package/dist/pam/player-management/__tests__/kyc-status-writer.test.js +5 -2
  119. package/dist/pam/player-management/__tests__/kyc-status-writer.test.js.map +1 -1
  120. package/dist/pam/player-management/__tests__/player.router.test.js +27 -20
  121. package/dist/pam/player-management/__tests__/player.router.test.js.map +1 -1
  122. package/dist/pam/player-management/__tests__/player.service.test.js +30 -31
  123. package/dist/pam/player-management/__tests__/player.service.test.js.map +1 -1
  124. package/dist/pam/player-management/contract/index.d.ts +37 -9
  125. package/dist/pam/player-management/contract/index.d.ts.map +1 -1
  126. package/dist/pam/player-management/contract/index.js +0 -1
  127. package/dist/pam/player-management/contract/index.js.map +1 -1
  128. package/dist/pam/player-management/plugin.d.ts.map +1 -1
  129. package/dist/pam/player-management/plugin.js +3 -2
  130. package/dist/pam/player-management/plugin.js.map +1 -1
  131. package/dist/pam/player-management/router/index.d.ts +32 -10
  132. package/dist/pam/player-management/router/index.d.ts.map +1 -1
  133. package/dist/pam/player-management/router/index.js +48 -16
  134. package/dist/pam/player-management/router/index.js.map +1 -1
  135. package/dist/pam/player-management/service/kyc-status-writer.d.ts +3 -2
  136. package/dist/pam/player-management/service/kyc-status-writer.d.ts.map +1 -1
  137. package/dist/pam/player-management/service/kyc-status-writer.js +24 -10
  138. package/dist/pam/player-management/service/kyc-status-writer.js.map +1 -1
  139. package/dist/pam/player-management/service/player.service.d.ts +10 -9
  140. package/dist/pam/player-management/service/player.service.d.ts.map +1 -1
  141. package/dist/pam/player-management/service/player.service.js +24 -12
  142. package/dist/pam/player-management/service/player.service.js.map +1 -1
  143. package/dist/pam/profile/contract/index.d.ts +2 -0
  144. package/dist/pam/profile/contract/index.d.ts.map +1 -1
  145. package/dist/pam/profile/drizzle/migrations/0001_powerful_tiger_shark.sql +1 -0
  146. package/dist/pam/profile/drizzle/migrations/meta/0001_snapshot.json +191 -0
  147. package/dist/pam/profile/drizzle/migrations/meta/_journal.json +7 -0
  148. package/dist/pam/profile/react/profile.d.ts +2 -2
  149. package/dist/pam/profile/router/index.d.ts +2 -0
  150. package/dist/pam/profile/router/index.d.ts.map +1 -1
  151. package/dist/pam/profile/schema/index.d.ts +3 -3
  152. package/dist/pam/profile/schema/index.d.ts.map +1 -1
  153. package/dist/pam/profile/service/profile.service.d.ts +2 -2
  154. package/dist/pam/shared/player-mapper.d.ts +1 -1
  155. package/dist/pam/tag/__tests__/tag-evaluation.service.test.js +619 -19
  156. package/dist/pam/tag/__tests__/tag-evaluation.service.test.js.map +1 -1
  157. package/dist/pam/tag/__tests__/tag-mappers.test.js +25 -0
  158. package/dist/pam/tag/__tests__/tag-mappers.test.js.map +1 -1
  159. package/dist/pam/tag/__tests__/tag.router.test.js +71 -1
  160. package/dist/pam/tag/__tests__/tag.router.test.js.map +1 -1
  161. package/dist/pam/tag/__tests__/tag.service.test.js +342 -15
  162. package/dist/pam/tag/__tests__/tag.service.test.js.map +1 -1
  163. package/dist/pam/tag/contract/index.d.ts +123 -0
  164. package/dist/pam/tag/contract/index.d.ts.map +1 -1
  165. package/dist/pam/tag/contract/index.js +3 -0
  166. package/dist/pam/tag/contract/index.js.map +1 -1
  167. package/dist/pam/tag/contract/player-tag-assign-metadata.d.ts +37 -0
  168. package/dist/pam/tag/contract/player-tag-assign-metadata.d.ts.map +1 -0
  169. package/dist/pam/tag/contract/player-tag-assign-metadata.js +20 -0
  170. package/dist/pam/tag/contract/player-tag-assign-metadata.js.map +1 -0
  171. package/dist/pam/tag/drizzle/migrations/0002_silent_skaar.sql +4 -0
  172. package/dist/pam/tag/drizzle/migrations/0003_overconfident_guardian.sql +3 -0
  173. package/dist/pam/tag/drizzle/migrations/0004_curvy_wither.sql +2 -0
  174. package/dist/pam/tag/drizzle/migrations/meta/0002_snapshot.json +335 -0
  175. package/dist/pam/tag/drizzle/migrations/meta/0003_snapshot.json +343 -0
  176. package/dist/pam/tag/drizzle/migrations/meta/0004_snapshot.json +345 -0
  177. package/dist/pam/tag/drizzle/migrations/meta/_journal.json +21 -0
  178. package/dist/pam/tag/migrate.d.ts.map +1 -1
  179. package/dist/pam/tag/migrate.js +34 -0
  180. package/dist/pam/tag/migrate.js.map +1 -1
  181. package/dist/pam/tag/plugin.d.ts.map +1 -1
  182. package/dist/pam/tag/plugin.js +43 -16
  183. package/dist/pam/tag/plugin.js.map +1 -1
  184. package/dist/pam/tag/router/index.d.ts +105 -0
  185. package/dist/pam/tag/router/index.d.ts.map +1 -1
  186. package/dist/pam/tag/router/index.js +34 -18
  187. package/dist/pam/tag/router/index.js.map +1 -1
  188. package/dist/pam/tag/schema/index.d.ts +42 -3
  189. package/dist/pam/tag/schema/index.d.ts.map +1 -1
  190. package/dist/pam/tag/schema/index.js +13 -2
  191. package/dist/pam/tag/schema/index.js.map +1 -1
  192. package/dist/pam/tag/seed/data/default-tag-rules.d.ts.map +1 -1
  193. package/dist/pam/tag/seed/data/default-tag-rules.js +42 -0
  194. package/dist/pam/tag/seed/data/default-tag-rules.js.map +1 -1
  195. package/dist/pam/tag/seed/data/default-tags.d.ts.map +1 -1
  196. package/dist/pam/tag/seed/data/default-tags.js +6 -0
  197. package/dist/pam/tag/seed/data/default-tags.js.map +1 -1
  198. package/dist/pam/tag/service/tag-evaluation.service.d.ts +141 -16
  199. package/dist/pam/tag/service/tag-evaluation.service.d.ts.map +1 -1
  200. package/dist/pam/tag/service/tag-evaluation.service.js +472 -47
  201. package/dist/pam/tag/service/tag-evaluation.service.js.map +1 -1
  202. package/dist/pam/tag/service/tag-mappers.d.ts +1 -1
  203. package/dist/pam/tag/service/tag-mappers.d.ts.map +1 -1
  204. package/dist/pam/tag/service/tag-mappers.js +1 -0
  205. package/dist/pam/tag/service/tag-mappers.js.map +1 -1
  206. package/dist/pam/tag/service/tag-rule.service.d.ts +3 -3
  207. package/dist/pam/tag/service/tag.service.d.ts +141 -11
  208. package/dist/pam/tag/service/tag.service.d.ts.map +1 -1
  209. package/dist/pam/tag/service/tag.service.js +242 -23
  210. package/dist/pam/tag/service/tag.service.js.map +1 -1
  211. package/dist/server/auth/permissions.d.ts +12 -0
  212. package/dist/server/auth/permissions.d.ts.map +1 -1
  213. package/dist/server/auth/permissions.js +2 -0
  214. package/dist/server/auth/permissions.js.map +1 -1
  215. package/dist/server/db/__tests__/migrate.test.js +79 -2
  216. package/dist/server/db/__tests__/migrate.test.js.map +1 -1
  217. package/dist/server/db/migrate.d.ts +11 -0
  218. package/dist/server/db/migrate.d.ts.map +1 -1
  219. package/dist/server/db/migrate.js +3 -0
  220. package/dist/server/db/migrate.js.map +1 -1
  221. package/dist/server/kernel/bullmq-job-queue.d.ts.map +1 -1
  222. package/dist/server/kernel/bullmq-job-queue.js +17 -0
  223. package/dist/server/kernel/bullmq-job-queue.js.map +1 -1
  224. package/dist/server/plugin-host/__tests__/core-plugins.test.js +1 -1
  225. package/dist/server/plugin-host/__tests__/core-plugins.test.js.map +1 -1
  226. package/dist/server/plugin-host/define-plugin.d.ts +2 -2
  227. package/dist/server/plugin-host/define-plugin.d.ts.map +1 -1
  228. package/dist/server/plugin-host/define-plugin.js.map +1 -1
  229. package/dist/wallet/__tests__/wallet-auto-withdrawal.test.js +60 -0
  230. package/dist/wallet/__tests__/wallet-auto-withdrawal.test.js.map +1 -1
  231. package/dist/wallet/__tests__/wallet.service.test.js +59 -0
  232. package/dist/wallet/__tests__/wallet.service.test.js.map +1 -1
  233. package/dist/wallet/adapters/wallet-reader.service.d.ts +1 -0
  234. package/dist/wallet/adapters/wallet-reader.service.d.ts.map +1 -1
  235. package/dist/wallet/adapters/wallet-reader.service.js +18 -1
  236. package/dist/wallet/adapters/wallet-reader.service.js.map +1 -1
  237. package/dist/wallet/contract/index.d.ts +4 -0
  238. package/dist/wallet/contract/index.d.ts.map +1 -1
  239. package/dist/wallet/plugin.d.ts.map +1 -1
  240. package/dist/wallet/plugin.js +7 -4
  241. package/dist/wallet/plugin.js.map +1 -1
  242. package/dist/wallet/router/index.d.ts +2 -0
  243. package/dist/wallet/router/index.d.ts.map +1 -1
  244. package/dist/wallet/service/wallet.service.d.ts +5 -4
  245. package/dist/wallet/service/wallet.service.d.ts.map +1 -1
  246. package/dist/wallet/service/wallet.service.js +28 -8
  247. package/dist/wallet/service/wallet.service.js.map +1 -1
  248. package/package.json +1 -1
@@ -1,12 +1,20 @@
1
- import { type WalletReader, type IdentityReader } from '@openora/core/contracts';
1
+ import { type WalletReader, type IdentityReader, type AdminUserDirectory, type User } from '@openora/core/contracts';
2
2
  import { TagService } from './tag.service.js';
3
3
  import { TagRuleService } from './tag-rule.service.js';
4
+ export type TagEvaluationServiceDeps = {
5
+ tag: TagService;
6
+ rule: TagRuleService;
7
+ walletReader: WalletReader;
8
+ identityReader: IdentityReader;
9
+ adminUserDirectory: AdminUserDirectory;
10
+ };
4
11
  export declare class TagEvaluationService {
5
12
  private readonly tag;
6
13
  private readonly rule;
7
14
  private readonly walletReader;
8
15
  private readonly identityReader;
9
- constructor(tag: TagService, rule: TagRuleService, walletReader: WalletReader, identityReader: IdentityReader);
16
+ private readonly adminUserDirectory;
17
+ constructor(deps: TagEvaluationServiceDeps);
10
18
  /** Loads a rule; returns null when it does not exist or is disabled. Never throws for a missing row. */
11
19
  private getEnabledRule;
12
20
  /** Idempotently assigns a tag; swallows TagAlreadyInUseError. */
@@ -18,37 +26,154 @@ export declare class TagEvaluationService {
18
26
  * Called on wallet.deposit.completed.
19
27
  */
20
28
  onDepositCompleted(payload: unknown): Promise<void>;
29
+ /** True when the withdrawal_review rule is enabled and amount crosses its threshold. Shared by the event path and the synchronous command-port path below so both stay in lockstep. */
30
+ private _withdrawalReviewThresholdCrossed;
31
+ /**
32
+ * Assigns withdrawal_review when a single withdrawal attempt exceeds its threshold.
33
+ * Called on wallet.withdrawal.requested (the attempt, before funds move) so the
34
+ * review tag lands before payout. Sticky - never auto-removed here or anywhere else.
35
+ * This is the async, best-effort fan-out path (other consumers may want the event) -
36
+ * wallet's own auto-approval decision does NOT wait on this; it calls
37
+ * evaluateWithdrawalRequested below instead. Idempotent with that path via
38
+ * TagAlreadyInUseError (see tryAssignTag).
39
+ */
40
+ onWithdrawalRequested(payload: unknown): Promise<void>;
41
+ /**
42
+ * Synchronous, transactional counterpart to onWithdrawalRequested, bound behind
43
+ * TAG_EVALUATION_COMMANDS. wallet.withdraw() awaits this on its own transaction handle
44
+ * BEFORE its maybeAutoApprove reads risk tags, so a withdrawal_review assignment is
45
+ * guaranteed committed before the auto-approval decision runs - closing the race the
46
+ * fire-and-forget EventBus emit above cannot (an EventBus emit is never awaited by the
47
+ * emitter). Money-adjacent: never events-only for this decision (see
48
+ * messaging-and-microservices "money never flows over events"). Any error here
49
+ * propagates and aborts the caller's withdrawal transaction - a review-gate evaluation
50
+ * failure must block the withdrawal rather than silently skip review.
51
+ */
52
+ evaluateWithdrawalRequested(tx: unknown, args: {
53
+ userId: User['id'];
54
+ amount: string;
55
+ }): Promise<void>;
56
+ private evaluateBasicKycNeededOnDeposit;
21
57
  /**
22
58
  * Evaluates the high_risk rule based on withdrawal amount and frequency.
23
- * Called on wallet.withdrawal.completed.
24
- * Only assigns the tag when a threshold is crossed; never auto-removes
25
- * (risk designation requires an explicit admin clear).
59
+ * Called on wallet.withdrawal.completed. Only assigns the tag when a threshold is
60
+ * crossed; removal is handled separately by the daily resweep in runDailyEvaluation
61
+ * (a rolling-window count/amount can drop back under threshold with no new
62
+ * withdrawal, so it can't be detected event-driven-only). Records which breach
63
+ * condition(s) fired in assignMetadata - the resweep uses this to know whether the
64
+ * amount dimension (never resweepable, see _runHighRiskResweep) was involved.
26
65
  */
27
66
  onWithdrawalCompleted(payload: unknown): Promise<void>;
28
67
  /**
29
- * Removes the inactive tag when a player logs in.
30
- * Called on identity.user.login.
68
+ * Handles password login side effects:
69
+ * - removes inactive/dormant_high_roller on activity
70
+ * - assigns multi_account + bonus_abuser when another player has used this login IP
31
71
  */
32
72
  onUserLogin(payload: unknown): Promise<void>;
33
73
  /**
34
- * Applies the kyc_pending tag on KYC submission and clears any prior kyc_rejected.
35
- * Called on compliance.kyc.submitted. Respects the kyc_pending rule's isEnabled flag.
74
+ * Phone-login path mirrors password-login risk evaluation. The signal is the same
75
+ * authenticated session IP; the login method is intentionally not encoded in the tag.
76
+ */
77
+ onUserPhoneLogin(payload: unknown): Promise<void>;
78
+ private onAuthenticatedLogin;
79
+ private evaluateSharedLoginIp;
80
+ /**
81
+ * Applies kyc_pending on KYC submission only while the profile still has a pending-like
82
+ * status, and clears basic_kyc_needed / advanced_kyc_needed. Does not clear kyc_rejected:
83
+ * that sticky tag remains until a later approved state explicitly clears it.
36
84
  */
37
85
  onKycSubmitted(payload: unknown): Promise<void>;
86
+ private removeKycNeededTags;
87
+ private evaluateBasicKycNeededOnRejection;
38
88
  /**
39
- * Manages kyc_pending / kyc_rejected lifecycle on KYC status changes.
40
- * Called on compliance.kyc.updated. Respects the kyc_pending rule's isEnabled flag.
89
+ * Manages kyc_pending / kyc_rejected / basic_kyc_needed / advanced_kyc_needed lifecycle
90
+ * on KYC status changes. Called on compliance.kyc.updated. Assignment respects each tag
91
+ * rule's isEnabled flag; terminal cleanup still runs so disabled rules cannot strand old
92
+ * active rows.
41
93
  *
42
94
  * Transitions:
43
- * verified / manually_overridden -> remove kyc_pending + kyc_rejected
44
- * rejected -> remove kyc_pending, assign kyc_rejected
45
- * resubmission_requested -> assign kyc_pending
95
+ * approved / manually_overridden -> remove kyc_pending + kyc_rejected + basic_kyc_needed + advanced_kyc_needed
96
+ * rejected -> remove kyc_pending, assign kyc_rejected, evaluate basic_kyc_needed
97
+ * resubmission_requested -> assign kyc_pending, keep kyc_rejected sticky
46
98
  */
47
99
  onKycStatusUpdated(payload: unknown): Promise<void>;
48
100
  /**
49
- * Daily scheduled evaluation: assigns inactive to players who have not logged in
50
- * for rule.thresholdDays days. Removal is handled by onUserLogin on next login.
101
+ * Assigns advanced_kyc_needed as a pure label over compliance's own re-KYC decision.
102
+ * Called on compliance.kyc.reverify_required. Respects the advanced_kyc_needed rule's
103
+ * isEnabled flag.
104
+ */
105
+ onKycReverifyRequired(payload: unknown): Promise<void>;
106
+ /**
107
+ * Assigns high_risk as a pure label over compliance's own device/IP screening decision.
108
+ * Called on compliance.kyc.high_risk_signal_detected. Respects the high_risk rule's
109
+ * isEnabled flag; never auto-removes (risk designation requires an explicit admin clear).
110
+ */
111
+ onKycHighRiskSignalDetected(payload: unknown): Promise<void>;
112
+ /**
113
+ * Assigns self_excluded when a player activates self-exclusion.
114
+ * Called on rg.self_exclusion.activated.
115
+ */
116
+ onSelfExclusionActivated(payload: unknown): Promise<void>;
117
+ /**
118
+ * Removes self_excluded when a player's self-exclusion is lifted.
119
+ * Called on rg.self_exclusion.lifted.
120
+ */
121
+ onSelfExclusionLifted(payload: unknown): Promise<void>;
122
+ /**
123
+ * Replaces the single mutable `level` tag with the player's new level.
124
+ * Called on player.level.changed (emitted by PlayerService.update() after commit).
125
+ * Not sticky - the level value lives only in assignReason text, never as a separate
126
+ * tag key per level. The swap goes through TagService.replacePlayerTag: removal of
127
+ * the prior active row (silent no-op when absent) + insert of the new one on ONE
128
+ * transaction, so a mid-swap failure can never strand the player with the old row
129
+ * removed and no new one committed. The loser of a concurrent replace throws
130
+ * TagAlreadyInUseError with nothing committed - swallowed here as the usual
131
+ * idempotent no-op (player.level itself stays the source of truth).
132
+ */
133
+ onPlayerLevelChanged(payload: unknown): Promise<void>;
134
+ /**
135
+ * Daily scheduled evaluation, three independent sweeps:
136
+ * - inactive: assigns to players who have not logged in for rule.thresholdDays
137
+ * days. Removal is handled by onUserLogin on next login.
138
+ * - dormant_high_roller: a co-occurrence check, not a history lookup - high_roller
139
+ * is only re-evaluated on deposit, so a player who goes quiet never loses it via
140
+ * that path. Assigns to players who are both currently inactive (per this tag's
141
+ * OWN thresholdDays, decoupled from the inactive rule's) and currently hold an
142
+ * active high_roller tag. Removal is handled by onUserLogin on next login.
143
+ * - high_risk resweep: removal-only, frequency dimension only. A rolling
144
+ * withdrawal-count window can drop back under threshold with no new withdrawal
145
+ * to trigger onWithdrawalCompleted, so current holders are rechecked here and
146
+ * removed once the count falls below threshold. Deliberately does NOT recheck
147
+ * the amount dimension - assignment's amount check has no time bound, so a
148
+ * windowed recheck would silently de-designate a still-risky player once their
149
+ * triggering withdrawal ages out of the window (an AML false negative). Now gated
150
+ * on each holder's assignMetadata (recorded at assignment): a holder whose
151
+ * metadata shows an amount breach is skipped regardless of their current count,
152
+ * and a holder with null metadata (pre-migration/legacy row, or manually
153
+ * assigned) is also skipped - "unknown why this was assigned" is treated as
154
+ * "do not auto-remove". Skipped entirely when thresholdDays or thresholdCount is
155
+ * null - an amount-only high_risk rule isn't resweepable by the cron; it stays
156
+ * until an admin clears it or a future withdrawal re-triggers assignment.
51
157
  */
52
158
  runDailyEvaluation(): Promise<void>;
159
+ private _runInactiveSweep;
160
+ private _runDormantHighRollerSweep;
161
+ /**
162
+ * Frequency-only removal. Assignment (onWithdrawalCompleted) checks a single
163
+ * withdrawal's amount with no time bound, so an amount-only breach from outside
164
+ * this rolling window is invisible to a windowed recheck - resweeping it would
165
+ * silently de-designate a still-risky player (an AML false negative). Only the
166
+ * count dimension, which IS windowed at assignment time, is safe to resweep. Each
167
+ * holder's assignMetadata (recorded at assignment) records which breach dimension(s)
168
+ * fired; a holder whose metadata shows an amount breach, or whose metadata is null
169
+ * (pre-migration/legacy row or manual assignment - unknown why it was assigned), is
170
+ * skipped regardless of their current windowed count - pinned until an admin
171
+ * manually clears the tag or a future onWithdrawalCompleted re-evaluation populates
172
+ * metadata. Skipped entirely when thresholdDays or thresholdCount is null - an
173
+ * amount-only rule has no frequency dimension to resweep against and is never
174
+ * auto-cleared by the cron, only by an admin or a future onWithdrawalCompleted
175
+ * re-evaluation.
176
+ */
177
+ private _runHighRiskResweep;
53
178
  }
54
179
  //# sourceMappingURL=tag-evaluation.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tag-evaluation.service.d.ts","sourceRoot":"","sources":["../../../../src/pam/tag/service/tag-evaluation.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAoD,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAK7E,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAHd,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,YAAY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