Seems like someone has already worked on an implementation. Linking it here for anyone else that may need it.