Merge 19b6ff4886
into 08b771c863
commit
f9782644d1
@ -0,0 +1,4 @@
|
||||
PORT=5000
|
||||
MONGO_CONN="mongodb+srv://shivam:Shivamkvs123@cluster0.czaej.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0"
|
||||
MONGO_URI="mongodb+srv://shivakvs2003:SOKWJZ3Blq5IlYeV@cluster0.gtatz.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0"
|
||||
JWT_SECRET="secret-123"
|
@ -0,0 +1,89 @@
|
||||
const UserModel = require("../Models/User");
|
||||
const bcrypt = require('bcryptjs');
|
||||
const jwt=require('jsonwebtoken');
|
||||
const signup = async (req, res) => {
|
||||
try {
|
||||
const { name, email, password } = req.body;
|
||||
|
||||
// Check if the user already exists
|
||||
const user = await UserModel.findOne({ email });
|
||||
if (user) {
|
||||
return res.status(409).json({
|
||||
message: "User already exists, you can login",
|
||||
success: false
|
||||
});
|
||||
}
|
||||
|
||||
// Hash the password
|
||||
const hashedPassword = await bcrypt.hash(password, 10);
|
||||
|
||||
// Create a new user instance with hashed password
|
||||
const userModel = new UserModel({
|
||||
name,
|
||||
email,
|
||||
password: hashedPassword // Set the hashed password here
|
||||
});
|
||||
|
||||
// Save the new user to the database
|
||||
await userModel.save();
|
||||
|
||||
res.status(201).json({
|
||||
message: "Signup successful",
|
||||
success: true
|
||||
});
|
||||
} catch (err) {
|
||||
// Log the error for debugging
|
||||
console.error("Error during signup:", err);
|
||||
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
success: false
|
||||
});
|
||||
}
|
||||
}
|
||||
const login = async (req, res) => {
|
||||
try {
|
||||
const { email, password } = req.body;
|
||||
|
||||
// Check if the user already exists
|
||||
const user = await UserModel.findOne({ email });
|
||||
const errorMsg='Auth failed email or password is wrong';
|
||||
if (!user) {
|
||||
return res.status(403).json({
|
||||
message: errorMsg,
|
||||
success: false
|
||||
});
|
||||
}
|
||||
|
||||
const isPassEqual=await bcrypt.compare(password,user.password);
|
||||
if(!isPassEqual){
|
||||
return res.status(403)
|
||||
.json({message:errorMsg,success:false});
|
||||
}
|
||||
const jwtToken=jwt.sign(
|
||||
{email:user.email,_id:user._id},
|
||||
process.env.JWT_SECRET,
|
||||
{expiresIn:'24h'}
|
||||
)
|
||||
res.status(200).json({
|
||||
message: "Login successful",
|
||||
success: true,
|
||||
jwtToken,
|
||||
email,
|
||||
name:user.name
|
||||
});
|
||||
} catch (err) {
|
||||
// Log the error for debugging
|
||||
console.error("Error during signup:", err);
|
||||
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
success: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
signup,
|
||||
login
|
||||
};
|
@ -0,0 +1,35 @@
|
||||
const Transaction = require('../Models/Transaction'); // Ensure this path is correct
|
||||
|
||||
// Function to get all transactions for a specific user
|
||||
const getTransactions = async (req, res) => {
|
||||
try {
|
||||
// Fetch transactions that belong to the logged-in user
|
||||
const transactions = await Transaction.find({ userId: req.user._id });
|
||||
res.json(transactions);
|
||||
} catch (err) {
|
||||
res.status(500).json({ message: err.message });
|
||||
}
|
||||
};
|
||||
|
||||
// Function to add a new transaction for the logged-in user
|
||||
const addTransaction = async (req, res) => {
|
||||
const newTransaction = new Transaction({
|
||||
description: req.body.description,
|
||||
amount: req.body.amount,
|
||||
transactionDate: req.body.transactionDate,
|
||||
userId: req.user._id, // Ensure user ID is associated with the transaction
|
||||
});
|
||||
|
||||
try {
|
||||
// Save the new transaction to the database
|
||||
const savedTransaction = await newTransaction.save();
|
||||
res.status(201).json(savedTransaction);
|
||||
} catch (err) {
|
||||
res.status(400).json({ message: err.message });
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getTransactions,
|
||||
addTransaction,
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
const jwt=require('jsonwebtoken');
|
||||
const ensureAuthenticated=(req,res,next)=>{
|
||||
const auth=req.headers['authorization'];
|
||||
if(!auth){
|
||||
return res.status(403)
|
||||
.json({message:'Unauthorized, JWT token is require'});
|
||||
}
|
||||
try{
|
||||
const decoded=jwt.verify(auth,process.env.JWT_SECRET);
|
||||
req.user=decoded;
|
||||
}catch(err){
|
||||
return res.status(403)
|
||||
.json({message:'Unauthorized, JWT token wrong or expired'});
|
||||
}
|
||||
}
|
||||
module.exports=ensureAuthenticated;
|
@ -0,0 +1,31 @@
|
||||
const Joi=require('joi');
|
||||
const signupValidation=(req,res,next)=>{
|
||||
const schema=Joi.object({
|
||||
name:Joi.string().min(3).max(100).required(),
|
||||
email:Joi.string().email().required(),
|
||||
password:Joi.string().min(4).max(100).required()
|
||||
});
|
||||
const {error}=schema.validate(req.body);
|
||||
if(error){
|
||||
return res.status(400)
|
||||
.json({message:"Bad request",error})
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
const loginValidation=(req,res,next)=>{
|
||||
const schema=Joi.object({
|
||||
email:Joi.string().email().required(),
|
||||
password:Joi.string().min(4).max(100).required()
|
||||
});
|
||||
const {error}=schema.validate(req.body);
|
||||
if(error){
|
||||
return res.status(400)
|
||||
.json({message:"Bad request",error})
|
||||
}
|
||||
next();
|
||||
}
|
||||
module.exports={
|
||||
signupValidation,
|
||||
loginValidation
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
const jwt = require('jsonwebtoken');
|
||||
const User = require('../Models/User');
|
||||
|
||||
const authMiddleware = async (req, res, next) => {
|
||||
const token = req.headers.authorization?.split(' ')[1];
|
||||
if (!token) {
|
||||
return res.status(401).json({ message: 'Authentication failed: No token provided' });
|
||||
}
|
||||
try {
|
||||
const decoded = jwt.verify(token, process.env.JWT_SECRET);
|
||||
req.user = await User.findById(decoded._id);
|
||||
if (!req.user) {
|
||||
return res.status(401).json({ message: 'Authentication failed: User not found' });
|
||||
}
|
||||
next();
|
||||
} catch (err) {
|
||||
res.status(401).json({ message: "Authentication failed: Invalid token." });
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = authMiddleware;
|
@ -0,0 +1,27 @@
|
||||
const mongoose = require('mongoose');
|
||||
//hello
|
||||
// Define the schema for transactions
|
||||
const transactionSchema = new mongoose.Schema({
|
||||
description: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
amount: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
transactionDate: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User',
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
// Create and export the Transaction model
|
||||
const Transaction = mongoose.model('Transaction', transactionSchema);
|
||||
|
||||
module.exports = Transaction;
|
@ -0,0 +1,27 @@
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
// Define the schema for the user
|
||||
const UserSchema = new mongoose.Schema({ // Corrected to UserSchema
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true
|
||||
},
|
||||
password: {
|
||||
type: String,
|
||||
required: true,
|
||||
}
|
||||
});
|
||||
|
||||
const db1Connection = mongoose.createConnection(process.env.MONGO_CONN, {
|
||||
serverSelectionTimeoutMS: 30000,
|
||||
connectTimeoutMS: 30000,
|
||||
});
|
||||
|
||||
const UserModel = db1Connection.model('users', UserSchema);
|
||||
|
||||
module.exports = UserModel;
|
@ -0,0 +1,15 @@
|
||||
const mongoose=require("mongoose");
|
||||
const bcrypt=require("bcryptjs");
|
||||
require('dotenv').config();
|
||||
const mongo_url=process.env.MONGO_CONN;
|
||||
//mongodb+srv://shivam:Shivamkvs@cluster0.czaej.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0
|
||||
const db1Connection=mongoose.createConnection(mongo_url,{
|
||||
serverSelectionTimeoutMS: 30000,
|
||||
connectTimeoutMS: 30000,
|
||||
});
|
||||
db1Connection.on('connected',()=>{
|
||||
console.log('connected to the first database');
|
||||
})
|
||||
db1Connection.on('error',(err)=>{
|
||||
console.error('Error connecting to the first database',err);
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
const express=require('express');
|
||||
const {signup, login}=require('../Controllers/AuthController');
|
||||
const { signupValidation } = require('../Middlewares/AuthValidation');
|
||||
const { loginValidation } = require('../Middlewares/AuthValidation');
|
||||
const router=express.Router();
|
||||
|
||||
|
||||
router.post('/signup',signupValidation,signup);
|
||||
router.post('/login',loginValidation,login);
|
||||
|
||||
module.exports=router;
|
@ -0,0 +1,10 @@
|
||||
const express = require('express');
|
||||
const { getTransactions, addTransaction } = require('../Controllers/TransactionController'); // Ensure the path is correct
|
||||
const authMiddleware = require('../Middlewares/authMiddleware'); // Correct import without destructuring
|
||||
const router = express.Router();
|
||||
|
||||
// Transaction routes
|
||||
router.get('/', authMiddleware, getTransactions);
|
||||
router.post('/', authMiddleware, addTransaction);
|
||||
|
||||
module.exports = router;
|
@ -0,0 +1,4 @@
|
||||
const crypto = require('crypto');
|
||||
|
||||
const secret = crypto.randomBytes(64).toString('hex');
|
||||
console.log(secret);
|
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../mime/cli.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../mime/cli.js" "$@"
|
||||
fi
|
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mime\cli.js" %*
|
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../mime/cli.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../mime/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../semver/bin/semver.js" "$@"
|
||||
fi
|
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver.js" %*
|
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,12 @@
|
||||
Copyright (c) 2011-2020, Sideway Inc, and project contributors
|
||||
Copyright (c) 2011-2014, Walmart
|
||||
Copyright (c) 2011, Yahoo Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -0,0 +1,102 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
const Clone = require('./clone');
|
||||
const Merge = require('./merge');
|
||||
const Reach = require('./reach');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (defaults, source, options = {}) {
|
||||
|
||||
Assert(defaults && typeof defaults === 'object', 'Invalid defaults value: must be an object');
|
||||
Assert(!source || source === true || typeof source === 'object', 'Invalid source value: must be true, falsy or an object');
|
||||
Assert(typeof options === 'object', 'Invalid options: must be an object');
|
||||
|
||||
if (!source) { // If no source, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
if (options.shallow) {
|
||||
return internals.applyToDefaultsWithShallow(defaults, source, options);
|
||||
}
|
||||
|
||||
const copy = Clone(defaults);
|
||||
|
||||
if (source === true) { // If source is set to true, use defaults
|
||||
return copy;
|
||||
}
|
||||
|
||||
const nullOverride = options.nullOverride !== undefined ? options.nullOverride : false;
|
||||
return Merge(copy, source, { nullOverride, mergeArrays: false });
|
||||
};
|
||||
|
||||
|
||||
internals.applyToDefaultsWithShallow = function (defaults, source, options) {
|
||||
|
||||
const keys = options.shallow;
|
||||
Assert(Array.isArray(keys), 'Invalid keys');
|
||||
|
||||
const seen = new Map();
|
||||
const merge = source === true ? null : new Set();
|
||||
|
||||
for (let key of keys) {
|
||||
key = Array.isArray(key) ? key : key.split('.'); // Pre-split optimization
|
||||
|
||||
const ref = Reach(defaults, key);
|
||||
if (ref &&
|
||||
typeof ref === 'object') {
|
||||
|
||||
seen.set(ref, merge && Reach(source, key) || ref);
|
||||
}
|
||||
else if (merge) {
|
||||
merge.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
const copy = Clone(defaults, {}, seen);
|
||||
|
||||
if (!merge) {
|
||||
return copy;
|
||||
}
|
||||
|
||||
for (const key of merge) {
|
||||
internals.reachCopy(copy, source, key);
|
||||
}
|
||||
|
||||
const nullOverride = options.nullOverride !== undefined ? options.nullOverride : false;
|
||||
return Merge(copy, source, { nullOverride, mergeArrays: false });
|
||||
};
|
||||
|
||||
|
||||
internals.reachCopy = function (dst, src, path) {
|
||||
|
||||
for (const segment of path) {
|
||||
if (!(segment in src)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const val = src[segment];
|
||||
|
||||
if (typeof val !== 'object' || val === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
src = val;
|
||||
}
|
||||
|
||||
const value = src;
|
||||
let ref = dst;
|
||||
for (let i = 0; i < path.length - 1; ++i) {
|
||||
const segment = path[i];
|
||||
if (typeof ref[segment] !== 'object') {
|
||||
ref[segment] = {};
|
||||
}
|
||||
|
||||
ref = ref[segment];
|
||||
}
|
||||
|
||||
ref[path[path.length - 1]] = value;
|
||||
};
|
@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
const AssertError = require('./error');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (condition, ...args) {
|
||||
|
||||
if (condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length === 1 &&
|
||||
args[0] instanceof Error) {
|
||||
|
||||
throw args[0];
|
||||
}
|
||||
|
||||
throw new AssertError(args);
|
||||
};
|
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = internals.Bench = class {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.ts = 0;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
||||
this.ts = internals.Bench.now();
|
||||
}
|
||||
|
||||
elapsed() {
|
||||
|
||||
return internals.Bench.now() - this.ts;
|
||||
}
|
||||
|
||||
static now() {
|
||||
|
||||
const ts = process.hrtime();
|
||||
return (ts[0] * 1e3) + (ts[1] / 1e6);
|
||||
}
|
||||
};
|
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const Ignore = require('./ignore');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function () {
|
||||
|
||||
return new Promise(Ignore);
|
||||
};
|
@ -0,0 +1,176 @@
|
||||
'use strict';
|
||||
|
||||
const Reach = require('./reach');
|
||||
const Types = require('./types');
|
||||
const Utils = require('./utils');
|
||||
|
||||
|
||||
const internals = {
|
||||
needsProtoHack: new Set([Types.set, Types.map, Types.weakSet, Types.weakMap])
|
||||
};
|
||||
|
||||
|
||||
module.exports = internals.clone = function (obj, options = {}, _seen = null) {
|
||||
|
||||
if (typeof obj !== 'object' ||
|
||||
obj === null) {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
let clone = internals.clone;
|
||||
let seen = _seen;
|
||||
|
||||
if (options.shallow) {
|
||||
if (options.shallow !== true) {
|
||||
return internals.cloneWithShallow(obj, options);
|
||||
}
|
||||
|
||||
clone = (value) => value;
|
||||
}
|
||||
else if (seen) {
|
||||
const lookup = seen.get(obj);
|
||||
if (lookup) {
|
||||
return lookup;
|
||||
}
|
||||
}
|
||||
else {
|
||||
seen = new Map();
|
||||
}
|
||||
|
||||
// Built-in object types
|
||||
|
||||
const baseProto = Types.getInternalProto(obj);
|
||||
if (baseProto === Types.buffer) {
|
||||
return Buffer && Buffer.from(obj); // $lab:coverage:ignore$
|
||||
}
|
||||
|
||||
if (baseProto === Types.date) {
|
||||
return new Date(obj.getTime());
|
||||
}
|
||||
|
||||
if (baseProto === Types.regex) {
|
||||
return new RegExp(obj);
|
||||
}
|
||||
|
||||
// Generic objects
|
||||
|
||||
const newObj = internals.base(obj, baseProto, options);
|
||||
if (newObj === obj) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (seen) {
|
||||
seen.set(obj, newObj); // Set seen, since obj could recurse
|
||||
}
|
||||
|
||||
if (baseProto === Types.set) {
|
||||
for (const value of obj) {
|
||||
newObj.add(clone(value, options, seen));
|
||||
}
|
||||
}
|
||||
else if (baseProto === Types.map) {
|
||||
for (const [key, value] of obj) {
|
||||
newObj.set(key, clone(value, options, seen));
|
||||
}
|
||||
}
|
||||
|
||||
const keys = Utils.keys(obj, options);
|
||||
for (const key of keys) {
|
||||
if (key === '__proto__') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (baseProto === Types.array &&
|
||||
key === 'length') {
|
||||
|
||||
newObj.length = obj.length;
|
||||
continue;
|
||||
}
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
|
||||
if (descriptor) {
|
||||
if (descriptor.get ||
|
||||
descriptor.set) {
|
||||
|
||||
Object.defineProperty(newObj, key, descriptor);
|
||||
}
|
||||
else if (descriptor.enumerable) {
|
||||
newObj[key] = clone(obj[key], options, seen);
|
||||
}
|
||||
else {
|
||||
Object.defineProperty(newObj, key, { enumerable: false, writable: true, configurable: true, value: clone(obj[key], options, seen) });
|
||||
}
|
||||
}
|
||||
else {
|
||||
Object.defineProperty(newObj, key, {
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
value: clone(obj[key], options, seen)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return newObj;
|
||||
};
|
||||
|
||||
|
||||
internals.cloneWithShallow = function (source, options) {
|
||||
|
||||
const keys = options.shallow;
|
||||
options = Object.assign({}, options);
|
||||
options.shallow = false;
|
||||
|
||||
const seen = new Map();
|
||||
|
||||
for (const key of keys) {
|
||||
const ref = Reach(source, key);
|
||||
if (typeof ref === 'object' ||
|
||||
typeof ref === 'function') {
|
||||
|
||||
seen.set(ref, ref);
|
||||
}
|
||||
}
|
||||
|
||||
return internals.clone(source, options, seen);
|
||||
};
|
||||
|
||||
|
||||
internals.base = function (obj, baseProto, options) {
|
||||
|
||||
if (options.prototype === false) { // Defaults to true
|
||||
if (internals.needsProtoHack.has(baseProto)) {
|
||||
return new baseProto.constructor();
|
||||
}
|
||||
|
||||
return baseProto === Types.array ? [] : {};
|
||||
}
|
||||
|
||||
const proto = Object.getPrototypeOf(obj);
|
||||
if (proto &&
|
||||
proto.isImmutable) {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (baseProto === Types.array) {
|
||||
const newObj = [];
|
||||
if (proto !== baseProto) {
|
||||
Object.setPrototypeOf(newObj, proto);
|
||||
}
|
||||
|
||||
return newObj;
|
||||
}
|
||||
|
||||
if (internals.needsProtoHack.has(baseProto)) {
|
||||
const newObj = new proto.constructor();
|
||||
if (proto !== baseProto) {
|
||||
Object.setPrototypeOf(newObj, proto);
|
||||
}
|
||||
|
||||
return newObj;
|
||||
}
|
||||
|
||||
return Object.create(proto);
|
||||
};
|
@ -0,0 +1,307 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
const DeepEqual = require('./deepEqual');
|
||||
const EscapeRegex = require('./escapeRegex');
|
||||
const Utils = require('./utils');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (ref, values, options = {}) { // options: { deep, once, only, part, symbols }
|
||||
|
||||
/*
|
||||
string -> string(s)
|
||||
array -> item(s)
|
||||
object -> key(s)
|
||||
object -> object (key:value)
|
||||
*/
|
||||
|
||||
if (typeof values !== 'object') {
|
||||
values = [values];
|
||||
}
|
||||
|
||||
Assert(!Array.isArray(values) || values.length, 'Values array cannot be empty');
|
||||
|
||||
// String
|
||||
|
||||
if (typeof ref === 'string') {
|
||||
return internals.string(ref, values, options);
|
||||
}
|
||||
|
||||
// Array
|
||||
|
||||
if (Array.isArray(ref)) {
|
||||
return internals.array(ref, values, options);
|
||||
}
|
||||
|
||||
// Object
|
||||
|
||||
Assert(typeof ref === 'object', 'Reference must be string or an object');
|
||||
return internals.object(ref, values, options);
|
||||
};
|
||||
|
||||
|
||||
internals.array = function (ref, values, options) {
|
||||
|
||||
if (!Array.isArray(values)) {
|
||||
values = [values];
|
||||
}
|
||||
|
||||
if (!ref.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.only &&
|
||||
options.once &&
|
||||
ref.length !== values.length) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let compare;
|
||||
|
||||
// Map values
|
||||
|
||||
const map = new Map();
|
||||
for (const value of values) {
|
||||
if (!options.deep ||
|
||||
!value ||
|
||||
typeof value !== 'object') {
|
||||
|
||||
const existing = map.get(value);
|
||||
if (existing) {
|
||||
++existing.allowed;
|
||||
}
|
||||
else {
|
||||
map.set(value, { allowed: 1, hits: 0 });
|
||||
}
|
||||
}
|
||||
else {
|
||||
compare = compare || internals.compare(options);
|
||||
|
||||
let found = false;
|
||||
for (const [key, existing] of map.entries()) {
|
||||
if (compare(key, value)) {
|
||||
++existing.allowed;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
map.set(value, { allowed: 1, hits: 0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Lookup values
|
||||
|
||||
let hits = 0;
|
||||
for (const item of ref) {
|
||||
let match;
|
||||
if (!options.deep ||
|
||||
!item ||
|
||||
typeof item !== 'object') {
|
||||
|
||||
match = map.get(item);
|
||||
}
|
||||
else {
|
||||
compare = compare || internals.compare(options);
|
||||
|
||||
for (const [key, existing] of map.entries()) {
|
||||
if (compare(key, item)) {
|
||||
match = existing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
++match.hits;
|
||||
++hits;
|
||||
|
||||
if (options.once &&
|
||||
match.hits > match.allowed) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate results
|
||||
|
||||
if (options.only &&
|
||||
hits !== ref.length) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const match of map.values()) {
|
||||
if (match.hits === match.allowed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (match.hits < match.allowed &&
|
||||
!options.part) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !!hits;
|
||||
};
|
||||
|
||||
|
||||
internals.object = function (ref, values, options) {
|
||||
|
||||
Assert(options.once === undefined, 'Cannot use option once with object');
|
||||
|
||||
const keys = Utils.keys(ref, options);
|
||||
if (!keys.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Keys list
|
||||
|
||||
if (Array.isArray(values)) {
|
||||
return internals.array(keys, values, options);
|
||||
}
|
||||
|
||||
// Key value pairs
|
||||
|
||||
const symbols = Object.getOwnPropertySymbols(values).filter((sym) => values.propertyIsEnumerable(sym));
|
||||
const targets = [...Object.keys(values), ...symbols];
|
||||
|
||||
const compare = internals.compare(options);
|
||||
const set = new Set(targets);
|
||||
|
||||
for (const key of keys) {
|
||||
if (!set.has(key)) {
|
||||
if (options.only) {
|
||||
return false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!compare(values[key], ref[key])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.delete(key);
|
||||
}
|
||||
|
||||
if (set.size) {
|
||||
return options.part ? set.size < targets.length : false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
internals.string = function (ref, values, options) {
|
||||
|
||||
// Empty string
|
||||
|
||||
if (ref === '') {
|
||||
return values.length === 1 && values[0] === '' || // '' contains ''
|
||||
!options.once && !values.some((v) => v !== ''); // '' contains multiple '' if !once
|
||||
}
|
||||
|
||||
// Map values
|
||||
|
||||
const map = new Map();
|
||||
const patterns = [];
|
||||
|
||||
for (const value of values) {
|
||||
Assert(typeof value === 'string', 'Cannot compare string reference to non-string value');
|
||||
|
||||
if (value) {
|
||||
const existing = map.get(value);
|
||||
if (existing) {
|
||||
++existing.allowed;
|
||||
}
|
||||
else {
|
||||
map.set(value, { allowed: 1, hits: 0 });
|
||||
patterns.push(EscapeRegex(value));
|
||||
}
|
||||
}
|
||||
else if (options.once ||
|
||||
options.only) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!patterns.length) { // Non-empty string contains unlimited empty string
|
||||
return true;
|
||||
}
|
||||
|
||||
// Match patterns
|
||||
|
||||
const regex = new RegExp(`(${patterns.join('|')})`, 'g');
|
||||
const leftovers = ref.replace(regex, ($0, $1) => {
|
||||
|
||||
++map.get($1).hits;
|
||||
return ''; // Remove from string
|
||||
});
|
||||
|
||||
// Validate results
|
||||
|
||||
if (options.only &&
|
||||
leftovers) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let any = false;
|
||||
for (const match of map.values()) {
|
||||
if (match.hits) {
|
||||
any = true;
|
||||
}
|
||||
|
||||
if (match.hits === match.allowed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (match.hits < match.allowed &&
|
||||
!options.part) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// match.hits > match.allowed
|
||||
|
||||
if (options.once) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !!any;
|
||||
};
|
||||
|
||||
|
||||
internals.compare = function (options) {
|
||||
|
||||
if (!options.deep) {
|
||||
return internals.shallow;
|
||||
}
|
||||
|
||||
const hasOnly = options.only !== undefined;
|
||||
const hasPart = options.part !== undefined;
|
||||
|
||||
const flags = {
|
||||
prototype: hasOnly ? options.only : hasPart ? !options.part : false,
|
||||
part: hasOnly ? !options.only : hasPart ? options.part : false
|
||||
};
|
||||
|
||||
return (a, b) => DeepEqual(a, b, flags);
|
||||
};
|
||||
|
||||
|
||||
internals.shallow = function (a, b) {
|
||||
|
||||
return a === b;
|
||||
};
|
@ -0,0 +1,317 @@
|
||||
'use strict';
|
||||
|
||||
const Types = require('./types');
|
||||
|
||||
|
||||
const internals = {
|
||||
mismatched: null
|
||||
};
|
||||
|
||||
|
||||
module.exports = function (obj, ref, options) {
|
||||
|
||||
options = Object.assign({ prototype: true }, options);
|
||||
|
||||
return !!internals.isDeepEqual(obj, ref, options, []);
|
||||
};
|
||||
|
||||
|
||||
internals.isDeepEqual = function (obj, ref, options, seen) {
|
||||
|
||||
if (obj === ref) { // Copied from Deep-eql, copyright(c) 2013 Jake Luer, jake@alogicalparadox.com, MIT Licensed, https://github.com/chaijs/deep-eql
|
||||
return obj !== 0 || 1 / obj === 1 / ref;
|
||||
}
|
||||
|
||||
const type = typeof obj;
|
||||
|
||||
if (type !== typeof ref) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj === null ||
|
||||
ref === null) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type === 'function') {
|
||||
if (!options.deepFunction ||
|
||||
obj.toString() !== ref.toString()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Continue as object
|
||||
}
|
||||
else if (type !== 'object') {
|
||||
return obj !== obj && ref !== ref; // NaN
|
||||
}
|
||||
|
||||
const instanceType = internals.getSharedType(obj, ref, !!options.prototype);
|
||||
switch (instanceType) {
|
||||
case Types.buffer:
|
||||
return Buffer && Buffer.prototype.equals.call(obj, ref); // $lab:coverage:ignore$
|
||||
case Types.promise:
|
||||
return obj === ref;
|
||||
case Types.regex:
|
||||
return obj.toString() === ref.toString();
|
||||
case internals.mismatched:
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = seen.length - 1; i >= 0; --i) {
|
||||
if (seen[i].isSame(obj, ref)) {
|
||||
return true; // If previous comparison failed, it would have stopped execution
|
||||
}
|
||||
}
|
||||
|
||||
seen.push(new internals.SeenEntry(obj, ref));
|
||||
|
||||
try {
|
||||
return !!internals.isDeepEqualObj(instanceType, obj, ref, options, seen);
|
||||
}
|
||||
finally {
|
||||
seen.pop();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.getSharedType = function (obj, ref, checkPrototype) {
|
||||
|
||||
if (checkPrototype) {
|
||||
if (Object.getPrototypeOf(obj) !== Object.getPrototypeOf(ref)) {
|
||||
return internals.mismatched;
|
||||
}
|
||||
|
||||
return Types.getInternalProto(obj);
|
||||
}
|
||||
|
||||
const type = Types.getInternalProto(obj);
|
||||
if (type !== Types.getInternalProto(ref)) {
|
||||
return internals.mismatched;
|
||||
}
|
||||
|
||||
return type;
|
||||
};
|
||||
|
||||
|
||||
internals.valueOf = function (obj) {
|
||||
|
||||
const objValueOf = obj.valueOf;
|
||||
if (objValueOf === undefined) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
try {
|
||||
return objValueOf.call(obj);
|
||||
}
|
||||
catch (err) {
|
||||
return err;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.hasOwnEnumerableProperty = function (obj, key) {
|
||||
|
||||
return Object.prototype.propertyIsEnumerable.call(obj, key);
|
||||
};
|
||||
|
||||
|
||||
internals.isSetSimpleEqual = function (obj, ref) {
|
||||
|
||||
for (const entry of Set.prototype.values.call(obj)) {
|
||||
if (!Set.prototype.has.call(ref, entry)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
internals.isDeepEqualObj = function (instanceType, obj, ref, options, seen) {
|
||||
|
||||
const { isDeepEqual, valueOf, hasOwnEnumerableProperty } = internals;
|
||||
const { keys, getOwnPropertySymbols } = Object;
|
||||
|
||||
if (instanceType === Types.array) {
|
||||
if (options.part) {
|
||||
|
||||
// Check if any index match any other index
|
||||
|
||||
for (const objValue of obj) {
|
||||
for (const refValue of ref) {
|
||||
if (isDeepEqual(objValue, refValue, options, seen)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (obj.length !== ref.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < obj.length; ++i) {
|
||||
if (!isDeepEqual(obj[i], ref[i], options, seen)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (instanceType === Types.set) {
|
||||
if (obj.size !== ref.size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!internals.isSetSimpleEqual(obj, ref)) {
|
||||
|
||||
// Check for deep equality
|
||||
|
||||
const ref2 = new Set(Set.prototype.values.call(ref));
|
||||
for (const objEntry of Set.prototype.values.call(obj)) {
|
||||
if (ref2.delete(objEntry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let found = false;
|
||||
for (const refEntry of ref2) {
|
||||
if (isDeepEqual(objEntry, refEntry, options, seen)) {
|
||||
ref2.delete(refEntry);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (instanceType === Types.map) {
|
||||
if (obj.size !== ref.size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const [key, value] of Map.prototype.entries.call(obj)) {
|
||||
if (value === undefined && !Map.prototype.has.call(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isDeepEqual(value, Map.prototype.get.call(ref, key), options, seen)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (instanceType === Types.error) {
|
||||
|
||||
// Always check name and message
|
||||
|
||||
if (obj.name !== ref.name ||
|
||||
obj.message !== ref.message) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check .valueOf()
|
||||
|
||||
const valueOfObj = valueOf(obj);
|
||||
const valueOfRef = valueOf(ref);
|
||||
if ((obj !== valueOfObj || ref !== valueOfRef) &&
|
||||
!isDeepEqual(valueOfObj, valueOfRef, options, seen)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check properties
|
||||
|
||||
const objKeys = keys(obj);
|
||||
if (!options.part &&
|
||||
objKeys.length !== keys(ref).length &&
|
||||
!options.skip) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let skipped = 0;
|
||||
for (const key of objKeys) {
|
||||
if (options.skip &&
|
||||
options.skip.includes(key)) {
|
||||
|
||||
if (ref[key] === undefined) {
|
||||
++skipped;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!hasOwnEnumerableProperty(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isDeepEqual(obj[key], ref[key], options, seen)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.part &&
|
||||
objKeys.length - skipped !== keys(ref).length) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check symbols
|
||||
|
||||
if (options.symbols !== false) { // Defaults to true
|
||||
const objSymbols = getOwnPropertySymbols(obj);
|
||||
const refSymbols = new Set(getOwnPropertySymbols(ref));
|
||||
|
||||
for (const key of objSymbols) {
|
||||
if (!options.skip ||
|
||||
!options.skip.includes(key)) {
|
||||
|
||||
if (hasOwnEnumerableProperty(obj, key)) {
|
||||
if (!hasOwnEnumerableProperty(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isDeepEqual(obj[key], ref[key], options, seen)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (hasOwnEnumerableProperty(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
refSymbols.delete(key);
|
||||
}
|
||||
|
||||
for (const key of refSymbols) {
|
||||
if (hasOwnEnumerableProperty(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
internals.SeenEntry = class {
|
||||
|
||||
constructor(obj, ref) {
|
||||
|
||||
this.obj = obj;
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
isSame(obj, ref) {
|
||||
|
||||
return this.obj === obj && this.ref === ref;
|
||||
}
|
||||
};
|
@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const Stringify = require('./stringify');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = class extends Error {
|
||||
|
||||
constructor(args) {
|
||||
|
||||
const msgs = args
|
||||
.filter((arg) => arg !== '')
|
||||
.map((arg) => {
|
||||
|
||||
return typeof arg === 'string' ? arg : arg instanceof Error ? arg.message : Stringify(arg);
|
||||
});
|
||||
|
||||
super(msgs.join(' ') || 'Unknown error');
|
||||
|
||||
if (typeof Error.captureStackTrace === 'function') { // $lab:coverage:ignore$
|
||||
Error.captureStackTrace(this, exports.assert);
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (attribute) {
|
||||
|
||||
// Allowed value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9, \, "
|
||||
|
||||
Assert(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~\"\\]*$/.test(attribute), 'Bad attribute value (' + attribute + ')');
|
||||
|
||||
return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"'); // Escape quotes and slash
|
||||
};
|
@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (input) {
|
||||
|
||||
if (!input) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let escaped = '';
|
||||
|
||||
for (let i = 0; i < input.length; ++i) {
|
||||
|
||||
const charCode = input.charCodeAt(i);
|
||||
|
||||
if (internals.isSafe(charCode)) {
|
||||
escaped += input[i];
|
||||
}
|
||||
else {
|
||||
escaped += internals.escapeHtmlChar(charCode);
|
||||
}
|
||||
}
|
||||
|
||||
return escaped;
|
||||
};
|
||||
|
||||
|
||||
internals.escapeHtmlChar = function (charCode) {
|
||||
|
||||
const namedEscape = internals.namedHtml.get(charCode);
|
||||
if (namedEscape) {
|
||||
return namedEscape;
|
||||
}
|
||||
|
||||
if (charCode >= 256) {
|
||||
return '&#' + charCode + ';';
|
||||
}
|
||||
|
||||
const hexValue = charCode.toString(16).padStart(2, '0');
|
||||
return `&#x${hexValue};`;
|
||||
};
|
||||
|
||||
|
||||
internals.isSafe = function (charCode) {
|
||||
|
||||
return internals.safeCharCodes.has(charCode);
|
||||
};
|
||||
|
||||
|
||||
internals.namedHtml = new Map([
|
||||
[38, '&'],
|
||||
[60, '<'],
|
||||
[62, '>'],
|
||||
[34, '"'],
|
||||
[160, ' '],
|
||||
[162, '¢'],
|
||||
[163, '£'],
|
||||
[164, '¤'],
|
||||
[169, '©'],
|
||||
[174, '®']
|
||||
]);
|
||||
|
||||
|
||||
internals.safeCharCodes = (function () {
|
||||
|
||||
const safe = new Set();
|
||||
|
||||
for (let i = 32; i < 123; ++i) {
|
||||
|
||||
if ((i >= 97) || // a-z
|
||||
(i >= 65 && i <= 90) || // A-Z
|
||||
(i >= 48 && i <= 57) || // 0-9
|
||||
i === 32 || // space
|
||||
i === 46 || // .
|
||||
i === 44 || // ,
|
||||
i === 45 || // -
|
||||
i === 58 || // :
|
||||
i === 95) { // _
|
||||
|
||||
safe.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return safe;
|
||||
}());
|
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (input) {
|
||||
|
||||
if (!input) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return input.replace(/[<>&\u2028\u2029]/g, internals.escape);
|
||||
};
|
||||
|
||||
|
||||
internals.escape = function (char) {
|
||||
|
||||
return internals.replacements.get(char);
|
||||
};
|
||||
|
||||
|
||||
internals.replacements = new Map([
|
||||
['<', '\\u003c'],
|
||||
['>', '\\u003e'],
|
||||
['&', '\\u0026'],
|
||||
['\u2028', '\\u2028'],
|
||||
['\u2029', '\\u2029']
|
||||
]);
|
@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (string) {
|
||||
|
||||
// Escape ^$.*+-?=!:|\/()[]{},
|
||||
|
||||
return string.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g, '\\$&');
|
||||
};
|
@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = internals.flatten = function (array, target) {
|
||||
|
||||
const result = target || [];
|
||||
|
||||
for (const entry of array) {
|
||||
if (Array.isArray(entry)) {
|
||||
internals.flatten(entry, result);
|
||||
}
|
||||
else {
|
||||
result.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function () { };
|
@ -0,0 +1,471 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
/**
|
||||
* Performs a deep comparison of the two values including support for circular dependencies, prototype, and enumerable properties.
|
||||
*
|
||||
* @param obj - The value being compared.
|
||||
* @param ref - The reference value used for comparison.
|
||||
*
|
||||
* @return true when the two values are equal, otherwise false.
|
||||
*/
|
||||
export function deepEqual(obj: any, ref: any, options?: deepEqual.Options): boolean;
|
||||
|
||||
export namespace deepEqual {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* Compare functions with difference references by comparing their internal code and properties.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly deepFunction?: boolean;
|
||||
|
||||
/**
|
||||
* Allow partial match.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly part?: boolean;
|
||||
|
||||
/**
|
||||
* Compare the objects' prototypes.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly prototype?: boolean;
|
||||
|
||||
/**
|
||||
* List of object keys to ignore different values of.
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
readonly skip?: (string | symbol)[];
|
||||
|
||||
/**
|
||||
* Compare symbol properties.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly symbols?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone any value, object, or array.
|
||||
*
|
||||
* @param obj - The value being cloned.
|
||||
* @param options - Optional settings.
|
||||
*
|
||||
* @returns A deep clone of `obj`.
|
||||
*/
|
||||
export function clone<T>(obj: T, options?: clone.Options): T;
|
||||
|
||||
export namespace clone {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* Clone the object's prototype.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly prototype?: boolean;
|
||||
|
||||
/**
|
||||
* Include symbol properties.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly symbols?: boolean;
|
||||
|
||||
/**
|
||||
* Shallow clone the specified keys.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
readonly shallow?: string[] | string[][] | boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Merge all the properties of source into target.
|
||||
*
|
||||
* @param target - The object being modified.
|
||||
* @param source - The object used to copy properties from.
|
||||
* @param options - Optional settings.
|
||||
*
|
||||
* @returns The `target` object.
|
||||
*/
|
||||
export function merge<T1 extends object, T2 extends object>(target: T1, source: T2, options?: merge.Options): T1 & T2;
|
||||
|
||||
export namespace merge {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* When true, null value from `source` overrides existing value in `target`.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly nullOverride?: boolean;
|
||||
|
||||
/**
|
||||
* When true, array value from `source` is merged with the existing value in `target`.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly mergeArrays?: boolean;
|
||||
|
||||
/**
|
||||
* Compare symbol properties.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly symbols?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply source to a copy of the defaults.
|
||||
*
|
||||
* @param defaults - An object with the default values to use of `options` does not contain the same keys.
|
||||
* @param source - The source used to override the `defaults`.
|
||||
* @param options - Optional settings.
|
||||
*
|
||||
* @returns A copy of `defaults` with `source` keys overriding any conflicts.
|
||||
*/
|
||||
export function applyToDefaults<T extends object>(defaults: Partial<T>, source: Partial<T> | boolean | null, options?: applyToDefaults.Options): Partial<T>;
|
||||
|
||||
export namespace applyToDefaults {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* When true, null value from `source` overrides existing value in `target`.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly nullOverride?: boolean;
|
||||
|
||||
/**
|
||||
* Shallow clone the specified keys.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
readonly shallow?: string[] | string[][];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find the common unique items in two arrays.
|
||||
*
|
||||
* @param array1 - The first array to compare.
|
||||
* @param array2 - The second array to compare.
|
||||
* @param options - Optional settings.
|
||||
*
|
||||
* @return - An array of the common items. If `justFirst` is true, returns the first common item.
|
||||
*/
|
||||
export function intersect<T1, T2>(array1: intersect.Array<T1>, array2: intersect.Array<T2>, options?: intersect.Options): Array<T1 | T2>;
|
||||
export function intersect<T1, T2>(array1: intersect.Array<T1>, array2: intersect.Array<T2>, options?: intersect.Options): T1 | T2;
|
||||
|
||||
export namespace intersect {
|
||||
|
||||
type Array<T> = ArrayLike<T> | Set<T> | null;
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* When true, return the first overlapping value.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly first?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the reference value contains the provided values.
|
||||
*
|
||||
* @param ref - The reference string, array, or object.
|
||||
* @param values - A single or array of values to find within `ref`. If `ref` is an object, `values` can be a key name, an array of key names, or an object with key-value pairs to compare.
|
||||
*
|
||||
* @return true if the value contains the provided values, otherwise false.
|
||||
*/
|
||||
export function contain(ref: string, values: string | string[], options?: contain.Options): boolean;
|
||||
export function contain(ref: any[], values: any, options?: contain.Options): boolean;
|
||||
export function contain(ref: object, values: string | string[] | object, options?: Omit<contain.Options, 'once'>): boolean;
|
||||
|
||||
export namespace contain {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* Perform a deep comparison.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly deep?: boolean;
|
||||
|
||||
/**
|
||||
* Allow only one occurrence of each value.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly once?: boolean;
|
||||
|
||||
/**
|
||||
* Allow only values explicitly listed.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly only?: boolean;
|
||||
|
||||
/**
|
||||
* Allow partial match.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly part?: boolean;
|
||||
|
||||
/**
|
||||
* Include symbol properties.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly symbols?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flatten an array with sub arrays
|
||||
*
|
||||
* @param array - an array of items or other arrays to flatten.
|
||||
* @param target - if provided, an array to shallow copy the flattened `array` items to
|
||||
*
|
||||
* @return a flat array of the provided values (appended to `target` is provided).
|
||||
*/
|
||||
export function flatten<T>(array: ArrayLike<T | ReadonlyArray<T>>, target?: ArrayLike<T | ReadonlyArray<T>>): T[];
|
||||
|
||||
|
||||
/**
|
||||
* Convert an object key chain string to reference.
|
||||
*
|
||||
* @param obj - the object from which to look up the value.
|
||||
* @param chain - the string path of the requested value. The chain string is split into key names using `options.separator`, or an array containing each individual key name. A chain including negative numbers will work like a negative index on an array.
|
||||
*
|
||||
* @return The value referenced by the chain if found, otherwise undefined. If chain is null, undefined, or false, the object itself will be returned.
|
||||
*/
|
||||
export function reach(obj: object | null, chain: string | (string | number)[] | false | null | undefined, options?: reach.Options): any;
|
||||
|
||||
export namespace reach {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* String to split chain path on. Defaults to '.'.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly separator?: string;
|
||||
|
||||
/**
|
||||
* Value to return if the path or value is not present. No default value.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly default?: any;
|
||||
|
||||
/**
|
||||
* If true, will throw an error on missing member in the chain. Default to false.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly strict?: boolean;
|
||||
|
||||
/**
|
||||
* If true, allows traversing functions for properties. false will throw an error if a function is part of the chain.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly functions?: boolean;
|
||||
|
||||
/**
|
||||
* If true, allows traversing Set and Map objects for properties. false will return undefined regardless of the Set or Map passed.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly iterables?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace string parameters (using format "{path.to.key}") with their corresponding object key values using `Hoek.reach()`.
|
||||
*
|
||||
* @param obj - the object from which to look up the value.
|
||||
* @param template - the string containing {} enclosed key paths to be replaced.
|
||||
*
|
||||
* @return The template string with the {} enclosed keys replaced with looked-up values.
|
||||
*/
|
||||
export function reachTemplate(obj: object | null, template: string, options?: reach.Options): string;
|
||||
|
||||
|
||||
/**
|
||||
* Throw an error if condition is falsy.
|
||||
*
|
||||
* @param condition - If `condition` is not truthy, an exception is thrown.
|
||||
* @param error - The error thrown if the condition fails.
|
||||
*
|
||||
* @return Does not return a value but throws if the `condition` is falsy.
|
||||
*/
|
||||
export function assert(condition: any, error: Error): void;
|
||||
|
||||
|
||||
/**
|
||||
* Throw an error if condition is falsy.
|
||||
*
|
||||
* @param condition - If `condition` is not truthy, an exception is thrown.
|
||||
* @param args - Any number of values, concatenated together (space separated) to create the error message.
|
||||
*
|
||||
* @return Does not return a value but throws if the `condition` is falsy.
|
||||
*/
|
||||
export function assert(condition: any, ...args: any): void;
|
||||
|
||||
|
||||
/**
|
||||
* A benchmarking timer, using the internal node clock for maximum accuracy.
|
||||
*/
|
||||
export class Bench {
|
||||
|
||||
constructor();
|
||||
|
||||
/** The starting timestamp expressed in the number of milliseconds since the epoch. */
|
||||
ts: number;
|
||||
|
||||
/** The time in milliseconds since the object was created. */
|
||||
elapsed(): number;
|
||||
|
||||
/** Reset the `ts` value to now. */
|
||||
reset(): void;
|
||||
|
||||
/** The current time in milliseconds since the epoch. */
|
||||
static now(): number;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Escape string for Regex construction by prefixing all reserved characters with a backslash.
|
||||
*
|
||||
* @param string - The string to be escaped.
|
||||
*
|
||||
* @return The escaped string.
|
||||
*/
|
||||
export function escapeRegex(string: string): string;
|
||||
|
||||
|
||||
/**
|
||||
* Escape string for usage as an attribute value in HTTP headers.
|
||||
*
|
||||
* @param attribute - The string to be escaped.
|
||||
*
|
||||
* @return The escaped string. Will throw on invalid characters that are not supported to be escaped.
|
||||
*/
|
||||
export function escapeHeaderAttribute(attribute: string): string;
|
||||
|
||||
|
||||
/**
|
||||
* Escape string for usage in HTML.
|
||||
*
|
||||
* @param string - The string to be escaped.
|
||||
*
|
||||
* @return The escaped string.
|
||||
*/
|
||||
export function escapeHtml(string: string): string;
|
||||
|
||||
|
||||
/**
|
||||
* Escape string for usage in JSON.
|
||||
*
|
||||
* @param string - The string to be escaped.
|
||||
*
|
||||
* @return The escaped string.
|
||||
*/
|
||||
export function escapeJson(string: string): string;
|
||||
|
||||
|
||||
/**
|
||||
* Wraps a function to ensure it can only execute once.
|
||||
*
|
||||
* @param method - The function to be wrapped.
|
||||
*
|
||||
* @return The wrapped function.
|
||||
*/
|
||||
export function once<T extends Function>(method: T): T;
|
||||
|
||||
|
||||
/**
|
||||
* A reusable no-op function.
|
||||
*/
|
||||
export function ignore(...ignore: any): void;
|
||||
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string with protection against thrown errors.
|
||||
*
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer The JSON.stringify() `replacer` argument.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*
|
||||
* @return The JSON string. If the operation fails, an error string value is returned (no exception thrown).
|
||||
*/
|
||||
export function stringify(value: any, replacer?: any, space?: string | number): string;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a Promise that resolves after the requested timeout.
|
||||
*
|
||||
* @param timeout - The number of milliseconds to wait before resolving the Promise.
|
||||
* @param returnValue - The value that the Promise will resolve to.
|
||||
*
|
||||
* @return A Promise that resolves with `returnValue`.
|
||||
*/
|
||||
export function wait<T>(timeout?: number, returnValue?: T): Promise<T>;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a Promise that never resolves.
|
||||
*/
|
||||
export function block(): Promise<void>;
|
||||
|
||||
|
||||
/**
|
||||
* Determines if an object is a promise.
|
||||
*
|
||||
* @param promise - the object tested.
|
||||
*
|
||||
* @returns true if the object is a promise, otherwise false.
|
||||
*/
|
||||
export function isPromise(promise: any): boolean;
|
||||
|
||||
|
||||
export namespace ts {
|
||||
|
||||
/**
|
||||
* Defines a type that can must be one of T or U but not both.
|
||||
*/
|
||||
type XOR<T, U> = (T | U) extends object ? (internals.Without<T, U> & U) | (internals.Without<U, T> & T) : T | U;
|
||||
}
|
||||
|
||||
|
||||
declare namespace internals {
|
||||
|
||||
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
exports.applyToDefaults = require('./applyToDefaults');
|
||||
|
||||
exports.assert = require('./assert');
|
||||
|
||||
exports.Bench = require('./bench');
|
||||
|
||||
exports.block = require('./block');
|
||||
|
||||
exports.clone = require('./clone');
|
||||
|
||||
exports.contain = require('./contain');
|
||||
|
||||
exports.deepEqual = require('./deepEqual');
|
||||
|
||||
exports.Error = require('./error');
|
||||
|
||||
exports.escapeHeaderAttribute = require('./escapeHeaderAttribute');
|
||||
|
||||
exports.escapeHtml = require('./escapeHtml');
|
||||
|
||||
exports.escapeJson = require('./escapeJson');
|
||||
|
||||
exports.escapeRegex = require('./escapeRegex');
|
||||
|
||||
exports.flatten = require('./flatten');
|
||||
|
||||
exports.ignore = require('./ignore');
|
||||
|
||||
exports.intersect = require('./intersect');
|
||||
|
||||
exports.isPromise = require('./isPromise');
|
||||
|
||||
exports.merge = require('./merge');
|
||||
|
||||
exports.once = require('./once');
|
||||
|
||||
exports.reach = require('./reach');
|
||||
|
||||
exports.reachTemplate = require('./reachTemplate');
|
||||
|
||||
exports.stringify = require('./stringify');
|
||||
|
||||
exports.wait = require('./wait');
|
@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (array1, array2, options = {}) {
|
||||
|
||||
if (!array1 ||
|
||||
!array2) {
|
||||
|
||||
return (options.first ? null : []);
|
||||
}
|
||||
|
||||
const common = [];
|
||||
const hash = (Array.isArray(array1) ? new Set(array1) : array1);
|
||||
const found = new Set();
|
||||
for (const value of array2) {
|
||||
if (internals.has(hash, value) &&
|
||||
!found.has(value)) {
|
||||
|
||||
if (options.first) {
|
||||
return value;
|
||||
}
|
||||
|
||||
common.push(value);
|
||||
found.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
return (options.first ? null : common);
|
||||
};
|
||||
|
||||
|
||||
internals.has = function (ref, key) {
|
||||
|
||||
if (typeof ref.has === 'function') {
|
||||
return ref.has(key);
|
||||
}
|
||||
|
||||
return ref[key] !== undefined;
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (promise) {
|
||||
|
||||
return !!promise && typeof promise.then === 'function';
|
||||
};
|
@ -0,0 +1,78 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
const Clone = require('./clone');
|
||||
const Utils = require('./utils');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = internals.merge = function (target, source, options) {
|
||||
|
||||
Assert(target && typeof target === 'object', 'Invalid target value: must be an object');
|
||||
Assert(source === null || source === undefined || typeof source === 'object', 'Invalid source value: must be null, undefined, or an object');
|
||||
|
||||
if (!source) {
|
||||
return target;
|
||||
}
|
||||
|
||||
options = Object.assign({ nullOverride: true, mergeArrays: true }, options);
|
||||
|
||||
if (Array.isArray(source)) {
|
||||
Assert(Array.isArray(target), 'Cannot merge array onto an object');
|
||||
if (!options.mergeArrays) {
|
||||
target.length = 0; // Must not change target assignment
|
||||
}
|
||||
|
||||
for (let i = 0; i < source.length; ++i) {
|
||||
target.push(Clone(source[i], { symbols: options.symbols }));
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
const keys = Utils.keys(source, options);
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
const key = keys[i];
|
||||
if (key === '__proto__' ||
|
||||
!Object.prototype.propertyIsEnumerable.call(source, key)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const value = source[key];
|
||||
if (value &&
|
||||
typeof value === 'object') {
|
||||
|
||||
if (target[key] === value) {
|
||||
continue; // Can occur for shallow merges
|
||||
}
|
||||
|
||||
if (!target[key] ||
|
||||
typeof target[key] !== 'object' ||
|
||||
(Array.isArray(target[key]) !== Array.isArray(value)) ||
|
||||
value instanceof Date ||
|
||||
(Buffer && Buffer.isBuffer(value)) || // $lab:coverage:ignore$
|
||||
value instanceof RegExp) {
|
||||
|
||||
target[key] = Clone(value, { symbols: options.symbols });
|
||||
}
|
||||
else {
|
||||
internals.merge(target[key], value, options);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (value !== null &&
|
||||
value !== undefined) { // Explicit to preserve empty strings
|
||||
|
||||
target[key] = value;
|
||||
}
|
||||
else if (options.nullOverride) {
|
||||
target[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {
|
||||
wrapped: Symbol('wrapped')
|
||||
};
|
||||
|
||||
|
||||
module.exports = function (method) {
|
||||
|
||||
if (method[internals.wrapped]) {
|
||||
return method;
|
||||
}
|
||||
|
||||
let once = false;
|
||||
const wrappedFn = function (...args) {
|
||||
|
||||
if (!once) {
|
||||
once = true;
|
||||
method(...args);
|
||||
}
|
||||
};
|
||||
|
||||
wrappedFn[internals.wrapped] = true;
|
||||
return wrappedFn;
|
||||
};
|
@ -0,0 +1,76 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (obj, chain, options) {
|
||||
|
||||
if (chain === false ||
|
||||
chain === null ||
|
||||
chain === undefined) {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
if (typeof options === 'string') {
|
||||
options = { separator: options };
|
||||
}
|
||||
|
||||
const isChainArray = Array.isArray(chain);
|
||||
|
||||
Assert(!isChainArray || !options.separator, 'Separator option is not valid for array-based chain');
|
||||
|
||||
const path = isChainArray ? chain : chain.split(options.separator || '.');
|
||||
let ref = obj;
|
||||
for (let i = 0; i < path.length; ++i) {
|
||||
let key = path[i];
|
||||
const type = options.iterables && internals.iterables(ref);
|
||||
|
||||
if (Array.isArray(ref) ||
|
||||
type === 'set') {
|
||||
|
||||
const number = Number(key);
|
||||
if (Number.isInteger(number)) {
|
||||
key = number < 0 ? ref.length + number : number;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ref ||
|
||||
typeof ref === 'function' && options.functions === false || // Defaults to true
|
||||
!type && ref[key] === undefined) {
|
||||
|
||||
Assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);
|
||||
Assert(typeof ref === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);
|
||||
ref = options.default;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!type) {
|
||||
ref = ref[key];
|
||||
}
|
||||
else if (type === 'set') {
|
||||
ref = [...ref][key];
|
||||
}
|
||||
else { // type === 'map'
|
||||
ref = ref.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
return ref;
|
||||
};
|
||||
|
||||
|
||||
internals.iterables = function (ref) {
|
||||
|
||||
if (ref instanceof Set) {
|
||||
return 'set';
|
||||
}
|
||||
|
||||
if (ref instanceof Map) {
|
||||
return 'map';
|
||||
}
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const Reach = require('./reach');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (obj, template, options) {
|
||||
|
||||
return template.replace(/{([^{}]+)}/g, ($0, chain) => {
|
||||
|
||||
const value = Reach(obj, chain, options);
|
||||
return (value === undefined || value === null ? '' : value);
|
||||
});
|
||||
};
|
@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (...args) {
|
||||
|
||||
try {
|
||||
return JSON.stringify(...args);
|
||||
}
|
||||
catch (err) {
|
||||
return '[Cannot display object: ' + err.message + ']';
|
||||
}
|
||||
};
|
@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports = module.exports = {
|
||||
array: Array.prototype,
|
||||
buffer: Buffer && Buffer.prototype, // $lab:coverage:ignore$
|
||||
date: Date.prototype,
|
||||
error: Error.prototype,
|
||||
generic: Object.prototype,
|
||||
map: Map.prototype,
|
||||
promise: Promise.prototype,
|
||||
regex: RegExp.prototype,
|
||||
set: Set.prototype,
|
||||
weakMap: WeakMap.prototype,
|
||||
weakSet: WeakSet.prototype
|
||||
};
|
||||
|
||||
|
||||
internals.typeMap = new Map([
|
||||
['[object Error]', exports.error],
|
||||
['[object Map]', exports.map],
|
||||
['[object Promise]', exports.promise],
|
||||
['[object Set]', exports.set],
|
||||
['[object WeakMap]', exports.weakMap],
|
||||
['[object WeakSet]', exports.weakSet]
|
||||
]);
|
||||
|
||||
|
||||
exports.getInternalProto = function (obj) {
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return exports.array;
|
||||
}
|
||||
|
||||
if (Buffer && obj instanceof Buffer) { // $lab:coverage:ignore$
|
||||
return exports.buffer;
|
||||
}
|
||||
|
||||
if (obj instanceof Date) {
|
||||
return exports.date;
|
||||
}
|
||||
|
||||
if (obj instanceof RegExp) {
|
||||
return exports.regex;
|
||||
}
|
||||
|
||||
if (obj instanceof Error) {
|
||||
return exports.error;
|
||||
}
|
||||
|
||||
const objName = Object.prototype.toString.call(obj);
|
||||
return internals.typeMap.get(objName) || exports.generic;
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports.keys = function (obj, options = {}) {
|
||||
|
||||
return options.symbols !== false ? Reflect.ownKeys(obj) : Object.getOwnPropertyNames(obj); // Defaults to true
|
||||
};
|
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {
|
||||
maxTimer: 2 ** 31 - 1 // ~25 days
|
||||
};
|
||||
|
||||
|
||||
module.exports = function (timeout, returnValue, options) {
|
||||
|
||||
if (typeof timeout === 'bigint') {
|
||||
timeout = Number(timeout);
|
||||
}
|
||||
|
||||
if (timeout >= Number.MAX_SAFE_INTEGER) { // Thousands of years
|
||||
timeout = Infinity;
|
||||
}
|
||||
|
||||
if (typeof timeout !== 'number' && timeout !== undefined) {
|
||||
throw new TypeError('Timeout must be a number or bigint');
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
|
||||
const _setTimeout = options ? options.setTimeout : setTimeout;
|
||||
|
||||
const activate = () => {
|
||||
|
||||
const time = Math.min(timeout, internals.maxTimer);
|
||||
timeout -= time;
|
||||
_setTimeout(() => (timeout > 0 ? activate() : resolve(returnValue)), time);
|
||||
};
|
||||
|
||||
if (timeout !== Infinity) {
|
||||
activate();
|
||||
}
|
||||
});
|
||||
};
|
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@hapi/hoek",
|
||||
"description": "General purpose node utilities",
|
||||
"version": "9.3.0",
|
||||
"repository": "git://github.com/hapijs/hoek",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"keywords": [
|
||||
"utilities"
|
||||
],
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"plugin:@hapi/module"
|
||||
]
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@hapi/code": "8.x.x",
|
||||
"@hapi/eslint-plugin": "*",
|
||||
"@hapi/lab": "^24.0.0",
|
||||
"typescript": "~4.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "lab -a @hapi/code -t 100 -L -Y",
|
||||
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
|
||||
},
|
||||
"license": "BSD-3-Clause"
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
Copyright (c) 2012-2020, Sideway Inc, and project contributors
|
||||
Copyright (c) 2012-2014, Walmart.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -0,0 +1,60 @@
|
||||
export class Sorter<T> {
|
||||
|
||||
/**
|
||||
* An array of the topologically sorted nodes. This list is renewed upon each call to topo.add().
|
||||
*/
|
||||
nodes: T[];
|
||||
|
||||
/**
|
||||
* Adds a node or list of nodes to be added and topologically sorted
|
||||
*
|
||||
* @param nodes - A mixed value or array of mixed values to be added as nodes to the topologically sorted list.
|
||||
* @param options - Optional sorting information about the nodes.
|
||||
*
|
||||
* @returns Returns an array of the topologically sorted nodes.
|
||||
*/
|
||||
add(nodes: T | T[], options?: Options): T[];
|
||||
|
||||
/**
|
||||
* Merges another Sorter object into the current object.
|
||||
*
|
||||
* @param others - The other object or array of objects to be merged into the current one.
|
||||
*
|
||||
* @returns Returns an array of the topologically sorted nodes.
|
||||
*/
|
||||
merge(others: Sorter<T> | Sorter<T>[]): T[];
|
||||
|
||||
/**
|
||||
* Sorts the nodes array (only required if the manual option is used when adding items)
|
||||
*/
|
||||
sort(): T[];
|
||||
}
|
||||
|
||||
|
||||
export interface Options {
|
||||
|
||||
/**
|
||||
* The sorting group the added items belong to
|
||||
*/
|
||||
readonly group?: string;
|
||||
|
||||
/**
|
||||
* The group or groups the added items must come before
|
||||
*/
|
||||
readonly before?: string | string[];
|
||||
|
||||
/**
|
||||
* The group or groups the added items must come after
|
||||
*/
|
||||
readonly after?: string | string[];
|
||||
|
||||
/**
|
||||
* A number used to sort items with equal before/after requirements
|
||||
*/
|
||||
readonly sort?: number;
|
||||
|
||||
/**
|
||||
* If true, the array is not sorted automatically until sort() is called
|
||||
*/
|
||||
readonly manual?: boolean;
|
||||
}
|
@ -0,0 +1,225 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('@hapi/hoek/lib/assert');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports.Sorter = class {
|
||||
|
||||
constructor() {
|
||||
|
||||
this._items = [];
|
||||
this.nodes = [];
|
||||
}
|
||||
|
||||
add(nodes, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Validate rules
|
||||
|
||||
const before = [].concat(options.before || []);
|
||||
const after = [].concat(options.after || []);
|
||||
const group = options.group || '?';
|
||||
const sort = options.sort || 0; // Used for merging only
|
||||
|
||||
Assert(!before.includes(group), `Item cannot come before itself: ${group}`);
|
||||
Assert(!before.includes('?'), 'Item cannot come before unassociated items');
|
||||
Assert(!after.includes(group), `Item cannot come after itself: ${group}`);
|
||||
Assert(!after.includes('?'), 'Item cannot come after unassociated items');
|
||||
|
||||
if (!Array.isArray(nodes)) {
|
||||
nodes = [nodes];
|
||||
}
|
||||
|
||||
for (const node of nodes) {
|
||||
const item = {
|
||||
seq: this._items.length,
|
||||
sort,
|
||||
before,
|
||||
after,
|
||||
group,
|
||||
node
|
||||
};
|
||||
|
||||
this._items.push(item);
|
||||
}
|
||||
|
||||
// Insert event
|
||||
|
||||
if (!options.manual) {
|
||||
const valid = this._sort();
|
||||
Assert(valid, 'item', group !== '?' ? `added into group ${group}` : '', 'created a dependencies error');
|
||||
}
|
||||
|
||||
return this.nodes;
|
||||
}
|
||||
|
||||
merge(others) {
|
||||
|
||||
if (!Array.isArray(others)) {
|
||||
others = [others];
|
||||
}
|
||||
|
||||
for (const other of others) {
|
||||
if (other) {
|
||||
for (const item of other._items) {
|
||||
this._items.push(Object.assign({}, item)); // Shallow cloned
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort items
|
||||
|
||||
this._items.sort(internals.mergeSort);
|
||||
for (let i = 0; i < this._items.length; ++i) {
|
||||
this._items[i].seq = i;
|
||||
}
|
||||
|
||||
const valid = this._sort();
|
||||
Assert(valid, 'merge created a dependencies error');
|
||||
|
||||
return this.nodes;
|
||||
}
|
||||
|
||||
sort() {
|
||||
|
||||
const valid = this._sort();
|
||||
Assert(valid, 'sort created a dependencies error');
|
||||
|
||||
return this.nodes;
|
||||
}
|
||||
|
||||
_sort() {
|
||||
|
||||
// Construct graph
|
||||
|
||||
const graph = {};
|
||||
const graphAfters = Object.create(null); // A prototype can bungle lookups w/ false positives
|
||||
const groups = Object.create(null);
|
||||
|
||||
for (const item of this._items) {
|
||||
const seq = item.seq; // Unique across all items
|
||||
const group = item.group;
|
||||
|
||||
// Determine Groups
|
||||
|
||||
groups[group] = groups[group] || [];
|
||||
groups[group].push(seq);
|
||||
|
||||
// Build intermediary graph using 'before'
|
||||
|
||||
graph[seq] = item.before;
|
||||
|
||||
// Build second intermediary graph with 'after'
|
||||
|
||||
for (const after of item.after) {
|
||||
graphAfters[after] = graphAfters[after] || [];
|
||||
graphAfters[after].push(seq);
|
||||
}
|
||||
}
|
||||
|
||||
// Expand intermediary graph
|
||||
|
||||
for (const node in graph) {
|
||||
const expandedGroups = [];
|
||||
|
||||
for (const graphNodeItem in graph[node]) {
|
||||
const group = graph[node][graphNodeItem];
|
||||
groups[group] = groups[group] || [];
|
||||
expandedGroups.push(...groups[group]);
|
||||
}
|
||||
|
||||
graph[node] = expandedGroups;
|
||||
}
|
||||
|
||||
// Merge intermediary graph using graphAfters into final graph
|
||||
|
||||
for (const group in graphAfters) {
|
||||
if (groups[group]) {
|
||||
for (const node of groups[group]) {
|
||||
graph[node].push(...graphAfters[group]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compile ancestors
|
||||
|
||||
const ancestors = {};
|
||||
for (const node in graph) {
|
||||
const children = graph[node];
|
||||
for (const child of children) {
|
||||
ancestors[child] = ancestors[child] || [];
|
||||
ancestors[child].push(node);
|
||||
}
|
||||
}
|
||||
|
||||
// Topo sort
|
||||
|
||||
const visited = {};
|
||||
const sorted = [];
|
||||
|
||||
for (let i = 0; i < this._items.length; ++i) { // Looping through item.seq values out of order
|
||||
let next = i;
|
||||
|
||||
if (ancestors[i]) {
|
||||
next = null;
|
||||
for (let j = 0; j < this._items.length; ++j) { // As above, these are item.seq values
|
||||
if (visited[j] === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ancestors[j]) {
|
||||
ancestors[j] = [];
|
||||
}
|
||||
|
||||
const shouldSeeCount = ancestors[j].length;
|
||||
let seenCount = 0;
|
||||
for (let k = 0; k < shouldSeeCount; ++k) {
|
||||
if (visited[ancestors[j][k]]) {
|
||||
++seenCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (seenCount === shouldSeeCount) {
|
||||
next = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (next !== null) {
|
||||
visited[next] = true;
|
||||
sorted.push(next);
|
||||
}
|
||||
}
|
||||
|
||||
if (sorted.length !== this._items.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const seqIndex = {};
|
||||
for (const item of this._items) {
|
||||
seqIndex[item.seq] = item;
|
||||
}
|
||||
|
||||
this._items = [];
|
||||
this.nodes = [];
|
||||
|
||||
for (const value of sorted) {
|
||||
const sortedItem = seqIndex[value];
|
||||
this.nodes.push(sortedItem.node);
|
||||
this._items.push(sortedItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.mergeSort = (a, b) => {
|
||||
|
||||
return a.sort === b.sort ? 0 : (a.sort < b.sort ? -1 : 1);
|
||||
};
|
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "@hapi/topo",
|
||||
"description": "Topological sorting with grouping support",
|
||||
"version": "5.1.0",
|
||||
"repository": "git://github.com/hapijs/topo",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"keywords": [
|
||||
"topological",
|
||||
"sort",
|
||||
"toposort",
|
||||
"topsort"
|
||||
],
|
||||
"dependencies": {
|
||||
"@hapi/hoek": "^9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@hapi/code": "8.x.x",
|
||||
"@hapi/lab": "24.x.x",
|
||||
"typescript": "~4.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "lab -a @hapi/code -t 100 -L -Y",
|
||||
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
|
||||
},
|
||||
"license": "BSD-3-Clause"
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
Copyright (c) 2014 Dmitry Tsvettsikh
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
@ -0,0 +1,4 @@
|
||||
import mod from "./node.js";
|
||||
|
||||
export default mod;
|
||||
export const saslprep = mod.saslprep;
|
@ -0,0 +1,5 @@
|
||||
declare const saslprep: (args_0: string, args_1?: {
|
||||
allowUnassigned?: boolean | undefined;
|
||||
} | undefined) => string;
|
||||
export = saslprep;
|
||||
//# sourceMappingURL=browser.d.ts.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,QAAQ;;wBAAmC,CAAC;AAIlD,SAAS,QAAQ,CAAC"}
|
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const index_1 = __importDefault(require("./index"));
|
||||
const memory_code_points_1 = require("./memory-code-points");
|
||||
const code_points_data_browser_1 = __importDefault(require("./code-points-data-browser"));
|
||||
const codePoints = (0, memory_code_points_1.createMemoryCodePoints)(code_points_data_browser_1.default);
|
||||
const saslprep = index_1.default.bind(null, codePoints);
|
||||
Object.assign(saslprep, { saslprep, default: saslprep });
|
||||
module.exports = saslprep;
|
||||
//# sourceMappingURL=browser.js.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";;;;AAAA,oDAAgC;AAChC,6DAA8D;AAC9D,0FAA8C;AAE9C,MAAM,UAAU,GAAG,IAAA,2CAAsB,EAAC,kCAAI,CAAC,CAAC;AAEhD,MAAM,QAAQ,GAAG,eAAS,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEzD,iBAAS,QAAQ,CAAC"}
|
@ -0,0 +1,4 @@
|
||||
/// <reference types="node" />
|
||||
declare const data: Buffer;
|
||||
export default data;
|
||||
//# sourceMappingURL=code-points-data-browser.d.ts.map
|
1
backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts.map
generated
vendored
1
backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts.map
generated
vendored
@ -0,0 +1 @@
|
||||
{"version":3,"file":"code-points-data-browser.d.ts","sourceRoot":"","sources":["../src/code-points-data-browser.ts"],"names":[],"mappings":";AAAA,QAAA,MAAM,IAAI,QAGT,CAAC;AACF,eAAe,IAAI,CAAC"}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
{"version":3,"file":"code-points-data-browser.js","sourceRoot":"","sources":["../src/code-points-data-browser.ts"],"names":[],"mappings":";;AAAA,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CACtB,8sliBAA8sliB,EAC9sliB,QAAQ,CACT,CAAC;AACF,kBAAe,IAAI,CAAC"}
|
@ -0,0 +1,4 @@
|
||||
/// <reference types="node" />
|
||||
declare const _default: Buffer;
|
||||
export default _default;
|
||||
//# sourceMappingURL=code-points-data.d.ts.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"code-points-data.d.ts","sourceRoot":"","sources":["../src/code-points-data.ts"],"names":[],"mappings":";;AAEA,wBAKE"}
|
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const zlib_1 = require("zlib");
|
||||
exports.default = (0, zlib_1.gunzipSync)(Buffer.from('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', 'base64'));
|
||||
//# sourceMappingURL=code-points-data.js.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"code-points-data.js","sourceRoot":"","sources":["../src/code-points-data.ts"],"names":[],"mappings":";;AAAA,+BAAkC;AAElC,kBAAe,IAAA,iBAAU,EACvB,MAAM,CAAC,IAAI,CACT,knFAAknF,EAClnF,QAAQ,CACT,CACF,CAAC"}
|
@ -0,0 +1,7 @@
|
||||
export declare const unassigned_code_points: Set<number>;
|
||||
export declare const commonly_mapped_to_nothing: Set<number>;
|
||||
export declare const non_ASCII_space_characters: Set<number>;
|
||||
export declare const prohibited_characters: Set<number>;
|
||||
export declare const bidirectional_r_al: Set<number>;
|
||||
export declare const bidirectional_l: Set<number>;
|
||||
//# sourceMappingURL=code-points-src.d.ts.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"code-points-src.d.ts","sourceRoot":"","sources":["../src/code-points-src.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB,aA6YjC,CAAC;AAMH,eAAO,MAAM,0BAA0B,aAIrC,CAAC;AAMH,eAAO,MAAM,0BAA0B,aASrC,CAAC;AAMH,eAAO,MAAM,qBAAqB,aA6GhC,CAAC;AAMH,eAAO,MAAM,kBAAkB,aAmC7B,CAAC;AAMH,eAAO,MAAM,eAAe,aAyW1B,CAAC"}
|
@ -0,0 +1,881 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.bidirectional_l = exports.bidirectional_r_al = exports.prohibited_characters = exports.non_ASCII_space_characters = exports.commonly_mapped_to_nothing = exports.unassigned_code_points = void 0;
|
||||
const util_1 = require("./util");
|
||||
exports.unassigned_code_points = new Set([
|
||||
0x0221,
|
||||
...(0, util_1.range)(0x0234, 0x024f),
|
||||
...(0, util_1.range)(0x02ae, 0x02af),
|
||||
...(0, util_1.range)(0x02ef, 0x02ff),
|
||||
...(0, util_1.range)(0x0350, 0x035f),
|
||||
...(0, util_1.range)(0x0370, 0x0373),
|
||||
...(0, util_1.range)(0x0376, 0x0379),
|
||||
...(0, util_1.range)(0x037b, 0x037d),
|
||||
...(0, util_1.range)(0x037f, 0x0383),
|
||||
0x038b,
|
||||
0x038d,
|
||||
0x03a2,
|
||||
0x03cf,
|
||||
...(0, util_1.range)(0x03f7, 0x03ff),
|
||||
0x0487,
|
||||
0x04cf,
|
||||
...(0, util_1.range)(0x04f6, 0x04f7),
|
||||
...(0, util_1.range)(0x04fa, 0x04ff),
|
||||
...(0, util_1.range)(0x0510, 0x0530),
|
||||
...(0, util_1.range)(0x0557, 0x0558),
|
||||
0x0560,
|
||||
0x0588,
|
||||
...(0, util_1.range)(0x058b, 0x0590),
|
||||
0x05a2,
|
||||
0x05ba,
|
||||
...(0, util_1.range)(0x05c5, 0x05cf),
|
||||
...(0, util_1.range)(0x05eb, 0x05ef),
|
||||
...(0, util_1.range)(0x05f5, 0x060b),
|
||||
...(0, util_1.range)(0x060d, 0x061a),
|
||||
...(0, util_1.range)(0x061c, 0x061e),
|
||||
0x0620,
|
||||
...(0, util_1.range)(0x063b, 0x063f),
|
||||
...(0, util_1.range)(0x0656, 0x065f),
|
||||
...(0, util_1.range)(0x06ee, 0x06ef),
|
||||
0x06ff,
|
||||
0x070e,
|
||||
...(0, util_1.range)(0x072d, 0x072f),
|
||||
...(0, util_1.range)(0x074b, 0x077f),
|
||||
...(0, util_1.range)(0x07b2, 0x0900),
|
||||
0x0904,
|
||||
...(0, util_1.range)(0x093a, 0x093b),
|
||||
...(0, util_1.range)(0x094e, 0x094f),
|
||||
...(0, util_1.range)(0x0955, 0x0957),
|
||||
...(0, util_1.range)(0x0971, 0x0980),
|
||||
0x0984,
|
||||
...(0, util_1.range)(0x098d, 0x098e),
|
||||
...(0, util_1.range)(0x0991, 0x0992),
|
||||
0x09a9,
|
||||
0x09b1,
|
||||
...(0, util_1.range)(0x09b3, 0x09b5),
|
||||
...(0, util_1.range)(0x09ba, 0x09bb),
|
||||
0x09bd,
|
||||
...(0, util_1.range)(0x09c5, 0x09c6),
|
||||
...(0, util_1.range)(0x09c9, 0x09ca),
|
||||
...(0, util_1.range)(0x09ce, 0x09d6),
|
||||
...(0, util_1.range)(0x09d8, 0x09db),
|
||||
0x09de,
|
||||
...(0, util_1.range)(0x09e4, 0x09e5),
|
||||
...(0, util_1.range)(0x09fb, 0x0a01),
|
||||
...(0, util_1.range)(0x0a03, 0x0a04),
|
||||
...(0, util_1.range)(0x0a0b, 0x0a0e),
|
||||
...(0, util_1.range)(0x0a11, 0x0a12),
|
||||
0x0a29,
|
||||
0x0a31,
|
||||
0x0a34,
|
||||
0x0a37,
|
||||
...(0, util_1.range)(0x0a3a, 0x0a3b),
|
||||
0x0a3d,
|
||||
...(0, util_1.range)(0x0a43, 0x0a46),
|
||||
...(0, util_1.range)(0x0a49, 0x0a4a),
|
||||
...(0, util_1.range)(0x0a4e, 0x0a58),
|
||||
0x0a5d,
|
||||
...(0, util_1.range)(0x0a5f, 0x0a65),
|
||||
...(0, util_1.range)(0x0a75, 0x0a80),
|
||||
0x0a84,
|
||||
0x0a8c,
|
||||
0x0a8e,
|
||||
0x0a92,
|
||||
0x0aa9,
|
||||
0x0ab1,
|
||||
0x0ab4,
|
||||
...(0, util_1.range)(0x0aba, 0x0abb),
|
||||
0x0ac6,
|
||||
0x0aca,
|
||||
...(0, util_1.range)(0x0ace, 0x0acf),
|
||||
...(0, util_1.range)(0x0ad1, 0x0adf),
|
||||
...(0, util_1.range)(0x0ae1, 0x0ae5),
|
||||
...(0, util_1.range)(0x0af0, 0x0b00),
|
||||
0x0b04,
|
||||
...(0, util_1.range)(0x0b0d, 0x0b0e),
|
||||
...(0, util_1.range)(0x0b11, 0x0b12),
|
||||
0x0b29,
|
||||
0x0b31,
|
||||
...(0, util_1.range)(0x0b34, 0x0b35),
|
||||
...(0, util_1.range)(0x0b3a, 0x0b3b),
|
||||
...(0, util_1.range)(0x0b44, 0x0b46),
|
||||
...(0, util_1.range)(0x0b49, 0x0b4a),
|
||||
...(0, util_1.range)(0x0b4e, 0x0b55),
|
||||
...(0, util_1.range)(0x0b58, 0x0b5b),
|
||||
0x0b5e,
|
||||
...(0, util_1.range)(0x0b62, 0x0b65),
|
||||
...(0, util_1.range)(0x0b71, 0x0b81),
|
||||
0x0b84,
|
||||
...(0, util_1.range)(0x0b8b, 0x0b8d),
|
||||
0x0b91,
|
||||
...(0, util_1.range)(0x0b96, 0x0b98),
|
||||
0x0b9b,
|
||||
0x0b9d,
|
||||
...(0, util_1.range)(0x0ba0, 0x0ba2),
|
||||
...(0, util_1.range)(0x0ba5, 0x0ba7),
|
||||
...(0, util_1.range)(0x0bab, 0x0bad),
|
||||
0x0bb6,
|
||||
...(0, util_1.range)(0x0bba, 0x0bbd),
|
||||
...(0, util_1.range)(0x0bc3, 0x0bc5),
|
||||
0x0bc9,
|
||||
...(0, util_1.range)(0x0bce, 0x0bd6),
|
||||
...(0, util_1.range)(0x0bd8, 0x0be6),
|
||||
...(0, util_1.range)(0x0bf3, 0x0c00),
|
||||
0x0c04,
|
||||
0x0c0d,
|
||||
0x0c11,
|
||||
0x0c29,
|
||||
0x0c34,
|
||||
...(0, util_1.range)(0x0c3a, 0x0c3d),
|
||||
0x0c45,
|
||||
0x0c49,
|
||||
...(0, util_1.range)(0x0c4e, 0x0c54),
|
||||
...(0, util_1.range)(0x0c57, 0x0c5f),
|
||||
...(0, util_1.range)(0x0c62, 0x0c65),
|
||||
...(0, util_1.range)(0x0c70, 0x0c81),
|
||||
0x0c84,
|
||||
0x0c8d,
|
||||
0x0c91,
|
||||
0x0ca9,
|
||||
0x0cb4,
|
||||
...(0, util_1.range)(0x0cba, 0x0cbd),
|
||||
0x0cc5,
|
||||
0x0cc9,
|
||||
...(0, util_1.range)(0x0cce, 0x0cd4),
|
||||
...(0, util_1.range)(0x0cd7, 0x0cdd),
|
||||
0x0cdf,
|
||||
...(0, util_1.range)(0x0ce2, 0x0ce5),
|
||||
...(0, util_1.range)(0x0cf0, 0x0d01),
|
||||
0x0d04,
|
||||
0x0d0d,
|
||||
0x0d11,
|
||||
0x0d29,
|
||||
...(0, util_1.range)(0x0d3a, 0x0d3d),
|
||||
...(0, util_1.range)(0x0d44, 0x0d45),
|
||||
0x0d49,
|
||||
...(0, util_1.range)(0x0d4e, 0x0d56),
|
||||
...(0, util_1.range)(0x0d58, 0x0d5f),
|
||||
...(0, util_1.range)(0x0d62, 0x0d65),
|
||||
...(0, util_1.range)(0x0d70, 0x0d81),
|
||||
0x0d84,
|
||||
...(0, util_1.range)(0x0d97, 0x0d99),
|
||||
0x0db2,
|
||||
0x0dbc,
|
||||
...(0, util_1.range)(0x0dbe, 0x0dbf),
|
||||
...(0, util_1.range)(0x0dc7, 0x0dc9),
|
||||
...(0, util_1.range)(0x0dcb, 0x0dce),
|
||||
0x0dd5,
|
||||
0x0dd7,
|
||||
...(0, util_1.range)(0x0de0, 0x0df1),
|
||||
...(0, util_1.range)(0x0df5, 0x0e00),
|
||||
...(0, util_1.range)(0x0e3b, 0x0e3e),
|
||||
...(0, util_1.range)(0x0e5c, 0x0e80),
|
||||
0x0e83,
|
||||
...(0, util_1.range)(0x0e85, 0x0e86),
|
||||
0x0e89,
|
||||
...(0, util_1.range)(0x0e8b, 0x0e8c),
|
||||
...(0, util_1.range)(0x0e8e, 0x0e93),
|
||||
0x0e98,
|
||||
0x0ea0,
|
||||
0x0ea4,
|
||||
0x0ea6,
|
||||
...(0, util_1.range)(0x0ea8, 0x0ea9),
|
||||
0x0eac,
|
||||
0x0eba,
|
||||
...(0, util_1.range)(0x0ebe, 0x0ebf),
|
||||
0x0ec5,
|
||||
0x0ec7,
|
||||
...(0, util_1.range)(0x0ece, 0x0ecf),
|
||||
...(0, util_1.range)(0x0eda, 0x0edb),
|
||||
...(0, util_1.range)(0x0ede, 0x0eff),
|
||||
0x0f48,
|
||||
...(0, util_1.range)(0x0f6b, 0x0f70),
|
||||
...(0, util_1.range)(0x0f8c, 0x0f8f),
|
||||
0x0f98,
|
||||
0x0fbd,
|
||||
...(0, util_1.range)(0x0fcd, 0x0fce),
|
||||
...(0, util_1.range)(0x0fd0, 0x0fff),
|
||||
0x1022,
|
||||
0x1028,
|
||||
0x102b,
|
||||
...(0, util_1.range)(0x1033, 0x1035),
|
||||
...(0, util_1.range)(0x103a, 0x103f),
|
||||
...(0, util_1.range)(0x105a, 0x109f),
|
||||
...(0, util_1.range)(0x10c6, 0x10cf),
|
||||
...(0, util_1.range)(0x10f9, 0x10fa),
|
||||
...(0, util_1.range)(0x10fc, 0x10ff),
|
||||
...(0, util_1.range)(0x115a, 0x115e),
|
||||
...(0, util_1.range)(0x11a3, 0x11a7),
|
||||
...(0, util_1.range)(0x11fa, 0x11ff),
|
||||
0x1207,
|
||||
0x1247,
|
||||
0x1249,
|
||||
...(0, util_1.range)(0x124e, 0x124f),
|
||||
0x1257,
|
||||
0x1259,
|
||||
...(0, util_1.range)(0x125e, 0x125f),
|
||||
0x1287,
|
||||
0x1289,
|
||||
...(0, util_1.range)(0x128e, 0x128f),
|
||||
0x12af,
|
||||
0x12b1,
|
||||
...(0, util_1.range)(0x12b6, 0x12b7),
|
||||
0x12bf,
|
||||
0x12c1,
|
||||
...(0, util_1.range)(0x12c6, 0x12c7),
|
||||
0x12cf,
|
||||
0x12d7,
|
||||
0x12ef,
|
||||
0x130f,
|
||||
0x1311,
|
||||
...(0, util_1.range)(0x1316, 0x1317),
|
||||
0x131f,
|
||||
0x1347,
|
||||
...(0, util_1.range)(0x135b, 0x1360),
|
||||
...(0, util_1.range)(0x137d, 0x139f),
|
||||
...(0, util_1.range)(0x13f5, 0x1400),
|
||||
...(0, util_1.range)(0x1677, 0x167f),
|
||||
...(0, util_1.range)(0x169d, 0x169f),
|
||||
...(0, util_1.range)(0x16f1, 0x16ff),
|
||||
0x170d,
|
||||
...(0, util_1.range)(0x1715, 0x171f),
|
||||
...(0, util_1.range)(0x1737, 0x173f),
|
||||
...(0, util_1.range)(0x1754, 0x175f),
|
||||
0x176d,
|
||||
0x1771,
|
||||
...(0, util_1.range)(0x1774, 0x177f),
|
||||
...(0, util_1.range)(0x17dd, 0x17df),
|
||||
...(0, util_1.range)(0x17ea, 0x17ff),
|
||||
0x180f,
|
||||
...(0, util_1.range)(0x181a, 0x181f),
|
||||
...(0, util_1.range)(0x1878, 0x187f),
|
||||
...(0, util_1.range)(0x18aa, 0x1dff),
|
||||
...(0, util_1.range)(0x1e9c, 0x1e9f),
|
||||
...(0, util_1.range)(0x1efa, 0x1eff),
|
||||
...(0, util_1.range)(0x1f16, 0x1f17),
|
||||
...(0, util_1.range)(0x1f1e, 0x1f1f),
|
||||
...(0, util_1.range)(0x1f46, 0x1f47),
|
||||
...(0, util_1.range)(0x1f4e, 0x1f4f),
|
||||
0x1f58,
|
||||
0x1f5a,
|
||||
0x1f5c,
|
||||
0x1f5e,
|
||||
...(0, util_1.range)(0x1f7e, 0x1f7f),
|
||||
0x1fb5,
|
||||
0x1fc5,
|
||||
...(0, util_1.range)(0x1fd4, 0x1fd5),
|
||||
0x1fdc,
|
||||
...(0, util_1.range)(0x1ff0, 0x1ff1),
|
||||
0x1ff5,
|
||||
0x1fff,
|
||||
...(0, util_1.range)(0x2053, 0x2056),
|
||||
...(0, util_1.range)(0x2058, 0x205e),
|
||||
...(0, util_1.range)(0x2064, 0x2069),
|
||||
...(0, util_1.range)(0x2072, 0x2073),
|
||||
...(0, util_1.range)(0x208f, 0x209f),
|
||||
...(0, util_1.range)(0x20b2, 0x20cf),
|
||||
...(0, util_1.range)(0x20eb, 0x20ff),
|
||||
...(0, util_1.range)(0x213b, 0x213c),
|
||||
...(0, util_1.range)(0x214c, 0x2152),
|
||||
...(0, util_1.range)(0x2184, 0x218f),
|
||||
...(0, util_1.range)(0x23cf, 0x23ff),
|
||||
...(0, util_1.range)(0x2427, 0x243f),
|
||||
...(0, util_1.range)(0x244b, 0x245f),
|
||||
0x24ff,
|
||||
...(0, util_1.range)(0x2614, 0x2615),
|
||||
0x2618,
|
||||
...(0, util_1.range)(0x267e, 0x267f),
|
||||
...(0, util_1.range)(0x268a, 0x2700),
|
||||
0x2705,
|
||||
...(0, util_1.range)(0x270a, 0x270b),
|
||||
0x2728,
|
||||
0x274c,
|
||||
0x274e,
|
||||
...(0, util_1.range)(0x2753, 0x2755),
|
||||
0x2757,
|
||||
...(0, util_1.range)(0x275f, 0x2760),
|
||||
...(0, util_1.range)(0x2795, 0x2797),
|
||||
0x27b0,
|
||||
...(0, util_1.range)(0x27bf, 0x27cf),
|
||||
...(0, util_1.range)(0x27ec, 0x27ef),
|
||||
...(0, util_1.range)(0x2b00, 0x2e7f),
|
||||
0x2e9a,
|
||||
...(0, util_1.range)(0x2ef4, 0x2eff),
|
||||
...(0, util_1.range)(0x2fd6, 0x2fef),
|
||||
...(0, util_1.range)(0x2ffc, 0x2fff),
|
||||
0x3040,
|
||||
...(0, util_1.range)(0x3097, 0x3098),
|
||||
...(0, util_1.range)(0x3100, 0x3104),
|
||||
...(0, util_1.range)(0x312d, 0x3130),
|
||||
0x318f,
|
||||
...(0, util_1.range)(0x31b8, 0x31ef),
|
||||
...(0, util_1.range)(0x321d, 0x321f),
|
||||
...(0, util_1.range)(0x3244, 0x3250),
|
||||
...(0, util_1.range)(0x327c, 0x327e),
|
||||
...(0, util_1.range)(0x32cc, 0x32cf),
|
||||
0x32ff,
|
||||
...(0, util_1.range)(0x3377, 0x337a),
|
||||
...(0, util_1.range)(0x33de, 0x33df),
|
||||
0x33ff,
|
||||
...(0, util_1.range)(0x4db6, 0x4dff),
|
||||
...(0, util_1.range)(0x9fa6, 0x9fff),
|
||||
...(0, util_1.range)(0xa48d, 0xa48f),
|
||||
...(0, util_1.range)(0xa4c7, 0xabff),
|
||||
...(0, util_1.range)(0xd7a4, 0xd7ff),
|
||||
...(0, util_1.range)(0xfa2e, 0xfa2f),
|
||||
...(0, util_1.range)(0xfa6b, 0xfaff),
|
||||
...(0, util_1.range)(0xfb07, 0xfb12),
|
||||
...(0, util_1.range)(0xfb18, 0xfb1c),
|
||||
0xfb37,
|
||||
0xfb3d,
|
||||
0xfb3f,
|
||||
0xfb42,
|
||||
0xfb45,
|
||||
...(0, util_1.range)(0xfbb2, 0xfbd2),
|
||||
...(0, util_1.range)(0xfd40, 0xfd4f),
|
||||
...(0, util_1.range)(0xfd90, 0xfd91),
|
||||
...(0, util_1.range)(0xfdc8, 0xfdcf),
|
||||
...(0, util_1.range)(0xfdfd, 0xfdff),
|
||||
...(0, util_1.range)(0xfe10, 0xfe1f),
|
||||
...(0, util_1.range)(0xfe24, 0xfe2f),
|
||||
...(0, util_1.range)(0xfe47, 0xfe48),
|
||||
0xfe53,
|
||||
0xfe67,
|
||||
...(0, util_1.range)(0xfe6c, 0xfe6f),
|
||||
0xfe75,
|
||||
...(0, util_1.range)(0xfefd, 0xfefe),
|
||||
0xff00,
|
||||
...(0, util_1.range)(0xffbf, 0xffc1),
|
||||
...(0, util_1.range)(0xffc8, 0xffc9),
|
||||
...(0, util_1.range)(0xffd0, 0xffd1),
|
||||
...(0, util_1.range)(0xffd8, 0xffd9),
|
||||
...(0, util_1.range)(0xffdd, 0xffdf),
|
||||
0xffe7,
|
||||
...(0, util_1.range)(0xffef, 0xfff8),
|
||||
...(0, util_1.range)(0x10000, 0x102ff),
|
||||
0x1031f,
|
||||
...(0, util_1.range)(0x10324, 0x1032f),
|
||||
...(0, util_1.range)(0x1034b, 0x103ff),
|
||||
...(0, util_1.range)(0x10426, 0x10427),
|
||||
...(0, util_1.range)(0x1044e, 0x1cfff),
|
||||
...(0, util_1.range)(0x1d0f6, 0x1d0ff),
|
||||
...(0, util_1.range)(0x1d127, 0x1d129),
|
||||
...(0, util_1.range)(0x1d1de, 0x1d3ff),
|
||||
0x1d455,
|
||||
0x1d49d,
|
||||
...(0, util_1.range)(0x1d4a0, 0x1d4a1),
|
||||
...(0, util_1.range)(0x1d4a3, 0x1d4a4),
|
||||
...(0, util_1.range)(0x1d4a7, 0x1d4a8),
|
||||
0x1d4ad,
|
||||
0x1d4ba,
|
||||
0x1d4bc,
|
||||
0x1d4c1,
|
||||
0x1d4c4,
|
||||
0x1d506,
|
||||
...(0, util_1.range)(0x1d50b, 0x1d50c),
|
||||
0x1d515,
|
||||
0x1d51d,
|
||||
0x1d53a,
|
||||
0x1d53f,
|
||||
0x1d545,
|
||||
...(0, util_1.range)(0x1d547, 0x1d549),
|
||||
0x1d551,
|
||||
...(0, util_1.range)(0x1d6a4, 0x1d6a7),
|
||||
...(0, util_1.range)(0x1d7ca, 0x1d7cd),
|
||||
...(0, util_1.range)(0x1d800, 0x1fffd),
|
||||
...(0, util_1.range)(0x2a6d7, 0x2f7ff),
|
||||
...(0, util_1.range)(0x2fa1e, 0x2fffd),
|
||||
...(0, util_1.range)(0x30000, 0x3fffd),
|
||||
...(0, util_1.range)(0x40000, 0x4fffd),
|
||||
...(0, util_1.range)(0x50000, 0x5fffd),
|
||||
...(0, util_1.range)(0x60000, 0x6fffd),
|
||||
...(0, util_1.range)(0x70000, 0x7fffd),
|
||||
...(0, util_1.range)(0x80000, 0x8fffd),
|
||||
...(0, util_1.range)(0x90000, 0x9fffd),
|
||||
...(0, util_1.range)(0xa0000, 0xafffd),
|
||||
...(0, util_1.range)(0xb0000, 0xbfffd),
|
||||
...(0, util_1.range)(0xc0000, 0xcfffd),
|
||||
...(0, util_1.range)(0xd0000, 0xdfffd),
|
||||
0xe0000,
|
||||
...(0, util_1.range)(0xe0002, 0xe001f),
|
||||
...(0, util_1.range)(0xe0080, 0xefffd),
|
||||
]);
|
||||
exports.commonly_mapped_to_nothing = new Set([
|
||||
0x00ad, 0x034f, 0x1806, 0x180b, 0x180c, 0x180d, 0x200b, 0x200c, 0x200d,
|
||||
0x2060, 0xfe00, 0xfe01, 0xfe02, 0xfe03, 0xfe04, 0xfe05, 0xfe06, 0xfe07,
|
||||
0xfe08, 0xfe09, 0xfe0a, 0xfe0b, 0xfe0c, 0xfe0d, 0xfe0e, 0xfe0f, 0xfeff,
|
||||
]);
|
||||
exports.non_ASCII_space_characters = new Set([
|
||||
0x00a0, 0x1680,
|
||||
0x2000, 0x2001, 0x2002,
|
||||
0x2003, 0x2004,
|
||||
0x2005, 0x2006,
|
||||
0x2007, 0x2008,
|
||||
0x2009, 0x200a,
|
||||
0x200b, 0x202f,
|
||||
0x205f, 0x3000,
|
||||
]);
|
||||
exports.prohibited_characters = new Set([
|
||||
...exports.non_ASCII_space_characters,
|
||||
...(0, util_1.range)(0, 0x001f),
|
||||
0x007f,
|
||||
...(0, util_1.range)(0x0080, 0x009f),
|
||||
0x06dd,
|
||||
0x070f,
|
||||
0x180e,
|
||||
0x200c,
|
||||
0x200d,
|
||||
0x2028,
|
||||
0x2029,
|
||||
0x2060,
|
||||
0x2061,
|
||||
0x2062,
|
||||
0x2063,
|
||||
...(0, util_1.range)(0x206a, 0x206f),
|
||||
0xfeff,
|
||||
...(0, util_1.range)(0xfff9, 0xfffc),
|
||||
...(0, util_1.range)(0x1d173, 0x1d17a),
|
||||
...(0, util_1.range)(0xe000, 0xf8ff),
|
||||
...(0, util_1.range)(0xf0000, 0xffffd),
|
||||
...(0, util_1.range)(0x100000, 0x10fffd),
|
||||
...(0, util_1.range)(0xfdd0, 0xfdef),
|
||||
...(0, util_1.range)(0xfffe, 0xffff),
|
||||
...(0, util_1.range)(0x1fffe, 0x1ffff),
|
||||
...(0, util_1.range)(0x2fffe, 0x2ffff),
|
||||
...(0, util_1.range)(0x3fffe, 0x3ffff),
|
||||
...(0, util_1.range)(0x4fffe, 0x4ffff),
|
||||
...(0, util_1.range)(0x5fffe, 0x5ffff),
|
||||
...(0, util_1.range)(0x6fffe, 0x6ffff),
|
||||
...(0, util_1.range)(0x7fffe, 0x7ffff),
|
||||
...(0, util_1.range)(0x8fffe, 0x8ffff),
|
||||
...(0, util_1.range)(0x9fffe, 0x9ffff),
|
||||
...(0, util_1.range)(0xafffe, 0xaffff),
|
||||
...(0, util_1.range)(0xbfffe, 0xbffff),
|
||||
...(0, util_1.range)(0xcfffe, 0xcffff),
|
||||
...(0, util_1.range)(0xdfffe, 0xdffff),
|
||||
...(0, util_1.range)(0xefffe, 0xeffff),
|
||||
...(0, util_1.range)(0x10fffe, 0x10ffff),
|
||||
...(0, util_1.range)(0xd800, 0xdfff),
|
||||
0xfff9,
|
||||
0xfffa,
|
||||
0xfffb,
|
||||
0xfffc,
|
||||
0xfffd,
|
||||
...(0, util_1.range)(0x2ff0, 0x2ffb),
|
||||
0x0340,
|
||||
0x0341,
|
||||
0x200e,
|
||||
0x200f,
|
||||
0x202a,
|
||||
0x202b,
|
||||
0x202c,
|
||||
0x202d,
|
||||
0x202e,
|
||||
0x206a,
|
||||
0x206b,
|
||||
0x206c,
|
||||
0x206d,
|
||||
0x206e,
|
||||
0x206f,
|
||||
0xe0001,
|
||||
...(0, util_1.range)(0xe0020, 0xe007f),
|
||||
]);
|
||||
exports.bidirectional_r_al = new Set([
|
||||
0x05be,
|
||||
0x05c0,
|
||||
0x05c3,
|
||||
...(0, util_1.range)(0x05d0, 0x05ea),
|
||||
...(0, util_1.range)(0x05f0, 0x05f4),
|
||||
0x061b,
|
||||
0x061f,
|
||||
...(0, util_1.range)(0x0621, 0x063a),
|
||||
...(0, util_1.range)(0x0640, 0x064a),
|
||||
...(0, util_1.range)(0x066d, 0x066f),
|
||||
...(0, util_1.range)(0x0671, 0x06d5),
|
||||
0x06dd,
|
||||
...(0, util_1.range)(0x06e5, 0x06e6),
|
||||
...(0, util_1.range)(0x06fa, 0x06fe),
|
||||
...(0, util_1.range)(0x0700, 0x070d),
|
||||
0x0710,
|
||||
...(0, util_1.range)(0x0712, 0x072c),
|
||||
...(0, util_1.range)(0x0780, 0x07a5),
|
||||
0x07b1,
|
||||
0x200f,
|
||||
0xfb1d,
|
||||
...(0, util_1.range)(0xfb1f, 0xfb28),
|
||||
...(0, util_1.range)(0xfb2a, 0xfb36),
|
||||
...(0, util_1.range)(0xfb38, 0xfb3c),
|
||||
0xfb3e,
|
||||
...(0, util_1.range)(0xfb40, 0xfb41),
|
||||
...(0, util_1.range)(0xfb43, 0xfb44),
|
||||
...(0, util_1.range)(0xfb46, 0xfbb1),
|
||||
...(0, util_1.range)(0xfbd3, 0xfd3d),
|
||||
...(0, util_1.range)(0xfd50, 0xfd8f),
|
||||
...(0, util_1.range)(0xfd92, 0xfdc7),
|
||||
...(0, util_1.range)(0xfdf0, 0xfdfc),
|
||||
...(0, util_1.range)(0xfe70, 0xfe74),
|
||||
...(0, util_1.range)(0xfe76, 0xfefc),
|
||||
]);
|
||||
exports.bidirectional_l = new Set([
|
||||
...(0, util_1.range)(0x0041, 0x005a),
|
||||
...(0, util_1.range)(0x0061, 0x007a),
|
||||
0x00aa,
|
||||
0x00b5,
|
||||
0x00ba,
|
||||
...(0, util_1.range)(0x00c0, 0x00d6),
|
||||
...(0, util_1.range)(0x00d8, 0x00f6),
|
||||
...(0, util_1.range)(0x00f8, 0x0220),
|
||||
...(0, util_1.range)(0x0222, 0x0233),
|
||||
...(0, util_1.range)(0x0250, 0x02ad),
|
||||
...(0, util_1.range)(0x02b0, 0x02b8),
|
||||
...(0, util_1.range)(0x02bb, 0x02c1),
|
||||
...(0, util_1.range)(0x02d0, 0x02d1),
|
||||
...(0, util_1.range)(0x02e0, 0x02e4),
|
||||
0x02ee,
|
||||
0x037a,
|
||||
0x0386,
|
||||
...(0, util_1.range)(0x0388, 0x038a),
|
||||
0x038c,
|
||||
...(0, util_1.range)(0x038e, 0x03a1),
|
||||
...(0, util_1.range)(0x03a3, 0x03ce),
|
||||
...(0, util_1.range)(0x03d0, 0x03f5),
|
||||
...(0, util_1.range)(0x0400, 0x0482),
|
||||
...(0, util_1.range)(0x048a, 0x04ce),
|
||||
...(0, util_1.range)(0x04d0, 0x04f5),
|
||||
...(0, util_1.range)(0x04f8, 0x04f9),
|
||||
...(0, util_1.range)(0x0500, 0x050f),
|
||||
...(0, util_1.range)(0x0531, 0x0556),
|
||||
...(0, util_1.range)(0x0559, 0x055f),
|
||||
...(0, util_1.range)(0x0561, 0x0587),
|
||||
0x0589,
|
||||
0x0903,
|
||||
...(0, util_1.range)(0x0905, 0x0939),
|
||||
...(0, util_1.range)(0x093d, 0x0940),
|
||||
...(0, util_1.range)(0x0949, 0x094c),
|
||||
0x0950,
|
||||
...(0, util_1.range)(0x0958, 0x0961),
|
||||
...(0, util_1.range)(0x0964, 0x0970),
|
||||
...(0, util_1.range)(0x0982, 0x0983),
|
||||
...(0, util_1.range)(0x0985, 0x098c),
|
||||
...(0, util_1.range)(0x098f, 0x0990),
|
||||
...(0, util_1.range)(0x0993, 0x09a8),
|
||||
...(0, util_1.range)(0x09aa, 0x09b0),
|
||||
0x09b2,
|
||||
...(0, util_1.range)(0x09b6, 0x09b9),
|
||||
...(0, util_1.range)(0x09be, 0x09c0),
|
||||
...(0, util_1.range)(0x09c7, 0x09c8),
|
||||
...(0, util_1.range)(0x09cb, 0x09cc),
|
||||
0x09d7,
|
||||
...(0, util_1.range)(0x09dc, 0x09dd),
|
||||
...(0, util_1.range)(0x09df, 0x09e1),
|
||||
...(0, util_1.range)(0x09e6, 0x09f1),
|
||||
...(0, util_1.range)(0x09f4, 0x09fa),
|
||||
...(0, util_1.range)(0x0a05, 0x0a0a),
|
||||
...(0, util_1.range)(0x0a0f, 0x0a10),
|
||||
...(0, util_1.range)(0x0a13, 0x0a28),
|
||||
...(0, util_1.range)(0x0a2a, 0x0a30),
|
||||
...(0, util_1.range)(0x0a32, 0x0a33),
|
||||
...(0, util_1.range)(0x0a35, 0x0a36),
|
||||
...(0, util_1.range)(0x0a38, 0x0a39),
|
||||
...(0, util_1.range)(0x0a3e, 0x0a40),
|
||||
...(0, util_1.range)(0x0a59, 0x0a5c),
|
||||
0x0a5e,
|
||||
...(0, util_1.range)(0x0a66, 0x0a6f),
|
||||
...(0, util_1.range)(0x0a72, 0x0a74),
|
||||
0x0a83,
|
||||
...(0, util_1.range)(0x0a85, 0x0a8b),
|
||||
0x0a8d,
|
||||
...(0, util_1.range)(0x0a8f, 0x0a91),
|
||||
...(0, util_1.range)(0x0a93, 0x0aa8),
|
||||
...(0, util_1.range)(0x0aaa, 0x0ab0),
|
||||
...(0, util_1.range)(0x0ab2, 0x0ab3),
|
||||
...(0, util_1.range)(0x0ab5, 0x0ab9),
|
||||
...(0, util_1.range)(0x0abd, 0x0ac0),
|
||||
0x0ac9,
|
||||
...(0, util_1.range)(0x0acb, 0x0acc),
|
||||
0x0ad0,
|
||||
0x0ae0,
|
||||
...(0, util_1.range)(0x0ae6, 0x0aef),
|
||||
...(0, util_1.range)(0x0b02, 0x0b03),
|
||||
...(0, util_1.range)(0x0b05, 0x0b0c),
|
||||
...(0, util_1.range)(0x0b0f, 0x0b10),
|
||||
...(0, util_1.range)(0x0b13, 0x0b28),
|
||||
...(0, util_1.range)(0x0b2a, 0x0b30),
|
||||
...(0, util_1.range)(0x0b32, 0x0b33),
|
||||
...(0, util_1.range)(0x0b36, 0x0b39),
|
||||
...(0, util_1.range)(0x0b3d, 0x0b3e),
|
||||
0x0b40,
|
||||
...(0, util_1.range)(0x0b47, 0x0b48),
|
||||
...(0, util_1.range)(0x0b4b, 0x0b4c),
|
||||
0x0b57,
|
||||
...(0, util_1.range)(0x0b5c, 0x0b5d),
|
||||
...(0, util_1.range)(0x0b5f, 0x0b61),
|
||||
...(0, util_1.range)(0x0b66, 0x0b70),
|
||||
0x0b83,
|
||||
...(0, util_1.range)(0x0b85, 0x0b8a),
|
||||
...(0, util_1.range)(0x0b8e, 0x0b90),
|
||||
...(0, util_1.range)(0x0b92, 0x0b95),
|
||||
...(0, util_1.range)(0x0b99, 0x0b9a),
|
||||
0x0b9c,
|
||||
...(0, util_1.range)(0x0b9e, 0x0b9f),
|
||||
...(0, util_1.range)(0x0ba3, 0x0ba4),
|
||||
...(0, util_1.range)(0x0ba8, 0x0baa),
|
||||
...(0, util_1.range)(0x0bae, 0x0bb5),
|
||||
...(0, util_1.range)(0x0bb7, 0x0bb9),
|
||||
...(0, util_1.range)(0x0bbe, 0x0bbf),
|
||||
...(0, util_1.range)(0x0bc1, 0x0bc2),
|
||||
...(0, util_1.range)(0x0bc6, 0x0bc8),
|
||||
...(0, util_1.range)(0x0bca, 0x0bcc),
|
||||
0x0bd7,
|
||||
...(0, util_1.range)(0x0be7, 0x0bf2),
|
||||
...(0, util_1.range)(0x0c01, 0x0c03),
|
||||
...(0, util_1.range)(0x0c05, 0x0c0c),
|
||||
...(0, util_1.range)(0x0c0e, 0x0c10),
|
||||
...(0, util_1.range)(0x0c12, 0x0c28),
|
||||
...(0, util_1.range)(0x0c2a, 0x0c33),
|
||||
...(0, util_1.range)(0x0c35, 0x0c39),
|
||||
...(0, util_1.range)(0x0c41, 0x0c44),
|
||||
...(0, util_1.range)(0x0c60, 0x0c61),
|
||||
...(0, util_1.range)(0x0c66, 0x0c6f),
|
||||
...(0, util_1.range)(0x0c82, 0x0c83),
|
||||
...(0, util_1.range)(0x0c85, 0x0c8c),
|
||||
...(0, util_1.range)(0x0c8e, 0x0c90),
|
||||
...(0, util_1.range)(0x0c92, 0x0ca8),
|
||||
...(0, util_1.range)(0x0caa, 0x0cb3),
|
||||
...(0, util_1.range)(0x0cb5, 0x0cb9),
|
||||
0x0cbe,
|
||||
...(0, util_1.range)(0x0cc0, 0x0cc4),
|
||||
...(0, util_1.range)(0x0cc7, 0x0cc8),
|
||||
...(0, util_1.range)(0x0cca, 0x0ccb),
|
||||
...(0, util_1.range)(0x0cd5, 0x0cd6),
|
||||
0x0cde,
|
||||
...(0, util_1.range)(0x0ce0, 0x0ce1),
|
||||
...(0, util_1.range)(0x0ce6, 0x0cef),
|
||||
...(0, util_1.range)(0x0d02, 0x0d03),
|
||||
...(0, util_1.range)(0x0d05, 0x0d0c),
|
||||
...(0, util_1.range)(0x0d0e, 0x0d10),
|
||||
...(0, util_1.range)(0x0d12, 0x0d28),
|
||||
...(0, util_1.range)(0x0d2a, 0x0d39),
|
||||
...(0, util_1.range)(0x0d3e, 0x0d40),
|
||||
...(0, util_1.range)(0x0d46, 0x0d48),
|
||||
...(0, util_1.range)(0x0d4a, 0x0d4c),
|
||||
0x0d57,
|
||||
...(0, util_1.range)(0x0d60, 0x0d61),
|
||||
...(0, util_1.range)(0x0d66, 0x0d6f),
|
||||
...(0, util_1.range)(0x0d82, 0x0d83),
|
||||
...(0, util_1.range)(0x0d85, 0x0d96),
|
||||
...(0, util_1.range)(0x0d9a, 0x0db1),
|
||||
...(0, util_1.range)(0x0db3, 0x0dbb),
|
||||
0x0dbd,
|
||||
...(0, util_1.range)(0x0dc0, 0x0dc6),
|
||||
...(0, util_1.range)(0x0dcf, 0x0dd1),
|
||||
...(0, util_1.range)(0x0dd8, 0x0ddf),
|
||||
...(0, util_1.range)(0x0df2, 0x0df4),
|
||||
...(0, util_1.range)(0x0e01, 0x0e30),
|
||||
...(0, util_1.range)(0x0e32, 0x0e33),
|
||||
...(0, util_1.range)(0x0e40, 0x0e46),
|
||||
...(0, util_1.range)(0x0e4f, 0x0e5b),
|
||||
...(0, util_1.range)(0x0e81, 0x0e82),
|
||||
0x0e84,
|
||||
...(0, util_1.range)(0x0e87, 0x0e88),
|
||||
0x0e8a,
|
||||
0x0e8d,
|
||||
...(0, util_1.range)(0x0e94, 0x0e97),
|
||||
...(0, util_1.range)(0x0e99, 0x0e9f),
|
||||
...(0, util_1.range)(0x0ea1, 0x0ea3),
|
||||
0x0ea5,
|
||||
0x0ea7,
|
||||
...(0, util_1.range)(0x0eaa, 0x0eab),
|
||||
...(0, util_1.range)(0x0ead, 0x0eb0),
|
||||
...(0, util_1.range)(0x0eb2, 0x0eb3),
|
||||
0x0ebd,
|
||||
...(0, util_1.range)(0x0ec0, 0x0ec4),
|
||||
0x0ec6,
|
||||
...(0, util_1.range)(0x0ed0, 0x0ed9),
|
||||
...(0, util_1.range)(0x0edc, 0x0edd),
|
||||
...(0, util_1.range)(0x0f00, 0x0f17),
|
||||
...(0, util_1.range)(0x0f1a, 0x0f34),
|
||||
0x0f36,
|
||||
0x0f38,
|
||||
...(0, util_1.range)(0x0f3e, 0x0f47),
|
||||
...(0, util_1.range)(0x0f49, 0x0f6a),
|
||||
0x0f7f,
|
||||
0x0f85,
|
||||
...(0, util_1.range)(0x0f88, 0x0f8b),
|
||||
...(0, util_1.range)(0x0fbe, 0x0fc5),
|
||||
...(0, util_1.range)(0x0fc7, 0x0fcc),
|
||||
0x0fcf,
|
||||
...(0, util_1.range)(0x1000, 0x1021),
|
||||
...(0, util_1.range)(0x1023, 0x1027),
|
||||
...(0, util_1.range)(0x1029, 0x102a),
|
||||
0x102c,
|
||||
0x1031,
|
||||
0x1038,
|
||||
...(0, util_1.range)(0x1040, 0x1057),
|
||||
...(0, util_1.range)(0x10a0, 0x10c5),
|
||||
...(0, util_1.range)(0x10d0, 0x10f8),
|
||||
0x10fb,
|
||||
...(0, util_1.range)(0x1100, 0x1159),
|
||||
...(0, util_1.range)(0x115f, 0x11a2),
|
||||
...(0, util_1.range)(0x11a8, 0x11f9),
|
||||
...(0, util_1.range)(0x1200, 0x1206),
|
||||
...(0, util_1.range)(0x1208, 0x1246),
|
||||
0x1248,
|
||||
...(0, util_1.range)(0x124a, 0x124d),
|
||||
...(0, util_1.range)(0x1250, 0x1256),
|
||||
0x1258,
|
||||
...(0, util_1.range)(0x125a, 0x125d),
|
||||
...(0, util_1.range)(0x1260, 0x1286),
|
||||
0x1288,
|
||||
...(0, util_1.range)(0x128a, 0x128d),
|
||||
...(0, util_1.range)(0x1290, 0x12ae),
|
||||
0x12b0,
|
||||
...(0, util_1.range)(0x12b2, 0x12b5),
|
||||
...(0, util_1.range)(0x12b8, 0x12be),
|
||||
0x12c0,
|
||||
...(0, util_1.range)(0x12c2, 0x12c5),
|
||||
...(0, util_1.range)(0x12c8, 0x12ce),
|
||||
...(0, util_1.range)(0x12d0, 0x12d6),
|
||||
...(0, util_1.range)(0x12d8, 0x12ee),
|
||||
...(0, util_1.range)(0x12f0, 0x130e),
|
||||
0x1310,
|
||||
...(0, util_1.range)(0x1312, 0x1315),
|
||||
...(0, util_1.range)(0x1318, 0x131e),
|
||||
...(0, util_1.range)(0x1320, 0x1346),
|
||||
...(0, util_1.range)(0x1348, 0x135a),
|
||||
...(0, util_1.range)(0x1361, 0x137c),
|
||||
...(0, util_1.range)(0x13a0, 0x13f4),
|
||||
...(0, util_1.range)(0x1401, 0x1676),
|
||||
...(0, util_1.range)(0x1681, 0x169a),
|
||||
...(0, util_1.range)(0x16a0, 0x16f0),
|
||||
...(0, util_1.range)(0x1700, 0x170c),
|
||||
...(0, util_1.range)(0x170e, 0x1711),
|
||||
...(0, util_1.range)(0x1720, 0x1731),
|
||||
...(0, util_1.range)(0x1735, 0x1736),
|
||||
...(0, util_1.range)(0x1740, 0x1751),
|
||||
...(0, util_1.range)(0x1760, 0x176c),
|
||||
...(0, util_1.range)(0x176e, 0x1770),
|
||||
...(0, util_1.range)(0x1780, 0x17b6),
|
||||
...(0, util_1.range)(0x17be, 0x17c5),
|
||||
...(0, util_1.range)(0x17c7, 0x17c8),
|
||||
...(0, util_1.range)(0x17d4, 0x17da),
|
||||
0x17dc,
|
||||
...(0, util_1.range)(0x17e0, 0x17e9),
|
||||
...(0, util_1.range)(0x1810, 0x1819),
|
||||
...(0, util_1.range)(0x1820, 0x1877),
|
||||
...(0, util_1.range)(0x1880, 0x18a8),
|
||||
...(0, util_1.range)(0x1e00, 0x1e9b),
|
||||
...(0, util_1.range)(0x1ea0, 0x1ef9),
|
||||
...(0, util_1.range)(0x1f00, 0x1f15),
|
||||
...(0, util_1.range)(0x1f18, 0x1f1d),
|
||||
...(0, util_1.range)(0x1f20, 0x1f45),
|
||||
...(0, util_1.range)(0x1f48, 0x1f4d),
|
||||
...(0, util_1.range)(0x1f50, 0x1f57),
|
||||
0x1f59,
|
||||
0x1f5b,
|
||||
0x1f5d,
|
||||
...(0, util_1.range)(0x1f5f, 0x1f7d),
|
||||
...(0, util_1.range)(0x1f80, 0x1fb4),
|
||||
...(0, util_1.range)(0x1fb6, 0x1fbc),
|
||||
0x1fbe,
|
||||
...(0, util_1.range)(0x1fc2, 0x1fc4),
|
||||
...(0, util_1.range)(0x1fc6, 0x1fcc),
|
||||
...(0, util_1.range)(0x1fd0, 0x1fd3),
|
||||
...(0, util_1.range)(0x1fd6, 0x1fdb),
|
||||
...(0, util_1.range)(0x1fe0, 0x1fec),
|
||||
...(0, util_1.range)(0x1ff2, 0x1ff4),
|
||||
...(0, util_1.range)(0x1ff6, 0x1ffc),
|
||||
0x200e,
|
||||
0x2071,
|
||||
0x207f,
|
||||
0x2102,
|
||||
0x2107,
|
||||
...(0, util_1.range)(0x210a, 0x2113),
|
||||
0x2115,
|
||||
...(0, util_1.range)(0x2119, 0x211d),
|
||||
0x2124,
|
||||
0x2126,
|
||||
0x2128,
|
||||
...(0, util_1.range)(0x212a, 0x212d),
|
||||
...(0, util_1.range)(0x212f, 0x2131),
|
||||
...(0, util_1.range)(0x2133, 0x2139),
|
||||
...(0, util_1.range)(0x213d, 0x213f),
|
||||
...(0, util_1.range)(0x2145, 0x2149),
|
||||
...(0, util_1.range)(0x2160, 0x2183),
|
||||
...(0, util_1.range)(0x2336, 0x237a),
|
||||
0x2395,
|
||||
...(0, util_1.range)(0x249c, 0x24e9),
|
||||
...(0, util_1.range)(0x3005, 0x3007),
|
||||
...(0, util_1.range)(0x3021, 0x3029),
|
||||
...(0, util_1.range)(0x3031, 0x3035),
|
||||
...(0, util_1.range)(0x3038, 0x303c),
|
||||
...(0, util_1.range)(0x3041, 0x3096),
|
||||
...(0, util_1.range)(0x309d, 0x309f),
|
||||
...(0, util_1.range)(0x30a1, 0x30fa),
|
||||
...(0, util_1.range)(0x30fc, 0x30ff),
|
||||
...(0, util_1.range)(0x3105, 0x312c),
|
||||
...(0, util_1.range)(0x3131, 0x318e),
|
||||
...(0, util_1.range)(0x3190, 0x31b7),
|
||||
...(0, util_1.range)(0x31f0, 0x321c),
|
||||
...(0, util_1.range)(0x3220, 0x3243),
|
||||
...(0, util_1.range)(0x3260, 0x327b),
|
||||
...(0, util_1.range)(0x327f, 0x32b0),
|
||||
...(0, util_1.range)(0x32c0, 0x32cb),
|
||||
...(0, util_1.range)(0x32d0, 0x32fe),
|
||||
...(0, util_1.range)(0x3300, 0x3376),
|
||||
...(0, util_1.range)(0x337b, 0x33dd),
|
||||
...(0, util_1.range)(0x33e0, 0x33fe),
|
||||
...(0, util_1.range)(0x3400, 0x4db5),
|
||||
...(0, util_1.range)(0x4e00, 0x9fa5),
|
||||
...(0, util_1.range)(0xa000, 0xa48c),
|
||||
...(0, util_1.range)(0xac00, 0xd7a3),
|
||||
...(0, util_1.range)(0xd800, 0xfa2d),
|
||||
...(0, util_1.range)(0xfa30, 0xfa6a),
|
||||
...(0, util_1.range)(0xfb00, 0xfb06),
|
||||
...(0, util_1.range)(0xfb13, 0xfb17),
|
||||
...(0, util_1.range)(0xff21, 0xff3a),
|
||||
...(0, util_1.range)(0xff41, 0xff5a),
|
||||
...(0, util_1.range)(0xff66, 0xffbe),
|
||||
...(0, util_1.range)(0xffc2, 0xffc7),
|
||||
...(0, util_1.range)(0xffca, 0xffcf),
|
||||
...(0, util_1.range)(0xffd2, 0xffd7),
|
||||
...(0, util_1.range)(0xffda, 0xffdc),
|
||||
...(0, util_1.range)(0x10300, 0x1031e),
|
||||
...(0, util_1.range)(0x10320, 0x10323),
|
||||
...(0, util_1.range)(0x10330, 0x1034a),
|
||||
...(0, util_1.range)(0x10400, 0x10425),
|
||||
...(0, util_1.range)(0x10428, 0x1044d),
|
||||
...(0, util_1.range)(0x1d000, 0x1d0f5),
|
||||
...(0, util_1.range)(0x1d100, 0x1d126),
|
||||
...(0, util_1.range)(0x1d12a, 0x1d166),
|
||||
...(0, util_1.range)(0x1d16a, 0x1d172),
|
||||
...(0, util_1.range)(0x1d183, 0x1d184),
|
||||
...(0, util_1.range)(0x1d18c, 0x1d1a9),
|
||||
...(0, util_1.range)(0x1d1ae, 0x1d1dd),
|
||||
...(0, util_1.range)(0x1d400, 0x1d454),
|
||||
...(0, util_1.range)(0x1d456, 0x1d49c),
|
||||
...(0, util_1.range)(0x1d49e, 0x1d49f),
|
||||
0x1d4a2,
|
||||
...(0, util_1.range)(0x1d4a5, 0x1d4a6),
|
||||
...(0, util_1.range)(0x1d4a9, 0x1d4ac),
|
||||
...(0, util_1.range)(0x1d4ae, 0x1d4b9),
|
||||
0x1d4bb,
|
||||
...(0, util_1.range)(0x1d4bd, 0x1d4c0),
|
||||
...(0, util_1.range)(0x1d4c2, 0x1d4c3),
|
||||
...(0, util_1.range)(0x1d4c5, 0x1d505),
|
||||
...(0, util_1.range)(0x1d507, 0x1d50a),
|
||||
...(0, util_1.range)(0x1d50d, 0x1d514),
|
||||
...(0, util_1.range)(0x1d516, 0x1d51c),
|
||||
...(0, util_1.range)(0x1d51e, 0x1d539),
|
||||
...(0, util_1.range)(0x1d53b, 0x1d53e),
|
||||
...(0, util_1.range)(0x1d540, 0x1d544),
|
||||
0x1d546,
|
||||
...(0, util_1.range)(0x1d54a, 0x1d550),
|
||||
...(0, util_1.range)(0x1d552, 0x1d6a3),
|
||||
...(0, util_1.range)(0x1d6a8, 0x1d7c9),
|
||||
...(0, util_1.range)(0x20000, 0x2a6d6),
|
||||
...(0, util_1.range)(0x2f800, 0x2fa1d),
|
||||
...(0, util_1.range)(0xf0000, 0xffffd),
|
||||
...(0, util_1.range)(0x100000, 0x10fffd),
|
||||
]);
|
||||
//# sourceMappingURL=code-points-src.js.map
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=generate-code-points.d.ts.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"generate-code-points.d.ts","sourceRoot":"","sources":["../src/generate-code-points.ts"],"names":[],"mappings":""}
|
@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const zlib_1 = require("zlib");
|
||||
const sparse_bitfield_1 = __importDefault(require("sparse-bitfield"));
|
||||
const codePoints = __importStar(require("./code-points-src"));
|
||||
const fs_1 = require("fs");
|
||||
const prettier = __importStar(require("prettier"));
|
||||
const unassigned_code_points = (0, sparse_bitfield_1.default)();
|
||||
const commonly_mapped_to_nothing = (0, sparse_bitfield_1.default)();
|
||||
const non_ascii_space_characters = (0, sparse_bitfield_1.default)();
|
||||
const prohibited_characters = (0, sparse_bitfield_1.default)();
|
||||
const bidirectional_r_al = (0, sparse_bitfield_1.default)();
|
||||
const bidirectional_l = (0, sparse_bitfield_1.default)();
|
||||
function traverse(bits, src) {
|
||||
for (const code of src.keys()) {
|
||||
bits.set(code, true);
|
||||
}
|
||||
const buffer = bits.toBuffer();
|
||||
return Buffer.concat([createSize(buffer), buffer]);
|
||||
}
|
||||
function createSize(buffer) {
|
||||
const buf = Buffer.alloc(4);
|
||||
buf.writeUInt32BE(buffer.length);
|
||||
return buf;
|
||||
}
|
||||
const memory = [];
|
||||
memory.push(traverse(unassigned_code_points, codePoints.unassigned_code_points), traverse(commonly_mapped_to_nothing, codePoints.commonly_mapped_to_nothing), traverse(non_ascii_space_characters, codePoints.non_ASCII_space_characters), traverse(prohibited_characters, codePoints.prohibited_characters), traverse(bidirectional_r_al, codePoints.bidirectional_r_al), traverse(bidirectional_l, codePoints.bidirectional_l));
|
||||
async function writeCodepoints() {
|
||||
const config = await prettier.resolveConfig(__dirname);
|
||||
const formatOptions = { ...config, parser: 'typescript' };
|
||||
function write(stream, chunk) {
|
||||
return new Promise((resolve) => stream.write(chunk, () => resolve()));
|
||||
}
|
||||
await write((0, fs_1.createWriteStream)(process.argv[2]), prettier.format(`import { gunzipSync } from 'zlib';
|
||||
|
||||
export default gunzipSync(
|
||||
Buffer.from(
|
||||
'${(0, zlib_1.gzipSync)(Buffer.concat(memory), { level: 9 }).toString('base64')}',
|
||||
'base64'
|
||||
)
|
||||
);
|
||||
`, formatOptions));
|
||||
const fsStreamUncompressedData = (0, fs_1.createWriteStream)(process.argv[3]);
|
||||
await write(fsStreamUncompressedData, prettier.format(`const data = Buffer.from('${Buffer.concat(memory).toString('base64')}', 'base64');\nexport default data;\n`, formatOptions));
|
||||
}
|
||||
writeCodepoints().catch((error) => console.error('error occurred generating saslprep codepoint data', { error }));
|
||||
//# sourceMappingURL=generate-code-points.js.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"generate-code-points.js","sourceRoot":"","sources":["../src/generate-code-points.ts"],"names":[],"mappings":"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"}
|
@ -0,0 +1,11 @@
|
||||
import type { createMemoryCodePoints } from './memory-code-points';
|
||||
declare function saslprep({ unassigned_code_points, commonly_mapped_to_nothing, non_ASCII_space_characters, prohibited_characters, bidirectional_r_al, bidirectional_l, }: ReturnType<typeof createMemoryCodePoints>, input: string, opts?: {
|
||||
allowUnassigned?: boolean;
|
||||
}): string;
|
||||
declare namespace saslprep {
|
||||
export var saslprep: typeof import(".");
|
||||
var _a: typeof import(".");
|
||||
export { _a as default };
|
||||
}
|
||||
export = saslprep;
|
||||
//# sourceMappingURL=index.d.ts.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAsCnE,iBAAS,QAAQ,CACf,EACE,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAChB,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,EAC5C,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,GACvC,MAAM,CAqGR;kBAhHQ,QAAQ;;;;;AAoHjB,SAAS,QAAQ,CAAC"}
|
@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
const getCodePoint = (character) => character.codePointAt(0);
|
||||
const first = (x) => x[0];
|
||||
const last = (x) => x[x.length - 1];
|
||||
function toCodePoints(input) {
|
||||
const codepoints = [];
|
||||
const size = input.length;
|
||||
for (let i = 0; i < size; i += 1) {
|
||||
const before = input.charCodeAt(i);
|
||||
if (before >= 0xd800 && before <= 0xdbff && size > i + 1) {
|
||||
const next = input.charCodeAt(i + 1);
|
||||
if (next >= 0xdc00 && next <= 0xdfff) {
|
||||
codepoints.push((before - 0xd800) * 0x400 + next - 0xdc00 + 0x10000);
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
codepoints.push(before);
|
||||
}
|
||||
return codepoints;
|
||||
}
|
||||
function saslprep({ unassigned_code_points, commonly_mapped_to_nothing, non_ASCII_space_characters, prohibited_characters, bidirectional_r_al, bidirectional_l, }, input, opts = {}) {
|
||||
const mapping2space = non_ASCII_space_characters;
|
||||
const mapping2nothing = commonly_mapped_to_nothing;
|
||||
if (typeof input !== 'string') {
|
||||
throw new TypeError('Expected string.');
|
||||
}
|
||||
if (input.length === 0) {
|
||||
return '';
|
||||
}
|
||||
const mapped_input = toCodePoints(input)
|
||||
.map((character) => (mapping2space.get(character) ? 0x20 : character))
|
||||
.filter((character) => !mapping2nothing.get(character));
|
||||
const normalized_input = String.fromCodePoint
|
||||
.apply(null, mapped_input)
|
||||
.normalize('NFKC');
|
||||
const normalized_map = toCodePoints(normalized_input);
|
||||
const hasProhibited = normalized_map.some((character) => prohibited_characters.get(character));
|
||||
if (hasProhibited) {
|
||||
throw new Error('Prohibited character, see https://tools.ietf.org/html/rfc4013#section-2.3');
|
||||
}
|
||||
if (opts.allowUnassigned !== true) {
|
||||
const hasUnassigned = normalized_map.some((character) => unassigned_code_points.get(character));
|
||||
if (hasUnassigned) {
|
||||
throw new Error('Unassigned code point, see https://tools.ietf.org/html/rfc4013#section-2.5');
|
||||
}
|
||||
}
|
||||
const hasBidiRAL = normalized_map.some((character) => bidirectional_r_al.get(character));
|
||||
const hasBidiL = normalized_map.some((character) => bidirectional_l.get(character));
|
||||
if (hasBidiRAL && hasBidiL) {
|
||||
throw new Error('String must not contain RandALCat and LCat at the same time,' +
|
||||
' see https://tools.ietf.org/html/rfc3454#section-6');
|
||||
}
|
||||
const isFirstBidiRAL = bidirectional_r_al.get(getCodePoint(first(normalized_input)));
|
||||
const isLastBidiRAL = bidirectional_r_al.get(getCodePoint(last(normalized_input)));
|
||||
if (hasBidiRAL && !(isFirstBidiRAL && isLastBidiRAL)) {
|
||||
throw new Error('Bidirectional RandALCat character must be the first and the last' +
|
||||
' character of the string, see https://tools.ietf.org/html/rfc3454#section-6');
|
||||
}
|
||||
return normalized_input;
|
||||
}
|
||||
saslprep.saslprep = saslprep;
|
||||
saslprep.default = saslprep;
|
||||
module.exports = saslprep;
|
||||
//# sourceMappingURL=index.js.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
@ -0,0 +1,11 @@
|
||||
/// <reference types="node" />
|
||||
import bitfield from 'sparse-bitfield';
|
||||
export declare function createMemoryCodePoints(data: Buffer): {
|
||||
unassigned_code_points: bitfield.BitFieldInstance;
|
||||
commonly_mapped_to_nothing: bitfield.BitFieldInstance;
|
||||
non_ASCII_space_characters: bitfield.BitFieldInstance;
|
||||
prohibited_characters: bitfield.BitFieldInstance;
|
||||
bidirectional_r_al: bitfield.BitFieldInstance;
|
||||
bidirectional_l: bitfield.BitFieldInstance;
|
||||
};
|
||||
//# sourceMappingURL=memory-code-points.d.ts.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"memory-code-points.d.ts","sourceRoot":"","sources":["../src/memory-code-points.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM;;;;;;;EA+BlD"}
|
@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createMemoryCodePoints = void 0;
|
||||
const sparse_bitfield_1 = __importDefault(require("sparse-bitfield"));
|
||||
function createMemoryCodePoints(data) {
|
||||
let offset = 0;
|
||||
function read() {
|
||||
const size = data.readUInt32BE(offset);
|
||||
offset += 4;
|
||||
const codepoints = data.slice(offset, offset + size);
|
||||
offset += size;
|
||||
return (0, sparse_bitfield_1.default)({ buffer: codepoints });
|
||||
}
|
||||
const unassigned_code_points = read();
|
||||
const commonly_mapped_to_nothing = read();
|
||||
const non_ASCII_space_characters = read();
|
||||
const prohibited_characters = read();
|
||||
const bidirectional_r_al = read();
|
||||
const bidirectional_l = read();
|
||||
return {
|
||||
unassigned_code_points,
|
||||
commonly_mapped_to_nothing,
|
||||
non_ASCII_space_characters,
|
||||
prohibited_characters,
|
||||
bidirectional_r_al,
|
||||
bidirectional_l,
|
||||
};
|
||||
}
|
||||
exports.createMemoryCodePoints = createMemoryCodePoints;
|
||||
//# sourceMappingURL=memory-code-points.js.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"memory-code-points.js","sourceRoot":"","sources":["../src/memory-code-points.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAuC;AAEvC,SAAgB,sBAAsB,CAAC,IAAY;IACjD,IAAI,MAAM,GAAG,CAAC,CAAC;IAKf,SAAS,IAAI;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,CAAC;QAEZ,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;QACrD,MAAM,IAAI,IAAI,CAAC;QAEf,OAAO,IAAA,yBAAQ,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,sBAAsB,GAAG,IAAI,EAAE,CAAC;IACtC,MAAM,0BAA0B,GAAG,IAAI,EAAE,CAAC;IAC1C,MAAM,0BAA0B,GAAG,IAAI,EAAE,CAAC;IAC1C,MAAM,qBAAqB,GAAG,IAAI,EAAE,CAAC;IACrC,MAAM,kBAAkB,GAAG,IAAI,EAAE,CAAC;IAClC,MAAM,eAAe,GAAG,IAAI,EAAE,CAAC;IAE/B,OAAO;QACL,sBAAsB;QACtB,0BAA0B;QAC1B,0BAA0B;QAC1B,qBAAqB;QACrB,kBAAkB;QAClB,eAAe;KAChB,CAAC;AACJ,CAAC;AA/BD,wDA+BC"}
|
@ -0,0 +1,10 @@
|
||||
declare function saslprep(input: string, opts?: {
|
||||
allowUnassigned?: boolean;
|
||||
}): string;
|
||||
declare namespace saslprep {
|
||||
export var saslprep: typeof import("./node");
|
||||
var _a: typeof import("./node");
|
||||
export { _a as default };
|
||||
}
|
||||
export = saslprep;
|
||||
//# sourceMappingURL=node.d.ts.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAMA,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAE7E;kBAFQ,QAAQ;;;;;AAOjB,SAAS,QAAQ,CAAC"}
|
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const index_1 = __importDefault(require("./index"));
|
||||
const memory_code_points_1 = require("./memory-code-points");
|
||||
const code_points_data_1 = __importDefault(require("./code-points-data"));
|
||||
const codePoints = (0, memory_code_points_1.createMemoryCodePoints)(code_points_data_1.default);
|
||||
function saslprep(input, opts) {
|
||||
return (0, index_1.default)(codePoints, input, opts);
|
||||
}
|
||||
saslprep.saslprep = saslprep;
|
||||
saslprep.default = saslprep;
|
||||
module.exports = saslprep;
|
||||
//# sourceMappingURL=node.js.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":";;;;AAAA,oDAAgC;AAChC,6DAA8D;AAC9D,0EAAsC;AAEtC,MAAM,UAAU,GAAG,IAAA,2CAAsB,EAAC,0BAAI,CAAC,CAAC;AAEhD,SAAS,QAAQ,CAAC,KAAa,EAAE,IAAoC;IACnE,OAAO,IAAA,eAAS,EAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC7B,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC;AAE5B,iBAAS,QAAQ,CAAC"}
|
@ -0,0 +1,2 @@
|
||||
export declare function range(from: number, to: number): number[];
|
||||
//# sourceMappingURL=util.d.ts.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAQxD"}
|
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.range = void 0;
|
||||
function range(from, to) {
|
||||
const list = new Array(to - from + 1);
|
||||
for (let i = 0; i < list.length; i += 1) {
|
||||
list[i] = from + i;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
exports.range = range;
|
||||
//# sourceMappingURL=util.js.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAGA,SAAgB,KAAK,CAAC,IAAY,EAAE,EAAU;IAE5C,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACvC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;KACpB;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AARD,sBAQC"}
|
@ -0,0 +1,87 @@
|
||||
{
|
||||
"name": "@mongodb-js/saslprep",
|
||||
"description": "SASLprep: Stringprep Profile for User Names and Passwords, rfc4013",
|
||||
"keywords": [
|
||||
"sasl",
|
||||
"saslprep",
|
||||
"stringprep",
|
||||
"rfc4013",
|
||||
"4013"
|
||||
],
|
||||
"author": "Dmitry Tsvettsikh <me@reklatsmasters.com>",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "dist/node.js",
|
||||
"bugs": {
|
||||
"url": "https://jira.mongodb.org/projects/COMPASS/issues",
|
||||
"email": "compass@mongodb.com"
|
||||
},
|
||||
"homepage": "https://github.com/mongodb-js/devtools-shared/tree/main/packages/saslprep",
|
||||
"version": "1.1.8",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mongodb-js/devtools-shared.git"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
"browser": {
|
||||
"types": "./dist/browser.d.ts",
|
||||
"default": "./dist/browser.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/node.d.ts",
|
||||
"default": "./dist/.esm-wrapper.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/node.d.ts",
|
||||
"default": "./dist/node.js"
|
||||
}
|
||||
},
|
||||
"types": "./dist/node.d.ts",
|
||||
"scripts": {
|
||||
"gen-code-points": "ts-node src/generate-code-points.ts src/code-points-data.ts src/code-points-data-browser.ts",
|
||||
"bootstrap": "npm run compile",
|
||||
"prepublishOnly": "npm run compile",
|
||||
"compile": "npm run gen-code-points && tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"eslint": "eslint",
|
||||
"prettier": "prettier",
|
||||
"lint": "npm run eslint . && npm run prettier -- --check .",
|
||||
"depcheck": "depcheck",
|
||||
"check": "npm run typecheck && npm run lint && npm run depcheck",
|
||||
"check-ci": "npm run check",
|
||||
"test": "mocha",
|
||||
"test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
|
||||
"test-watch": "npm run test -- --watch",
|
||||
"test-ci": "npm run test-cov",
|
||||
"reformat": "npm run prettier -- --write ."
|
||||
},
|
||||
"dependencies": {
|
||||
"sparse-bitfield": "^3.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mongodb-js/eslint-config-devtools": "0.9.10",
|
||||
"@mongodb-js/mocha-config-devtools": "^1.0.3",
|
||||
"@mongodb-js/prettier-config-devtools": "^1.0.1",
|
||||
"@mongodb-js/tsconfig-devtools": "^1.0.2",
|
||||
"@types/chai": "^4.2.21",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node": "^17.0.35",
|
||||
"@types/sinon-chai": "^3.2.5",
|
||||
"@types/sparse-bitfield": "^3.0.1",
|
||||
"chai": "^4.3.6",
|
||||
"depcheck": "^1.4.1",
|
||||
"eslint": "^7.25.0",
|
||||
"gen-esm-wrapper": "^1.1.0",
|
||||
"mocha": "^8.4.0",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier": "^2.3.2",
|
||||
"sinon": "^9.2.3",
|
||||
"typescript": "^5.0.4"
|
||||
},
|
||||
"gitHead": "8037a984c0ae116b11c10e9c361a09dfeb45db85"
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
# saslprep
|
||||
|
||||
_Note: This is a fork of the original [`saslprep`](https://www.npmjs.com/package/saslprep) npm package
|
||||
and provides equivalent functionality._
|
||||
|
||||
Stringprep Profile for User Names and Passwords, [rfc4013](https://tools.ietf.org/html/rfc4013)
|
||||
|
||||
### Usage
|
||||
|
||||
```js
|
||||
const saslprep = require('@mongodb-js/saslprep');
|
||||
|
||||
saslprep('password\u00AD'); // password
|
||||
saslprep('password\u0007'); // Error: prohibited character
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
##### `saslprep(input: String, opts: Options): String`
|
||||
|
||||
Normalize user name or password.
|
||||
|
||||
##### `Options.allowUnassigned: bool`
|
||||
|
||||
A special behavior for unassigned code points, see https://tools.ietf.org/html/rfc4013#section-2.5. Disabled by default.
|
||||
|
||||
## License
|
||||
|
||||
MIT, 2017-2019 (c) Dmitriy Tsvettsikh
|
@ -0,0 +1,9 @@
|
||||
Copyright (c) 2019-2020, Sideway, Inc. and Project contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -0,0 +1,14 @@
|
||||
# @sideway/address
|
||||
|
||||
#### Validate email address and domain.
|
||||
|
||||
**address** is part of the **joi** ecosystem.
|
||||
|
||||
### Visit the [joi.dev](https://joi.dev) Developer Portal for tutorials, documentation, and support
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Documentation and API](https://joi.dev/module/address/)
|
||||
- [Versions status](https://joi.dev/resources/status/#address)
|
||||
- [Changelog](https://joi.dev/module/address/changelog/)
|
||||
- [Project policies](https://joi.dev/policies/)
|
@ -0,0 +1,120 @@
|
||||
'use strict';
|
||||
|
||||
// Adapted from:
|
||||
// Copyright (c) 2017-2019 Justin Ridgewell, MIT Licensed, https://github.com/jridgewell/safe-decode-string-component
|
||||
// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>, MIT Licensed, http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports.decode = function (string) {
|
||||
|
||||
let percentPos = string.indexOf('%');
|
||||
if (percentPos === -1) {
|
||||
return string;
|
||||
}
|
||||
|
||||
let decoded = '';
|
||||
let last = 0;
|
||||
let codepoint = 0;
|
||||
let startOfOctets = percentPos;
|
||||
let state = internals.utf8.accept;
|
||||
|
||||
while (percentPos > -1 &&
|
||||
percentPos < string.length) {
|
||||
|
||||
const high = internals.resolveHex(string[percentPos + 1], 4);
|
||||
const low = internals.resolveHex(string[percentPos + 2], 0);
|
||||
const byte = high | low;
|
||||
const type = internals.utf8.data[byte];
|
||||
state = internals.utf8.data[256 + state + type];
|
||||
codepoint = (codepoint << 6) | (byte & internals.utf8.data[364 + type]);
|
||||
|
||||
if (state === internals.utf8.accept) {
|
||||
decoded += string.slice(last, startOfOctets);
|
||||
decoded += codepoint <= 0xFFFF
|
||||
? String.fromCharCode(codepoint)
|
||||
: String.fromCharCode(0xD7C0 + (codepoint >> 10), 0xDC00 + (codepoint & 0x3FF));
|
||||
|
||||
codepoint = 0;
|
||||
last = percentPos + 3;
|
||||
percentPos = string.indexOf('%', last);
|
||||
startOfOctets = percentPos;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state === internals.utf8.reject) {
|
||||
return null;
|
||||
}
|
||||
|
||||
percentPos += 3;
|
||||
|
||||
if (percentPos >= string.length ||
|
||||
string[percentPos] !== '%') {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return decoded + string.slice(last);
|
||||
};
|
||||
|
||||
|
||||
internals.resolveHex = function (char, shift) {
|
||||
|
||||
const i = internals.hex[char];
|
||||
return i === undefined ? 255 : i << shift;
|
||||
};
|
||||
|
||||
|
||||
internals.hex = {
|
||||
'0': 0, '1': 1, '2': 2, '3': 3, '4': 4,
|
||||
'5': 5, '6': 6, '7': 7, '8': 8, '9': 9,
|
||||
'a': 10, 'A': 10, 'b': 11, 'B': 11, 'c': 12,
|
||||
'C': 12, 'd': 13, 'D': 13, 'e': 14, 'E': 14,
|
||||
'f': 15, 'F': 15
|
||||
};
|
||||
|
||||
|
||||
internals.utf8 = {
|
||||
accept: 12,
|
||||
reject: 0,
|
||||
data: [
|
||||
|
||||
// Maps bytes to character to a transition
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7,
|
||||
10, 9, 9, 9, 11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
|
||||
// Maps a state to a new state when adding a transition
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
12, 0, 0, 0, 0, 24, 36, 48, 60, 72, 84, 96,
|
||||
0, 12, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
// Maps the current transition to a mask that needs to apply to the byte
|
||||
|
||||
0x7F, 0x3F, 0x3F, 0x3F, 0x00, 0x1F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07
|
||||
]
|
||||
};
|
@ -0,0 +1,123 @@
|
||||
'use strict';
|
||||
|
||||
const Url = require('url');
|
||||
|
||||
const Errors = require('./errors');
|
||||
|
||||
|
||||
const internals = {
|
||||
minDomainSegments: 2,
|
||||
nonAsciiRx: /[^\x00-\x7f]/,
|
||||
domainControlRx: /[\x00-\x20@\:\/\\#!\$&\'\(\)\*\+,;=\?]/, // Control + space + separators
|
||||
tldSegmentRx: /^[a-zA-Z](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,
|
||||
domainSegmentRx: /^[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,
|
||||
URL: Url.URL || URL // $lab:coverage:ignore$
|
||||
};
|
||||
|
||||
|
||||
exports.analyze = function (domain, options = {}) {
|
||||
|
||||
if (!domain) { // Catch null / undefined
|
||||
return Errors.code('DOMAIN_NON_EMPTY_STRING');
|
||||
}
|
||||
|
||||
if (typeof domain !== 'string') {
|
||||
throw new Error('Invalid input: domain must be a string');
|
||||
}
|
||||
|
||||
if (domain.length > 256) {
|
||||
return Errors.code('DOMAIN_TOO_LONG');
|
||||
}
|
||||
|
||||
const ascii = !internals.nonAsciiRx.test(domain);
|
||||
if (!ascii) {
|
||||
if (options.allowUnicode === false) { // Defaults to true
|
||||
return Errors.code('DOMAIN_INVALID_UNICODE_CHARS');
|
||||
}
|
||||
|
||||
domain = domain.normalize('NFC');
|
||||
}
|
||||
|
||||
if (internals.domainControlRx.test(domain)) {
|
||||
return Errors.code('DOMAIN_INVALID_CHARS');
|
||||
}
|
||||
|
||||
domain = internals.punycode(domain);
|
||||
|
||||
// https://tools.ietf.org/html/rfc1035 section 2.3.1
|
||||
|
||||
if (options.allowFullyQualified &&
|
||||
domain[domain.length - 1] === '.') {
|
||||
|
||||
domain = domain.slice(0, -1);
|
||||
}
|
||||
|
||||
const minDomainSegments = options.minDomainSegments || internals.minDomainSegments;
|
||||
|
||||
const segments = domain.split('.');
|
||||
if (segments.length < minDomainSegments) {
|
||||
return Errors.code('DOMAIN_SEGMENTS_COUNT');
|
||||
}
|
||||
|
||||
if (options.maxDomainSegments) {
|
||||
if (segments.length > options.maxDomainSegments) {
|
||||
return Errors.code('DOMAIN_SEGMENTS_COUNT_MAX');
|
||||
}
|
||||
}
|
||||
|
||||
const tlds = options.tlds;
|
||||
if (tlds) {
|
||||
const tld = segments[segments.length - 1].toLowerCase();
|
||||
if (tlds.deny && tlds.deny.has(tld) ||
|
||||
tlds.allow && !tlds.allow.has(tld)) {
|
||||
|
||||
return Errors.code('DOMAIN_FORBIDDEN_TLDS');
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < segments.length; ++i) {
|
||||
const segment = segments[i];
|
||||
|
||||
if (!segment.length) {
|
||||
return Errors.code('DOMAIN_EMPTY_SEGMENT');
|
||||
}
|
||||
|
||||
if (segment.length > 63) {
|
||||
return Errors.code('DOMAIN_LONG_SEGMENT');
|
||||
}
|
||||
|
||||
if (i < segments.length - 1) {
|
||||
if (!internals.domainSegmentRx.test(segment)) {
|
||||
return Errors.code('DOMAIN_INVALID_CHARS');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!internals.tldSegmentRx.test(segment)) {
|
||||
return Errors.code('DOMAIN_INVALID_TLDS_CHARS');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
exports.isValid = function (domain, options) {
|
||||
|
||||
return !exports.analyze(domain, options);
|
||||
};
|
||||
|
||||
|
||||
internals.punycode = function (domain) {
|
||||
|
||||
if (domain.includes('%')) {
|
||||
domain = domain.replace(/%/g, '%25');
|
||||
}
|
||||
|
||||
try {
|
||||
return new internals.URL(`http://${domain}`).host;
|
||||
}
|
||||
catch (err) {
|
||||
return domain;
|
||||
}
|
||||
};
|
@ -0,0 +1,170 @@
|
||||
'use strict';
|
||||
|
||||
const Util = require('util');
|
||||
|
||||
const Domain = require('./domain');
|
||||
const Errors = require('./errors');
|
||||
|
||||
|
||||
const internals = {
|
||||
nonAsciiRx: /[^\x00-\x7f]/,
|
||||
encoder: new (Util.TextEncoder || TextEncoder)() // $lab:coverage:ignore$
|
||||
};
|
||||
|
||||
|
||||
exports.analyze = function (email, options) {
|
||||
|
||||
return internals.email(email, options);
|
||||
};
|
||||
|
||||
|
||||
exports.isValid = function (email, options) {
|
||||
|
||||
return !internals.email(email, options);
|
||||
};
|
||||
|
||||
|
||||
internals.email = function (email, options = {}) {
|
||||
|
||||
if (typeof email !== 'string') {
|
||||
throw new Error('Invalid input: email must be a string');
|
||||
}
|
||||
|
||||
if (!email) {
|
||||
return Errors.code('EMPTY_STRING');
|
||||
}
|
||||
|
||||
// Unicode
|
||||
|
||||
const ascii = !internals.nonAsciiRx.test(email);
|
||||
if (!ascii) {
|
||||
if (options.allowUnicode === false) { // Defaults to true
|
||||
return Errors.code('FORBIDDEN_UNICODE');
|
||||
}
|
||||
|
||||
email = email.normalize('NFC');
|
||||
}
|
||||
|
||||
// Basic structure
|
||||
|
||||
const parts = email.split('@');
|
||||
if (parts.length !== 2) {
|
||||
return parts.length > 2 ? Errors.code('MULTIPLE_AT_CHAR') : Errors.code('MISSING_AT_CHAR');
|
||||
}
|
||||
|
||||
const [local, domain] = parts;
|
||||
|
||||
if (!local) {
|
||||
return Errors.code('EMPTY_LOCAL');
|
||||
}
|
||||
|
||||
if (!options.ignoreLength) {
|
||||
if (email.length > 254) { // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3
|
||||
return Errors.code('ADDRESS_TOO_LONG');
|
||||
}
|
||||
|
||||
if (internals.encoder.encode(local).length > 64) { // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.1
|
||||
return Errors.code('LOCAL_TOO_LONG');
|
||||
}
|
||||
}
|
||||
|
||||
// Validate parts
|
||||
|
||||
return internals.local(local, ascii) || Domain.analyze(domain, options);
|
||||
};
|
||||
|
||||
|
||||
internals.local = function (local, ascii) {
|
||||
|
||||
const segments = local.split('.');
|
||||
for (const segment of segments) {
|
||||
if (!segment.length) {
|
||||
return Errors.code('EMPTY_LOCAL_SEGMENT');
|
||||
}
|
||||
|
||||
if (ascii) {
|
||||
if (!internals.atextRx.test(segment)) {
|
||||
return Errors.code('INVALID_LOCAL_CHARS');
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const char of segment) {
|
||||
if (internals.atextRx.test(char)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const binary = internals.binary(char);
|
||||
if (!internals.atomRx.test(binary)) {
|
||||
return Errors.code('INVALID_LOCAL_CHARS');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.binary = function (char) {
|
||||
|
||||
return Array.from(internals.encoder.encode(char)).map((v) => String.fromCharCode(v)).join('');
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
From RFC 5321:
|
||||
|
||||
Mailbox = Local-part "@" ( Domain / address-literal )
|
||||
|
||||
Local-part = Dot-string / Quoted-string
|
||||
Dot-string = Atom *("." Atom)
|
||||
Atom = 1*atext
|
||||
atext = ALPHA / DIGIT / "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "/" / "=" / "?" / "^" / "_" / "`" / "{" / "|" / "}" / "~"
|
||||
|
||||
Domain = sub-domain *("." sub-domain)
|
||||
sub-domain = Let-dig [Ldh-str]
|
||||
Let-dig = ALPHA / DIGIT
|
||||
Ldh-str = *( ALPHA / DIGIT / "-" ) Let-dig
|
||||
|
||||
ALPHA = %x41-5A / %x61-7A ; a-z, A-Z
|
||||
DIGIT = %x30-39 ; 0-9
|
||||
|
||||
From RFC 6531:
|
||||
|
||||
sub-domain =/ U-label
|
||||
atext =/ UTF8-non-ascii
|
||||
|
||||
UTF8-non-ascii = UTF8-2 / UTF8-3 / UTF8-4
|
||||
|
||||
UTF8-2 = %xC2-DF UTF8-tail
|
||||
UTF8-3 = %xE0 %xA0-BF UTF8-tail /
|
||||
%xE1-EC 2( UTF8-tail ) /
|
||||
%xED %x80-9F UTF8-tail /
|
||||
%xEE-EF 2( UTF8-tail )
|
||||
UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) /
|
||||
%xF1-F3 3( UTF8-tail ) /
|
||||
%xF4 %x80-8F 2( UTF8-tail )
|
||||
|
||||
UTF8-tail = %x80-BF
|
||||
|
||||
Note: The following are not supported:
|
||||
|
||||
RFC 5321: address-literal, Quoted-string
|
||||
RFC 5322: obs-*, CFWS
|
||||
*/
|
||||
|
||||
|
||||
internals.atextRx = /^[\w!#\$%&'\*\+\-/=\?\^`\{\|\}~]+$/; // _ included in \w
|
||||
|
||||
|
||||
internals.atomRx = new RegExp([
|
||||
|
||||
// %xC2-DF UTF8-tail
|
||||
'(?:[\\xc2-\\xdf][\\x80-\\xbf])',
|
||||
|
||||
// %xE0 %xA0-BF UTF8-tail %xE1-EC 2( UTF8-tail ) %xED %x80-9F UTF8-tail %xEE-EF 2( UTF8-tail )
|
||||
'(?:\\xe0[\\xa0-\\xbf][\\x80-\\xbf])|(?:[\\xe1-\\xec][\\x80-\\xbf]{2})|(?:\\xed[\\x80-\\x9f][\\x80-\\xbf])|(?:[\\xee-\\xef][\\x80-\\xbf]{2})',
|
||||
|
||||
// %xF0 %x90-BF 2( UTF8-tail ) %xF1-F3 3( UTF8-tail ) %xF4 %x80-8F 2( UTF8-tail )
|
||||
'(?:\\xf0[\\x90-\\xbf][\\x80-\\xbf]{2})|(?:[\\xf1-\\xf3][\\x80-\\xbf]{3})|(?:\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})'
|
||||
|
||||
].join('|'));
|
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
exports.codes = {
|
||||
EMPTY_STRING: 'Address must be a non-empty string',
|
||||
FORBIDDEN_UNICODE: 'Address contains forbidden Unicode characters',
|
||||
MULTIPLE_AT_CHAR: 'Address cannot contain more than one @ character',
|
||||
MISSING_AT_CHAR: 'Address must contain one @ character',
|
||||
EMPTY_LOCAL: 'Address local part cannot be empty',
|
||||
ADDRESS_TOO_LONG: 'Address too long',
|
||||
LOCAL_TOO_LONG: 'Address local part too long',
|
||||
EMPTY_LOCAL_SEGMENT: 'Address local part contains empty dot-separated segment',
|
||||
INVALID_LOCAL_CHARS: 'Address local part contains invalid character',
|
||||
DOMAIN_NON_EMPTY_STRING: 'Domain must be a non-empty string',
|
||||
DOMAIN_TOO_LONG: 'Domain too long',
|
||||
DOMAIN_INVALID_UNICODE_CHARS: 'Domain contains forbidden Unicode characters',
|
||||
DOMAIN_INVALID_CHARS: 'Domain contains invalid character',
|
||||
DOMAIN_INVALID_TLDS_CHARS: 'Domain contains invalid tld character',
|
||||
DOMAIN_SEGMENTS_COUNT: 'Domain lacks the minimum required number of segments',
|
||||
DOMAIN_SEGMENTS_COUNT_MAX: 'Domain contains too many segments',
|
||||
DOMAIN_FORBIDDEN_TLDS: 'Domain uses forbidden TLD',
|
||||
DOMAIN_EMPTY_SEGMENT: 'Domain contains empty dot-separated segment',
|
||||
DOMAIN_LONG_SEGMENT: 'Domain contains dot-separated segment that is too long'
|
||||
};
|
||||
|
||||
|
||||
exports.code = function (code) {
|
||||
|
||||
return { code, error: exports.codes[code] };
|
||||
};
|
@ -0,0 +1,255 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as Hoek from '@hapi/hoek';
|
||||
|
||||
|
||||
export namespace domain {
|
||||
|
||||
/**
|
||||
* Analyzes a string to verify it is a valid domain name.
|
||||
*
|
||||
* @param domain - the domain name to validate.
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @return - undefined when valid, otherwise an object with single error key with a string message value.
|
||||
*/
|
||||
function analyze(domain: string, options?: Options): Analysis | null;
|
||||
|
||||
/**
|
||||
* Analyzes a string to verify it is a valid domain name.
|
||||
*
|
||||
* @param domain - the domain name to validate.
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @return - true when valid, otherwise false.
|
||||
*/
|
||||
function isValid(domain: string, options?: Options): boolean;
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* Determines whether Unicode characters are allowed.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly allowUnicode?: boolean;
|
||||
|
||||
/**
|
||||
* The minimum number of domain segments (e.g. `x.y.z` has 3 segments) required.
|
||||
*
|
||||
* @default 2
|
||||
*/
|
||||
readonly minDomainSegments?: number;
|
||||
|
||||
/**
|
||||
* Top-level-domain options
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly tlds?: Tlds.Allow | Tlds.Deny | boolean;
|
||||
}
|
||||
|
||||
namespace Tlds {
|
||||
|
||||
interface Allow {
|
||||
|
||||
readonly allow: Set<string> | true;
|
||||
}
|
||||
|
||||
interface Deny {
|
||||
|
||||
readonly deny: Set<string>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export namespace email {
|
||||
|
||||
/**
|
||||
* Analyzes a string to verify it is a valid email address.
|
||||
*
|
||||
* @param email - the email address to validate.
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @return - undefined when valid, otherwise an object with single error key with a string message value.
|
||||
*/
|
||||
function analyze(email: string, options?: Options): Analysis | null;
|
||||
|
||||
/**
|
||||
* Analyzes a string to verify it is a valid email address.
|
||||
*
|
||||
* @param email - the email address to validate.
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @return - true when valid, otherwise false.
|
||||
*/
|
||||
function isValid(email: string, options?: Options): boolean;
|
||||
|
||||
interface Options extends domain.Options {
|
||||
|
||||
/**
|
||||
* Determines whether to ignore the standards maximum email length limit.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly ignoreLength?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export interface Analysis {
|
||||
|
||||
/**
|
||||
* The reason validation failed.
|
||||
*/
|
||||
error: string;
|
||||
|
||||
/**
|
||||
* The error code.
|
||||
*/
|
||||
code: string;
|
||||
}
|
||||
|
||||
|
||||
export const errors: Record<string, string>;
|
||||
|
||||
|
||||
export namespace ip {
|
||||
|
||||
/**
|
||||
* Generates a regular expression used to validate IP addresses.
|
||||
*
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @returns an object with the regular expression and meta data.
|
||||
*/
|
||||
function regex(options?: Options): Expression;
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* The required CIDR mode.
|
||||
*
|
||||
* @default 'optional'
|
||||
*/
|
||||
readonly cidr?: Cidr;
|
||||
|
||||
/**
|
||||
* The allowed versions.
|
||||
*
|
||||
* @default ['ipv4', 'ipv6', 'ipvfuture']
|
||||
*/
|
||||
readonly version?: Version | Version[];
|
||||
}
|
||||
|
||||
type Cidr = 'optional' | 'required' | 'forbidden';
|
||||
type Version = 'ipv4' | 'ipv6' | 'ipvfuture';
|
||||
|
||||
interface Expression {
|
||||
|
||||
/**
|
||||
* The CIDR mode.
|
||||
*/
|
||||
cidr: Cidr;
|
||||
|
||||
/**
|
||||
* The raw regular expression string.
|
||||
*/
|
||||
raw: string;
|
||||
|
||||
/**
|
||||
* The regular expression.
|
||||
*/
|
||||
regex: RegExp;
|
||||
|
||||
/**
|
||||
* The array of versions allowed.
|
||||
*/
|
||||
versions: Version[];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export namespace uri {
|
||||
|
||||
/**
|
||||
* Faster version of decodeURIComponent() that does not throw.
|
||||
*
|
||||
* @param string - the URL string to decode.
|
||||
*
|
||||
* @returns the decoded string or null if invalid.
|
||||
*/
|
||||
function decode(string: string): string | null;
|
||||
|
||||
/**
|
||||
* Generates a regular expression used to validate URI addresses.
|
||||
*
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @returns an object with the regular expression and meta data.
|
||||
*/
|
||||
function regex(options?: Options): Expression;
|
||||
|
||||
type Options = Hoek.ts.XOR<Options.Options, Options.Relative>;
|
||||
|
||||
namespace Options {
|
||||
|
||||
interface Query {
|
||||
|
||||
/**
|
||||
* Allow the use of [] in query parameters.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly allowQuerySquareBrackets?: boolean;
|
||||
}
|
||||
|
||||
interface Relative extends Query {
|
||||
|
||||
/**
|
||||
* Requires the URI to be relative.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly relativeOnly?: boolean;
|
||||
}
|
||||
|
||||
interface Options extends Query {
|
||||
|
||||
/**
|
||||
* Allow relative URIs.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly allowRelative?: boolean;
|
||||
|
||||
/**
|
||||
* Capture domain segment ($1).
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly domain?: boolean;
|
||||
|
||||
/**
|
||||
* The allowed URI schemes.
|
||||
*/
|
||||
readonly scheme?: Scheme | Scheme[];
|
||||
}
|
||||
|
||||
type Scheme = string | RegExp;
|
||||
}
|
||||
|
||||
interface Expression {
|
||||
|
||||
/**
|
||||
* The raw regular expression string.
|
||||
*/
|
||||
raw: string;
|
||||
|
||||
/**
|
||||
* The regular expression.
|
||||
*/
|
||||
regex: RegExp;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue