]> git.codecow.com Git - libnemo.git/commitdiff
Validate subtype of frontier blocks.
authorChris Duncan <chris@codecow.com>
Wed, 5 Aug 2026 01:00:41 +0000 (18:00 -0700)
committerChris Duncan <chris@codecow.com>
Wed, 5 Aug 2026 01:00:41 +0000 (18:00 -0700)
src/lib/account/refresh.ts

index b79dd4599beb1370d956ca0b1de67309cbd55ad3..f956dc814976a8de4e885f362bc5e6d0f7788a90 100644 (file)
@@ -46,6 +46,9 @@ export async function _refresh (account: Account, rpc: unknown): Promise<void> {
                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<void> {
                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')
        }