{"id":869,"date":"2018-12-10T18:00:01","date_gmt":"2018-12-10T17:00:01","guid":{"rendered":"https:\/\/blog.wojtek.pro\/?p=869"},"modified":"2018-12-10T18:00:01","modified_gmt":"2018-12-10T17:00:01","slug":"javascript-for-aad-b2c-custom-ui-public-preview","status":"publish","type":"post","link":"https:\/\/wojtek.pro\/?p=869","title":{"rendered":"JavaScript for AAD B2C custom UI &#8211; public preview"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A news from the AAD B2C world at last! It&#8217;s only a preview but still &#8211; a new feature is a new feature.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Technically two features are moving to a public preview phase:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Page contracts<\/li><li>JavaScript<\/li><\/ul>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">Page contracts allow to choose a specific data contract version so in case of a change the policy behaviour remains the same. You need to move to a newly published contract explicitly by updating the code of the custom policy. This is production-good &#8211; no (or at least less) unexpected changes from the underlying code.<br>Switching to page contracts (requires updating custom policy code) allows enabling of JavaScript too.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enabling custom JavaScript in UI templates for custom policies opens a ton of possibilities. Not without restrictions though. I don&#8217;t want to retype <a rel=\"noreferrer noopener\" aria-label=\"Enabling custom JavaScript in UI templates for custom policies opens a ton of possibilities. Not without restrictions though. I don't want to retype documentation but can't resist from giving a small glimpse in what it can (and cannot) do: (opens in a new tab)\" href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/active-directory-b2c\/javascript-samples\" target=\"_blank\">documentation<\/a> but can&#8217;t resist from giving a small glimpse in what it can&nbsp; do:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>call any REST API (unlimited power!)<\/li><li>read AAD B2C parameters from the <em>window<\/em> object properties (useful to check things like locale or current policy)<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">and what it can&#8217;t:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>bind clicks on &lt;a&gt; elements (yes, application developers still need to handle error after &#8220;Forgot your password?&#8221;)<\/li><li>most JS frameworks are not supported (now this is intriguing, I will investigate which ones fall into the supported minority)<\/li><li>change order of HTML elements (pity, some of them could use reordering instead of arguably clean CSS tricks)<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Or maybe it can but you just shouldn&#8217;t try for your own good? That&#8217;s yet to be verified with a help from someone better with JS than me.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now I&#8217;m eager to check if my wild ideas can work despite a list of limitations. Can&#8217;t wait to give them a try!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A news from the AAD B2C world at last! It&#8217;s only a preview but still &#8211; a new feature is a new feature. Technically two features are moving to a public preview phase: Page contracts JavaScript<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[21,24,62,83,91],"class_list":["post-869","post","type-post","status-publish","format-standard","hentry","category-news","tag-azure","tag-b2c","tag-identity","tag-news","tag-policies"],"_links":{"self":[{"href":"https:\/\/wojtek.pro\/index.php?rest_route=\/wp\/v2\/posts\/869","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wojtek.pro\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wojtek.pro\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wojtek.pro\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wojtek.pro\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=869"}],"version-history":[{"count":0,"href":"https:\/\/wojtek.pro\/index.php?rest_route=\/wp\/v2\/posts\/869\/revisions"}],"wp:attachment":[{"href":"https:\/\/wojtek.pro\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wojtek.pro\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wojtek.pro\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}