topicCredentials.ts 792 B

123456789101112131415161718192021222324
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License. See License.txt in the project root for license information.
  3. import { ApiKeyCredentials, ApiKeyCredentialOptions } from "./apiKeyCredentials";
  4. export class TopicCredentials extends ApiKeyCredentials {
  5. /**
  6. * Creates a new EventGrid TopicCredentials object.
  7. *
  8. * @constructor
  9. * @param {string} topicKey The EventGrid topic key
  10. */
  11. constructor(topicKey: string) {
  12. if (!topicKey || (topicKey && typeof topicKey !== "string")) {
  13. throw new Error("topicKey cannot be null or undefined and must be of type string.");
  14. }
  15. const options: ApiKeyCredentialOptions = {
  16. inHeader: {
  17. "aeg-sas-key": topicKey
  18. }
  19. };
  20. super(options);
  21. }
  22. }