@pumper/server-sdk 1.0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # PumpHQ TypeScript SDK
2
+
3
+ ## Usage
@@ -0,0 +1,60 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ZodType, output } from 'zod';
3
+
4
+ interface ClientOptions {
5
+ apiSitekey: string;
6
+ apiSecret: string;
7
+ }
8
+ declare class PumpClient {
9
+ sitekey: string;
10
+ secret: string;
11
+ api: AxiosInstance;
12
+ constructor(options: ClientOptions);
13
+ bonus: (data: {
14
+ playerId: string;
15
+ txId: string;
16
+ kind: "admin:credit" | "admin:tip" | "affiliate:commission" | "affiliate:leaderboard" | "community:battle" | "community:case" | "giveaway:discord" | "giveaway:kick" | "giveaway:telegram" | "giveaway:twitter" | "offer:signup-cases" | "promocode:discord" | "promocode:kick" | "race:payouts" | "raffle:payouts" | "rain:base" | "rain:tips" | "rain:tax" | "rakeback:daily-case" | "rakeback:daily" | "rakeback:level" | "rakeback:monthly" | "rakeback:weekly" | "vip:bonus" | "vip:lossback";
17
+ amountUSD: number;
18
+ }) => Promise<{
19
+ eventId: string;
20
+ }>;
21
+ deposit: (data: {
22
+ playerId: string;
23
+ txId: string;
24
+ kind: "crypto:ADA" | "crypto:BCH" | "crypto:BNB" | "crypto:BTC" | "crypto:DOGE" | "crypto:ETH" | "crypto:LTC" | "crypto:POL" | "crypto:SOL" | "crypto:TON" | "crypto:TRX" | "crypto:XRP" | "crypto:ZEC" | "crypto:DAI_ERC-20" | "crypto:ETH_BASE" | "crypto:LINK_ERC-20" | "crypto:PYUSD_ERC-20" | "crypto:SHIB_ERC-20" | "crypto:USDC_ERC-20" | "crypto:USDC_SPL" | "crypto:USDT_BEP-20" | "crypto:USDT_ERC-20" | "crypto:USDT_SPL" | "crypto:USDT_TRC-20" | "fiat:meld" | "fiat:softkeys" | "fiat:swapped" | "fiat:zen" | "giftcard:difmark" | "giftcard:g2a" | "giftcard:kinguin" | "giftcard:pulse" | "item:skindeck" | "item:skinify" | "item:skinsback";
25
+ amountUSD: string;
26
+ feeUSD: string;
27
+ }) => Promise<{
28
+ eventId: string;
29
+ }>;
30
+ game: (data: {
31
+ playerId: string;
32
+ txId: string;
33
+ kind: "battles" | "blackjack" | "cases" | "dice" | "double" | "keno" | "limbo" | "mines" | "plinko" | "slots" | "upgrader";
34
+ wagerUSD: string;
35
+ wonUSD: string;
36
+ edgeRate: number;
37
+ }) => Promise<{
38
+ eventId: string;
39
+ }>;
40
+ withdraw: (data: {
41
+ playerId: string;
42
+ txId: string;
43
+ kind: "crypto:ADA" | "crypto:BCH" | "crypto:BNB" | "crypto:BTC" | "crypto:DOGE" | "crypto:ETH" | "crypto:LTC" | "crypto:POL" | "crypto:SOL" | "crypto:TON" | "crypto:TRX" | "crypto:XRP" | "crypto:ZEC" | "crypto:DAI_ERC-20" | "crypto:ETH_BASE" | "crypto:LINK_ERC-20" | "crypto:PYUSD_ERC-20" | "crypto:SHIB_ERC-20" | "crypto:USDC_ERC-20" | "crypto:USDC_SPL" | "crypto:USDT_BEP-20" | "crypto:USDT_ERC-20" | "crypto:USDT_SPL" | "crypto:USDT_TRC-20" | "item:skindeck" | "item:skinify" | "item:skinsback";
44
+ amountUSD: string;
45
+ feeUSD: string;
46
+ }) => Promise<{
47
+ eventId: string;
48
+ }>;
49
+ shape<TReq extends ZodType<any, any, any>, TRes extends ZodType<any, any, any>, TReqData extends output<TReq>, TResData extends output<TRes>>({ method, path, }: {
50
+ method: "GET" | "POST";
51
+ path: string;
52
+ req: TReq;
53
+ res: TRes;
54
+ }): (data: TReqData) => Promise<TResData>;
55
+ private get;
56
+ private post;
57
+ private getRequestError;
58
+ }
59
+
60
+ export { type ClientOptions, PumpClient };
@@ -0,0 +1,60 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ZodType, output } from 'zod';
3
+
4
+ interface ClientOptions {
5
+ apiSitekey: string;
6
+ apiSecret: string;
7
+ }
8
+ declare class PumpClient {
9
+ sitekey: string;
10
+ secret: string;
11
+ api: AxiosInstance;
12
+ constructor(options: ClientOptions);
13
+ bonus: (data: {
14
+ playerId: string;
15
+ txId: string;
16
+ kind: "admin:credit" | "admin:tip" | "affiliate:commission" | "affiliate:leaderboard" | "community:battle" | "community:case" | "giveaway:discord" | "giveaway:kick" | "giveaway:telegram" | "giveaway:twitter" | "offer:signup-cases" | "promocode:discord" | "promocode:kick" | "race:payouts" | "raffle:payouts" | "rain:base" | "rain:tips" | "rain:tax" | "rakeback:daily-case" | "rakeback:daily" | "rakeback:level" | "rakeback:monthly" | "rakeback:weekly" | "vip:bonus" | "vip:lossback";
17
+ amountUSD: number;
18
+ }) => Promise<{
19
+ eventId: string;
20
+ }>;
21
+ deposit: (data: {
22
+ playerId: string;
23
+ txId: string;
24
+ kind: "crypto:ADA" | "crypto:BCH" | "crypto:BNB" | "crypto:BTC" | "crypto:DOGE" | "crypto:ETH" | "crypto:LTC" | "crypto:POL" | "crypto:SOL" | "crypto:TON" | "crypto:TRX" | "crypto:XRP" | "crypto:ZEC" | "crypto:DAI_ERC-20" | "crypto:ETH_BASE" | "crypto:LINK_ERC-20" | "crypto:PYUSD_ERC-20" | "crypto:SHIB_ERC-20" | "crypto:USDC_ERC-20" | "crypto:USDC_SPL" | "crypto:USDT_BEP-20" | "crypto:USDT_ERC-20" | "crypto:USDT_SPL" | "crypto:USDT_TRC-20" | "fiat:meld" | "fiat:softkeys" | "fiat:swapped" | "fiat:zen" | "giftcard:difmark" | "giftcard:g2a" | "giftcard:kinguin" | "giftcard:pulse" | "item:skindeck" | "item:skinify" | "item:skinsback";
25
+ amountUSD: string;
26
+ feeUSD: string;
27
+ }) => Promise<{
28
+ eventId: string;
29
+ }>;
30
+ game: (data: {
31
+ playerId: string;
32
+ txId: string;
33
+ kind: "battles" | "blackjack" | "cases" | "dice" | "double" | "keno" | "limbo" | "mines" | "plinko" | "slots" | "upgrader";
34
+ wagerUSD: string;
35
+ wonUSD: string;
36
+ edgeRate: number;
37
+ }) => Promise<{
38
+ eventId: string;
39
+ }>;
40
+ withdraw: (data: {
41
+ playerId: string;
42
+ txId: string;
43
+ kind: "crypto:ADA" | "crypto:BCH" | "crypto:BNB" | "crypto:BTC" | "crypto:DOGE" | "crypto:ETH" | "crypto:LTC" | "crypto:POL" | "crypto:SOL" | "crypto:TON" | "crypto:TRX" | "crypto:XRP" | "crypto:ZEC" | "crypto:DAI_ERC-20" | "crypto:ETH_BASE" | "crypto:LINK_ERC-20" | "crypto:PYUSD_ERC-20" | "crypto:SHIB_ERC-20" | "crypto:USDC_ERC-20" | "crypto:USDC_SPL" | "crypto:USDT_BEP-20" | "crypto:USDT_ERC-20" | "crypto:USDT_SPL" | "crypto:USDT_TRC-20" | "item:skindeck" | "item:skinify" | "item:skinsback";
44
+ amountUSD: string;
45
+ feeUSD: string;
46
+ }) => Promise<{
47
+ eventId: string;
48
+ }>;
49
+ shape<TReq extends ZodType<any, any, any>, TRes extends ZodType<any, any, any>, TReqData extends output<TReq>, TResData extends output<TRes>>({ method, path, }: {
50
+ method: "GET" | "POST";
51
+ path: string;
52
+ req: TReq;
53
+ res: TRes;
54
+ }): (data: TReqData) => Promise<TResData>;
55
+ private get;
56
+ private post;
57
+ private getRequestError;
58
+ }
59
+
60
+ export { type ClientOptions, PumpClient };
package/dist/index.js ADDED
@@ -0,0 +1,382 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.ts
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ PumpClient: () => PumpClient
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // ../shared-core/src/schema/index.ts
39
+ var schema_exports = {};
40
+ __export(schema_exports, {
41
+ createContract: () => createContract,
42
+ kebab: () => kebab,
43
+ password: () => password,
44
+ tfac: () => tfac,
45
+ username: () => username,
46
+ v: () => v_exports
47
+ });
48
+
49
+ // ../shared-core/src/schema/v.ts
50
+ var v_exports = {};
51
+ __export(v_exports, {
52
+ kebab: () => kebab,
53
+ password: () => password,
54
+ tfac: () => tfac,
55
+ username: () => username
56
+ });
57
+ __reExport(v_exports, require("zod"));
58
+
59
+ // ../shared-core/src/schema/custom/kebab.ts
60
+ var import_zod = require("zod");
61
+ function kebab() {
62
+ return import_zod.z.string().regex(
63
+ /^[a-z0-9\-]+$/,
64
+ "Must only include lowercase letters, numbers, or dashes"
65
+ );
66
+ }
67
+
68
+ // ../shared-core/src/schema/custom/password.ts
69
+ var import_zod2 = require("zod");
70
+ function password() {
71
+ return import_zod2.z.string().min(6, "Password must be at least 6 characters");
72
+ }
73
+
74
+ // ../shared-core/src/schema/custom/tfac.ts
75
+ var import_zod3 = require("zod");
76
+ function tfac() {
77
+ return import_zod3.z.string().min(6, "Token must be 6 digits.").max(6, "Token must be 6 digits.");
78
+ }
79
+
80
+ // ../shared-core/src/schema/custom/username.ts
81
+ var import_zod4 = require("zod");
82
+ function username() {
83
+ return import_zod4.z.string().min(2, "Username must be at least 2 characters").max(16, "Username must be at most 16 characters").regex(/^[a-zA-Z0-9]+$/, "Username must only include letters or numbers");
84
+ }
85
+
86
+ // ../shared-core/src/schema/index.ts
87
+ __reExport(schema_exports, v_exports);
88
+
89
+ // ../shared-core/src/schema/contract/createContract.ts
90
+ function createContract(contract) {
91
+ return contract;
92
+ }
93
+
94
+ // ../shared-core/src/types/products/bonus.ts
95
+ var bonusKinds = [
96
+ "admin:credit",
97
+ "admin:tip",
98
+ "affiliate:commission",
99
+ "affiliate:leaderboard",
100
+ "community:battle",
101
+ "community:case",
102
+ "giveaway:discord",
103
+ "giveaway:kick",
104
+ "giveaway:telegram",
105
+ "giveaway:twitter",
106
+ "offer:signup-cases",
107
+ "promocode:discord",
108
+ "promocode:kick",
109
+ "race:payouts",
110
+ "raffle:payouts",
111
+ "rain:base",
112
+ "rain:tips",
113
+ "rain:tax",
114
+ "rakeback:daily-case",
115
+ "rakeback:daily",
116
+ "rakeback:level",
117
+ "rakeback:monthly",
118
+ "rakeback:weekly",
119
+ "vip:bonus",
120
+ "vip:lossback"
121
+ ];
122
+
123
+ // ../shared-product/src/schema/events/bonus.ts
124
+ var bonusSchema = createContract({
125
+ method: "POST",
126
+ path: "/events/bonus",
127
+ req: v_exports.object({
128
+ playerId: v_exports.string(),
129
+ txId: v_exports.string(),
130
+ kind: v_exports.enum(bonusKinds),
131
+ amountUSD: v_exports.number()
132
+ }),
133
+ res: v_exports.custom()
134
+ });
135
+
136
+ // ../shared-core/src/types/economy/crypto.ts
137
+ var cryptoCurrencies = [
138
+ "ADA",
139
+ "BCH",
140
+ "BNB",
141
+ "BTC",
142
+ "DAI_ERC-20",
143
+ "DOGE",
144
+ "ETH",
145
+ "ETH_BASE",
146
+ "LINK_ERC-20",
147
+ "LTC",
148
+ "POL",
149
+ "PYUSD_ERC-20",
150
+ "SHIB_ERC-20",
151
+ "SOL",
152
+ "TON",
153
+ "TRX",
154
+ "USDC_ERC-20",
155
+ "USDC_SPL",
156
+ "USDT_BEP-20",
157
+ "USDT_ERC-20",
158
+ "USDT_SPL",
159
+ "USDT_TRC-20",
160
+ "XRP",
161
+ "ZEC"
162
+ ];
163
+
164
+ // ../shared-core/src/types/economy/fiat.ts
165
+ var fiatProviders = ["meld", "softkeys", "swapped", "zen"];
166
+
167
+ // ../shared-core/src/types/economy/giftcard.ts
168
+ var giftcardProviders = [
169
+ "difmark",
170
+ "g2a",
171
+ "kinguin",
172
+ "pulse"
173
+ ];
174
+
175
+ // ../shared-core/src/types/economy/item.ts
176
+ var itemProviders = ["skindeck", "skinify", "skinsback"];
177
+
178
+ // ../shared-core/src/types/products/deposit.ts
179
+ var depositKinds = [
180
+ ...cryptoCurrencies.map((x) => `crypto:${x}`),
181
+ ...fiatProviders.map((x) => `fiat:${x}`),
182
+ ...giftcardProviders.map((x) => `giftcard:${x}`),
183
+ ...itemProviders.map((x) => `item:${x}`)
184
+ ];
185
+
186
+ // ../shared-product/src/schema/events/deposit.ts
187
+ var depositSchema = createContract({
188
+ method: "POST",
189
+ path: "/events/deposit",
190
+ req: v_exports.object({
191
+ playerId: v_exports.string(),
192
+ txId: v_exports.string(),
193
+ kind: v_exports.enum(depositKinds),
194
+ amountUSD: v_exports.string(),
195
+ feeUSD: v_exports.string()
196
+ }),
197
+ res: v_exports.custom()
198
+ });
199
+
200
+ // ../shared-core/src/types/products/game.ts
201
+ var gameKinds = [
202
+ "battles",
203
+ "blackjack",
204
+ "cases",
205
+ "dice",
206
+ "double",
207
+ "keno",
208
+ "limbo",
209
+ "mines",
210
+ "plinko",
211
+ "slots",
212
+ "upgrader"
213
+ ];
214
+
215
+ // ../shared-product/src/schema/events/game.ts
216
+ var gameSchema = createContract({
217
+ method: "POST",
218
+ path: "/events/game",
219
+ req: v_exports.object({
220
+ playerId: v_exports.string(),
221
+ txId: v_exports.string(),
222
+ kind: v_exports.enum(gameKinds),
223
+ wagerUSD: v_exports.string(),
224
+ wonUSD: v_exports.string(),
225
+ edgeRate: v_exports.number()
226
+ }),
227
+ res: v_exports.custom()
228
+ });
229
+
230
+ // ../shared-core/src/types/products/withdraw.ts
231
+ var withdrawKinds = [
232
+ ...cryptoCurrencies.map((x) => `crypto:${x}`),
233
+ ...itemProviders.map((x) => `item:${x}`)
234
+ ];
235
+
236
+ // ../shared-product/src/schema/events/withdraw.ts
237
+ var withdrawSchema = createContract({
238
+ method: "POST",
239
+ path: "/events/withdraw",
240
+ req: v_exports.object({
241
+ playerId: v_exports.string(),
242
+ txId: v_exports.string(),
243
+ kind: v_exports.enum(withdrawKinds),
244
+ amountUSD: v_exports.string(),
245
+ feeUSD: v_exports.string()
246
+ }),
247
+ res: v_exports.custom()
248
+ });
249
+
250
+ // src/client/PumpClient.ts
251
+ var import_axios = __toESM(require("axios"));
252
+
253
+ // ../shared-core/src/lib/dates.ts
254
+ var dates_exports = {};
255
+ __export(dates_exports, {
256
+ Dates: () => Dates
257
+ });
258
+ __reExport(dates_exports, require("date-fns"));
259
+ var Dates = class {
260
+ static toTimestamp(date) {
261
+ return date.toLocaleDateString("en-US", {
262
+ hour: "2-digit",
263
+ hour12: false,
264
+ minute: "numeric",
265
+ weekday: "short",
266
+ day: "numeric",
267
+ month: "short"
268
+ });
269
+ }
270
+ static toDayId(date) {
271
+ date = new Date(date);
272
+ return Math.floor(date.getTime() / 1e3 / 60 / 60 / 24);
273
+ }
274
+ static parse(field) {
275
+ if (field === null || field === void 0 || typeof field !== "object") {
276
+ return;
277
+ }
278
+ const obj = field;
279
+ for (const key of Object.keys(obj)) {
280
+ const value = obj[key];
281
+ if (this.isISO(value)) {
282
+ obj[key] = new Date(value);
283
+ } else if (typeof value === "object") {
284
+ this.parse(value);
285
+ }
286
+ }
287
+ }
288
+ static isISO(value) {
289
+ const isoDateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d*)?(?:[-+]\d{2}:?\d{2}|Z)?$/;
290
+ return value != null && typeof value === "string" && isoDateFormat.test(value);
291
+ }
292
+ };
293
+
294
+ // ../shared-core/src/services/system/encode.ts
295
+ var import_crypto3 = __toESM(require("crypto"), 1);
296
+ function signData({ data, secret }) {
297
+ const serialized = JSON.stringify(data ?? {});
298
+ const signature = import_crypto3.default.createHmac("sha256", secret).update(serialized).digest("base64url");
299
+ return signature;
300
+ }
301
+
302
+ // src/errors/PumpError.ts
303
+ var PumpError = class _PumpError extends Error {
304
+ constructor(message) {
305
+ super(message);
306
+ Object.setPrototypeOf(this, _PumpError.prototype);
307
+ }
308
+ };
309
+
310
+ // src/client/PumpClient.ts
311
+ var PumpClient = class {
312
+ sitekey;
313
+ secret;
314
+ api;
315
+ constructor(options) {
316
+ this.sitekey = options.apiSitekey;
317
+ this.secret = options.apiSecret;
318
+ this.api = import_axios.default.create({
319
+ baseURL: "https://api.obrut.tech/product",
320
+ headers: {
321
+ Authorization: this.secret
322
+ },
323
+ withCredentials: true
324
+ });
325
+ }
326
+ bonus = this.shape(bonusSchema);
327
+ deposit = this.shape(depositSchema);
328
+ game = this.shape(gameSchema);
329
+ withdraw = this.shape(withdrawSchema);
330
+ shape({
331
+ method,
332
+ path
333
+ }) {
334
+ if (method === "GET") {
335
+ return async (data) => {
336
+ return this.get(path, data);
337
+ };
338
+ } else {
339
+ return async (data) => {
340
+ return this.post(path, data);
341
+ };
342
+ }
343
+ }
344
+ async get(path, data) {
345
+ try {
346
+ const params = {
347
+ ...data,
348
+ signature: signData({ data, secret: this.secret })
349
+ };
350
+ const result = await this.api.get(path, { params });
351
+ Dates.parse(result.data);
352
+ return result.data;
353
+ } catch (err) {
354
+ throw this.getRequestError(err);
355
+ }
356
+ }
357
+ async post(path, data) {
358
+ try {
359
+ const payload = {
360
+ ...data,
361
+ signature: signData({ data, secret: this.secret })
362
+ };
363
+ const result = await this.api.post(path, payload);
364
+ Dates.parse(result.data);
365
+ return result.data;
366
+ } catch (err) {
367
+ throw this.getRequestError(err);
368
+ }
369
+ }
370
+ getRequestError(err) {
371
+ if ((0, import_axios.isAxiosError)(err) && err.response?.data?.error) {
372
+ return new PumpError(err.response.data.error);
373
+ } else {
374
+ console.error(err);
375
+ return new PumpError("Unknown request error.");
376
+ }
377
+ }
378
+ };
379
+ // Annotate the CommonJS export names for ESM import in node:
380
+ 0 && (module.exports = {
381
+ PumpClient
382
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,364 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+
19
+ // ../shared-core/src/schema/index.ts
20
+ var schema_exports = {};
21
+ __export(schema_exports, {
22
+ createContract: () => createContract,
23
+ kebab: () => kebab,
24
+ password: () => password,
25
+ tfac: () => tfac,
26
+ username: () => username,
27
+ v: () => v_exports
28
+ });
29
+
30
+ // ../shared-core/src/schema/v.ts
31
+ var v_exports = {};
32
+ __export(v_exports, {
33
+ kebab: () => kebab,
34
+ password: () => password,
35
+ tfac: () => tfac,
36
+ username: () => username
37
+ });
38
+ __reExport(v_exports, zod_star);
39
+ import * as zod_star from "zod";
40
+
41
+ // ../shared-core/src/schema/custom/kebab.ts
42
+ import { z } from "zod";
43
+ function kebab() {
44
+ return z.string().regex(
45
+ /^[a-z0-9\-]+$/,
46
+ "Must only include lowercase letters, numbers, or dashes"
47
+ );
48
+ }
49
+
50
+ // ../shared-core/src/schema/custom/password.ts
51
+ import { z as z2 } from "zod";
52
+ function password() {
53
+ return z2.string().min(6, "Password must be at least 6 characters");
54
+ }
55
+
56
+ // ../shared-core/src/schema/custom/tfac.ts
57
+ import { z as z3 } from "zod";
58
+ function tfac() {
59
+ return z3.string().min(6, "Token must be 6 digits.").max(6, "Token must be 6 digits.");
60
+ }
61
+
62
+ // ../shared-core/src/schema/custom/username.ts
63
+ import { z as z4 } from "zod";
64
+ function username() {
65
+ return z4.string().min(2, "Username must be at least 2 characters").max(16, "Username must be at most 16 characters").regex(/^[a-zA-Z0-9]+$/, "Username must only include letters or numbers");
66
+ }
67
+
68
+ // ../shared-core/src/schema/index.ts
69
+ __reExport(schema_exports, v_exports);
70
+
71
+ // ../shared-core/src/schema/contract/createContract.ts
72
+ function createContract(contract) {
73
+ return contract;
74
+ }
75
+
76
+ // ../shared-core/src/types/products/bonus.ts
77
+ var bonusKinds = [
78
+ "admin:credit",
79
+ "admin:tip",
80
+ "affiliate:commission",
81
+ "affiliate:leaderboard",
82
+ "community:battle",
83
+ "community:case",
84
+ "giveaway:discord",
85
+ "giveaway:kick",
86
+ "giveaway:telegram",
87
+ "giveaway:twitter",
88
+ "offer:signup-cases",
89
+ "promocode:discord",
90
+ "promocode:kick",
91
+ "race:payouts",
92
+ "raffle:payouts",
93
+ "rain:base",
94
+ "rain:tips",
95
+ "rain:tax",
96
+ "rakeback:daily-case",
97
+ "rakeback:daily",
98
+ "rakeback:level",
99
+ "rakeback:monthly",
100
+ "rakeback:weekly",
101
+ "vip:bonus",
102
+ "vip:lossback"
103
+ ];
104
+
105
+ // ../shared-product/src/schema/events/bonus.ts
106
+ var bonusSchema = createContract({
107
+ method: "POST",
108
+ path: "/events/bonus",
109
+ req: v_exports.object({
110
+ playerId: v_exports.string(),
111
+ txId: v_exports.string(),
112
+ kind: v_exports.enum(bonusKinds),
113
+ amountUSD: v_exports.number()
114
+ }),
115
+ res: v_exports.custom()
116
+ });
117
+
118
+ // ../shared-core/src/types/economy/crypto.ts
119
+ var cryptoCurrencies = [
120
+ "ADA",
121
+ "BCH",
122
+ "BNB",
123
+ "BTC",
124
+ "DAI_ERC-20",
125
+ "DOGE",
126
+ "ETH",
127
+ "ETH_BASE",
128
+ "LINK_ERC-20",
129
+ "LTC",
130
+ "POL",
131
+ "PYUSD_ERC-20",
132
+ "SHIB_ERC-20",
133
+ "SOL",
134
+ "TON",
135
+ "TRX",
136
+ "USDC_ERC-20",
137
+ "USDC_SPL",
138
+ "USDT_BEP-20",
139
+ "USDT_ERC-20",
140
+ "USDT_SPL",
141
+ "USDT_TRC-20",
142
+ "XRP",
143
+ "ZEC"
144
+ ];
145
+
146
+ // ../shared-core/src/types/economy/fiat.ts
147
+ var fiatProviders = ["meld", "softkeys", "swapped", "zen"];
148
+
149
+ // ../shared-core/src/types/economy/giftcard.ts
150
+ var giftcardProviders = [
151
+ "difmark",
152
+ "g2a",
153
+ "kinguin",
154
+ "pulse"
155
+ ];
156
+
157
+ // ../shared-core/src/types/economy/item.ts
158
+ var itemProviders = ["skindeck", "skinify", "skinsback"];
159
+
160
+ // ../shared-core/src/types/products/deposit.ts
161
+ var depositKinds = [
162
+ ...cryptoCurrencies.map((x) => `crypto:${x}`),
163
+ ...fiatProviders.map((x) => `fiat:${x}`),
164
+ ...giftcardProviders.map((x) => `giftcard:${x}`),
165
+ ...itemProviders.map((x) => `item:${x}`)
166
+ ];
167
+
168
+ // ../shared-product/src/schema/events/deposit.ts
169
+ var depositSchema = createContract({
170
+ method: "POST",
171
+ path: "/events/deposit",
172
+ req: v_exports.object({
173
+ playerId: v_exports.string(),
174
+ txId: v_exports.string(),
175
+ kind: v_exports.enum(depositKinds),
176
+ amountUSD: v_exports.string(),
177
+ feeUSD: v_exports.string()
178
+ }),
179
+ res: v_exports.custom()
180
+ });
181
+
182
+ // ../shared-core/src/types/products/game.ts
183
+ var gameKinds = [
184
+ "battles",
185
+ "blackjack",
186
+ "cases",
187
+ "dice",
188
+ "double",
189
+ "keno",
190
+ "limbo",
191
+ "mines",
192
+ "plinko",
193
+ "slots",
194
+ "upgrader"
195
+ ];
196
+
197
+ // ../shared-product/src/schema/events/game.ts
198
+ var gameSchema = createContract({
199
+ method: "POST",
200
+ path: "/events/game",
201
+ req: v_exports.object({
202
+ playerId: v_exports.string(),
203
+ txId: v_exports.string(),
204
+ kind: v_exports.enum(gameKinds),
205
+ wagerUSD: v_exports.string(),
206
+ wonUSD: v_exports.string(),
207
+ edgeRate: v_exports.number()
208
+ }),
209
+ res: v_exports.custom()
210
+ });
211
+
212
+ // ../shared-core/src/types/products/withdraw.ts
213
+ var withdrawKinds = [
214
+ ...cryptoCurrencies.map((x) => `crypto:${x}`),
215
+ ...itemProviders.map((x) => `item:${x}`)
216
+ ];
217
+
218
+ // ../shared-product/src/schema/events/withdraw.ts
219
+ var withdrawSchema = createContract({
220
+ method: "POST",
221
+ path: "/events/withdraw",
222
+ req: v_exports.object({
223
+ playerId: v_exports.string(),
224
+ txId: v_exports.string(),
225
+ kind: v_exports.enum(withdrawKinds),
226
+ amountUSD: v_exports.string(),
227
+ feeUSD: v_exports.string()
228
+ }),
229
+ res: v_exports.custom()
230
+ });
231
+
232
+ // src/client/PumpClient.ts
233
+ import axios, { isAxiosError } from "axios";
234
+
235
+ // ../shared-core/src/lib/dates.ts
236
+ var dates_exports = {};
237
+ __export(dates_exports, {
238
+ Dates: () => Dates
239
+ });
240
+ __reExport(dates_exports, date_fns_star);
241
+ import * as date_fns_star from "date-fns";
242
+ var Dates = class {
243
+ static toTimestamp(date) {
244
+ return date.toLocaleDateString("en-US", {
245
+ hour: "2-digit",
246
+ hour12: false,
247
+ minute: "numeric",
248
+ weekday: "short",
249
+ day: "numeric",
250
+ month: "short"
251
+ });
252
+ }
253
+ static toDayId(date) {
254
+ date = new Date(date);
255
+ return Math.floor(date.getTime() / 1e3 / 60 / 60 / 24);
256
+ }
257
+ static parse(field) {
258
+ if (field === null || field === void 0 || typeof field !== "object") {
259
+ return;
260
+ }
261
+ const obj = field;
262
+ for (const key of Object.keys(obj)) {
263
+ const value = obj[key];
264
+ if (this.isISO(value)) {
265
+ obj[key] = new Date(value);
266
+ } else if (typeof value === "object") {
267
+ this.parse(value);
268
+ }
269
+ }
270
+ }
271
+ static isISO(value) {
272
+ const isoDateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d*)?(?:[-+]\d{2}:?\d{2}|Z)?$/;
273
+ return value != null && typeof value === "string" && isoDateFormat.test(value);
274
+ }
275
+ };
276
+
277
+ // ../shared-core/src/services/system/encode.ts
278
+ import crypto from "crypto";
279
+ function signData({ data, secret }) {
280
+ const serialized = JSON.stringify(data ?? {});
281
+ const signature = crypto.createHmac("sha256", secret).update(serialized).digest("base64url");
282
+ return signature;
283
+ }
284
+
285
+ // src/errors/PumpError.ts
286
+ var PumpError = class _PumpError extends Error {
287
+ constructor(message) {
288
+ super(message);
289
+ Object.setPrototypeOf(this, _PumpError.prototype);
290
+ }
291
+ };
292
+
293
+ // src/client/PumpClient.ts
294
+ var PumpClient = class {
295
+ sitekey;
296
+ secret;
297
+ api;
298
+ constructor(options) {
299
+ this.sitekey = options.apiSitekey;
300
+ this.secret = options.apiSecret;
301
+ this.api = axios.create({
302
+ baseURL: "https://api.obrut.tech/product",
303
+ headers: {
304
+ Authorization: this.secret
305
+ },
306
+ withCredentials: true
307
+ });
308
+ }
309
+ bonus = this.shape(bonusSchema);
310
+ deposit = this.shape(depositSchema);
311
+ game = this.shape(gameSchema);
312
+ withdraw = this.shape(withdrawSchema);
313
+ shape({
314
+ method,
315
+ path
316
+ }) {
317
+ if (method === "GET") {
318
+ return async (data) => {
319
+ return this.get(path, data);
320
+ };
321
+ } else {
322
+ return async (data) => {
323
+ return this.post(path, data);
324
+ };
325
+ }
326
+ }
327
+ async get(path, data) {
328
+ try {
329
+ const params = {
330
+ ...data,
331
+ signature: signData({ data, secret: this.secret })
332
+ };
333
+ const result = await this.api.get(path, { params });
334
+ Dates.parse(result.data);
335
+ return result.data;
336
+ } catch (err) {
337
+ throw this.getRequestError(err);
338
+ }
339
+ }
340
+ async post(path, data) {
341
+ try {
342
+ const payload = {
343
+ ...data,
344
+ signature: signData({ data, secret: this.secret })
345
+ };
346
+ const result = await this.api.post(path, payload);
347
+ Dates.parse(result.data);
348
+ return result.data;
349
+ } catch (err) {
350
+ throw this.getRequestError(err);
351
+ }
352
+ }
353
+ getRequestError(err) {
354
+ if (isAxiosError(err) && err.response?.data?.error) {
355
+ return new PumpError(err.response.data.error);
356
+ } else {
357
+ console.error(err);
358
+ return new PumpError("Unknown request error.");
359
+ }
360
+ }
361
+ };
362
+ export {
363
+ PumpClient
364
+ };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@pumper/server-sdk",
3
+ "description": "The Official TypeScript SDK for PumpTech",
4
+ "version": "1.0.0",
5
+ "files": ["dist"],
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js",
14
+ "default": "./dist/index.mjs"
15
+ }
16
+ },
17
+ "scripts": {
18
+ "build": "tsup src/index.ts",
19
+ "deploy": "npm run build && npm publish --access public"
20
+ },
21
+ "dependencies": {
22
+ "axios": "^1.9.0",
23
+ "decimal.js": "^10.5.0",
24
+ "zod": "^4.1.1"
25
+ },
26
+ "devDependencies": {
27
+ "@shared/config": "*",
28
+ "@shared/core": "*",
29
+ "@shared/product": "*",
30
+ "@types/node": "^24.1.0",
31
+ "tsup": "^8.5.0",
32
+ "typescript": "^5.9.2"
33
+ },
34
+ "repository": {
35
+ "type": "git"
36
+ },
37
+ "keywords": [
38
+ "pumptech",
39
+ "sdk",
40
+ "typescript",
41
+ "node"
42
+ ],
43
+ "author": "pumptech",
44
+ "license": "MIT"
45
+ }