// @pdsjs/core/html - Shared helpers for the server-rendered pages
/**
* Escape HTML special characters.
* @param {string} s
* @returns {string}
*/
export function escapeHtml(s) {
return s
.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"');
}
/**
* base64url helpers for inline passkey scripts. WebAuthn speaks ArrayBuffers;
* every field crossing the wire here is base64url text.
*/
export const B64_SCRIPT = `
const b64 = (buf) => btoa(String.fromCharCode(...new Uint8Array(buf)))
.replace(/\\+/g,'-').replace(/\\//g,'_').replace(/=+$/,'');
const unb64 = (s) => Uint8Array.from(
atob(s.replace(/-/g,'+').replace(/_/g,'/')), (c) => c.charCodeAt(0));
`;