Add iOS node push-token registration foundation

This commit is contained in:
William Valentin
2026-02-16 12:47:34 -08:00
parent bea4c54f3b
commit 58c4b0b9bb
19 changed files with 448 additions and 7 deletions
+38
View File
@@ -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 };
}