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-5/

Secure API Request Validator

Build a utility that validates and prepares token request configurations for secure API calls using Proof of Possession (PoP) authentication.

Requirements

Your solution should:

  1. Create a function that accepts resource request parameters (HTTP method, URL, and nonce) and returns a properly structured token request options object suitable for PoP authentication
  2. Validate that the HTTP method is one of the standard methods (GET, POST, PUT, DELETE, PATCH)
  3. Validate that the URL is a valid HTTPS URL
  4. Validate that the nonce is a non-empty string
  5. Return null if any validation fails
  6. Include the PoP-specific options in the returned configuration

Test Cases

  • When given valid inputs (method: "GET", URL: "https://api.example.com/data", nonce: "abc123"), it returns a valid configuration object with PoP options @test
  • When given an invalid HTTP method (e.g., "INVALID"), it returns null @test
  • When given a non-HTTPS URL (e.g., "http://api.example.com"), it returns null @test
  • When given an empty nonce, it returns null @test

@generates

API

/**
 * Creates a token request options object configured for Proof of Possession authentication.
 *
 * @param method - The HTTP method for the resource request
 * @param url - The URL of the resource being accessed (must be HTTPS)
 * @param nonce - A unique nonce value for the PoP token
 * @returns A token request options object with PoP configuration, or null if validation fails
 */
export function createPopTokenOptions(
  method: string,
  url: string,
  nonce: string
): any | null;

Dependencies { .dependencies }

@azure/core-auth { .dependency }

Provides authentication interfaces and token request configuration types.

Install with Tessl CLI

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

tile.json