"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setSecurityDetails=exports.getSecurityDetails=exports.setSecurityDetailsVariants=void 0;const theme_1=require("@redocly/theme"),string_1=require("./string"),session_storage_1=require("./session-storage");function setSecurityDetailsVariants(e,s){e=(0,string_1.escapeFormId)(e),(0,session_storage_1.toSessionStorage)(`auth.${e}.variants`,JSON.stringify(s))}function getSecurityDetails(e,s={}){return{raw:s[e+theme_1.SecurityVariablesEnvSuffix.APIKey],password:s[e+theme_1.SecurityVariablesEnvSuffix.Password],username:s[e+theme_1.SecurityVariablesEnvSuffix.Username],token:s[e+theme_1.SecurityVariablesEnvSuffix.Token]?{access_token:s[e+theme_1.SecurityVariablesEnvSuffix.Token]}:void 0,client_id:s[e+theme_1.SecurityVariablesEnvSuffix.ClientId],client_secret:s[e+theme_1.SecurityVariablesEnvSuffix.ClientSecret],scopes:(0,session_storage_1.fromSessionStorage)(`auth.${e}.scopes`)}}function setSecurityDetails(e,s){e=(0,string_1.escapeFormId)(e),"string"==typeof s?(0,session_storage_1.toSessionStorage)("auth."+e,s):s&&((0,session_storage_1.toSessionStorage)(`auth.${e}.password`,s.password||""),(0,session_storage_1.toSessionStorage)(`auth.${e}.username`,s.username||""),(0,session_storage_1.toSessionStorage)(`auth.${e}.token`,s.token&&JSON.stringify(s.token)||""),(0,session_storage_1.toSessionStorage)(`auth.${e}.client_id`,s.client_id||""),(0,session_storage_1.toSessionStorage)(`auth.${e}.client_secret`,s.client_secret||""),(0,session_storage_1.toSessionStorage)(`auth.${e}.scopes`,s.scopes&&JSON.stringify(s.scopes)||""))}exports.setSecurityDetailsVariants=setSecurityDetailsVariants,exports.getSecurityDetails=getSecurityDetails,exports.setSecurityDetails=setSecurityDetails;
//# sourceMappingURL=security-details.js.map