microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 2.35 kB
Source Map (JSON)
{"version":3,"sources":["src/common.speech/CognitiveTokenAuthentication.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGjE,qBAAa,4BAA6B,YAAW,eAAe;IAChE,OAAO,CAAC,MAAM,CAAC,eAAe,CAAqB;IACnD,OAAO,CAAC,iBAAiB,CAAgD;IACzE,OAAO,CAAC,yBAAyB,CAAgD;gBAE9D,aAAa,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;IAa9I,KAAK,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIlD,aAAa,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CAGpE","file":"CognitiveTokenAuthentication.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ArgumentNullError } from \"../common/Exports.js\";\r\nimport { AuthInfo, IAuthentication } from \"./IAuthentication.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\n\r\nexport class CognitiveTokenAuthentication implements IAuthentication {\r\n private static privTokenPrefix: string = \"Bearer \";\r\n private privFetchCallback: (authFetchEventId: string) => Promise<string>;\r\n private privFetchOnExpiryCallback: (authFetchEventId: string) => Promise<string>;\r\n\r\n public constructor(fetchCallback: (authFetchEventId: string) => Promise<string>, fetchOnExpiryCallback: (authFetchEventId: string) => Promise<string>) {\r\n if (!fetchCallback) {\r\n throw new ArgumentNullError(\"fetchCallback\");\r\n }\r\n\r\n if (!fetchOnExpiryCallback) {\r\n throw new ArgumentNullError(\"fetchOnExpiryCallback\");\r\n }\r\n\r\n this.privFetchCallback = fetchCallback;\r\n this.privFetchOnExpiryCallback = fetchOnExpiryCallback;\r\n }\r\n\r\n public fetch(authFetchEventId: string): Promise<AuthInfo> {\r\n return this.privFetchCallback(authFetchEventId).then((token: string): AuthInfo => new AuthInfo(HeaderNames.Authorization, token === undefined ? undefined : CognitiveTokenAuthentication.privTokenPrefix + token));\r\n }\r\n\r\n public fetchOnExpiry(authFetchEventId: string): Promise<AuthInfo> {\r\n return this.privFetchOnExpiryCallback(authFetchEventId).then((token: string): AuthInfo => new AuthInfo(HeaderNames.Authorization, token === undefined ? undefined : CognitiveTokenAuthentication.privTokenPrefix + token));\r\n }\r\n}\r\n"]}