{"version":3,"file":"SignedHttpRequest.js","sources":["../../src/crypto/SignedHttpRequest.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { CryptoOps } from \"./CryptoOps\";\nimport { Logger, LoggerOptions, PopTokenGenerator, SignedHttpRequestParameters } from \"@azure/msal-common\";\nimport { version, name } from \"../packageMetadata\";\n\nexport type SignedHttpRequestOptions = {\n loggerOptions: LoggerOptions\n};\n\nexport class SignedHttpRequest {\n private popTokenGenerator: PopTokenGenerator;\n private cryptoOps: CryptoOps;\n private shrParameters: SignedHttpRequestParameters;\n private logger: Logger;\n\n constructor(shrParameters: SignedHttpRequestParameters, shrOptions?: SignedHttpRequestOptions) {\n const loggerOptions = (shrOptions && shrOptions.loggerOptions) || {};\n this.logger = new Logger(loggerOptions, name, version);\n this.cryptoOps = new CryptoOps(this.logger);\n this.popTokenGenerator = new PopTokenGenerator(this.cryptoOps);\n this.shrParameters = shrParameters;\n }\n\n /**\n * Generates and caches a keypair for the given request options.\n * @returns Public key digest, which should be sent to the token issuer.\n */\n async generatePublicKeyThumbprint(): Promise {\n const { kid } = await this.popTokenGenerator.generateKid(this.shrParameters);\n\n return kid;\n }\n\n /**\n * Generates a signed http request for the given payload with the given key.\n * @param payload Payload to sign (e.g. access token)\n * @param publicKeyThumbprint Public key digest (from generatePublicKeyThumbprint API)\n * @param claims Additional claims to include/override in the signed JWT \n * @returns Pop token signed with the corresponding private key\n */\n async signRequest(payload: string, publicKeyThumbprint: string, claims?: object): Promise {\n return this.popTokenGenerator.signPayload(\n payload, \n publicKeyThumbprint,\n this.shrParameters, \n claims\n );\n }\n\n /**\n * Removes cached keys from browser for given public key thumbprint\n * @param publicKeyThumbprint Public key digest (from generatePublicKeyThumbprint API)\n * @returns If keys are properly deleted\n */\n async removeKeys(publicKeyThumbprint: string): Promise {\n return await this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;IAmBI,2BAAY,aAA0C,EAAE,UAAqC;QACzF,IAAM,aAAa,GAAG,CAAC,UAAU,IAAI,UAAU,CAAC,aAAa,KAAK,EAAE,CAAC;QACrE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/D,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;KACtC;;;;;IAMK,uDAA2B,GAAjC;;;;;4BACoB,qBAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,EAAA;;wBAApE,GAAG,GAAK,CAAA,SAA4D,KAAjE;wBAEX,sBAAO,GAAG,EAAC;;;;KACd;;;;;;;;IASK,uCAAW,GAAjB,UAAkB,OAAe,EAAE,mBAA2B,EAAE,MAAe;;;gBAC3E,sBAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CACrC,OAAO,EACP,mBAAmB,EACnB,IAAI,CAAC,aAAa,EAClB,MAAM,CACT,EAAC;;;KACL;;;;;;IAOK,sCAAU,GAAhB,UAAiB,mBAA2B;;;;4BACjC,qBAAM,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,mBAAmB,CAAC,EAAA;4BAAtE,sBAAO,SAA+D,EAAC;;;;KAC1E;IACL,wBAAC;AAAD,CAAC;;;;"}