279 lines
5.5 KiB
TypeScript
279 lines
5.5 KiB
TypeScript
import { z } from "zod";
|
|
import type { integer } from "types/misc";
|
|
|
|
export const PowerOnRequestV1Schema = z.object({
|
|
game_id: z.string().max(5),
|
|
ver: z.string().max(5),
|
|
serial: z.string().max(11),
|
|
ip: z.string().ip(),
|
|
firm_ver: z.coerce.number().optional(),
|
|
boot_ver: z.coerce.number().optional(),
|
|
encode: z.enum(["Shift_JIS", "EUC-JP", "UTF-8"]).default("EUC-JP"),
|
|
format_ver: z.literal("1"),
|
|
hops: z.coerce.number().default(-1),
|
|
});
|
|
|
|
export type PowerOnRequestV1 = z.infer<typeof PowerOnRequestV1Schema>;
|
|
|
|
export const PowerOnRequestV2Schema = PowerOnRequestV1Schema.extend({
|
|
format_ver: z.literal("2"),
|
|
});
|
|
|
|
export type PowerOnRequestV2 = z.infer<typeof PowerOnRequestV2Schema>;
|
|
|
|
export const PowerOnRequestV3Schema = PowerOnRequestV2Schema.extend({
|
|
format_ver: z.literal("3"),
|
|
token: z.string().optional(),
|
|
});
|
|
|
|
export type PowerOnRequestV3 = z.infer<typeof PowerOnRequestV3Schema>;
|
|
|
|
export const PowerOnRequestV5Schema = z.object({
|
|
title_id: z.string().max(5),
|
|
title_ver: z.string().max(5),
|
|
machine: z.string().max(11),
|
|
firm_ver: z.coerce.number().optional(),
|
|
boot_ver: z.coerce.number().optional(),
|
|
encode: z.enum(["Shift_JIS", "EUC-JP", "UTF-8"]).default("EUC-JP"),
|
|
format_ver: z.literal("5"),
|
|
hops: z.coerce.number().default(-1),
|
|
token: z.string().optional(),
|
|
});
|
|
|
|
export type PowerOnRequestV5 = z.infer<typeof PowerOnRequestV5Schema>;
|
|
|
|
export const PowerOnRequestChinaSchema = z.object({
|
|
game_id: z.string().max(5),
|
|
game_ver: z.string().max(5),
|
|
machine: z.string().max(11),
|
|
server: z.string(),
|
|
firm_ver: z.coerce.number().optional(),
|
|
boot_ver: z.coerce.number().optional(),
|
|
encode: z.enum(["Shift_JIS", "EUC-JP", "UTF-8"]).default("EUC-JP"),
|
|
format_ver: z.literal("3"),
|
|
hops: z.coerce.number().default(-1),
|
|
token: z.string().optional(),
|
|
});
|
|
|
|
export type PowerOnRequestChina = z.infer<typeof PowerOnRequestChinaSchema>;
|
|
|
|
export const PowerOnRequestV6Schema = PowerOnRequestV3Schema.extend({
|
|
format_ver: z.literal("6"),
|
|
auth_data: z.string().max(1535),
|
|
});
|
|
|
|
export type PowerOnRequestV6 = z.infer<typeof PowerOnRequestV6Schema>;
|
|
|
|
export const enum PowerOnStat {
|
|
SUCCESS = 1,
|
|
GAME_ERROR = -1,
|
|
BOARD_ERROR = -2,
|
|
LOCATION_ERROR = -3,
|
|
}
|
|
|
|
export interface PowerOnResponseV1 {
|
|
/**
|
|
* ALL.Net authentication status
|
|
*/
|
|
stat: PowerOnStat;
|
|
|
|
/**
|
|
* The arcade's place ID, encoded as an uppercase hexadecimal string.
|
|
*/
|
|
place_id: string;
|
|
|
|
/**
|
|
* Title server URI. Will be present, but empty, if authentication
|
|
* is not successful.
|
|
*/
|
|
uri: string;
|
|
|
|
/**
|
|
* Title server hostname. Will be present, but empty, if authentication
|
|
* is not successful.
|
|
*
|
|
* @note The hostname (if present) in URI is only used for name resolution.
|
|
* This value is passed to the title server in the `Host` header, and can be
|
|
* utilized as an extra authentication step.
|
|
*/
|
|
host: string;
|
|
|
|
/**
|
|
* ALL.Net location name
|
|
*
|
|
* @note URL-encoded UTF-8.
|
|
*/
|
|
name: string;
|
|
|
|
/**
|
|
* ALL.Net location nickname
|
|
*
|
|
* @note URL-encoded UTF-8.
|
|
*/
|
|
nickname: string;
|
|
|
|
/**
|
|
* Server time's year
|
|
*/
|
|
year: integer;
|
|
|
|
/**
|
|
* Server time's month
|
|
*/
|
|
month: integer;
|
|
|
|
/**
|
|
* Server time's day
|
|
*/
|
|
day: integer;
|
|
|
|
/**
|
|
* Server time's hour
|
|
*/
|
|
hour: integer;
|
|
|
|
/**
|
|
* Server time's minute
|
|
*/
|
|
minute: integer;
|
|
|
|
/**
|
|
* Server time's second
|
|
*/
|
|
second: integer;
|
|
|
|
/**
|
|
* Game-specific setting.
|
|
*
|
|
* @note In practice this appears to be used as a "network allowed" flag.
|
|
* If ever unsure, specify this field as `1`.
|
|
*/
|
|
setting: integer;
|
|
|
|
/**
|
|
* Region code
|
|
*/
|
|
region0: integer;
|
|
|
|
/**
|
|
* Region 1
|
|
*
|
|
* @note URL-encoded UTF-8.
|
|
*/
|
|
region_name0: string;
|
|
|
|
/**
|
|
* Region 2
|
|
*
|
|
* @note URL-encoded UTF-8.
|
|
*/
|
|
region_name1: string;
|
|
|
|
/**
|
|
* Region 3
|
|
*
|
|
* @note URL-encoded UTF-8.
|
|
*/
|
|
region_name2: string;
|
|
|
|
/**
|
|
* Region 4
|
|
*
|
|
* @note URL-encoded UTF-8.
|
|
*/
|
|
region_name3: string;
|
|
}
|
|
|
|
export interface PowerOnResponseV2 extends PowerOnResponseV1 {
|
|
/**
|
|
* Country code
|
|
*/
|
|
country: string;
|
|
|
|
timezone: "+09:00";
|
|
|
|
res_class: "PowerOnResponseVer2";
|
|
}
|
|
|
|
export interface PowerOnResponseV3
|
|
extends Omit<
|
|
PowerOnResponseV2,
|
|
"day" | "hour" | "minute" | "month" | "res_class" | "second" | "timezone" | "year"
|
|
> {
|
|
res_ver: 3;
|
|
|
|
/**
|
|
* ALL.Net ID
|
|
*/
|
|
allnet_id: integer;
|
|
|
|
/**
|
|
* Authentication time. Format must be `yyyy-MM-dd'T'HH:mm:ss'Z'`.
|
|
*/
|
|
utc_time: string;
|
|
|
|
/**
|
|
* @example `+0900`
|
|
*/
|
|
client_timezone: string;
|
|
|
|
/**
|
|
* Echoes the request token. The literal `null` will be used if token is not
|
|
* present in request.
|
|
*/
|
|
token: string;
|
|
}
|
|
|
|
export interface PowerOnResponseV5
|
|
extends Omit<PowerOnResponseV3, "host" | "res_ver" | "stat" | "uri"> {
|
|
res_ver: 5;
|
|
|
|
/**
|
|
* ALL.Net authentication status
|
|
*/
|
|
result: PowerOnStat;
|
|
|
|
/**
|
|
* Title server URI. Will be present, but empty, if authentication
|
|
* is not successful.
|
|
*/
|
|
title_uri: string;
|
|
|
|
/**
|
|
* Title server hostname. Will be present, but empty, if authentication
|
|
* is not successful.
|
|
*
|
|
* @note The hostname (if present) in URI is only used for name resolution.
|
|
* This value is passed to the title server in the `Host` header, and can be
|
|
* utilized as an extra authentication step.
|
|
*/
|
|
title_host: string;
|
|
}
|
|
|
|
export interface PowerOnResponseChina
|
|
extends Omit<PowerOnResponseV3, "client_timezone" | "country" | "host" | "stat" | "uri"> {
|
|
/**
|
|
* ALL.Net authentication status
|
|
*/
|
|
result: PowerOnStat;
|
|
|
|
/**
|
|
* Title server URI 1
|
|
*/
|
|
uri1: string;
|
|
|
|
/**
|
|
* Title server URI 2
|
|
*/
|
|
uri2: string;
|
|
|
|
country: "CHN";
|
|
|
|
client_timezone: "+800";
|
|
}
|
|
|
|
export interface PowerOnResponseV6 {
|
|
auth_data: string;
|
|
packet_data: string;
|
|
}
|