The CLI may have something similar to this function (see `pg:credentials`).