Function expandTemplatePermissions

  • Expands template-based permissions into concrete datamanager permissions.

    Entries of the form dm:template-<templateID>:<rest> are replaced with one dm:<dataManagerID>:<rest> per datamanager created from that template (looked up via getTemplateDataManagers, cached ~5 min). All other permission strings pass through unchanged. The result is deduplicated while preserving order.

    The fdk deliberately does no matching itself (no shiro-trie, no dm: parsing beyond this expansion): the returned array is still raw data to be fed into your own matcher on the consumer side. Run raw account permissions through this helper before matching whenever template grants may be present.

    Fail-closed: entries with an invalid (non-v4) template UUID are left untouched, and if the lookup route fails for a template, its entries stay unexpanded (raw dm:template-… string) instead of throwing — so a transient outage never silently widens or drops access.

    Parameters

    Returns Promise<string[]>

    import { fdk, expandTemplatePermissions } from "ec.fdk";
    const raw = await fdk("stage").token(token).dm("83cc6374").getPermissions();
    const perms = await expandTemplatePermissions({ env: "stage", token }, raw);
    // pair `perms` with shiro-trie (or any matcher) on the consumer side