@4us-dev/crypto
Version:
Utility classes to assist developers during software development
19 lines (18 loc) • 739 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.caracteresAllowed = void 0;
var utils_1 = require("@4us-dev/utils");
var randomUtils = new utils_1.RandomUtils();
var minLength = 43;
var maxLength = 128;
exports.caracteresAllowed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~';
/**
* See https://tools.ietf.org/html/rfc7636#section-4.1 to more information
*/
exports.default = (function (length) {
if (length === void 0) { length = maxLength; }
if (length < minLength || length > maxLength) {
throw new Error('the code verifier must be between 43 and 128 characters long.');
}
return randomUtils.nextStringCustom(length, exports.caracteresAllowed);
});