asdfasdf
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import z from "zod";
|
||||
import { createHonoRoute } from "../../../util/import.ts";
|
||||
import { authenticate } from "../../../util/api.ts";
|
||||
import { authenticate, statusResponse } from "../../../util/api.ts";
|
||||
import { typedZValidator } from "../../../util/validators.ts";
|
||||
import Server from "../../../server/server.ts";
|
||||
import { HTTPStatus } from "@oneday/http-status";
|
||||
|
||||
export const route = createHonoRoute("/players");
|
||||
|
||||
@@ -13,8 +14,10 @@ route.app.get('/v2/progression/bulk', c => {
|
||||
const getProgParamSchema = z.object({
|
||||
id: z.coerce.number()
|
||||
});
|
||||
route.app.get('/v1/progression/:id', authenticate, typedZValidator('param', getProgParamSchema), async c => {
|
||||
return c.json(await c.get('profile').Progression.get());
|
||||
route.app.get('/v1/progression/:id', typedZValidator('param', getProgParamSchema), async c => {
|
||||
const prof = await Server.Profiles.get(c.req.valid('param').id);
|
||||
if (!prof) return statusResponse(c, HTTPStatus.NotFound);
|
||||
return c.json(await prof.Progression.get());
|
||||
});
|
||||
|
||||
const getProgBulkBodySchema = z.object({
|
||||
|
||||
21
src/routes/api/routes/storefronts.ts
Normal file
21
src/routes/api/routes/storefronts.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import z from "zod";
|
||||
import { authenticate } from "../../../util/api.ts";
|
||||
import { createHonoRoute } from "../../../util/import.ts";
|
||||
import { transformCheckEnum, typedZValidator } from "../../../util/validators.ts";
|
||||
import { CurrencyType, StorefrontBalanceType, StorefrontTypes } from "../../../server/storefronts/types.ts";
|
||||
|
||||
export const route = createHonoRoute("/storefronts");
|
||||
|
||||
const getGiftDropStoreParamSchema = z.object({
|
||||
storeId: z.coerce.number().transform(transformCheckEnum<StorefrontTypes>(StorefrontTypes))
|
||||
});
|
||||
route.app.get('/v3/giftdropstore/:storeId', authenticate, typedZValidator('param', getGiftDropStoreParamSchema), c => {
|
||||
return c.json({ StoreItems: [] }); // stub
|
||||
});
|
||||
|
||||
const getCurrencyByTypeParamSchema = z.object({
|
||||
currencyType: z.coerce.number().transform(transformCheckEnum<CurrencyType>(CurrencyType))
|
||||
});
|
||||
route.app.get('/v4/balance/:currencyType', authenticate, typedZValidator('param', getCurrencyByTypeParamSchema), c => {
|
||||
return c.json([ { Balance: 0, CurrencyType: c.req.valid('param').currencyType, BalanceType: StorefrontBalanceType.NonPurchasedNonP2P } ]); // stub
|
||||
});
|
||||
@@ -35,7 +35,8 @@ const authBodyBaseSchema = z.object({
|
||||
} catch {
|
||||
ctx.addIssue("Steam Auth Ticket could not be parsed");
|
||||
}
|
||||
})
|
||||
}),
|
||||
"x-patch-plugin-hash": z.string()
|
||||
});
|
||||
|
||||
const cachedLoginGrantSchema = authBodyBaseSchema.extend({
|
||||
@@ -80,6 +81,7 @@ route.app.post('/token', typedZValidator('form', tokenGrantSchema), async c => {
|
||||
|
||||
const form = c.req.valid('form');
|
||||
if (typeof form.platform_auth == 'undefined' || typeof form.platform == 'undefined') return error(TokenRequestError.AccessDenied);
|
||||
if (typeof form.device_class !== 'number') return error(TokenRequestError.AccessDenied);
|
||||
|
||||
const { valid } = await Steam.AuthenticateUserTicket(form.platform_auth, form.platform_id);
|
||||
if (valid == SteamAuthResult.Failure) return error(TokenRequestError.AccessDenied, TokenRequestErrorDescriptions.PlatformVerificationFailed);
|
||||
@@ -99,6 +101,8 @@ route.app.post('/token', typedZValidator('form', tokenGrantSchema), async c => {
|
||||
const profile = await Server.Profiles.get(token.sub);
|
||||
if (!profile) return error(TokenRequestError.AccessDenied);
|
||||
|
||||
await profile.Matchmaking.setLastDeviceClass(form.device_class!);
|
||||
|
||||
return c.json({
|
||||
access_token: await Server.Platforms.getToken(profile, TokenType.Access),
|
||||
refresh_token: await Server.Platforms.getToken(profile, TokenType.Refresh),
|
||||
@@ -113,7 +117,9 @@ route.app.post('/token', typedZValidator('form', tokenGrantSchema), async c => {
|
||||
const profile = await Server.Profiles.get(form.account_id);
|
||||
if (!profile) return error(TokenRequestError.InvalidRequest, "No such profile");
|
||||
await Server.Platforms.updateLastLoginTime(form.platform, form.platform_id, form.account_id);
|
||||
await profile.Matchmaking.setLastDeviceClass(form.device_class!);
|
||||
|
||||
log.d(`Patch hash: ${form["x-patch-plugin-hash"]}`);
|
||||
return c.json({
|
||||
access_token: await Server.Platforms.getToken(profile, TokenType.Access),
|
||||
refresh_token: await Server.Platforms.getToken(profile, TokenType.Refresh),
|
||||
|
||||
Reference in New Issue
Block a user