Fetch URL of customer account programmatically

Has anyone had any success fetching the URL of the customer account (new, not legacy) of a store programmatically as an app?

From what I understand, the URL pattern is either https://shopify.com/:shopId/account or https://:custom.store-domain.com(if set up).

In the Shopify admin, under Settings > Customer accounts, the respective URL is displayed. But can it also be fetched programmatically?

https://shopify.com/:storeId/pages/:uuid-of-my-customer-account-ui-extension appears to always properly redirect, even if a custom domain is set up, so fetching the shop ID programmatically would probably be sufficient here.

PS. I am aware that https://store-domain.com/account always links to the customer account, regardless of whether a custom domain is set up or not. But this is not sufficient because my use case is providing ready-to-use links to customer account extensions (e.g. https://:custom.store-domain.com/pages/:uuid-of-my-customer-account-ui-extension)