feat(auth): implement user authentication system
This commit is contained in:
parent
4847ab793a
commit
25cea4fbe8
12051 changed files with 1462377 additions and 0 deletions
21
backend/node_modules/named-placeholders/LICENSE
generated
vendored
Normal file
21
backend/node_modules/named-placeholders/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Andrey Sidorov
|
||||
|
||||
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.
|
||||
27
backend/node_modules/named-placeholders/README.md
generated
vendored
Normal file
27
backend/node_modules/named-placeholders/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
[](https://nodei.co/npm/named-placeholders/)
|
||||
|
||||
[](https://github.com/mysqljs/named-placeholders/actions/workflows/ci.yml)
|
||||
|
||||
# named-placeholders
|
||||
|
||||
compiles "select foo where foo.id = :bar and foo.baz < :baz" into "select foo where foo.id = ? and foo.baz < ?" + ["bar", "baz"]
|
||||
|
||||
## usage
|
||||
|
||||
```sh
|
||||
npm install named-placeholders
|
||||
```
|
||||
|
||||
see [this mysql2 discussion](https://github.com/sidorares/node-mysql2/issues/117)
|
||||
|
||||
```js
|
||||
var mysql = require('mysql');
|
||||
var toUnnamed = require('named-placeholders')();
|
||||
|
||||
var q = toUnnamed('select 1+:test', { test: 123 });
|
||||
mysql.createConnection().query(q[0], q[1]);
|
||||
```
|
||||
|
||||
## credits
|
||||
|
||||
parser is based on @mscdex code of his excellent [node-mariasql](https://github.com/mscdex/node-mariasql) library
|
||||
179
backend/node_modules/named-placeholders/index.js
generated
vendored
Normal file
179
backend/node_modules/named-placeholders/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
'use strict';
|
||||
|
||||
// based on code from Brian White @mscdex mariasql library - https://github.com/mscdex/node-mariasql/blob/master/lib/Client.js#L272-L332
|
||||
// License: https://github.com/mscdex/node-mariasql/blob/master/LICENSE
|
||||
|
||||
const RE_PARAM = /(?:\?)|(?::(\d+|(?:[a-zA-Z][a-zA-Z0-9_]*)))/g,
|
||||
DQUOTE = 34,
|
||||
SQUOTE = 39,
|
||||
BSLASH = 92;
|
||||
|
||||
function parse(query) {
|
||||
let ppos = RE_PARAM.exec(query);
|
||||
let curpos = 0;
|
||||
let start = 0;
|
||||
let end;
|
||||
const parts = [];
|
||||
let inQuote = false;
|
||||
let escape = false;
|
||||
let qchr;
|
||||
const tokens = [];
|
||||
let qcnt = 0;
|
||||
let lastTokenEndPos = 0;
|
||||
let i;
|
||||
|
||||
if (ppos) {
|
||||
do {
|
||||
for (i = curpos, end = ppos.index; i < end; ++i) {
|
||||
const chr = query.charCodeAt(i);
|
||||
if (chr === BSLASH) escape = !escape;
|
||||
else {
|
||||
if (escape) {
|
||||
escape = false;
|
||||
continue;
|
||||
}
|
||||
if (inQuote && chr === qchr) {
|
||||
if (query.charCodeAt(i + 1) === qchr) {
|
||||
// quote escaped via "" or ''
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
inQuote = false;
|
||||
} else if (!inQuote && (chr === DQUOTE || chr === SQUOTE)) {
|
||||
inQuote = true;
|
||||
qchr = chr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!inQuote) {
|
||||
parts.push(query.substring(start, end));
|
||||
tokens.push(ppos[0].length === 1 ? qcnt++ : ppos[1]);
|
||||
start = end + ppos[0].length;
|
||||
lastTokenEndPos = start;
|
||||
}
|
||||
curpos = end + ppos[0].length;
|
||||
} while ((ppos = RE_PARAM.exec(query)));
|
||||
|
||||
if (tokens.length) {
|
||||
if (curpos < query.length) {
|
||||
parts.push(query.substring(lastTokenEndPos));
|
||||
}
|
||||
return [parts, tokens];
|
||||
}
|
||||
}
|
||||
return [query];
|
||||
}
|
||||
|
||||
function createCompiler(config) {
|
||||
if (!config) config = {};
|
||||
if (!config.placeholder) {
|
||||
config.placeholder = '?';
|
||||
}
|
||||
let ncache = 100;
|
||||
let cache;
|
||||
if (typeof config.cache === 'number') {
|
||||
ncache = config.cache;
|
||||
}
|
||||
if (typeof config.cache === 'object') {
|
||||
cache = config.cache;
|
||||
}
|
||||
if (config.cache !== false && !cache) {
|
||||
cache = require('lru.min').createLRU({ max: ncache });
|
||||
}
|
||||
|
||||
function toArrayParams(tree, params) {
|
||||
const arr = [];
|
||||
if (tree.length === 1) {
|
||||
return [tree[0], []];
|
||||
}
|
||||
|
||||
if (typeof params === 'undefined')
|
||||
throw new Error(
|
||||
'Named query contains placeholders, but parameters object is undefined'
|
||||
);
|
||||
|
||||
const tokens = tree[1];
|
||||
for (let i = 0; i < tokens.length; ++i) {
|
||||
arr.push(params[tokens[i]]);
|
||||
}
|
||||
return [tree[0], arr];
|
||||
}
|
||||
|
||||
function noTailingSemicolon(s) {
|
||||
if (s.slice(-1) === ':') {
|
||||
return s.slice(0, -1);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
function join(tree) {
|
||||
if (tree.length === 1) {
|
||||
return tree;
|
||||
}
|
||||
|
||||
let unnamed = noTailingSemicolon(tree[0][0]);
|
||||
for (let i = 1; i < tree[0].length; ++i) {
|
||||
if (tree[0][i - 1].slice(-1) === ':') {
|
||||
unnamed += config.placeholder;
|
||||
}
|
||||
unnamed += config.placeholder;
|
||||
unnamed += noTailingSemicolon(tree[0][i]);
|
||||
}
|
||||
|
||||
const last = tree[0][tree[0].length - 1];
|
||||
if (tree[0].length === tree[1].length) {
|
||||
if (last.slice(-1) === ':') {
|
||||
unnamed += config.placeholder;
|
||||
}
|
||||
unnamed += config.placeholder;
|
||||
}
|
||||
return [unnamed, tree[1]];
|
||||
}
|
||||
|
||||
function compile(query, paramsObj) {
|
||||
let tree;
|
||||
if (cache && (tree = cache.get(query))) {
|
||||
return toArrayParams(tree, paramsObj);
|
||||
}
|
||||
tree = join(parse(query));
|
||||
if (cache) {
|
||||
cache.set(query, tree);
|
||||
}
|
||||
return toArrayParams(tree, paramsObj);
|
||||
}
|
||||
|
||||
compile.parse = parse;
|
||||
return compile;
|
||||
}
|
||||
|
||||
// named :one :two to postgres-style numbered $1 $2 $3
|
||||
function toNumbered(q, params) {
|
||||
const tree = parse(q);
|
||||
const paramsArr = [];
|
||||
if (tree.length === 1) {
|
||||
return [tree[0], paramsArr];
|
||||
}
|
||||
|
||||
const pIndexes = {};
|
||||
let pLastIndex = 0;
|
||||
let qs = '';
|
||||
let varIndex;
|
||||
const varNames = [];
|
||||
for (let i = 0; i < tree[0].length; ++i) {
|
||||
varIndex = pIndexes[tree[1][i]];
|
||||
if (!varIndex) {
|
||||
varIndex = ++pLastIndex;
|
||||
pIndexes[tree[1][i]] = varIndex;
|
||||
}
|
||||
if (tree[1][i]) {
|
||||
varNames[varIndex - 1] = tree[1][i];
|
||||
qs += `${tree[0][i]}$${varIndex}`;
|
||||
} else {
|
||||
qs += tree[0][i];
|
||||
}
|
||||
}
|
||||
return [qs, varNames.map((n) => params[n])];
|
||||
}
|
||||
|
||||
module.exports = createCompiler;
|
||||
module.exports.toNumbered = toNumbered;
|
||||
36
backend/node_modules/named-placeholders/package.json
generated
vendored
Normal file
36
backend/node_modules/named-placeholders/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "named-placeholders",
|
||||
"version": "1.1.6",
|
||||
"description": "sql named placeholders to unnamed compiler",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "node --test",
|
||||
"lint": "biome lint --error-on-warnings && prettier --check .",
|
||||
"lint:fix": "biome lint --write && prettier --write .github/workflows/*.yml ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mysqljs/named-placeholders"
|
||||
},
|
||||
"keywords": [
|
||||
"sql",
|
||||
"pdo",
|
||||
"named",
|
||||
"placeholders",
|
||||
"mysql",
|
||||
"postgres"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"author": "Andrey Sidorov <sidorares@yandex.com>",
|
||||
"files": [],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lru.min": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.3.8",
|
||||
"prettier": "^3.7.4"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue