@numen-crypto/contract 0.1.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,740 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
5
+ // src/constants/error-codes.ts
6
+ var ERROR_CODE = {
7
+ // generic
8
+ VALIDATION: "VALIDATION",
9
+ NOT_FOUND: "NOT_FOUND",
10
+ CONFLICT: "CONFLICT",
11
+ UNAUTHORIZED: "UNAUTHORIZED",
12
+ FORBIDDEN: "FORBIDDEN",
13
+ RATE_LIMITED: "RATE_LIMITED",
14
+ INTERNAL: "INTERNAL",
15
+ // auth
16
+ EMAIL_TAKEN: "EMAIL_TAKEN",
17
+ REFERRER_NOT_FOUND: "REFERRER_NOT_FOUND",
18
+ INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
19
+ SESSION_INVALID: "SESSION_INVALID",
20
+ SESSION_EXPIRED: "SESSION_EXPIRED",
21
+ TOTP_REQUIRED: "TOTP_REQUIRED",
22
+ TOTP_ALREADY_ENABLED: "TOTP_ALREADY_ENABLED",
23
+ // wallet / purchase / withdrawal (reserved for next slices)
24
+ INSUFFICIENT_BALANCE: "INSUFFICIENT_BALANCE",
25
+ PURCHASE_LIMIT_EXCEEDED: "PURCHASE_LIMIT_EXCEEDED",
26
+ SALE_PHASE_INACTIVE: "SALE_PHASE_INACTIVE",
27
+ WITHDRAWAL_COOLOFF: "WITHDRAWAL_COOLOFF",
28
+ // bonus
29
+ BONUS_ALREADY_CLAIMED: "BONUS_ALREADY_CLAIMED",
30
+ // account linking
31
+ LINK_PROVIDER_DISABLED: "LINK_PROVIDER_DISABLED",
32
+ LINK_VERIFICATION_FAILED: "LINK_VERIFICATION_FAILED",
33
+ LINK_ALREADY_USED: "LINK_ALREADY_USED"
34
+ };
35
+ var MONEY_REGEX = /^-?\d+(\.\d{1,18})?$/;
36
+ var MoneyStringSchema = zod.z.string().regex(MONEY_REGEX, "invalid money string (max 18 fractional digits)");
37
+ var PositiveMoneyStringSchema = MoneyStringSchema.refine(
38
+ (v) => !v.startsWith("-") && Number.parseFloat(v) > 0,
39
+ "must be positive"
40
+ );
41
+ var UuidSchema = zod.z.string().uuid();
42
+ var ErrorResponseSchema = zod.z.object({
43
+ error: zod.z.object({
44
+ code: zod.z.string(),
45
+ message: zod.z.string()
46
+ }),
47
+ requestId: zod.z.string().optional()
48
+ });
49
+ var PaginationQuerySchema = zod.z.object({
50
+ page: zod.z.coerce.number().int().min(1).default(1),
51
+ pageSize: zod.z.coerce.number().int().min(1).max(100).default(20)
52
+ });
53
+ function PaginatedSchema(item) {
54
+ return zod.z.object({
55
+ items: zod.z.array(item),
56
+ total: zod.z.number().int().nonnegative(),
57
+ page: zod.z.number().int().min(1),
58
+ pageSize: zod.z.number().int().min(1)
59
+ });
60
+ }
61
+ var UserStatusSchema = zod.z.enum(["pending", "active", "suspended", "deleted"]);
62
+ var UserProfileSchema = zod.z.object({
63
+ id: zod.z.string().uuid(),
64
+ email: zod.z.string().email(),
65
+ displayName: zod.z.string().nullable(),
66
+ avatarUrl: zod.z.string().url().nullable(),
67
+ referrerId: zod.z.string().uuid().nullable(),
68
+ rankId: zod.z.string().uuid().nullable(),
69
+ status: UserStatusSchema,
70
+ totpEnabled: zod.z.boolean(),
71
+ createdAt: zod.z.string().datetime()
72
+ });
73
+ var SessionInfoSchema = zod.z.object({
74
+ id: zod.z.string(),
75
+ ip: zod.z.string().nullable(),
76
+ userAgent: zod.z.string().nullable(),
77
+ createdAt: zod.z.string().datetime(),
78
+ lastSeenAt: zod.z.string().datetime(),
79
+ current: zod.z.boolean()
80
+ });
81
+ var ASSET_SYMBOLS = ["NMN", "USDT", "BTC", "ETH", "BNB", "TRX", "SOL"];
82
+ var AssetSymbolSchema = zod.z.enum(ASSET_SYMBOLS);
83
+ var DEPOSITABLE_ASSETS = ["USDT", "BTC", "ETH", "BNB", "TRX", "SOL"];
84
+ var DepositableAssetSchema = zod.z.enum(DEPOSITABLE_ASSETS);
85
+ var TOKEN_ASSET = "NMN";
86
+ var FUNDING_ASSET = "USDT";
87
+ var AssetBalanceSchema = zod.z.object({
88
+ asset: AssetSymbolSchema,
89
+ name: zod.z.string(),
90
+ networks: zod.z.array(zod.z.string()),
91
+ depositable: zod.z.boolean(),
92
+ available: MoneyStringSchema,
93
+ locked: MoneyStringSchema,
94
+ usdValue: MoneyStringSchema,
95
+ isZero: zod.z.boolean()
96
+ });
97
+ var WalletOverviewSchema = zod.z.object({
98
+ totalUsd: MoneyStringSchema,
99
+ assets: zod.z.array(AssetBalanceSchema)
100
+ });
101
+ var TransactionTypeSchema = zod.z.enum([
102
+ "DEPOSIT",
103
+ "WITHDRAWAL",
104
+ "BUY",
105
+ "SELL",
106
+ "COMMISSION",
107
+ "BONUS",
108
+ "ADJUSTMENT"
109
+ ]);
110
+ var TransactionStatusSchema = zod.z.enum([
111
+ "PENDING",
112
+ "PROCESSING",
113
+ "COMPLETED",
114
+ "FAILED",
115
+ "CANCELLED"
116
+ ]);
117
+ var TransactionSchema = zod.z.object({
118
+ id: zod.z.string().uuid(),
119
+ type: TransactionTypeSchema,
120
+ asset: AssetSymbolSchema,
121
+ amount: MoneyStringSchema,
122
+ status: TransactionStatusSchema,
123
+ reference: zod.z.string().nullable(),
124
+ createdAt: zod.z.string().datetime()
125
+ });
126
+ var DepositAddressSchema = zod.z.object({
127
+ asset: DepositableAssetSchema,
128
+ network: zod.z.string(),
129
+ address: zod.z.string(),
130
+ minAmount: MoneyStringSchema,
131
+ confirmations: zod.z.number().int().nonnegative()
132
+ });
133
+ var PartnerLevelSchema = zod.z.object({
134
+ level: zod.z.number().int().min(1).max(10),
135
+ partners: zod.z.number().int().nonnegative()
136
+ });
137
+ var PartnersOverviewSchema = zod.z.object({
138
+ referralCode: zod.z.string(),
139
+ totalPartners: zod.z.number().int().nonnegative(),
140
+ directPartners: zod.z.number().int().nonnegative(),
141
+ networkTurnover: MoneyStringSchema,
142
+ affiliateIncome: MoneyStringSchema,
143
+ levels: zod.z.array(PartnerLevelSchema)
144
+ });
145
+ var RankDefSchema = zod.z.object({
146
+ name: zod.z.string(),
147
+ order: zod.z.number().int().nonnegative(),
148
+ minTurnover: MoneyStringSchema
149
+ });
150
+ var UserRankSchema = zod.z.object({
151
+ name: zod.z.string(),
152
+ order: zod.z.number().int().nonnegative(),
153
+ minTurnover: MoneyStringSchema,
154
+ nextName: zod.z.string().nullable(),
155
+ nextMinTurnover: MoneyStringSchema.nullable(),
156
+ progressPct: zod.z.string()
157
+ });
158
+ var EarningsOverviewSchema = zod.z.object({
159
+ tokenBalance: MoneyStringSchema,
160
+ tokenPrice: MoneyStringSchema,
161
+ tokenValueUsd: MoneyStringSchema,
162
+ affiliateIncome: MoneyStringSchema,
163
+ networkTurnover: MoneyStringSchema,
164
+ rank: UserRankSchema
165
+ });
166
+ var UserSettingsSchema = zod.z.object({
167
+ notifyTrades: zod.z.boolean(),
168
+ notifyByEmail: zod.z.boolean(),
169
+ withdrawalEmailConfirm: zod.z.boolean()
170
+ });
171
+ var DailyBonusDaySchema = zod.z.object({
172
+ dayIndex: zod.z.number().int().min(1),
173
+ rewardNmn: MoneyStringSchema,
174
+ surprise: zod.z.boolean()
175
+ });
176
+ var DailyBonusStatusSchema = zod.z.object({
177
+ currentStreak: zod.z.number().int().nonnegative(),
178
+ cycleLength: zod.z.number().int().positive(),
179
+ claimableToday: zod.z.boolean(),
180
+ todayDayIndex: zod.z.number().int().min(1),
181
+ nextRewardNmn: MoneyStringSchema,
182
+ days: zod.z.array(DailyBonusDaySchema)
183
+ });
184
+ var DailyBonusClaimResultSchema = zod.z.object({
185
+ claimed: zod.z.boolean(),
186
+ dayIndex: zod.z.number().int().min(1),
187
+ rewardNmn: MoneyStringSchema,
188
+ currentStreak: zod.z.number().int().positive()
189
+ });
190
+ var NotificationTypeSchema = zod.z.enum([
191
+ "TRADE_EXECUTED",
192
+ "DEPOSIT_CREDITED",
193
+ "COMMISSION_ACCRUED",
194
+ "WITHDRAWAL_SENT",
195
+ "BONUS_CLAIMED",
196
+ "SYSTEM"
197
+ ]);
198
+ var NotificationSchema = zod.z.object({
199
+ id: zod.z.string().uuid(),
200
+ type: NotificationTypeSchema,
201
+ title: zod.z.string(),
202
+ body: zod.z.string(),
203
+ read: zod.z.boolean(),
204
+ meta: zod.z.record(zod.z.unknown()).nullable(),
205
+ createdAt: zod.z.string().datetime()
206
+ });
207
+ var LeaderboardPeriodSchema = zod.z.enum(["week", "month", "year", "all"]);
208
+ var LeaderboardEntrySchema = zod.z.object({
209
+ rank: zod.z.number().int().positive(),
210
+ userId: zod.z.string().uuid(),
211
+ displayName: zod.z.string(),
212
+ line: zod.z.number().int().min(1).max(10).nullable(),
213
+ partners: zod.z.number().int().nonnegative(),
214
+ turnoverUsd: MoneyStringSchema,
215
+ changePct: zod.z.number(),
216
+ isSelf: zod.z.boolean()
217
+ });
218
+ var LeaderboardSchema = zod.z.object({
219
+ period: LeaderboardPeriodSchema,
220
+ items: zod.z.array(LeaderboardEntrySchema),
221
+ self: LeaderboardEntrySchema.nullable()
222
+ });
223
+ var LinkProviderSchema = zod.z.enum(["telegram", "google"]);
224
+ var LinkedAccountSchema = zod.z.object({
225
+ provider: LinkProviderSchema,
226
+ providerUserId: zod.z.string(),
227
+ displayName: zod.z.string().nullable(),
228
+ linkedAt: zod.z.string().datetime()
229
+ });
230
+ var IncomePeriodSchema = zod.z.enum(["week", "month", "year", "all"]);
231
+ var PartnerAccrualSchema = zod.z.object({
232
+ id: zod.z.string().uuid(),
233
+ level: zod.z.number().int().min(1).max(10),
234
+ sourceUserId: zod.z.string().uuid(),
235
+ sourceName: zod.z.string(),
236
+ amountUsd: MoneyStringSchema,
237
+ createdAt: zod.z.string().datetime()
238
+ });
239
+ var MonthlyPricePointSchema = zod.z.object({
240
+ month: zod.z.string(),
241
+ fromPrice: MoneyStringSchema,
242
+ toPrice: MoneyStringSchema,
243
+ holdingGrowthUsd: MoneyStringSchema
244
+ });
245
+ var IncomeOverviewSchema = zod.z.object({
246
+ period: IncomePeriodSchema,
247
+ tokenGrowthIncomeUsd: MoneyStringSchema,
248
+ tokenGrowthPct: zod.z.number(),
249
+ affiliateIncomeNmn: MoneyStringSchema,
250
+ affiliateIncomeUsd: MoneyStringSchema,
251
+ totalEarnedUsd: MoneyStringSchema,
252
+ partnerAccruals: zod.z.array(PartnerAccrualSchema),
253
+ monthlyPrice: zod.z.array(MonthlyPricePointSchema)
254
+ });
255
+ var WithdrawalStatusSchema = zod.z.enum([
256
+ "AWAITING_CONFIRM",
257
+ "AWAITING_COOLOFF",
258
+ "QUEUED",
259
+ "SENT",
260
+ "CONFIRMED",
261
+ "FAILED",
262
+ "CANCELLED"
263
+ ]);
264
+ var WithdrawalSchema = zod.z.object({
265
+ id: zod.z.string().uuid(),
266
+ asset: AssetSymbolSchema,
267
+ amount: MoneyStringSchema,
268
+ address: zod.z.string(),
269
+ status: WithdrawalStatusSchema,
270
+ createdAt: zod.z.string().datetime()
271
+ });
272
+ var TokenPriceSchema = zod.z.object({
273
+ price: MoneyStringSchema,
274
+ change24hPct: zod.z.string(),
275
+ tradeIndex: zod.z.number().int().nonnegative(),
276
+ updatedAt: zod.z.string().datetime()
277
+ });
278
+ var ChartPeriodSchema = zod.z.enum(["day", "week", "month", "year"]);
279
+ var ChartPointSchema = zod.z.object({
280
+ t: zod.z.string().datetime(),
281
+ price: MoneyStringSchema
282
+ });
283
+ var SwapSideSchema = zod.z.enum(["BUY", "SELL"]);
284
+ var TradeResultSchema = zod.z.object({
285
+ tradeId: zod.z.string().uuid(),
286
+ side: SwapSideSchema,
287
+ usdtAmount: MoneyStringSchema,
288
+ nmnAmount: MoneyStringSchema,
289
+ price: MoneyStringSchema,
290
+ feeUsdt: MoneyStringSchema
291
+ });
292
+
293
+ // src/commands/command.types.ts
294
+ function endpoint(method, path, summary) {
295
+ return { method, path, summary };
296
+ }
297
+ exports.RegisterCommand = void 0;
298
+ ((RegisterCommand2) => {
299
+ RegisterCommand2.endpointDetails = endpoint("POST", "/auth/register", "Register a new user");
300
+ RegisterCommand2.RequestSchema = zod.z.object({
301
+ email: zod.z.string().email().max(254),
302
+ password: zod.z.string().min(12).max(128),
303
+ referralCode: zod.z.string().min(4).max(64).optional()
304
+ });
305
+ RegisterCommand2.ResponseSchema = zod.z.object({
306
+ userId: zod.z.string().uuid()
307
+ });
308
+ })(exports.RegisterCommand || (exports.RegisterCommand = {}));
309
+ exports.LoginCommand = void 0;
310
+ ((LoginCommand2) => {
311
+ LoginCommand2.endpointDetails = endpoint("POST", "/auth/login", "Login with email and password");
312
+ LoginCommand2.RequestSchema = zod.z.object({
313
+ email: zod.z.string().email().max(254),
314
+ password: zod.z.string().min(1).max(128),
315
+ totp: zod.z.string().regex(/^\d{6}$/).optional()
316
+ });
317
+ LoginCommand2.ResponseSchema = zod.z.object({
318
+ user: UserProfileSchema
319
+ });
320
+ })(exports.LoginCommand || (exports.LoginCommand = {}));
321
+ exports.LogoutCommand = void 0;
322
+ ((LogoutCommand2) => {
323
+ LogoutCommand2.endpointDetails = endpoint("POST", "/auth/logout", "Terminate the current session");
324
+ LogoutCommand2.RequestSchema = zod.z.object({
325
+ allDevices: zod.z.boolean().optional().default(false)
326
+ });
327
+ LogoutCommand2.ResponseSchema = zod.z.void();
328
+ })(exports.LogoutCommand || (exports.LogoutCommand = {}));
329
+ exports.MeCommand = void 0;
330
+ ((MeCommand2) => {
331
+ MeCommand2.endpointDetails = endpoint("GET", "/auth/me", "Get the current authenticated user");
332
+ MeCommand2.ResponseSchema = zod.z.object({
333
+ user: UserProfileSchema
334
+ });
335
+ })(exports.MeCommand || (exports.MeCommand = {}));
336
+ exports.SetupTotpCommand = void 0;
337
+ ((SetupTotpCommand2) => {
338
+ SetupTotpCommand2.endpointDetails = endpoint("POST", "/auth/totp/setup", "Begin TOTP enrollment");
339
+ SetupTotpCommand2.ResponseSchema = zod.z.object({
340
+ secret: zod.z.string(),
341
+ otpauthUrl: zod.z.string()
342
+ });
343
+ })(exports.SetupTotpCommand || (exports.SetupTotpCommand = {}));
344
+ exports.ConfirmTotpCommand = void 0;
345
+ ((ConfirmTotpCommand2) => {
346
+ ConfirmTotpCommand2.endpointDetails = endpoint("POST", "/auth/totp/confirm", "Confirm and enable TOTP");
347
+ ConfirmTotpCommand2.RequestSchema = zod.z.object({
348
+ secret: zod.z.string().min(16).max(128),
349
+ otp: zod.z.string().regex(/^\d{6}$/)
350
+ });
351
+ ConfirmTotpCommand2.ResponseSchema = zod.z.void();
352
+ })(exports.ConfirmTotpCommand || (exports.ConfirmTotpCommand = {}));
353
+
354
+ // src/commands/wallet/get-wallet.command.ts
355
+ exports.GetWalletCommand = void 0;
356
+ ((GetWalletCommand2) => {
357
+ GetWalletCommand2.endpointDetails = endpoint("GET", "/wallet", "Get wallet overview with all asset balances");
358
+ GetWalletCommand2.ResponseSchema = WalletOverviewSchema;
359
+ })(exports.GetWalletCommand || (exports.GetWalletCommand = {}));
360
+
361
+ // src/commands/wallet/get-transactions.command.ts
362
+ exports.GetTransactionsCommand = void 0;
363
+ ((GetTransactionsCommand2) => {
364
+ GetTransactionsCommand2.endpointDetails = endpoint("GET", "/wallet/transactions", "List the user transaction history");
365
+ GetTransactionsCommand2.QuerySchema = PaginationQuerySchema.extend({
366
+ type: TransactionTypeSchema.optional()
367
+ });
368
+ GetTransactionsCommand2.ResponseSchema = PaginatedSchema(TransactionSchema);
369
+ })(exports.GetTransactionsCommand || (exports.GetTransactionsCommand = {}));
370
+ exports.DepositAddressCommand = void 0;
371
+ ((DepositAddressCommand2) => {
372
+ DepositAddressCommand2.endpointDetails = endpoint(
373
+ "POST",
374
+ "/wallet/deposit-address",
375
+ "Get a deposit address for the given asset"
376
+ );
377
+ DepositAddressCommand2.RequestSchema = zod.z.object({
378
+ asset: DepositableAssetSchema,
379
+ network: zod.z.string().min(2).max(32)
380
+ });
381
+ DepositAddressCommand2.ResponseSchema = DepositAddressSchema;
382
+ })(exports.DepositAddressCommand || (exports.DepositAddressCommand = {}));
383
+
384
+ // src/commands/token/get-price.command.ts
385
+ exports.GetTokenPriceCommand = void 0;
386
+ ((GetTokenPriceCommand2) => {
387
+ GetTokenPriceCommand2.endpointDetails = endpoint("GET", "/token/price", "Current NMN price and 24h change");
388
+ GetTokenPriceCommand2.ResponseSchema = TokenPriceSchema;
389
+ })(exports.GetTokenPriceCommand || (exports.GetTokenPriceCommand = {}));
390
+ exports.GetTokenChartCommand = void 0;
391
+ ((GetTokenChartCommand2) => {
392
+ GetTokenChartCommand2.endpointDetails = endpoint("GET", "/token/chart", "NMN price chart points for a period");
393
+ GetTokenChartCommand2.QuerySchema = zod.z.object({
394
+ period: ChartPeriodSchema.default("day")
395
+ });
396
+ GetTokenChartCommand2.ResponseSchema = zod.z.object({
397
+ period: ChartPeriodSchema,
398
+ points: zod.z.array(ChartPointSchema)
399
+ });
400
+ })(exports.GetTokenChartCommand || (exports.GetTokenChartCommand = {}));
401
+ exports.SwapCommand = void 0;
402
+ ((SwapCommand2) => {
403
+ SwapCommand2.endpointDetails = endpoint("POST", "/swap", "Buy or sell NMN against USDT at the live price");
404
+ SwapCommand2.RequestSchema = zod.z.object({
405
+ side: SwapSideSchema,
406
+ amount: PositiveMoneyStringSchema,
407
+ maxPrice: PositiveMoneyStringSchema.optional(),
408
+ idempotencyKey: zod.z.string().min(8).max(128)
409
+ });
410
+ SwapCommand2.ResponseSchema = TradeResultSchema;
411
+ })(exports.SwapCommand || (exports.SwapCommand = {}));
412
+
413
+ // src/commands/partners/get-partners.command.ts
414
+ exports.GetPartnersCommand = void 0;
415
+ ((GetPartnersCommand2) => {
416
+ GetPartnersCommand2.endpointDetails = endpoint("GET", "/partners", "Affiliate network overview with 10 levels");
417
+ GetPartnersCommand2.ResponseSchema = PartnersOverviewSchema;
418
+ })(exports.GetPartnersCommand || (exports.GetPartnersCommand = {}));
419
+ exports.GetRanksCommand = void 0;
420
+ ((GetRanksCommand2) => {
421
+ GetRanksCommand2.endpointDetails = endpoint("GET", "/ranks", "List all rank tiers");
422
+ GetRanksCommand2.ResponseSchema = zod.z.object({
423
+ ranks: zod.z.array(RankDefSchema)
424
+ });
425
+ })(exports.GetRanksCommand || (exports.GetRanksCommand = {}));
426
+
427
+ // src/commands/earnings/get-earnings.command.ts
428
+ exports.GetEarningsCommand = void 0;
429
+ ((GetEarningsCommand2) => {
430
+ GetEarningsCommand2.endpointDetails = endpoint("GET", "/earnings", "Earnings overview: token growth + affiliate + rank");
431
+ GetEarningsCommand2.ResponseSchema = EarningsOverviewSchema;
432
+ })(exports.GetEarningsCommand || (exports.GetEarningsCommand = {}));
433
+ exports.RequestWithdrawalCommand = void 0;
434
+ ((RequestWithdrawalCommand2) => {
435
+ RequestWithdrawalCommand2.endpointDetails = endpoint("POST", "/withdrawals", "Request a withdrawal to an external address");
436
+ RequestWithdrawalCommand2.RequestSchema = zod.z.object({
437
+ asset: DepositableAssetSchema,
438
+ amount: PositiveMoneyStringSchema,
439
+ address: zod.z.string().min(8).max(256),
440
+ totp: zod.z.string().regex(/^\d{6}$/).optional(),
441
+ idempotencyKey: zod.z.string().min(8).max(128)
442
+ });
443
+ RequestWithdrawalCommand2.ResponseSchema = zod.z.object({
444
+ withdrawalId: zod.z.string().uuid(),
445
+ status: WithdrawalStatusSchema
446
+ });
447
+ })(exports.RequestWithdrawalCommand || (exports.RequestWithdrawalCommand = {}));
448
+ exports.ListWithdrawalsCommand = void 0;
449
+ ((ListWithdrawalsCommand2) => {
450
+ ListWithdrawalsCommand2.endpointDetails = endpoint("GET", "/withdrawals", "List the user withdrawals");
451
+ ListWithdrawalsCommand2.ResponseSchema = zod.z.object({
452
+ items: zod.z.array(WithdrawalSchema)
453
+ });
454
+ })(exports.ListWithdrawalsCommand || (exports.ListWithdrawalsCommand = {}));
455
+ exports.CancelWithdrawalCommand = void 0;
456
+ ((CancelWithdrawalCommand2) => {
457
+ CancelWithdrawalCommand2.endpointDetails = endpoint("POST", "/withdrawals/:id/cancel", "Cancel a pending withdrawal");
458
+ CancelWithdrawalCommand2.ResponseSchema = zod.z.object({
459
+ status: WithdrawalStatusSchema
460
+ });
461
+ })(exports.CancelWithdrawalCommand || (exports.CancelWithdrawalCommand = {}));
462
+ exports.ConfirmWithdrawalCommand = void 0;
463
+ ((ConfirmWithdrawalCommand2) => {
464
+ ConfirmWithdrawalCommand2.endpointDetails = endpoint("POST", "/withdrawals/:id/confirm", "Confirm a withdrawal with the email token");
465
+ ConfirmWithdrawalCommand2.RequestSchema = zod.z.object({
466
+ token: zod.z.string().min(6).max(128)
467
+ });
468
+ ConfirmWithdrawalCommand2.ResponseSchema = zod.z.object({
469
+ status: WithdrawalStatusSchema
470
+ });
471
+ })(exports.ConfirmWithdrawalCommand || (exports.ConfirmWithdrawalCommand = {}));
472
+ var AVATAR_CONTENT_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif"];
473
+ var AvatarContentTypeSchema = zod.z.enum(AVATAR_CONTENT_TYPES);
474
+ exports.RequestEmailChangeCommand = void 0;
475
+ ((RequestEmailChangeCommand2) => {
476
+ RequestEmailChangeCommand2.endpointDetails = endpoint("POST", "/settings/email/request", "Start an email change (sends a code)");
477
+ RequestEmailChangeCommand2.RequestSchema = zod.z.object({
478
+ newEmail: zod.z.string().email().max(254)
479
+ });
480
+ RequestEmailChangeCommand2.ResponseSchema = zod.z.object({ sent: zod.z.boolean() });
481
+ })(exports.RequestEmailChangeCommand || (exports.RequestEmailChangeCommand = {}));
482
+ exports.ConfirmEmailChangeCommand = void 0;
483
+ ((ConfirmEmailChangeCommand2) => {
484
+ ConfirmEmailChangeCommand2.endpointDetails = endpoint("POST", "/settings/email/confirm", "Confirm an email change with the code");
485
+ ConfirmEmailChangeCommand2.RequestSchema = zod.z.object({
486
+ code: zod.z.string().regex(/^\d{6}$/)
487
+ });
488
+ ConfirmEmailChangeCommand2.ResponseSchema = zod.z.object({ email: zod.z.string().email() });
489
+ })(exports.ConfirmEmailChangeCommand || (exports.ConfirmEmailChangeCommand = {}));
490
+ exports.DisableTotpCommand = void 0;
491
+ ((DisableTotpCommand2) => {
492
+ DisableTotpCommand2.endpointDetails = endpoint("POST", "/auth/totp/disable", "Disable TOTP two-factor auth");
493
+ DisableTotpCommand2.RequestSchema = zod.z.object({
494
+ totp: zod.z.string().regex(/^\d{6}$/)
495
+ });
496
+ DisableTotpCommand2.ResponseSchema = zod.z.void();
497
+ })(exports.DisableTotpCommand || (exports.DisableTotpCommand = {}));
498
+ exports.UpdateProfileCommand = void 0;
499
+ ((UpdateProfileCommand2) => {
500
+ UpdateProfileCommand2.endpointDetails = endpoint("PATCH", "/settings/profile", "Update display name and avatar");
501
+ UpdateProfileCommand2.RequestSchema = zod.z.object({
502
+ displayName: zod.z.string().min(2).max(48).nullable().optional(),
503
+ avatarKey: zod.z.string().max(256).nullable().optional()
504
+ }).refine((v) => v.displayName !== void 0 || v.avatarKey !== void 0, "no fields to update");
505
+ UpdateProfileCommand2.ResponseSchema = UserProfileSchema;
506
+ })(exports.UpdateProfileCommand || (exports.UpdateProfileCommand = {}));
507
+ exports.AvatarUploadUrlCommand = void 0;
508
+ ((AvatarUploadUrlCommand2) => {
509
+ AvatarUploadUrlCommand2.endpointDetails = endpoint("POST", "/settings/avatar/upload-url", "Get a presigned avatar upload URL");
510
+ AvatarUploadUrlCommand2.RequestSchema = zod.z.object({
511
+ contentType: AvatarContentTypeSchema
512
+ });
513
+ AvatarUploadUrlCommand2.ResponseSchema = zod.z.object({
514
+ key: zod.z.string(),
515
+ uploadUrl: zod.z.string().url(),
516
+ publicUrl: zod.z.string().url(),
517
+ expiresInSec: zod.z.number().int().positive(),
518
+ maxBytes: zod.z.number().int().positive()
519
+ });
520
+ })(exports.AvatarUploadUrlCommand || (exports.AvatarUploadUrlCommand = {}));
521
+ exports.GetSettingsCommand = void 0;
522
+ ((GetSettingsCommand2) => {
523
+ GetSettingsCommand2.endpointDetails = endpoint("GET", "/settings", "Get user preferences");
524
+ GetSettingsCommand2.ResponseSchema = UserSettingsSchema;
525
+ })(exports.GetSettingsCommand || (exports.GetSettingsCommand = {}));
526
+ exports.UpdateSettingsCommand = void 0;
527
+ ((UpdateSettingsCommand2) => {
528
+ UpdateSettingsCommand2.endpointDetails = endpoint("PATCH", "/settings", "Update user preferences");
529
+ UpdateSettingsCommand2.RequestSchema = zod.z.object({
530
+ notifyTrades: zod.z.boolean().optional(),
531
+ notifyByEmail: zod.z.boolean().optional(),
532
+ withdrawalEmailConfirm: zod.z.boolean().optional()
533
+ }).refine((v) => Object.keys(v).length > 0, "no fields to update");
534
+ UpdateSettingsCommand2.ResponseSchema = UserSettingsSchema;
535
+ })(exports.UpdateSettingsCommand || (exports.UpdateSettingsCommand = {}));
536
+
537
+ // src/commands/bonus/bonus.command.ts
538
+ exports.GetDailyBonusCommand = void 0;
539
+ ((GetDailyBonusCommand2) => {
540
+ GetDailyBonusCommand2.endpointDetails = endpoint("GET", "/bonus/daily", "Daily bonus status and current streak");
541
+ GetDailyBonusCommand2.ResponseSchema = DailyBonusStatusSchema;
542
+ })(exports.GetDailyBonusCommand || (exports.GetDailyBonusCommand = {}));
543
+ exports.ClaimDailyBonusCommand = void 0;
544
+ ((ClaimDailyBonusCommand2) => {
545
+ ClaimDailyBonusCommand2.endpointDetails = endpoint("POST", "/bonus/daily/claim", "Claim today's daily bonus");
546
+ ClaimDailyBonusCommand2.ResponseSchema = DailyBonusClaimResultSchema;
547
+ })(exports.ClaimDailyBonusCommand || (exports.ClaimDailyBonusCommand = {}));
548
+ exports.GetLeaderboardCommand = void 0;
549
+ ((GetLeaderboardCommand2) => {
550
+ GetLeaderboardCommand2.endpointDetails = endpoint("GET", "/leaderboard", "Top partners ranked by network turnover");
551
+ GetLeaderboardCommand2.QuerySchema = zod.z.object({
552
+ period: LeaderboardPeriodSchema.default("month"),
553
+ limit: zod.z.coerce.number().int().min(1).max(100).default(20)
554
+ });
555
+ GetLeaderboardCommand2.ResponseSchema = LeaderboardSchema;
556
+ })(exports.GetLeaderboardCommand || (exports.GetLeaderboardCommand = {}));
557
+ exports.GetIncomeCommand = void 0;
558
+ ((GetIncomeCommand2) => {
559
+ GetIncomeCommand2.endpointDetails = endpoint("GET", "/income", "Income overview: token growth + affiliate earnings");
560
+ GetIncomeCommand2.QuerySchema = zod.z.object({
561
+ period: IncomePeriodSchema.default("month")
562
+ });
563
+ GetIncomeCommand2.ResponseSchema = IncomeOverviewSchema;
564
+ })(exports.GetIncomeCommand || (exports.GetIncomeCommand = {}));
565
+ exports.ListNotificationsCommand = void 0;
566
+ ((ListNotificationsCommand2) => {
567
+ ListNotificationsCommand2.endpointDetails = endpoint("GET", "/notifications", "List in-app notifications");
568
+ ListNotificationsCommand2.QuerySchema = PaginationQuerySchema.extend({
569
+ unreadOnly: zod.z.union([zod.z.boolean(), zod.z.string()]).optional().transform((v) => v === true || v === "true" || v === "1")
570
+ });
571
+ ListNotificationsCommand2.ResponseSchema = PaginatedSchema(NotificationSchema).extend({
572
+ unread: zod.z.number().int().nonnegative()
573
+ });
574
+ })(exports.ListNotificationsCommand || (exports.ListNotificationsCommand = {}));
575
+ exports.MarkNotificationsReadCommand = void 0;
576
+ ((MarkNotificationsReadCommand2) => {
577
+ MarkNotificationsReadCommand2.endpointDetails = endpoint("POST", "/notifications/read", "Mark notifications as read");
578
+ MarkNotificationsReadCommand2.RequestSchema = zod.z.object({
579
+ ids: zod.z.array(zod.z.string().uuid()).max(500).optional(),
580
+ all: zod.z.boolean().optional()
581
+ });
582
+ MarkNotificationsReadCommand2.ResponseSchema = zod.z.object({ updated: zod.z.number().int().nonnegative() });
583
+ })(exports.MarkNotificationsReadCommand || (exports.MarkNotificationsReadCommand = {}));
584
+ exports.ListLinkedAccountsCommand = void 0;
585
+ ((ListLinkedAccountsCommand2) => {
586
+ ListLinkedAccountsCommand2.endpointDetails = endpoint("GET", "/settings/links", "List linked external accounts");
587
+ ListLinkedAccountsCommand2.ResponseSchema = zod.z.object({ items: zod.z.array(LinkedAccountSchema) });
588
+ })(exports.ListLinkedAccountsCommand || (exports.ListLinkedAccountsCommand = {}));
589
+ exports.LinkTelegramCommand = void 0;
590
+ ((LinkTelegramCommand2) => {
591
+ LinkTelegramCommand2.endpointDetails = endpoint("POST", "/settings/link/telegram", "Link a Telegram account (login widget)");
592
+ LinkTelegramCommand2.RequestSchema = zod.z.object({
593
+ id: zod.z.union([zod.z.number(), zod.z.string()]),
594
+ auth_date: zod.z.union([zod.z.number(), zod.z.string()]),
595
+ hash: zod.z.string(),
596
+ first_name: zod.z.string().optional(),
597
+ last_name: zod.z.string().optional(),
598
+ username: zod.z.string().optional(),
599
+ photo_url: zod.z.string().optional()
600
+ });
601
+ LinkTelegramCommand2.ResponseSchema = LinkedAccountSchema;
602
+ })(exports.LinkTelegramCommand || (exports.LinkTelegramCommand = {}));
603
+ exports.LinkGoogleCommand = void 0;
604
+ ((LinkGoogleCommand2) => {
605
+ LinkGoogleCommand2.endpointDetails = endpoint("POST", "/settings/link/google", "Link a Google account (ID token)");
606
+ LinkGoogleCommand2.RequestSchema = zod.z.object({ idToken: zod.z.string().min(10) });
607
+ LinkGoogleCommand2.ResponseSchema = LinkedAccountSchema;
608
+ })(exports.LinkGoogleCommand || (exports.LinkGoogleCommand = {}));
609
+ exports.UnlinkAccountCommand = void 0;
610
+ ((UnlinkAccountCommand2) => {
611
+ UnlinkAccountCommand2.endpointDetails = endpoint("DELETE", "/settings/link/:provider", "Unlink an external account");
612
+ UnlinkAccountCommand2.ParamsSchema = zod.z.object({ provider: LinkProviderSchema });
613
+ UnlinkAccountCommand2.ResponseSchema = zod.z.void();
614
+ })(exports.UnlinkAccountCommand || (exports.UnlinkAccountCommand = {}));
615
+
616
+ // src/api/routes.ts
617
+ var REST_API = {
618
+ AUTH: {
619
+ REGISTER: "/auth/register",
620
+ LOGIN: "/auth/login",
621
+ LOGOUT: "/auth/logout",
622
+ ME: "/auth/me",
623
+ TOTP_SETUP: "/auth/totp/setup",
624
+ TOTP_CONFIRM: "/auth/totp/confirm"
625
+ },
626
+ WALLET: {
627
+ OVERVIEW: "/wallet",
628
+ TRANSACTIONS: "/wallet/transactions",
629
+ DEPOSIT_ADDRESS: "/wallet/deposit-address"
630
+ },
631
+ TOKEN: {
632
+ PRICE: "/token/price",
633
+ CHART: "/token/chart"
634
+ },
635
+ SWAP: {
636
+ EXECUTE: "/swap"
637
+ },
638
+ PARTNERS: {
639
+ OVERVIEW: "/partners"
640
+ },
641
+ RANKS: {
642
+ LIST: "/ranks"
643
+ },
644
+ EARNINGS: {
645
+ OVERVIEW: "/earnings"
646
+ },
647
+ WITHDRAWALS: {
648
+ REQUEST: "/withdrawals",
649
+ LIST: "/withdrawals",
650
+ CANCEL: "/withdrawals/:id/cancel",
651
+ CONFIRM: "/withdrawals/:id/confirm"
652
+ },
653
+ SETTINGS: {
654
+ EMAIL_REQUEST: "/settings/email/request",
655
+ EMAIL_CONFIRM: "/settings/email/confirm",
656
+ TOTP_DISABLE: "/auth/totp/disable",
657
+ PROFILE: "/settings/profile",
658
+ AVATAR_UPLOAD_URL: "/settings/avatar/upload-url",
659
+ PREFERENCES: "/settings",
660
+ LINKS: "/settings/links",
661
+ LINK_TELEGRAM: "/settings/link/telegram",
662
+ LINK_GOOGLE: "/settings/link/google",
663
+ UNLINK: "/settings/link/:provider"
664
+ },
665
+ BONUS: {
666
+ DAILY: "/bonus/daily",
667
+ DAILY_CLAIM: "/bonus/daily/claim"
668
+ },
669
+ LEADERBOARD: {
670
+ OVERVIEW: "/leaderboard"
671
+ },
672
+ INCOME: {
673
+ OVERVIEW: "/income"
674
+ },
675
+ NOTIFICATIONS: {
676
+ LIST: "/notifications",
677
+ READ: "/notifications/read"
678
+ }
679
+ };
680
+ var API_PREFIX = "/api";
681
+ var API_VERSION = "v1";
682
+
683
+ exports.API_PREFIX = API_PREFIX;
684
+ exports.API_VERSION = API_VERSION;
685
+ exports.ASSET_SYMBOLS = ASSET_SYMBOLS;
686
+ exports.AVATAR_CONTENT_TYPES = AVATAR_CONTENT_TYPES;
687
+ exports.AssetBalanceSchema = AssetBalanceSchema;
688
+ exports.AssetSymbolSchema = AssetSymbolSchema;
689
+ exports.AvatarContentTypeSchema = AvatarContentTypeSchema;
690
+ exports.ChartPeriodSchema = ChartPeriodSchema;
691
+ exports.ChartPointSchema = ChartPointSchema;
692
+ exports.DEPOSITABLE_ASSETS = DEPOSITABLE_ASSETS;
693
+ exports.DailyBonusClaimResultSchema = DailyBonusClaimResultSchema;
694
+ exports.DailyBonusDaySchema = DailyBonusDaySchema;
695
+ exports.DailyBonusStatusSchema = DailyBonusStatusSchema;
696
+ exports.DepositAddressSchema = DepositAddressSchema;
697
+ exports.DepositableAssetSchema = DepositableAssetSchema;
698
+ exports.ERROR_CODE = ERROR_CODE;
699
+ exports.EarningsOverviewSchema = EarningsOverviewSchema;
700
+ exports.ErrorResponseSchema = ErrorResponseSchema;
701
+ exports.FUNDING_ASSET = FUNDING_ASSET;
702
+ exports.IncomeOverviewSchema = IncomeOverviewSchema;
703
+ exports.IncomePeriodSchema = IncomePeriodSchema;
704
+ exports.LeaderboardEntrySchema = LeaderboardEntrySchema;
705
+ exports.LeaderboardPeriodSchema = LeaderboardPeriodSchema;
706
+ exports.LeaderboardSchema = LeaderboardSchema;
707
+ exports.LinkProviderSchema = LinkProviderSchema;
708
+ exports.LinkedAccountSchema = LinkedAccountSchema;
709
+ exports.MONEY_REGEX = MONEY_REGEX;
710
+ exports.MoneyStringSchema = MoneyStringSchema;
711
+ exports.MonthlyPricePointSchema = MonthlyPricePointSchema;
712
+ exports.NotificationSchema = NotificationSchema;
713
+ exports.NotificationTypeSchema = NotificationTypeSchema;
714
+ exports.PaginatedSchema = PaginatedSchema;
715
+ exports.PaginationQuerySchema = PaginationQuerySchema;
716
+ exports.PartnerAccrualSchema = PartnerAccrualSchema;
717
+ exports.PartnerLevelSchema = PartnerLevelSchema;
718
+ exports.PartnersOverviewSchema = PartnersOverviewSchema;
719
+ exports.PositiveMoneyStringSchema = PositiveMoneyStringSchema;
720
+ exports.REST_API = REST_API;
721
+ exports.RankDefSchema = RankDefSchema;
722
+ exports.SessionInfoSchema = SessionInfoSchema;
723
+ exports.SwapSideSchema = SwapSideSchema;
724
+ exports.TOKEN_ASSET = TOKEN_ASSET;
725
+ exports.TokenPriceSchema = TokenPriceSchema;
726
+ exports.TradeResultSchema = TradeResultSchema;
727
+ exports.TransactionSchema = TransactionSchema;
728
+ exports.TransactionStatusSchema = TransactionStatusSchema;
729
+ exports.TransactionTypeSchema = TransactionTypeSchema;
730
+ exports.UserProfileSchema = UserProfileSchema;
731
+ exports.UserRankSchema = UserRankSchema;
732
+ exports.UserSettingsSchema = UserSettingsSchema;
733
+ exports.UserStatusSchema = UserStatusSchema;
734
+ exports.UuidSchema = UuidSchema;
735
+ exports.WalletOverviewSchema = WalletOverviewSchema;
736
+ exports.WithdrawalSchema = WithdrawalSchema;
737
+ exports.WithdrawalStatusSchema = WithdrawalStatusSchema;
738
+ exports.endpoint = endpoint;
739
+ //# sourceMappingURL=index.cjs.map
740
+ //# sourceMappingURL=index.cjs.map