From: Chris Duncan Date: Wed, 5 Aug 2026 01:00:41 +0000 (-0700) Subject: Validate subtype of frontier blocks. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=81a585f3a0ebfe6f4205ea07c2df552b873bdf62;p=libnemo.git Validate subtype of frontier blocks. --- diff --git a/src/lib/account/refresh.ts b/src/lib/account/refresh.ts index b79dd45..f956dc8 100644 --- a/src/lib/account/refresh.ts +++ b/src/lib/account/refresh.ts @@ -46,6 +46,9 @@ export async function _refresh (account: Account, rpc: unknown): Promise { throw new Error('Confirmed frontier block info subtype not found') } const confirmedFrontierSubtype = resConfirmedFrontierBlockInfo.subtype + if (!['change', 'epoch', 'open', 'receive', 'send'].includes(confirmedFrontierSubtype) { + throw new RangeError('Invalid subtype for confirmed frontier block', { cause: confirmedFrontierSubtype }) + } if (!('contents' in resConfirmedFrontierBlockInfo) || resConfirmedFrontierBlockInfo.contents == null || typeof resConfirmedFrontierBlockInfo.contents !== 'object') { throw new Error('Confirmed frontier block info contents not found') } @@ -74,6 +77,9 @@ export async function _refresh (account: Account, rpc: unknown): Promise { throw new Error('Frontier block info subtype not found') } const frontierSubtype = resFrontierBlockInfo.subtype + if (!['change', 'epoch', 'open', 'receive', 'send'].includes(frontierSubtype) { + throw new RangeError('Invalid subtype for frontier block', { cause: frontierSubtype }) + } if (!('contents' in resFrontierBlockInfo) || resFrontierBlockInfo.contents == null || typeof resFrontierBlockInfo.contents !== 'object') { throw new Error('Frontier block info contents not found') }