Add iOS node push-token registration foundation
This commit is contained in:
@@ -44,6 +44,14 @@ export interface NodeStatusSetParams {
|
||||
powerSource?: 'ac' | 'battery' | 'unknown';
|
||||
}
|
||||
|
||||
export interface NodePushTokenSetParams {
|
||||
connectionId: string;
|
||||
provider: 'apns';
|
||||
token: string;
|
||||
topic?: string;
|
||||
environment?: 'sandbox' | 'production';
|
||||
}
|
||||
|
||||
// ── Server → Client ────────────────────────────────────────────
|
||||
|
||||
export interface GatewayResponse {
|
||||
@@ -293,6 +301,36 @@ export function parseNodeStatusSetParams(params: unknown): NodeStatusSetParams |
|
||||
};
|
||||
}
|
||||
|
||||
export function parseNodePushTokenSetParams(params: unknown): NodePushTokenSetParams | null {
|
||||
if (!params || typeof params !== 'object') {
|
||||
return null;
|
||||
}
|
||||
const p = params as Record<string, unknown>;
|
||||
if (typeof p.connectionId !== 'string' || !p.connectionId.trim()) {
|
||||
return null;
|
||||
}
|
||||
if (p.provider !== 'apns') {
|
||||
return null;
|
||||
}
|
||||
if (typeof p.token !== 'string' || p.token.trim().length < 16) {
|
||||
return null;
|
||||
}
|
||||
if (p.topic !== undefined && typeof p.topic !== 'string') {
|
||||
return null;
|
||||
}
|
||||
if (p.environment !== undefined && p.environment !== 'sandbox' && p.environment !== 'production') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
connectionId: p.connectionId,
|
||||
provider: 'apns',
|
||||
token: p.token.trim(),
|
||||
topic: typeof p.topic === 'string' ? p.topic.trim() : undefined,
|
||||
environment: p.environment as NodePushTokenSetParams['environment'] | undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function makeResponse(id: number, result: unknown): GatewayResponse {
|
||||
return { id, result };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user