generateDigestAuthHeader (auth/digest.ts)

hoppscotch · packages/hoppscotch-cli/src/utils/auth/digest.ts · typescript · MIT
auth

Generates HTTP Digest authentication headers and fetches initial auth info.

// Source: https://github.com/hoppscotch/hoppscotch | License: MIT | Copyright 2022
// Provided via justclaw.it.com; keep this notice with the code.
import axios from "axios";
import { md5 } from "js-md5";

import { exceptionColors } from "../getters";

export interface DigestAuthParams {
  username: string;
  password: string;
  realm: string;
  nonce: string;
  endpoint: string;
  method: string;
  algorithm: string;
  qop: string;
  nc?: string;
  opaque?: string;
  cnonce?: string; // client nonce (optional but typically required in qop='auth')
  reqBody?: string;
}

export interface DigestAuthInfo {
  realm: string;
  nonce: string;
  qop: string;
  opaque?: string;
  algorithm: string;
}

// Utility function to parse Digest auth header values
const parseDigestAuthHeader = (
  header:

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key