diff --git a/src/codec.ts b/src/codec.ts index 3bfa8a2..0d9c6d3 100644 --- a/src/codec.ts +++ b/src/codec.ts @@ -128,7 +128,7 @@ export function decodeBuiltin(raw: string): BuiltinEnvelope { throw new CodecError("Missing or invalid 'type' field in envelope"); } - return envelope as BuiltinEnvelope; + return envelope as unknown as BuiltinEnvelope; } catch (cause) { if (cause instanceof CodecError) { throw cause; diff --git a/src/types.ts b/src/types.ts index ea4d261..f7a7618 100644 --- a/src/types.ts +++ b/src/types.ts @@ -22,7 +22,7 @@ export type BuiltinMessageType = (typeof builtinMessageTypes)[number]; export interface BuiltinEnvelope< TType extends BuiltinMessageType = BuiltinMessageType, - TPayload extends Record = Record + TPayload = Record > { type: TType; requestId?: string; @@ -30,7 +30,7 @@ export interface BuiltinEnvelope< payload?: TPayload; } -export interface HelloPayload { +export interface HelloPayload extends Record { identifier: string; hasSecret: boolean; hasKeyPair: boolean; @@ -44,14 +44,14 @@ export type HelloAckNextAction = | "rejected" | "waiting_pair_confirm"; -export interface HelloAckPayload { +export interface HelloAckPayload extends Record { identifier: string; nextAction: HelloAckNextAction; } export type AdminNotificationStatus = "sent" | "failed"; -export interface PairRequestPayload { +export interface PairRequestPayload extends Record { identifier: string; expiresAt: number; ttlSeconds: number; @@ -59,12 +59,12 @@ export interface PairRequestPayload { codeDelivery: "out_of_band"; } -export interface PairConfirmPayload { +export interface PairConfirmPayload extends Record { identifier: string; pairingCode: string; } -export interface PairSuccessPayload { +export interface PairSuccessPayload extends Record { identifier: string; secret: string; pairedAt: number; @@ -77,12 +77,12 @@ export type PairFailedReason = | "admin_notification_failed" | "internal_error"; -export interface PairFailedPayload { +export interface PairFailedPayload extends Record { identifier: string; reason: PairFailedReason; } -export interface AuthRequestPayload { +export interface AuthRequestPayload extends Record { identifier: string; nonce: string; proofTimestamp: number; @@ -90,7 +90,7 @@ export interface AuthRequestPayload { publicKey?: string; } -export interface AuthSuccessPayload { +export interface AuthSuccessPayload extends Record { identifier: string; authenticatedAt: number; status: "online"; @@ -107,33 +107,33 @@ export type AuthFailedReason = | "rate_limited" | "re_pair_required"; -export interface AuthFailedPayload { +export interface AuthFailedPayload extends Record { identifier: string; reason: AuthFailedReason; } -export interface RePairRequiredPayload { +export interface RePairRequiredPayload extends Record { identifier: string; reason: "nonce_collision" | "rate_limited" | "trust_revoked"; } -export interface HeartbeatPayload { +export interface HeartbeatPayload extends Record { identifier: string; status: "alive"; } -export interface HeartbeatAckPayload { +export interface HeartbeatAckPayload extends Record { identifier: string; status: "online" | "unstable" | "offline"; } -export interface StatusUpdatePayload { +export interface StatusUpdatePayload extends Record { identifier: string; status: "online" | "unstable" | "offline"; reason: string; } -export interface DisconnectNoticePayload { +export interface DisconnectNoticePayload extends Record { identifier: string; reason: string; } @@ -152,7 +152,7 @@ export type ProtocolErrorCode = | "CLIENT_OFFLINE" | "INTERNAL_ERROR"; -export interface ErrorPayload { +export interface ErrorPayload extends Record { code: ProtocolErrorCode; message?: string; details?: Record;