@moneypot/hub 1.19.6 → 1.19.8

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.
@@ -1,5 +1,26 @@
1
1
  import { logger } from "./logger.js";
2
+ const DELTA_TOLERANCE = 0.0001;
2
3
  export async function insertAuditLog(pgClient, type, audit) {
4
+ if (type === "player-balance" || type === "both") {
5
+ const { balanceOld, balanceNew, balanceDelta } = audit;
6
+ const expected = balanceOld + balanceDelta;
7
+ if (Math.abs(balanceNew - expected) > DELTA_TOLERANCE) {
8
+ logger.warn({ balanceOld, balanceDelta, balanceNew, expected, action: audit.action }, "Audit balance delta mismatch");
9
+ }
10
+ }
11
+ if (type === "house-bankroll" || type === "both") {
12
+ const { bankrollOld, bankrollNew, bankrollDelta } = audit;
13
+ const expected = bankrollOld + bankrollDelta;
14
+ if (Math.abs(bankrollNew - expected) > DELTA_TOLERANCE) {
15
+ logger.warn({
16
+ bankrollOld,
17
+ bankrollDelta,
18
+ bankrollNew,
19
+ expected,
20
+ action: audit.action,
21
+ }, "Audit bankroll delta mismatch");
22
+ }
23
+ }
3
24
  await pgClient.query(`
4
25
  INSERT INTO hub.audit_log (
5
26
  balance_id,
@@ -76,6 +76,12 @@ export const HubChatSubscriptionPlugin = extendSchema((build) => {
76
76
  return false;
77
77
  }
78
78
  if (typeof item !== "string") {
79
+ if (typeof item === "object" &&
80
+ item !== null &&
81
+ "done" in item &&
82
+ item.done === true) {
83
+ return false;
84
+ }
79
85
  logger.warn(item, `hubChatAlert: item is not a string`);
80
86
  return false;
81
87
  }
@@ -32,7 +32,7 @@ const OutcomeSchema = z
32
32
  const InputSchema = z
33
33
  .object({
34
34
  kind: z.string(),
35
- clientSeed: z.string(),
35
+ clientSeed: z.string().max(32),
36
36
  wager: z
37
37
  .number()
38
38
  .int("Wager must be an integer")
@@ -32,6 +32,12 @@ export const HubPutAlertPlugin = extendSchema((_build) => {
32
32
  });
33
33
  return listenWithFilter($pgSubscriber, $channelKey, jsonParse, $identity, (item, identity) => {
34
34
  if (typeof item !== "string") {
35
+ if (typeof item === "object" &&
36
+ item !== null &&
37
+ "done" in item &&
38
+ item.done === true) {
39
+ return false;
40
+ }
35
41
  logger.warn(item, `hubPutAlert: item is not a string`);
36
42
  return false;
37
43
  }
@@ -101,8 +101,7 @@ async function dbAlreadyUsedUserToken(pgClient, { userToken }) {
101
101
  SELECT 1
102
102
  FROM hub.session
103
103
  WHERE user_token = $1
104
-
105
- FOR UPDATE SKIP LOCKED
104
+ FOR UPDATE
106
105
  `, [userToken])
107
106
  .then(maybeOneRow);
108
107
  return !!result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneypot/hub",
3
- "version": "1.19.6",
3
+ "version": "1.19.8",
4
4
  "author": "moneypot.com",
5
5
  "homepage": "https://moneypot.com/hub",
6
6
  "keywords": [