UNPKG

782 BPlain TextView Raw
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
4import { ApiKeyCredentials, ApiKeyCredentialOptions } from "./apiKeyCredentials";
5
6export class TopicCredentials extends ApiKeyCredentials {
7 /**
8 * Creates a new EventGrid TopicCredentials object.
9 *
10 * @constructor
11 * @param {string} topicKey The EventGrid topic key
12 */
13 constructor(topicKey: string) {
14 if (!topicKey || (topicKey && typeof topicKey !== "string")) {
15 throw new Error("topicKey cannot be null or undefined and must be of type string.");
16 }
17 const options: ApiKeyCredentialOptions = {
18 inHeader: {
19 "aeg-sas-key": topicKey,
20 },
21 };
22 super(options);
23 }
24}