CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-azure--core-auth

Provides low-level interfaces and helper methods for authentication in Azure SDK

Overall
score

97%

Overview
Eval results
Files

task.mdevals/scenario-6/

Configuration Manager with Name/Key Pair Authentication

Build a configuration manager that handles authentication credentials consisting of both a name and a secret key. The manager should support secure credential storage, retrieval, and rotation operations.

Requirements

Core Functionality

The configuration manager must:

  1. Store authentication credentials that consist of both a name identifier and a secret key value
  2. Provide read-only access to both the name and key components
  3. Support atomic updates of both name and key values simultaneously
  4. Validate that neither the name nor the key is empty when creating or updating credentials
  5. Throw appropriate errors for invalid input (empty or undefined values)

Credential Validation

The manager should include a validation function that can:

  1. Determine whether a given object represents a valid name/key credential
  2. Return true if the object has both required properties (name and key)
  3. Return false otherwise
  4. Provide proper type narrowing for TypeScript usage

Implementation

@generates

API

/**
 * Creates a new credential manager with initial name and key values.
 * @param name - The credential name identifier
 * @param key - The secret key value
 * @throws Error if name or key is empty or undefined
 */
function createCredentialManager(name: string, key: string): CredentialManager;

/**
 * Represents a credential manager instance
 */
interface CredentialManager {
  /** Gets the current name value */
  getName(): string;

  /** Gets the current key value */
  getKey(): string;

  /**
   * Updates both name and key values atomically
   * @param newName - The new name value
   * @param newKey - The new key value
   * @throws Error if newName or newKey is empty or undefined
   */
  rotate(newName: string, newKey: string): void;
}

/**
 * Validates whether an object is a valid name/key credential
 * @param obj - Object to validate
 * @returns true if object has name and key properties
 */
function isValidCredential(obj: unknown): boolean;

Test Cases

  • Creating a credential manager with valid name and key returns a manager with accessible name and key values @test
  • Attempting to create a credential manager with an empty name throws an error @test
  • Attempting to create a credential manager with an empty key throws an error @test
  • Rotating credentials with valid new name and key updates both values successfully @test
  • Attempting to rotate with an empty name throws an error @test
  • Attempting to rotate with an empty key throws an error @test
  • Validating an object with both name and key properties returns true @test
  • Validating an object without name or key properties returns false @test

Dependencies { .dependencies }

@azure/core-auth { .dependency }

Provides authentication credential interfaces and implementations for Azure services.

Install with Tessl CLI

npx tessl i tessl/npm-azure--core-auth

tile.json