{"version":3,"sources":["src/common.speech/CognitiveTokenAuthentication.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAI9D,qBAAa,4BAA6B,YAAW,eAAe;IAChE,OAAO,CAAC,iBAAiB,CAAgD;IACzE,OAAO,CAAC,yBAAyB,CAAgD;gBAErE,aAAa,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;IAavI,KAAK,kDAEX;IAEM,aAAa,kDAEnB;CACJ","file":"CognitiveTokenAuthentication.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { ArgumentNullError, Promise } from \"../common/Exports\";\nimport { AuthInfo, IAuthentication } from \"./IAuthentication\";\n\nconst AuthHeader: string = \"Authorization\";\n\nexport class CognitiveTokenAuthentication implements IAuthentication {\n    private privFetchCallback: (authFetchEventId: string) => Promise<string>;\n    private privFetchOnExpiryCallback: (authFetchEventId: string) => Promise<string>;\n\n    constructor(fetchCallback: (authFetchEventId: string) => Promise<string>, fetchOnExpiryCallback: (authFetchEventId: string) => Promise<string>) {\n        if (!fetchCallback) {\n            throw new ArgumentNullError(\"fetchCallback\");\n        }\n\n        if (!fetchOnExpiryCallback) {\n            throw new ArgumentNullError(\"fetchOnExpiryCallback\");\n        }\n\n        this.privFetchCallback = fetchCallback;\n        this.privFetchOnExpiryCallback = fetchOnExpiryCallback;\n    }\n\n    public fetch = (authFetchEventId: string): Promise<AuthInfo> => {\n        return  this.privFetchCallback(authFetchEventId).onSuccessContinueWith((token: string) => new AuthInfo(AuthHeader, token));\n    }\n\n    public fetchOnExpiry = (authFetchEventId: string): Promise<AuthInfo> => {\n        return  this.privFetchOnExpiryCallback(authFetchEventId).onSuccessContinueWith((token: string) => new AuthInfo(AuthHeader, token));\n    }\n}\n"]}