{"version":3,"file":"BrowserProtocolUtils.js","sources":["../../src/utils/BrowserProtocolUtils.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { InteractionType } from \"./BrowserConstants\";\nimport { StringUtils, ClientAuthError, ICrypto, RequestStateObject, ProtocolUtils, ServerAuthorizationCodeResponse, UrlString } from \"@azure/msal-common\";\n\nexport type BrowserStateObject = {\n interactionType: InteractionType\n};\n\nexport class BrowserProtocolUtils {\n\n /**\n * Extracts the BrowserStateObject from the state string.\n * @param browserCrypto \n * @param state \n */\n static extractBrowserRequestState(browserCrypto: ICrypto, state: string): BrowserStateObject | null {\n if (StringUtils.isEmpty(state)) {\n return null;\n }\n\n try {\n const requestStateObj: RequestStateObject = ProtocolUtils.parseRequestState(browserCrypto, state);\n return requestStateObj.libraryState.meta as BrowserStateObject;\n } catch (e) {\n throw ClientAuthError.createInvalidStateError(state, e);\n }\n }\n\n /**\n * Parses properties of server response from url hash\n * @param locationHash Hash from url\n */\n static parseServerResponseFromHash(locationHash: string): ServerAuthorizationCodeResponse {\n if (!locationHash) {\n return {};\n }\n \n const hashUrlString = new UrlString(locationHash);\n return UrlString.getDeserializedHash(hashUrlString.getHash());\n }\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;IAYA;KAgCC;;;;;;IAzBU,+CAA0B,GAAjC,UAAkC,aAAsB,EAAE,KAAa;QACnE,IAAI,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC5B,OAAO,IAAI,CAAC;SACf;QAED,IAAI;YACA,IAAM,eAAe,GAAuB,aAAa,CAAC,iBAAiB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;YAClG,OAAO,eAAe,CAAC,YAAY,CAAC,IAA0B,CAAC;SAClE;QAAC,OAAO,CAAC,EAAE;YACR,MAAM,eAAe,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC3D;KACJ;;;;;IAMM,gDAA2B,GAAlC,UAAmC,YAAoB;QACnD,IAAI,CAAC,YAAY,EAAE;YACf,OAAO,EAAE,CAAC;SACb;QAED,IAAM,aAAa,GAAG,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC;QAClD,OAAO,SAAS,CAAC,mBAAmB,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;KACjE;IACL,2BAAC;AAAD,CAAC;;;;"}