mirror of
https://github.com/djhackersdev/minime.git
synced 2026-04-24 23:47:21 -05:00
aimedb: Stub a FeliCa lookup response
This commit is contained in:
parent
af8cdf3072
commit
9dd45558ec
|
|
@ -19,6 +19,15 @@ function readRegisterRequest(msg: Buffer): Request.RegisterRequest {
|
|||
};
|
||||
}
|
||||
|
||||
function readFeliCaLookupRequest(msg: Buffer): Request.FeliCaLookupRequest {
|
||||
return {
|
||||
...begin(msg),
|
||||
type: "felica_lookup",
|
||||
idm: msg.slice(0x0020, 0x0028).toString("hex"),
|
||||
pmm: msg.slice(0x0028, 0x0030).toString("hex"),
|
||||
};
|
||||
}
|
||||
|
||||
function readLogRequest(msg: Buffer): Request.LogRequest {
|
||||
// idk what any of this stuff means yet
|
||||
// field20 and field28 appear to be an aime id but that is all.
|
||||
|
|
@ -79,6 +88,7 @@ function readGoodbyeRequest(msg: Buffer): Request.GoodbyeRequest {
|
|||
|
||||
const readers = new Map<number, (msg: Buffer) => Request.AimeRequest>();
|
||||
|
||||
readers.set(0x0001, readFeliCaLookupRequest);
|
||||
readers.set(0x0004, readLookupRequest);
|
||||
readers.set(0x0005, readRegisterRequest);
|
||||
readers.set(0x0009, readLogRequest);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,14 @@ export class Encoder extends Transform {
|
|||
let buf: Buffer;
|
||||
|
||||
switch (msg.type) {
|
||||
case "felica_lookup":
|
||||
buf = begin(0x0030);
|
||||
buf.writeUInt16LE(0x0003, 0x0004); // cmd code
|
||||
buf.writeUInt16LE(msg.status, 0x0008);
|
||||
buf.write(msg.accessCode, 0x0024, "hex");
|
||||
|
||||
break;
|
||||
|
||||
case "hello":
|
||||
buf = begin(0x0020);
|
||||
buf.writeUInt16LE(0x0065, 0x0004); // cmd code
|
||||
|
|
@ -92,6 +100,8 @@ export class Encoder extends Transform {
|
|||
break;
|
||||
|
||||
default:
|
||||
const exhaust: never = msg;
|
||||
|
||||
return callback(new Error("Unimplemented response type"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,18 @@ function campaign(
|
|||
return { type: req.type, status: 1 };
|
||||
}
|
||||
|
||||
function feliCaLookup(
|
||||
rep: Repositories,
|
||||
req: Req.FeliCaLookupRequest,
|
||||
now: Date
|
||||
): Res.FeliCaLookupResponse {
|
||||
console.log("Aimedb: FeliCa access code lookup");
|
||||
|
||||
// Well, this access code transformation is the million dollar question eh
|
||||
|
||||
return { type: req.type, status: 1, accessCode: "00010203040506070809" };
|
||||
}
|
||||
|
||||
async function lookup(
|
||||
rep: Repositories,
|
||||
req: Req.LookupRequest,
|
||||
|
|
@ -88,6 +100,9 @@ export async function dispatch(
|
|||
case "campaign":
|
||||
return campaign(rep, req, now);
|
||||
|
||||
case "felica_lookup":
|
||||
return feliCaLookup(rep, req, now);
|
||||
|
||||
case "lookup":
|
||||
return lookup(rep, req, now);
|
||||
|
||||
|
|
@ -106,6 +121,8 @@ export async function dispatch(
|
|||
return undefined;
|
||||
|
||||
default:
|
||||
const exhaust: never = req;
|
||||
|
||||
throw new Error("Aimedb: Handler not implemented!");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@ export interface AimeRequestBase {
|
|||
keychipId: string;
|
||||
}
|
||||
|
||||
export interface FeliCaLookupRequest extends AimeRequestBase {
|
||||
type: "felica_lookup";
|
||||
idm: string;
|
||||
pmm: string;
|
||||
}
|
||||
|
||||
export interface RegisterRequest extends AimeRequestBase {
|
||||
type: "register";
|
||||
luid: string;
|
||||
|
|
@ -43,6 +49,7 @@ export interface GoodbyeRequest {
|
|||
}
|
||||
|
||||
export type AimeRequest =
|
||||
| FeliCaLookupRequest
|
||||
| CampaignRequest
|
||||
| GoodbyeRequest
|
||||
| HelloRequest
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ export interface AimeResponseBase {
|
|||
status: number;
|
||||
}
|
||||
|
||||
export interface FeliCaLookupResponse extends AimeResponseBase {
|
||||
type: "felica_lookup";
|
||||
accessCode: string;
|
||||
}
|
||||
|
||||
export interface CampaignResponse extends AimeResponseBase {
|
||||
type: "campaign";
|
||||
}
|
||||
|
|
@ -38,6 +43,7 @@ export interface RegisterResponse extends AimeResponseBase {
|
|||
}
|
||||
|
||||
export type AimeResponse =
|
||||
| FeliCaLookupResponse
|
||||
| CampaignResponse
|
||||
| HelloResponse
|
||||
| LogResponse
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user