generateCodeVerifier (auth/pkce.ts)

nitrostack · sample-apps/Agentic-Bridge/nitrostack-main/typescript/packages/core/src/auth/pkce.ts · typescript · Apache-2.0
auth

Functions to generate and validate PKCE code verifier and challenge per RFC 7636.

// Source: https://github.com/nitrocloudofficial/nitrostack | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import crypto from 'crypto';
import { PKCEParams } from './types.js';

// Re-export PKCEParams for convenience
export type { PKCEParams } from './types.js';

/**
 * PKCE (Proof Key for Code Exchange) Utilities
 * Implements RFC 7636
 * 
 * PKCE is REQUIRED by OAuth 2.1 to prevent authorization code interception attacks
 */

/**
 * Generate a cryptographically secure random code verifier
 * 
 * Per RFC 7636:
 * - code_verifier = high-entropy cryptographic random STRING
 * - using unreserved characters [A-Z] / [a-z] / [0-9] / "-" / "." / "_" / "~"
 * - minimum length of 43 cha

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

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

Get a free API key