Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/@azure/core-auth/dist-esm/src/azureNamedKeyCredential.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
62 lines (62 sloc)
1.85 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) Microsoft Corporation. | |
// Licensed under the MIT license. | |
import { isObjectWithProperties } from "./typeguards"; | |
/** | |
* A static name/key-based credential that supports updating | |
* the underlying name and key values. | |
*/ | |
export class AzureNamedKeyCredential { | |
/** | |
* Create an instance of an AzureNamedKeyCredential for use | |
* with a service client. | |
* | |
* @param name - The initial value of the name to use in authentication. | |
* @param key - The initial value of the key to use in authentication. | |
*/ | |
constructor(name, key) { | |
if (!name || !key) { | |
throw new TypeError("name and key must be non-empty strings"); | |
} | |
this._name = name; | |
this._key = key; | |
} | |
/** | |
* The value of the key to be used in authentication. | |
*/ | |
get key() { | |
return this._key; | |
} | |
/** | |
* The value of the name to be used in authentication. | |
*/ | |
get name() { | |
return this._name; | |
} | |
/** | |
* Change the value of the key. | |
* | |
* Updates will take effect upon the next request after | |
* updating the key value. | |
* | |
* @param newName - The new name value to be used. | |
* @param newKey - The new key value to be used. | |
*/ | |
update(newName, newKey) { | |
if (!newName || !newKey) { | |
throw new TypeError("newName and newKey must be non-empty strings"); | |
} | |
this._name = newName; | |
this._key = newKey; | |
} | |
} | |
/** | |
* Tests an object to determine whether it implements NamedKeyCredential. | |
* | |
* @param credential - The assumed NamedKeyCredential to be tested. | |
*/ | |
export function isNamedKeyCredential(credential) { | |
return (isObjectWithProperties(credential, ["name", "key"]) && | |
typeof credential.key === "string" && | |
typeof credential.name === "string"); | |
} | |
//# sourceMappingURL=azureNamedKeyCredential.js.map |