PageSourceSearch

https://avisendanmark.dk/assets/1790063100/kodus/jfm-site/js/app/pugpigAutologin.js

js avisendanmark.dk collected 2026-09-24 17:13:43 UTC 9,155 bytes, 1 lines download raw bytes

1var pugpigAutologin;(()=>{"use strict";var t={entries:[],log:function(e){var n,o,i=e;(void 0===i?"undefined":(n=i)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)=="object"&&(i=JSON.stringify(i,void 0,2)),t.entries.push(i);var r=document.createElement("li");r.classList.add("js-logger__item"),r.innerHTML=i,null==(o=document.querySelector("[data-log-list] ul"))||o.append(r)}},e="blaize_jwt";let n={parseJwt:function(t){var e,n=t.split(".");if(3!==n.length)throw Error("[AuthToken:parseJwt] Invalid JWT format: expected 3 parts (header.payload.signature)");var o=n[1];try{var i=atob(o);e=JSON.parse(i)}catch(t){var r,a=(null!=(r=Error)&&"u">typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](t):t instanceof r)?t.message:String(t);throw Error("[AuthToken:parseJwt] Failed to decode JWT payload: ".concat(a))}if(!e.sub||"string"!=typeof e.sub)throw Error('[AuthToken:parseJwt] Missing or invalid "sub" claim');if("string"!=typeof e.user_session)throw Error('[AuthToken:parseJwt] Missing or invalid "user_session" claim');if(!Array.isArray(e.entitlements))throw Error('[AuthToken:parseJwt] Missing or invalid "entitlements" claim (must be an array)');if("aid"!==e.user_type&&"zephr"!==e.user_type)throw Error('[AuthToken:parseJwt] Invalid "user_type" claim (must be "aid" or "zephr")');return{sub:e.sub,userSession:e.user_session,entitlements:e.entitlements,userType:e.user_type}},getJwtPayload:function(){var n=document.cookie.split("; ").find(function(t){return t.startsWith("".concat(e,"="))});if(!n)return t.log("[AuthToken] No ".concat(e," cookie found")),null;var o=n.split("=")[1];if(!o)return t.log("[AuthToken] No ".concat(e," cookie value found")),null;try{return this.parseJwt(o)}catch(t){console.error("Failed to parse JWT:",t)}return null},isLoggedIn:function(){return null!==this.getJwtPayload()},getUserType:function(){var e,n=this.getJwtPayload(),o=null!=(e=null==n?void 0:n.userType)?e:null;return o||t.log("[AuthToken] Unable to determine user type: no JWT payload found"),o}};function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}function i(t,e,n,o,i,r,a){try{var u=t[r](a),s=u.value}catch(t){n(t);return}u.done?e(s):Promise.resolve(s).then(o,i)}function r(t){return function(){var e=this,n=arguments;return new Promise(function(o,r){var a=t.apply(e,n);function u(t){i(a,o,r,u,s,"next",t)}function s(t){i(a,o,r,u,s,"throw",t)}u(void 0)})}}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,o,i=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r=[],a=!0,u=!1;try{for(i=i.call(t);!(a=(n=i.next()).done)&&(r.push(n.value),!e||r.length!==e);a=!0);}catch(t){u=!0,o=t}finally{try{a||null==i.return||i.return()}finally{if(u)throw o}}return r}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,e){var n,o,i,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:s(0)}),u(a,"throw",{value:s(1)}),u(a,"return",{value:s(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function s(u){return function(s){var l=[u,s];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(r=0)),r;)try{if(n=1,o&&(i=2&l[0]?o.return:l[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,l[1])).done)return i;switch(o=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,o=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(!(i=(i=r.trys).length>0&&i[i.length-1])&&(6===l[0]||2===l[0])){r=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){r.label=l[1];break}if(6===l[0]&&r.label<i[1]){r.label=i[1],i=l;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(l);break}i[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(t){l=[6,t],o=0}finally{n=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var s=function(){window.redirectAttempted=!0;var t=new Event("sso_redirect_attempted");document.dispatchEvent(t)};({isPugpigContext:function(){return void 0!==window.parent&&void 0!==window.parent.pugpigBridgeService&&"function"==typeof window.parent.pugpigBridgeService.authorisationStatus},extractOAuthToken:function(e){var n=e.token||"unknown";return n&&"unknown"!==n?n:(t.log("[PugpigAutoLogin] Invalid or missing OAuth token found in payload"),null)},extractZephrSessionFromOAuthToken:function(e){try{var o,i=null!=(o=n.parseJwt(e).userSession)?o:null;return i&&t.log("[PugpigAutoLogin] Extracted Zephr session from OAuth token"),i}catch(e){var r,a=(null!=(r=Error)&&"u">typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r)?e.message:String(e);return t.log("[PugpigAutoLogin] Failed to extract Zephr session from OAuth token: ".concat(a)),null}},extractZephrSessionFromUserInfo:function(e){var n,o=(null==(n=e.userInfo)?void 0:n["http://schema.pugpig.com/attribute/blaize_session"])||"unknown";return o&&"unknown"!==o?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(o)?(t.log("[PugpigAutoLogin] Extracted Zephr session from userInfo"),o):(t.log("[PugpigAutoLogin] Invalid UUID format for Zephr session token"),null):(t.log("[PugpigAutoLogin] No Zephr session found in userInfo"),null)},fetchUserTokens:function(){return r(function(){var e,n,o,i,r;return u(this,function(a){switch(a.label){case 0:if(t.log("[PugpigAutoLogin] Fetching user tokens from Pugpig Bridge Service"),!(null==(e=window.parent.pugpigBridgeService)?void 0:e.authorisationStatus))return t.log("[PugpigAutoLogin] Authorization status not available"),[2,null];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,window.parent.pugpigBridgeService.authorisationStatus()];case 2:return n=JSON.parse(a.sent()),o=this.extractOAuthToken(n),i=null,o&&(i=this.extractZephrSessionFromOAuthToken(o)),i||(i=this.extractZephrSessionFromUserInfo(n)),[2,{zephrToken:i,oauthToken:o}];case 3:return r=a.sent(),t.log("[PugpigAutoLogin] Failed to fetch user tokens: ".concat(r)),[2,null];case 4:return[2]}})}).call(this)},updateTokenCookie:function(e,n,o){return r(function(){var i,r;return u(this,function(a){return(t.log("[PugpigAutoLogin] Attempting login by ".concat(n," token")),(r=(i=document.cookie.split("; ").find(function(t){return t.startsWith("".concat(o,"="))}))?i.split("=")[1]:void 0)===e)?(t.log("[PugpigAutoLogin] Token is already synchronized, skipping login"),[2,!1]):"invalid"!==r||e?e&&"unknown"!==e?(window.isSecureContext||t.log("[PugpigAutoLogin] Warning: Not in secure context, cookie may not be set properly"),t.log("[PugpigAutoLogin] Setting ".concat(o," cookie for auto-login")),document.cookie="".concat(o,"=").concat(e,"; path=/; samesite=lax; secure"),[2,!0]):r?(t.log("[PugpigAutoLogin] Invalidating ".concat(o," cookie as token is empty")),document.cookie="".concat(o,"=invalid; path=/; samesite=lax; secure;"),[2,!0]):(t.log("[PugpigAutoLogin] Invalid token provided and no existing cookie, skipping"),[2,!1]):(t.log("[PugpigAutoLogin] Cookie already invali
1dated and no new token, skipping"),[2,!1])})})()},handlePugpigUpdate:function(e,n){return r(function(){var o,i,r,l,g;return u(this,function(u){switch(u.label){case 0:if(window.parent.originalPugpigUpdate&&window.parent.originalPugpigUpdate(e,n),t.log("[PugpigAutoLogin] Received Pugpig update: ".concat(e)),"authorisationStatus"!==e)return t.log("[PugpigAutoLogin] Ignoring Pugpig update for method: ".concat(e)),[2];return[4,this.fetchUserTokens()];case 1:if(!(o=u.sent()))return t.log("[PugpigAutoLogin] No token found, signaling autologin complete"),s(),[2];return[4,Promise.all([this.updateTokenCookie(o.zephrToken,"zephr","blaize_session"),this.updateTokenCookie(o.oauthToken,"oauth","blaize_jwt")])];case 2:return r=(i=a.apply(void 0,[u.sent(),2]))[0],l=i[1],r||l?(g=new URL(window.location.href),window.history.replaceState({},document.title,g.pathname+g.search+g.hash),t.log("[PugpigAutoLogin] Reloading page to apply login"),window.location.reload()):s(),[2]}})}).call(this)},initializePugpigAutoLogin:function(){var e=this;this.isPugpigContext()?(window.isPugpigContext=!0,t.log("[PugpigAutoLogin] Initializing Pugpig auto-login"),window.parent.originalPugpigUpdate=window.pugpigUpdate||void 0,window.pugpigUpdate=function(t,n){e.handlePugpigUpdate(t,n)},"loading"===document.readyState?window.addEventListener("DOMContentLoaded",function(){return e.handlePugpigUpdate("authorisationStatus")}):this.handlePugpigUpdate("authorisationStatus")):t.log("[PugpigAutoLogin] Not in Pugpig context, skipping initialization")}}).initializePugpigAutoLogin(),pugpigAutologin={}})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.