@moneypot/hub 1.17.0-dev.1 → 1.17.0-dev.3

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 (33) hide show
  1. package/dist/cli/add-casino.js +6 -3
  2. package/dist/dashboard/assets/index-32DtKox_.css +5 -0
  3. package/dist/dashboard/assets/index-B4xPUnuF.js +412 -0
  4. package/dist/dashboard/index.html +2 -2
  5. package/dist/src/__generated__/graphql.d.ts +74 -32
  6. package/dist/src/__generated__/graphql.js +23 -14
  7. package/dist/src/db/index.js +29 -13
  8. package/dist/src/db/transaction.js +1 -1
  9. package/dist/src/hash-chain/db-hash-chain.d.ts +2 -1
  10. package/dist/src/hash-chain/db-hash-chain.js +11 -16
  11. package/dist/src/hash-chain/plugins/hub-reveal-hash-chain.js +9 -10
  12. package/dist/src/hash-chain/reveal-hash-chain.d.ts +3 -3
  13. package/dist/src/hash-chain/reveal-hash-chain.js +28 -5
  14. package/dist/src/plugins/chat/hub-chat-subscription.d.ts +1 -1
  15. package/dist/src/plugins/hub-authenticate.js +5 -5
  16. package/dist/src/plugins/hub-make-outcome-bet.d.ts +4 -44
  17. package/dist/src/plugins/hub-make-outcome-bet.js +2 -1
  18. package/dist/src/plugins/hub-put-alert.js +2 -2
  19. package/dist/src/plugins/listen-with-filter.d.ts +4 -3
  20. package/dist/src/plugins/listen-with-filter.js +65 -8
  21. package/dist/src/plugins/validate-fields.js +25 -33
  22. package/dist/src/process-transfers/index.js +1 -1
  23. package/dist/src/risk-policy.js +1 -1
  24. package/dist/src/server/index.js +1 -1
  25. package/dist/src/services/jwt-service.js +1 -1
  26. package/dist/src/take-request/process-take-request.js +19 -13
  27. package/dist/src/validate-zod.d.ts +3 -0
  28. package/dist/src/validate-zod.js +19 -0
  29. package/package.json +3 -4
  30. package/dist/dashboard/assets/index-D7SlWXgD.js +0 -383
  31. package/dist/dashboard/assets/index-LZVcTrKv.css +0 -5
  32. package/dist/src/validate.d.ts +0 -9
  33. package/dist/src/validate.js +0 -91
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Dashboard</title>
7
- <script type="module" crossorigin src="/dashboard/assets/index-D7SlWXgD.js"></script>
8
- <link rel="stylesheet" crossorigin href="/dashboard/assets/index-LZVcTrKv.css">
7
+ <script type="module" crossorigin src="/dashboard/assets/index-B4xPUnuF.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/dashboard/assets/index-32DtKox_.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
@@ -65,6 +65,7 @@ export type Scalars = {
65
65
  export type Account = {
66
66
  __typename?: 'Account';
67
67
  balance: Scalars['Float']['output'];
68
+ balanceAuditsByAccountId: BalanceAuditConnection;
68
69
  balanceDraftLimit: Scalars['Float']['output'];
69
70
  currency: Scalars['String']['output'];
70
71
  currencyByCurrency?: Maybe<Currency>;
@@ -74,6 +75,15 @@ export type Account = {
74
75
  transfersByFromAccountId: TransferConnection;
75
76
  transfersByToAccountId: TransferConnection;
76
77
  };
78
+ export type AccountBalanceAuditsByAccountIdArgs = {
79
+ after?: InputMaybe<Scalars['Cursor']['input']>;
80
+ before?: InputMaybe<Scalars['Cursor']['input']>;
81
+ condition?: InputMaybe<BalanceAuditCondition>;
82
+ first?: InputMaybe<Scalars['Int']['input']>;
83
+ last?: InputMaybe<Scalars['Int']['input']>;
84
+ offset?: InputMaybe<Scalars['Int']['input']>;
85
+ orderBy?: InputMaybe<Array<BalanceAuditOrderBy>>;
86
+ };
77
87
  export type AccountTransfersByFromAccountIdArgs = {
78
88
  after?: InputMaybe<Scalars['Cursor']['input']>;
79
89
  before?: InputMaybe<Scalars['Cursor']['input']>;
@@ -129,6 +139,16 @@ export type ActiveSession = {
129
139
  userByUserId?: Maybe<User>;
130
140
  userId?: Maybe<Scalars['UUID']['output']>;
131
141
  };
142
+ export type ActiveSessionCondition = {
143
+ expiredAt?: InputMaybe<Scalars['Datetime']['input']>;
144
+ id?: InputMaybe<Scalars['UUID']['input']>;
145
+ key?: InputMaybe<Scalars['UUID']['input']>;
146
+ lastUsedAt?: InputMaybe<Scalars['Datetime']['input']>;
147
+ revokedAt?: InputMaybe<Scalars['Datetime']['input']>;
148
+ trackingId?: InputMaybe<Scalars['UUID']['input']>;
149
+ userAgent?: InputMaybe<Scalars['String']['input']>;
150
+ userId?: InputMaybe<Scalars['UUID']['input']>;
151
+ };
132
152
  export type ActiveSessionConnection = {
133
153
  __typename?: 'ActiveSessionConnection';
134
154
  edges: Array<Maybe<ActiveSessionEdge>>;
@@ -142,9 +162,25 @@ export type ActiveSessionEdge = {
142
162
  node?: Maybe<ActiveSession>;
143
163
  };
144
164
  export declare enum ActiveSessionOrderBy {
165
+ ExpiredAtAsc = "EXPIRED_AT_ASC",
166
+ ExpiredAtDesc = "EXPIRED_AT_DESC",
167
+ IdAsc = "ID_ASC",
168
+ IdDesc = "ID_DESC",
169
+ KeyAsc = "KEY_ASC",
170
+ KeyDesc = "KEY_DESC",
171
+ LastUsedAtAsc = "LAST_USED_AT_ASC",
172
+ LastUsedAtDesc = "LAST_USED_AT_DESC",
145
173
  Natural = "NATURAL",
146
174
  PrimaryKeyAsc = "PRIMARY_KEY_ASC",
147
- PrimaryKeyDesc = "PRIMARY_KEY_DESC"
175
+ PrimaryKeyDesc = "PRIMARY_KEY_DESC",
176
+ RevokedAtAsc = "REVOKED_AT_ASC",
177
+ RevokedAtDesc = "REVOKED_AT_DESC",
178
+ TrackingIdAsc = "TRACKING_ID_ASC",
179
+ TrackingIdDesc = "TRACKING_ID_DESC",
180
+ UserAgentAsc = "USER_AGENT_ASC",
181
+ UserAgentDesc = "USER_AGENT_DESC",
182
+ UserIdAsc = "USER_ID_ASC",
183
+ UserIdDesc = "USER_ID_DESC"
148
184
  }
149
185
  export type AdminTransfer = Transfer & {
150
186
  __typename?: 'AdminTransfer';
@@ -214,9 +250,7 @@ export declare enum AdminTransferOrderBy {
214
250
  ToAccountIdAsc = "TO_ACCOUNT_ID_ASC",
215
251
  ToAccountIdDesc = "TO_ACCOUNT_ID_DESC",
216
252
  ToHolderIdAsc = "TO_HOLDER_ID_ASC",
217
- ToHolderIdDesc = "TO_HOLDER_ID_DESC",
218
- TypeAsc = "TYPE_ASC",
219
- TypeDesc = "TYPE_DESC"
253
+ ToHolderIdDesc = "TO_HOLDER_ID_DESC"
220
254
  }
221
255
  export type ApiKey = {
222
256
  __typename?: 'ApiKey';
@@ -371,6 +405,7 @@ export type BalanceAudit = {
371
405
  refType?: Maybe<Scalars['String']['output']>;
372
406
  };
373
407
  export type BalanceAuditCondition = {
408
+ accountId?: InputMaybe<Scalars['UUID']['input']>;
374
409
  currency?: InputMaybe<Scalars['String']['input']>;
375
410
  id?: InputMaybe<Scalars['UUID']['input']>;
376
411
  };
@@ -387,6 +422,8 @@ export type BalanceAuditEdge = {
387
422
  node?: Maybe<BalanceAudit>;
388
423
  };
389
424
  export declare enum BalanceAuditOrderBy {
425
+ AccountIdAsc = "ACCOUNT_ID_ASC",
426
+ AccountIdDesc = "ACCOUNT_ID_DESC",
390
427
  IdAsc = "ID_ASC",
391
428
  IdDesc = "ID_DESC",
392
429
  Natural = "NATURAL",
@@ -512,7 +549,6 @@ export type Controller = Holder & {
512
549
  accountByCurrency?: Maybe<Account>;
513
550
  accountsByHolderId: AccountConnection;
514
551
  apiKeysByControllerId: ApiKeyConnection;
515
- balanceByCurrency?: Maybe<Scalars['Float']['output']>;
516
552
  deletedAt?: Maybe<Scalars['Datetime']['output']>;
517
553
  experiencesByControllerId: ExperienceConnection;
518
554
  faucetClaimsByHolderId: FaucetClaimConnection;
@@ -547,9 +583,6 @@ export type ControllerApiKeysByControllerIdArgs = {
547
583
  offset?: InputMaybe<Scalars['Int']['input']>;
548
584
  orderBy?: InputMaybe<Array<ApiKeyOrderBy>>;
549
585
  };
550
- export type ControllerBalanceByCurrencyArgs = {
551
- currency: Scalars['String']['input'];
552
- };
553
586
  export type ControllerExperiencesByControllerIdArgs = {
554
587
  after?: InputMaybe<Scalars['Cursor']['input']>;
555
588
  before?: InputMaybe<Scalars['Cursor']['input']>;
@@ -689,9 +722,7 @@ export declare enum ControllerTransferOrderBy {
689
722
  ToAccountIdAsc = "TO_ACCOUNT_ID_ASC",
690
723
  ToAccountIdDesc = "TO_ACCOUNT_ID_DESC",
691
724
  ToHolderIdAsc = "TO_HOLDER_ID_ASC",
692
- ToHolderIdDesc = "TO_HOLDER_ID_DESC",
693
- TypeAsc = "TYPE_ASC",
694
- TypeDesc = "TYPE_DESC"
725
+ ToHolderIdDesc = "TO_HOLDER_ID_DESC"
695
726
  }
696
727
  export type CreateApiKeyInput = {
697
728
  clientMutationId?: InputMaybe<Scalars['String']['input']>;
@@ -1115,9 +1146,7 @@ export declare enum ExperienceTransferOrderBy {
1115
1146
  ToAccountIdAsc = "TO_ACCOUNT_ID_ASC",
1116
1147
  ToAccountIdDesc = "TO_ACCOUNT_ID_DESC",
1117
1148
  ToHolderIdAsc = "TO_HOLDER_ID_ASC",
1118
- ToHolderIdDesc = "TO_HOLDER_ID_DESC",
1119
- TypeAsc = "TYPE_ASC",
1120
- TypeDesc = "TYPE_DESC"
1149
+ ToHolderIdDesc = "TO_HOLDER_ID_DESC"
1121
1150
  }
1122
1151
  export type FaucetClaim = {
1123
1152
  __typename?: 'FaucetClaim';
@@ -1194,7 +1223,6 @@ export type GetDepositInvoicePayload = {
1194
1223
  export type Holder = {
1195
1224
  accountByCurrency?: Maybe<Account>;
1196
1225
  accountsByHolderId: AccountConnection;
1197
- balanceByCurrency?: Maybe<Scalars['Float']['output']>;
1198
1226
  deletedAt?: Maybe<Scalars['Datetime']['output']>;
1199
1227
  faucetClaimsByHolderId: FaucetClaimConnection;
1200
1228
  id: Scalars['UUID']['output'];
@@ -1212,9 +1240,6 @@ export type HolderAccountsByHolderIdArgs = {
1212
1240
  last?: InputMaybe<Scalars['Int']['input']>;
1213
1241
  offset?: InputMaybe<Scalars['Int']['input']>;
1214
1242
  };
1215
- export type HolderBalanceByCurrencyArgs = {
1216
- currency: Scalars['String']['input'];
1217
- };
1218
1243
  export type HolderFaucetClaimsByHolderIdArgs = {
1219
1244
  after?: InputMaybe<Scalars['Cursor']['input']>;
1220
1245
  before?: InputMaybe<Scalars['Cursor']['input']>;
@@ -1383,6 +1408,10 @@ export type LoginMagicTokenPayload = {
1383
1408
  query?: Maybe<Query>;
1384
1409
  sessionKey?: Maybe<Scalars['UUID']['output']>;
1385
1410
  };
1411
+ export declare enum LoginMode {
1412
+ MagicLink = "MAGIC_LINK",
1413
+ OneTimeCode = "ONE_TIME_CODE"
1414
+ }
1386
1415
  export type LoginOneTimeCodeInput = {
1387
1416
  clientMutationId?: InputMaybe<Scalars['String']['input']>;
1388
1417
  code: Scalars['String']['input'];
@@ -1934,6 +1963,7 @@ export type Query = {
1934
1963
  transactionStatusChangeById?: Maybe<TransactionStatusChange>;
1935
1964
  transfersByExperience?: Maybe<TransfersByExperienceConnection>;
1936
1965
  transfersByHolder?: Maybe<TransfersByHolderConnection>;
1966
+ transfersByHolder2?: Maybe<TransfersByHolder2Connection>;
1937
1967
  userById?: Maybe<User>;
1938
1968
  userByUname?: Maybe<User>;
1939
1969
  userEmailById?: Maybe<UserEmail>;
@@ -1966,6 +1996,7 @@ export type QueryAllAccountsArgs = {
1966
1996
  export type QueryAllActiveSessionsArgs = {
1967
1997
  after?: InputMaybe<Scalars['Cursor']['input']>;
1968
1998
  before?: InputMaybe<Scalars['Cursor']['input']>;
1999
+ condition?: InputMaybe<ActiveSessionCondition>;
1969
2000
  first?: InputMaybe<Scalars['Int']['input']>;
1970
2001
  includeRevoked?: InputMaybe<IncludeRevokedOption>;
1971
2002
  last?: InputMaybe<Scalars['Int']['input']>;
@@ -2373,6 +2404,16 @@ export type QueryTransfersByExperienceArgs = {
2373
2404
  export type QueryTransfersByHolderArgs = {
2374
2405
  input: TransfersByHolderInput;
2375
2406
  };
2407
+ export type QueryTransfersByHolder2Args = {
2408
+ after?: InputMaybe<Scalars['Cursor']['input']>;
2409
+ direction?: InputMaybe<TransferDirection>;
2410
+ first?: InputMaybe<Scalars['Int']['input']>;
2411
+ holderId: Scalars['UUID']['input'];
2412
+ orderBy?: InputMaybe<TransfersByHolderOrderBy>;
2413
+ otherHolderId?: InputMaybe<Scalars['UUID']['input']>;
2414
+ status?: InputMaybe<TransferStatusKind>;
2415
+ type?: InputMaybe<TransferType>;
2416
+ };
2376
2417
  export type QueryUserByIdArgs = {
2377
2418
  id: Scalars['UUID']['input'];
2378
2419
  };
@@ -2556,6 +2597,7 @@ export type StartEmailChangePayload = {
2556
2597
  export type StartLoginInput = {
2557
2598
  clientMutationId?: InputMaybe<Scalars['String']['input']>;
2558
2599
  email: Scalars['String']['input'];
2600
+ mode: LoginMode;
2559
2601
  };
2560
2602
  export type StartLoginPayload = {
2561
2603
  __typename?: 'StartLoginPayload';
@@ -2682,8 +2724,6 @@ export declare enum TakeRequestOrderBy {
2682
2724
  Natural = "NATURAL",
2683
2725
  PrimaryKeyAsc = "PRIMARY_KEY_ASC",
2684
2726
  PrimaryKeyDesc = "PRIMARY_KEY_DESC",
2685
- StatusAsc = "STATUS_ASC",
2686
- StatusDesc = "STATUS_DESC",
2687
2727
  UserIdAsc = "USER_ID_ASC",
2688
2728
  UserIdDesc = "USER_ID_DESC"
2689
2729
  }
@@ -2959,9 +2999,7 @@ export declare enum TransferOrderBy {
2959
2999
  ToAccountIdAsc = "TO_ACCOUNT_ID_ASC",
2960
3000
  ToAccountIdDesc = "TO_ACCOUNT_ID_DESC",
2961
3001
  ToHolderIdAsc = "TO_HOLDER_ID_ASC",
2962
- ToHolderIdDesc = "TO_HOLDER_ID_DESC",
2963
- TypeAsc = "TYPE_ASC",
2964
- TypeDesc = "TYPE_DESC"
3002
+ ToHolderIdDesc = "TO_HOLDER_ID_DESC"
2965
3003
  }
2966
3004
  export type TransferStatus = {
2967
3005
  __typename?: 'TransferStatus';
@@ -3041,6 +3079,17 @@ export type TransfersByExperiencePageInfo = {
3041
3079
  endCursor?: Maybe<Scalars['Cursor']['output']>;
3042
3080
  hasNextPage: Scalars['Boolean']['output'];
3043
3081
  };
3082
+ export type TransfersByHolder2Connection = {
3083
+ __typename?: 'TransfersByHolder2Connection';
3084
+ edges: Array<TransfersByHolder2Edge>;
3085
+ nodes: Array<Transfer>;
3086
+ pageInfo: PageInfo;
3087
+ };
3088
+ export type TransfersByHolder2Edge = {
3089
+ __typename?: 'TransfersByHolder2Edge';
3090
+ cursor: Scalars['Cursor']['output'];
3091
+ node: Transfer;
3092
+ };
3044
3093
  export type TransfersByHolderConnection = {
3045
3094
  __typename?: 'TransfersByHolderConnection';
3046
3095
  edges: Array<TransfersByHolderEdge>;
@@ -3111,7 +3160,6 @@ export type User = Holder & {
3111
3160
  accountsByHolderId: AccountConnection;
3112
3161
  activeSessionsByUserId: ActiveSessionConnection;
3113
3162
  balanceAudits: BalanceAuditConnection;
3114
- balanceByCurrency?: Maybe<Scalars['Float']['output']>;
3115
3163
  controllersByUserId: ControllerConnection;
3116
3164
  deletedAt?: Maybe<Scalars['Datetime']['output']>;
3117
3165
  email?: Maybe<Scalars['String']['output']>;
@@ -3152,6 +3200,7 @@ export type UserAccountsByHolderIdArgs = {
3152
3200
  export type UserActiveSessionsByUserIdArgs = {
3153
3201
  after?: InputMaybe<Scalars['Cursor']['input']>;
3154
3202
  before?: InputMaybe<Scalars['Cursor']['input']>;
3203
+ condition?: InputMaybe<ActiveSessionCondition>;
3155
3204
  first?: InputMaybe<Scalars['Int']['input']>;
3156
3205
  includeRevoked?: InputMaybe<IncludeRevokedOption>;
3157
3206
  last?: InputMaybe<Scalars['Int']['input']>;
@@ -3167,9 +3216,6 @@ export type UserBalanceAuditsArgs = {
3167
3216
  offset?: InputMaybe<Scalars['Int']['input']>;
3168
3217
  orderBy?: InputMaybe<Array<BalanceAuditOrderBy>>;
3169
3218
  };
3170
- export type UserBalanceByCurrencyArgs = {
3171
- currency: Scalars['String']['input'];
3172
- };
3173
3219
  export type UserControllersByUserIdArgs = {
3174
3220
  after?: InputMaybe<Scalars['Cursor']['input']>;
3175
3221
  before?: InputMaybe<Scalars['Cursor']['input']>;
@@ -3386,8 +3432,6 @@ export declare enum UserOrderBy {
3386
3432
  Natural = "NATURAL",
3387
3433
  PrimaryKeyAsc = "PRIMARY_KEY_ASC",
3388
3434
  PrimaryKeyDesc = "PRIMARY_KEY_DESC",
3389
- RoleAsc = "ROLE_ASC",
3390
- RoleDesc = "ROLE_DESC",
3391
3435
  UnameAsc = "UNAME_ASC",
3392
3436
  UnameDesc = "UNAME_DESC"
3393
3437
  }
@@ -3469,9 +3513,7 @@ export declare enum UserTransferOrderBy {
3469
3513
  ToHolderIdAsc = "TO_HOLDER_ID_ASC",
3470
3514
  ToHolderIdDesc = "TO_HOLDER_ID_DESC",
3471
3515
  ToUserIdAsc = "TO_USER_ID_ASC",
3472
- ToUserIdDesc = "TO_USER_ID_DESC",
3473
- TypeAsc = "TYPE_ASC",
3474
- TypeDesc = "TYPE_DESC"
3516
+ ToUserIdDesc = "TO_USER_ID_DESC"
3475
3517
  }
3476
3518
  export type VerifyEmailTokenInput = {
3477
3519
  clientMutationId?: InputMaybe<Scalars['String']['input']>;
@@ -10,9 +10,25 @@ export var AccountOrderBy;
10
10
  })(AccountOrderBy || (AccountOrderBy = {}));
11
11
  export var ActiveSessionOrderBy;
12
12
  (function (ActiveSessionOrderBy) {
13
+ ActiveSessionOrderBy["ExpiredAtAsc"] = "EXPIRED_AT_ASC";
14
+ ActiveSessionOrderBy["ExpiredAtDesc"] = "EXPIRED_AT_DESC";
15
+ ActiveSessionOrderBy["IdAsc"] = "ID_ASC";
16
+ ActiveSessionOrderBy["IdDesc"] = "ID_DESC";
17
+ ActiveSessionOrderBy["KeyAsc"] = "KEY_ASC";
18
+ ActiveSessionOrderBy["KeyDesc"] = "KEY_DESC";
19
+ ActiveSessionOrderBy["LastUsedAtAsc"] = "LAST_USED_AT_ASC";
20
+ ActiveSessionOrderBy["LastUsedAtDesc"] = "LAST_USED_AT_DESC";
13
21
  ActiveSessionOrderBy["Natural"] = "NATURAL";
14
22
  ActiveSessionOrderBy["PrimaryKeyAsc"] = "PRIMARY_KEY_ASC";
15
23
  ActiveSessionOrderBy["PrimaryKeyDesc"] = "PRIMARY_KEY_DESC";
24
+ ActiveSessionOrderBy["RevokedAtAsc"] = "REVOKED_AT_ASC";
25
+ ActiveSessionOrderBy["RevokedAtDesc"] = "REVOKED_AT_DESC";
26
+ ActiveSessionOrderBy["TrackingIdAsc"] = "TRACKING_ID_ASC";
27
+ ActiveSessionOrderBy["TrackingIdDesc"] = "TRACKING_ID_DESC";
28
+ ActiveSessionOrderBy["UserAgentAsc"] = "USER_AGENT_ASC";
29
+ ActiveSessionOrderBy["UserAgentDesc"] = "USER_AGENT_DESC";
30
+ ActiveSessionOrderBy["UserIdAsc"] = "USER_ID_ASC";
31
+ ActiveSessionOrderBy["UserIdDesc"] = "USER_ID_DESC";
16
32
  })(ActiveSessionOrderBy || (ActiveSessionOrderBy = {}));
17
33
  export var AdminTransferOrderBy;
18
34
  (function (AdminTransferOrderBy) {
@@ -31,8 +47,6 @@ export var AdminTransferOrderBy;
31
47
  AdminTransferOrderBy["ToAccountIdDesc"] = "TO_ACCOUNT_ID_DESC";
32
48
  AdminTransferOrderBy["ToHolderIdAsc"] = "TO_HOLDER_ID_ASC";
33
49
  AdminTransferOrderBy["ToHolderIdDesc"] = "TO_HOLDER_ID_DESC";
34
- AdminTransferOrderBy["TypeAsc"] = "TYPE_ASC";
35
- AdminTransferOrderBy["TypeDesc"] = "TYPE_DESC";
36
50
  })(AdminTransferOrderBy || (AdminTransferOrderBy = {}));
37
51
  export var ApiKeyOrderBy;
38
52
  (function (ApiKeyOrderBy) {
@@ -78,6 +92,8 @@ export var AuthnRequestType;
78
92
  })(AuthnRequestType || (AuthnRequestType = {}));
79
93
  export var BalanceAuditOrderBy;
80
94
  (function (BalanceAuditOrderBy) {
95
+ BalanceAuditOrderBy["AccountIdAsc"] = "ACCOUNT_ID_ASC";
96
+ BalanceAuditOrderBy["AccountIdDesc"] = "ACCOUNT_ID_DESC";
81
97
  BalanceAuditOrderBy["IdAsc"] = "ID_ASC";
82
98
  BalanceAuditOrderBy["IdDesc"] = "ID_DESC";
83
99
  BalanceAuditOrderBy["Natural"] = "NATURAL";
@@ -111,8 +127,6 @@ export var ControllerTransferOrderBy;
111
127
  ControllerTransferOrderBy["ToAccountIdDesc"] = "TO_ACCOUNT_ID_DESC";
112
128
  ControllerTransferOrderBy["ToHolderIdAsc"] = "TO_HOLDER_ID_ASC";
113
129
  ControllerTransferOrderBy["ToHolderIdDesc"] = "TO_HOLDER_ID_DESC";
114
- ControllerTransferOrderBy["TypeAsc"] = "TYPE_ASC";
115
- ControllerTransferOrderBy["TypeDesc"] = "TYPE_DESC";
116
130
  })(ControllerTransferOrderBy || (ControllerTransferOrderBy = {}));
117
131
  export var CurrencyOrderBy;
118
132
  (function (CurrencyOrderBy) {
@@ -183,8 +197,6 @@ export var ExperienceTransferOrderBy;
183
197
  ExperienceTransferOrderBy["ToAccountIdDesc"] = "TO_ACCOUNT_ID_DESC";
184
198
  ExperienceTransferOrderBy["ToHolderIdAsc"] = "TO_HOLDER_ID_ASC";
185
199
  ExperienceTransferOrderBy["ToHolderIdDesc"] = "TO_HOLDER_ID_DESC";
186
- ExperienceTransferOrderBy["TypeAsc"] = "TYPE_ASC";
187
- ExperienceTransferOrderBy["TypeDesc"] = "TYPE_DESC";
188
200
  })(ExperienceTransferOrderBy || (ExperienceTransferOrderBy = {}));
189
201
  export var FaucetClaimOrderBy;
190
202
  (function (FaucetClaimOrderBy) {
@@ -254,6 +266,11 @@ export var KeyPairOrderBy;
254
266
  KeyPairOrderBy["PrimaryKeyAsc"] = "PRIMARY_KEY_ASC";
255
267
  KeyPairOrderBy["PrimaryKeyDesc"] = "PRIMARY_KEY_DESC";
256
268
  })(KeyPairOrderBy || (KeyPairOrderBy = {}));
269
+ export var LoginMode;
270
+ (function (LoginMode) {
271
+ LoginMode["MagicLink"] = "MAGIC_LINK";
272
+ LoginMode["OneTimeCode"] = "ONE_TIME_CODE";
273
+ })(LoginMode || (LoginMode = {}));
257
274
  export var Network;
258
275
  (function (Network) {
259
276
  Network["Mainnet"] = "mainnet";
@@ -370,8 +387,6 @@ export var TakeRequestOrderBy;
370
387
  TakeRequestOrderBy["Natural"] = "NATURAL";
371
388
  TakeRequestOrderBy["PrimaryKeyAsc"] = "PRIMARY_KEY_ASC";
372
389
  TakeRequestOrderBy["PrimaryKeyDesc"] = "PRIMARY_KEY_DESC";
373
- TakeRequestOrderBy["StatusAsc"] = "STATUS_ASC";
374
- TakeRequestOrderBy["StatusDesc"] = "STATUS_DESC";
375
390
  TakeRequestOrderBy["UserIdAsc"] = "USER_ID_ASC";
376
391
  TakeRequestOrderBy["UserIdDesc"] = "USER_ID_DESC";
377
392
  })(TakeRequestOrderBy || (TakeRequestOrderBy = {}));
@@ -435,8 +450,6 @@ export var TransferOrderBy;
435
450
  TransferOrderBy["ToAccountIdDesc"] = "TO_ACCOUNT_ID_DESC";
436
451
  TransferOrderBy["ToHolderIdAsc"] = "TO_HOLDER_ID_ASC";
437
452
  TransferOrderBy["ToHolderIdDesc"] = "TO_HOLDER_ID_DESC";
438
- TransferOrderBy["TypeAsc"] = "TYPE_ASC";
439
- TransferOrderBy["TypeDesc"] = "TYPE_DESC";
440
453
  })(TransferOrderBy || (TransferOrderBy = {}));
441
454
  export var TransferStatusKind;
442
455
  (function (TransferStatusKind) {
@@ -491,8 +504,6 @@ export var UserOrderBy;
491
504
  UserOrderBy["Natural"] = "NATURAL";
492
505
  UserOrderBy["PrimaryKeyAsc"] = "PRIMARY_KEY_ASC";
493
506
  UserOrderBy["PrimaryKeyDesc"] = "PRIMARY_KEY_DESC";
494
- UserOrderBy["RoleAsc"] = "ROLE_ASC";
495
- UserOrderBy["RoleDesc"] = "ROLE_DESC";
496
507
  UserOrderBy["UnameAsc"] = "UNAME_ASC";
497
508
  UserOrderBy["UnameDesc"] = "UNAME_DESC";
498
509
  })(UserOrderBy || (UserOrderBy = {}));
@@ -522,8 +533,6 @@ export var UserTransferOrderBy;
522
533
  UserTransferOrderBy["ToHolderIdDesc"] = "TO_HOLDER_ID_DESC";
523
534
  UserTransferOrderBy["ToUserIdAsc"] = "TO_USER_ID_ASC";
524
535
  UserTransferOrderBy["ToUserIdDesc"] = "TO_USER_ID_DESC";
525
- UserTransferOrderBy["TypeAsc"] = "TYPE_ASC";
526
- UserTransferOrderBy["TypeDesc"] = "TYPE_DESC";
527
536
  })(UserTransferOrderBy || (UserTransferOrderBy = {}));
528
537
  export var WithdrawalOrderBy;
529
538
  (function (WithdrawalOrderBy) {
@@ -138,10 +138,10 @@ export async function insertDeposit(pool, o) {
138
138
  if (o.amount <= 0) {
139
139
  throw new UserFriendlyError("amount must be positive");
140
140
  }
141
- return withPgPoolTransaction(pool, async (client) => {
141
+ return withPgPoolTransaction(pool, async (pgClient) => {
142
142
  let dbDeposit;
143
143
  try {
144
- dbDeposit = await client
144
+ dbDeposit = await pgClient
145
145
  .query(`
146
146
  INSERT INTO hub.deposit(casino_id, mp_transfer_id, user_id, experience_id, amount, currency_key)
147
147
  VALUES ($1, $2, $3, $4, $5, $6)
@@ -166,19 +166,35 @@ export async function insertDeposit(pool, o) {
166
166
  }
167
167
  throw e;
168
168
  }
169
- const dbBalance = await client
169
+ await pgClient.query(`
170
+ INSERT INTO hub.balance (casino_id, user_id, experience_id, currency_key, amount)
171
+ VALUES ($1, $2, $3, $4, 0)
172
+ ON CONFLICT (casino_id, user_id, experience_id, currency_key) DO NOTHING
173
+ `, [o.casinoId, o.userId, o.experienceId, o.currency]);
174
+ const dbLockedBalance = await pgClient
170
175
  .query(`
171
- insert into hub.balance(casino_id, user_id, experience_id, currency_key, amount)
172
- values ($1, $2, $3, $4, $5)
173
- on conflict (casino_id, user_id, experience_id, currency_key) do update
174
- set amount = balance.amount + excluded.amount
175
- returning id, amount
176
- `, [o.casinoId, o.userId, o.experienceId, o.currency, o.amount])
176
+ SELECT id, amount
177
+ FROM hub.balance
178
+ WHERE casino_id = $1
179
+ AND user_id = $2
180
+ AND experience_id = $3
181
+ AND currency_key = $4
182
+
183
+ FOR UPDATE
184
+ `, [o.casinoId, o.userId, o.experienceId, o.currency])
185
+ .then(exactlyOneRow);
186
+ const dbBalanceAfterUpdate = await pgClient
187
+ .query(`
188
+ UPDATE hub.balance
189
+ SET amount = amount + $1
190
+ WHERE id = $2
191
+ RETURNING id, amount
192
+ `, [o.amount, dbLockedBalance.id])
177
193
  .then(exactlyOneRow);
178
- await insertAuditLog(client, "player-balance", {
179
- balanceId: dbBalance.id,
180
- balanceOld: dbBalance.amount - o.amount,
181
- balanceNew: dbBalance.amount,
194
+ await insertAuditLog(pgClient, "player-balance", {
195
+ balanceId: dbLockedBalance.id,
196
+ balanceOld: dbLockedBalance.amount,
197
+ balanceNew: dbBalanceAfterUpdate.amount,
182
198
  balanceDelta: o.amount,
183
199
  action: "hub:deposit",
184
200
  refType: "hub.deposit",
@@ -25,7 +25,7 @@ export const IsolationLevel = {
25
25
  };
26
26
  export async function withPgPoolTransaction(pool, callbackOrIsolationLevel, callbackOrRetryCount, retryCountOrMaxRetries = 0, maxRetries = 3) {
27
27
  let callback;
28
- let isolationLevel = IsolationLevel.READ_COMMITTED;
28
+ let isolationLevel = IsolationLevel.SERIALIZABLE;
29
29
  let retryCount = 0;
30
30
  if (typeof callbackOrIsolationLevel === "function") {
31
31
  callback = callbackOrIsolationLevel;
@@ -1,10 +1,11 @@
1
1
  import { DbCasino, DbExperience, DbHash, DbHashChain, DbUser } from "../db/types.js";
2
2
  import { PgClientInTransaction } from "../db/index.js";
3
- export declare function dbLockHubHashChain(pgClient: PgClientInTransaction, { userId, experienceId, casinoId, hashChainId, }: {
3
+ export declare function dbLockHubHashChain(pgClient: PgClientInTransaction, { userId, experienceId, casinoId, hashChainId, active, }: {
4
4
  userId: DbUser["id"];
5
5
  experienceId: DbExperience["id"];
6
6
  casinoId: DbCasino["id"];
7
7
  hashChainId: DbHashChain["id"];
8
+ active: "must-be-active" | "active-or-inactive";
8
9
  }): Promise<DbHashChain | null>;
9
10
  export declare function dbInsertHubHash(pgClient: PgClientInTransaction, { hashChainId, kind, digest, iteration, clientSeed, metadata, }: {
10
11
  hashChainId: DbHashChain["id"];
@@ -2,25 +2,20 @@ import { DbHashKind, } from "../db/types.js";
2
2
  import { exactlyOneRow, maybeOneRow, } from "../db/index.js";
3
3
  import { assert } from "tsafe";
4
4
  import { logger } from "../logger.js";
5
- export async function dbLockHubHashChain(pgClient, { userId, experienceId, casinoId, hashChainId, }) {
6
- const hashChain = await pgClient
5
+ export async function dbLockHubHashChain(pgClient, { userId, experienceId, casinoId, hashChainId, active, }) {
6
+ const dbLockedHashChain = await pgClient
7
7
  .query(`
8
- SELECT *
9
- FROM hub.hash_chain
10
- WHERE id = $1
11
- AND user_id = $2
12
- AND experience_id = $3
13
- AND casino_id = $4
14
- AND active = TRUE
15
-
16
- FOR UPDATE
17
- `, [hashChainId, userId, experienceId, casinoId])
8
+ SELECT *
9
+ FROM hub.hash_chain
10
+ WHERE id = $1
11
+ AND user_id = $2
12
+ AND experience_id = $3
13
+ AND casino_id = $4
14
+ AND ($5::text = 'active-or-inactive' OR active = TRUE)
15
+ FOR UPDATE`, [hashChainId, userId, experienceId, casinoId, active])
18
16
  .then(maybeOneRow)
19
17
  .then((row) => row ?? null);
20
- if (hashChain) {
21
- assert(hashChain.current_iteration >= 1, "Hash chain iteration must be >= 1");
22
- }
23
- return hashChain;
18
+ return dbLockedHashChain;
24
19
  }
25
20
  export async function dbInsertHubHash(pgClient, { hashChainId, kind, digest, iteration, clientSeed, metadata = {}, }) {
26
21
  logger.debug({
@@ -1,14 +1,13 @@
1
1
  import { context, object, sideEffect } from "postgraphile/grafast";
2
- import { gql, makeExtendSchemaPlugin } from "postgraphile/utils";
2
+ import { gql, extendSchema } from "postgraphile/utils";
3
3
  import { dbLockHubHashChain, withPgPoolTransaction } from "../../db/index.js";
4
4
  import z, { prettifyError } from "zod/v4";
5
5
  import { GraphQLError } from "graphql";
6
- import { assert } from "tsafe";
7
6
  import { dbRevealHashChain } from "../reveal-hash-chain.js";
8
7
  const InputSchema = z.object({
9
8
  hashChainId: z.uuidv7("Invalid hash chain ID"),
10
9
  });
11
- export const HubRevealHashChainPlugin = makeExtendSchemaPlugin((build) => {
10
+ export const HubRevealHashChainPlugin = extendSchema((build) => {
12
11
  const hashTable = build.input.pgRegistry.pgResources.hub_hash;
13
12
  return {
14
13
  typeDefs: gql `
@@ -47,20 +46,20 @@ export const HubRevealHashChainPlugin = makeExtendSchemaPlugin((build) => {
47
46
  throw e;
48
47
  }
49
48
  return withPgPoolTransaction(superuserPool, async (pgClient) => {
50
- const hashChain = await dbLockHubHashChain(pgClient, {
49
+ const dbLockedHashChain = await dbLockHubHashChain(pgClient, {
51
50
  userId: identity.session.user_id,
52
51
  experienceId: identity.session.experience_id,
53
52
  casinoId: identity.session.casino_id,
54
53
  hashChainId: input.hashChainId,
54
+ active: "active-or-inactive",
55
55
  });
56
- if (!hashChain || !hashChain.active) {
57
- throw new GraphQLError("Active hash chain not found");
56
+ if (!dbLockedHashChain) {
57
+ throw new GraphQLError("Hash chain not found");
58
58
  }
59
- assert(hashChain.current_iteration >= 1, "Invalid hash chain iteration");
60
- const dbPreimageHash = await dbRevealHashChain(pgClient, {
61
- hashChainId: input.hashChainId,
59
+ const dbPreimageHashId = await dbRevealHashChain(pgClient, {
60
+ hashChainId: dbLockedHashChain.id,
62
61
  });
63
- return dbPreimageHash.id;
62
+ return dbPreimageHashId;
64
63
  });
65
64
  });
66
65
  return object({
@@ -1,5 +1,5 @@
1
- import { DbHash } from "../db/types.js";
1
+ import { DbHash, DbHashChain } from "../db/types.js";
2
2
  import { PgClientInTransaction } from "../db/index.js";
3
3
  export declare function dbRevealHashChain(pgClient: PgClientInTransaction, { hashChainId, }: {
4
- hashChainId: string;
5
- }): Promise<DbHash>;
4
+ hashChainId: DbHashChain["id"];
5
+ }): Promise<DbHash["id"]>;
@@ -1,16 +1,39 @@
1
1
  import { logger } from "../logger.js";
2
2
  import { getPreimageHash } from "./get-hash.js";
3
3
  import { DbHashKind } from "../db/types.js";
4
- import { dbInsertHubHash } from "../db/index.js";
4
+ import { dbInsertHubHash, maybeOneRow, } from "../db/index.js";
5
5
  export async function dbRevealHashChain(pgClient, { hashChainId, }) {
6
6
  logger.debug({ hashChainId }, "Revealing hash chain");
7
+ const dbLockedHashChain = await pgClient
8
+ .query(`
9
+ SELECT *
10
+ FROM hub.hash_chain
11
+ WHERE id = $1
12
+ FOR UPDATE
13
+ `, [hashChainId])
14
+ .then(maybeOneRow);
15
+ if (!dbLockedHashChain) {
16
+ throw new Error("Hash chain not found");
17
+ }
18
+ const dbPreimageHash = await pgClient
19
+ .query(`
20
+ SELECT id
21
+ FROM hub.hash
22
+ WHERE hash_chain_id = $1
23
+ AND kind = 'PREIMAGE'
24
+ AND iteration = 0
25
+ `, [hashChainId])
26
+ .then(maybeOneRow);
27
+ if (dbPreimageHash) {
28
+ return dbPreimageHash.id;
29
+ }
7
30
  const preimageHashResult = await getPreimageHash({
8
- hashChainId,
31
+ hashChainId: dbLockedHashChain.id,
9
32
  });
10
33
  logger.debug({ preimageHashResult }, "Preimage hash result");
11
34
  if (preimageHashResult.type === "success") {
12
35
  const dbPreimageHash = await dbInsertHubHash(pgClient, {
13
- hashChainId,
36
+ hashChainId: dbLockedHashChain.id,
14
37
  kind: DbHashKind.PREIMAGE,
15
38
  digest: preimageHashResult.hash,
16
39
  iteration: 0,
@@ -20,11 +43,11 @@ export async function dbRevealHashChain(pgClient, { hashChainId, }) {
20
43
  SET current_iteration = 0,
21
44
  active = false
22
45
  WHERE id = $1
23
- `, [hashChainId]);
46
+ `, [dbLockedHashChain.id]);
24
47
  if (result.rowCount !== 1) {
25
48
  throw new Error("Failed to update hash chain iteration");
26
49
  }
27
- return dbPreimageHash;
50
+ return dbPreimageHash.id;
28
51
  }
29
52
  else {
30
53
  logger.warn({ hashChainId, error: preimageHashResult }, "Failed to reveal hash chain");
@@ -8,7 +8,7 @@ declare const ChatPgNotifyPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
8
8
  }, z.core.$strip>, z.ZodObject<{
9
9
  type: z.ZodLiteral<"unmute">;
10
10
  user_id: z.ZodString;
11
- }, z.core.$strip>]>;
11
+ }, z.core.$strip>], "type">;
12
12
  export type ChatPgNotifyPayload = z.infer<typeof ChatPgNotifyPayloadSchema>;
13
13
  export declare const HubChatSubscriptionPlugin: GraphileConfig.Plugin;
14
14
  export {};