Skip to content

Commit 2f20b23

Browse files
authored
Merge pull request #20 from privy-open-source/fix/validate-name-call
fix(ghostscript): validate rpc call name
2 parents c113f09 + bef06f8 commit 2f20b23

File tree

1 file changed

+4
-1
lines changed
  • packages/ghoulscript/src/rpc

1 file changed

+4
-1
lines changed

packages/ghoulscript/src/rpc/call.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import * as core from '../core'
22

33
export type Core = typeof core
44

5-
export type Commands = keyof Core
5+
export type Commands = keyof Core & string
66

77
export type CommandArgs<C extends Commands> = Parameters<Core[C]>
88

99
export type CommandResult<C extends Commands> = ReturnType<Core[C]>
1010

1111
export async function callRPC<C extends Commands> (name: C, args: CommandArgs<C>): Promise<CommandResult<C>> {
12+
if (typeof core[name] !== 'function')
13+
throw new TypeError(`Invalid action: "${name}"`)
14+
1215
return await (core[name] as (...args: any[]) => Promise<any>)(...args)
1316
}

0 commit comments

Comments
 (0)