const crypto = require("crypto");

/**
 * Generates a URL-safe random string.
 * Example output: "qN8vZ1qZ9rHc2p4K"
 */
function randomId(length = 16) {
  // Generate bytes then convert to base64url
  // base64url supported in Node 18+
  return crypto.randomBytes(length).toString("base64url");
}

function generateDID() {
  return `DID-${randomId(12)}`;
}

function generateSIS() {
  return `SIS-${randomId(12)}`;
}

module.exports = { generateDID, generateSIS };
