//#region src/generate-cnpj/generate-cnpj.d.ts /** * The parameters `generateCnpj` accepts, an alternative to passing the version positionally. */ export type GenerateCnpjParams = { /** * The version of the CNPJ to be generated: `1` for the numeric CNPJ and `2` for the * alphanumeric one. Defaults to `1`, and any other runtime value also generates a version 1 * (numeric) CNPJ. */ version?: 1 | 2; /** * The "número de ordem" (filial) block, positions 9 to 12 of the CNPJ: an integer from 1 to * 9999, written zero padded to four characters (`3` becomes `"0003"`). Defaults to a random * block, and an integer outside that range, a fractional number or any other runtime value is * ignored, so a random block is used for those as well. The block stays numeric on the * alphanumeric version, which the IN RFB nº 2.229/2024 layout allows. */ branch?: number; }; /** * Generates a valid random CNPJ (Cadastro Nacional da Pessoa Jurídica). * * Uses `Math.random()` internally, so it is not cryptographically secure, do not use for security purposes. * * The first argument is either the version, as it has always been, or a `GenerateCnpjParams` * object carrying that same version plus the "número de ordem" (filial) block to write in * positions 9 to 12. * * @param {1 | 2 | GenerateCnpjParams} [versionOrParams] - The version of the CNPJ to be * generated: `1` for the numeric CNPJ and `2` for the alphanumeric one, or an options object. * Defaults to `1`, and never throws: `null`, `undefined` and any other runtime value that is * neither `2` nor an object also generate a version 1 (numeric) CNPJ. * @param {1 | 2} [versionOrParams.version] - The version of the CNPJ to be generated, as above. * @param {number} [versionOrParams.branch] - The "número de ordem" (filial) block, an integer * from 1 to 9999 written zero padded to four characters. Defaults to a random block, and an * invalid branch is ignored rather than reported, so a random block is used for it too. * @returns {string} A valid 14-digit CNPJ string without formatting. * * @example * ```typescript * generateCnpj(); // "12345678000195" * generateCnpj(2); // "Q0SLFMBD7VX439" * generateCnpj({ version: 2 }); // "Q0SLFMBD7VX439" * generateCnpj({ branch: 3 }); // "12345678000372", the ordem block is "0003" * generateCnpj({ version: 2, branch: 1 }); // "Q0SLFMBD000148", the ordem block is "0001" * generateCnpj({ branch: 0 }); // "12345678472695", an out of range branch draws a random block * ``` * * @see Official: https://www.gov.br/receitafederal/pt-br/assuntos/orientacao-tributaria/cadastros/cnpj * @see Official: https://www.gov.br/receitafederal/pt-br/centrais-de-conteudo/publicacoes/documentos-tecnicos/cnpj/manual-dv-cnpj.pdf * @see Official: https://www.gov.br/receitafederal/pt-br/acesso-a-informacao/acoes-e-programas/programas-e-atividades/cnpj-alfanumerico */ export declare const generateCnpj: (versionOrParams?: 1 | 2 | GenerateCnpjParams) => string; //#endregion