Firebase hosting with cloud functions - how to purge/refresh CDN cache?

I inadvertently found the answer while trying to fix another issue.

You need to be on a paid Firebase plan to make external API calls: https://firebase.google.com/pricing/

So the PURGE method does work so long as you have upgraded you plan. Here is the code that allows you to purge the CDN (Node.js in Typescript):

import * as request from "request-promise";

const purgeUrl = `examplesite.com`;
await request(purgeUrl, { method: "PURGE" });

Simply execute a curl command:

curl -X PURGE https://yoursite.com/path