This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.11.0
uses: actions/setup-node@v2
with:
node-version: 12.11.0
- run: npm install
- run: npm run lint
- run: npm run build
- run: npm run test

21
frontend/node_modules/oblivious-set/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Daniel Meyer
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.

30
frontend/node_modules/oblivious-set/README.md generated vendored Normal file
View File

@@ -0,0 +1,30 @@
# oblivious-set
Like a JavaScript Set() but with a TTL for entries.
In difference to other caches with TTLs out there, this one does not need intervals or timeouts to work.
This means it can be properly garbage collected when there is no more reference to the instance.
## Usage
```ts
import { ObliviousSet } from 'oblivious-set';
// create a set
const obliviousSet = new ObliviousSet(
100 // TTL in milliseconds
);
// add a value
obliviousSet.add('foobar');
// check existence
console.log(obliviousSet.has('foobar')); // > true
console.log(obliviousSet.has('barfoo')); // > false
// clear
obliviousSet.clear();
```

20
frontend/node_modules/oblivious-set/dist/es/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
/**
* this is a set which automatically forgets
* a given entry when a new entry is set and the ttl
* of the old one is over
*/
export declare class ObliviousSet<T = any> {
readonly ttl: number;
readonly set: Set<unknown>;
readonly timeMap: Map<any, any>;
constructor(ttl: number);
has(value: T): boolean;
add(value: T): void;
clear(): void;
}
/**
* Removes all entries from the set
* where the TTL has expired
*/
export declare function removeTooOldValues(obliviousSet: ObliviousSet): void;
export declare function now(): number;

66
frontend/node_modules/oblivious-set/dist/es/index.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
/**
* this is a set which automatically forgets
* a given entry when a new entry is set and the ttl
* of the old one is over
*/
var ObliviousSet = /** @class */ (function () {
function ObliviousSet(ttl) {
this.ttl = ttl;
this.set = new Set();
this.timeMap = new Map();
}
ObliviousSet.prototype.has = function (value) {
return this.set.has(value);
};
ObliviousSet.prototype.add = function (value) {
var _this = this;
this.timeMap.set(value, now());
this.set.add(value);
/**
* When a new value is added,
* start the cleanup at the next tick
* to not block the cpu for more important stuff
* that might happen.
*/
setTimeout(function () {
removeTooOldValues(_this);
}, 0);
};
ObliviousSet.prototype.clear = function () {
this.set.clear();
this.timeMap.clear();
};
return ObliviousSet;
}());
export { ObliviousSet };
/**
* Removes all entries from the set
* where the TTL has expired
*/
export function removeTooOldValues(obliviousSet) {
var olderThen = now() - obliviousSet.ttl;
var iterator = obliviousSet.set[Symbol.iterator]();
/**
* Because we can assume the new values are added at the bottom,
* we start from the top and stop as soon as we reach a non-too-old value.
*/
while (true) {
var value = iterator.next().value;
if (!value) {
return; // no more elements
}
var time = obliviousSet.timeMap.get(value);
if (time < olderThen) {
obliviousSet.timeMap.delete(value);
obliviousSet.set.delete(value);
}
else {
// We reached a value that is not old enough
return;
}
}
}
export function now() {
return new Date().getTime();
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 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AC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,IAAI,GAAG,SAAS,EAAE;YAClB,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAClC;aAAM;YACH,4CAA4C;YAC5C,OAAO;SACV;KACJ;AACL,CAAC;AAED,MAAM,UAAU,GAAG;IACf,OAAO,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;AAChC,CAAC"}

View File

@@ -0,0 +1,20 @@
/**
* this is a set which automatically forgets
* a given entry when a new entry is set and the ttl
* of the old one is over
*/
export declare class ObliviousSet<T = any> {
readonly ttl: number;
readonly set: Set<unknown>;
readonly timeMap: Map<any, any>;
constructor(ttl: number);
has(value: T): boolean;
add(value: T): void;
clear(): void;
}
/**
* Removes all entries from the set
* where the TTL has expired
*/
export declare function removeTooOldValues(obliviousSet: ObliviousSet): void;
export declare function now(): number;

71
frontend/node_modules/oblivious-set/dist/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.now = exports.removeTooOldValues = exports.ObliviousSet = void 0;
/**
* this is a set which automatically forgets
* a given entry when a new entry is set and the ttl
* of the old one is over
*/
var ObliviousSet = /** @class */ (function () {
function ObliviousSet(ttl) {
this.ttl = ttl;
this.set = new Set();
this.timeMap = new Map();
}
ObliviousSet.prototype.has = function (value) {
return this.set.has(value);
};
ObliviousSet.prototype.add = function (value) {
var _this = this;
this.timeMap.set(value, now());
this.set.add(value);
/**
* When a new value is added,
* start the cleanup at the next tick
* to not block the cpu for more important stuff
* that might happen.
*/
setTimeout(function () {
removeTooOldValues(_this);
}, 0);
};
ObliviousSet.prototype.clear = function () {
this.set.clear();
this.timeMap.clear();
};
return ObliviousSet;
}());
exports.ObliviousSet = ObliviousSet;
/**
* Removes all entries from the set
* where the TTL has expired
*/
function removeTooOldValues(obliviousSet) {
var olderThen = now() - obliviousSet.ttl;
var iterator = obliviousSet.set[Symbol.iterator]();
/**
* Because we can assume the new values are added at the bottom,
* we start from the top and stop as soon as we reach a non-too-old value.
*/
while (true) {
var value = iterator.next().value;
if (!value) {
return; // no more elements
}
var time = obliviousSet.timeMap.get(value);
if (time < olderThen) {
obliviousSet.timeMap.delete(value);
obliviousSet.set.delete(value);
}
else {
// We reached a value that is not old enough
return;
}
}
}
exports.removeTooOldValues = removeTooOldValues;
function now() {
return new Date().getTime();
}
exports.now = now;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA;;;;GAIG;AACH;IAGI,sBACoB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAHf,QAAG,GAAG,IAAI,GAAG,EAAE,CAAC;QAChB,YAAO,GAAG,IAAI,GAAG,EAAE,CAAC;IAGhC,CAAC;IAEL,0BAAG,GAAH,UAAI,KAAQ;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,0BAAG,GAAH,UAAI,KAAQ;QAAZ,iBAaC;QAZG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEpB;;;;;WAKG;QACH,UAAU,CAAC;YACP,kBAAkB,CAAC,KAAI,CAAC,CAAC;QAC7B,CAAC,EAAE,CAAC,CAAC,CAAC;IACV,CAAC;IAED,4BAAK,GAAL;QACI,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACjB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IACL,mBAAC;AAAD,CAAC,AA9BD,IA8BC;AA9BY,oCAAY;AAiCzB;;;GAGG;AACH,SAAgB,kBAAkB,CAC9B,YAA0B;IAE1B,IAAM,SAAS,GAAG,GAAG,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC;IAC3C,IAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAErD;;;OAGG;IACH,OAAO,IAAI,EAAE;QACT,IAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;QACpC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO,CAAC,mBAAmB;SAC9B;QACD,IAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,IAAI,GAAG,SAAS,EAAE;YAClB,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAClC;aAAM;YACH,4CAA4C;YAC5C,OAAO;SACV;KACJ;AACL,CAAC;AAxBD,gDAwBC;AAED,SAAgB,GAAG;IACf,OAAO,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;AAChC,CAAC;AAFD,kBAEC"}

36
frontend/node_modules/oblivious-set/package.json generated vendored Normal file
View File

@@ -0,0 +1,36 @@
{
"name": "oblivious-set",
"version": "1.0.0",
"description": "Like a JavaScript Set() but with a TTL for entries",
"license": "MIT",
"main": "./dist/lib/index.js",
"jsnext:main": "./dist/es/index.js",
"module": "./dist/es/index.js",
"types": "./dist/es/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/pubkey/oblivious-set"
},
"scripts": {
"prepublish": "npm run build",
"lint": "tslint --project .",
"lint:fix": "tslint --project . --fix",
"transpile": "tsc -p ./ && echo '# transpile es5 (require) sucess!'",
"transpile:es": "tsc -p ./ --target ES5 --module ES6 --outDir ./dist/es && echo '# transpile es (modules) sucess!'",
"build": "rimraf -r ./dist && npm run transpile && npm run transpile:es",
"test": "mocha -r ts-node/register test/unit.test.ts --timeout 20000 --bail"
},
"author": "pubkey",
"devDependencies": {
"@types/mocha": "8.2.2",
"@types/node": "14.17.1",
"assert": "2.0.0",
"async-test-util": "1.7.3",
"mocha": "8.4.0",
"rimraf": "3.0.2",
"ts-node": "10.0.0",
"tslint": "6.1.3",
"typescript": "4.3.2"
}
}

74
frontend/node_modules/oblivious-set/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,74 @@
/**
* this is a set which automatically forgets
* a given entry when a new entry is set and the ttl
* of the old one is over
*/
export class ObliviousSet<T = any> {
public readonly set = new Set();
public readonly timeMap = new Map();
constructor(
public readonly ttl: number
) { }
has(value: T): boolean {
return this.set.has(value);
}
add(value: T): void {
this.timeMap.set(value, now());
this.set.add(value);
/**
* When a new value is added,
* start the cleanup at the next tick
* to not block the cpu for more important stuff
* that might happen.
*/
setTimeout(() => {
removeTooOldValues(this);
}, 0);
}
clear() {
this.set.clear();
this.timeMap.clear();
}
}
/**
* Removes all entries from the set
* where the TTL has expired
*/
export function removeTooOldValues(
obliviousSet: ObliviousSet
) {
const olderThen = now() - obliviousSet.ttl;
const iterator = obliviousSet.set[Symbol.iterator]();
/**
* Because we can assume the new values are added at the bottom,
* we start from the top and stop as soon as we reach a non-too-old value.
*/
while (true) {
const value = iterator.next().value;
if (!value) {
return; // no more elements
}
const time = obliviousSet.timeMap.get(value);
if (time < olderThen) {
obliviousSet.timeMap.delete(value);
obliviousSet.set.delete(value);
} else {
// We reached a value that is not old enough
return;
}
}
}
export function now(): number {
return new Date().getTime();
}

52
frontend/node_modules/oblivious-set/test/unit.test.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
import AsyncTestUtil from 'async-test-util';
import * as assert from 'assert';
import {
ObliviousSet
} from '../src/index';
describe('unit.test.js', () => {
it('create, add, has, get, clear', () => {
const set = new ObliviousSet(100);
set.add('foobar');
const has = set.has('foobar');
assert.ok(has);
set.clear();
const hasAfter = set.has('foobar');
assert.strictEqual(false, hasAfter);
});
it('.removeTooOldValues() should clear the old values when a new one is given', async () => {
const set = new ObliviousSet(100);
set.add('foobar');
assert.ok(set.has('foobar'));
await AsyncTestUtil.wait(200);
set.add('foobar2');
await AsyncTestUtil.wait(100);
const has = set.has('foobar');
assert.strictEqual(false, has);
});
it('.removeTooOldValues() should NOT clear to young values when a new one is given', async () => {
const set = new ObliviousSet(500);
set.add('foobar');
assert.ok(set.has('foobar'));
await AsyncTestUtil.wait(50);
set.add('foobar2');
assert.ok(set.has('foobar'));
});
it('should clear the value after its ttl', async () => {
const set = new ObliviousSet(100);
set.add('foobar');
await AsyncTestUtil.wait(200);
set.add('foobar2');
await AsyncTestUtil.wait(100);
const has = set.has('foobar');
assert.strictEqual(false, has);
});
});

38
frontend/node_modules/oblivious-set/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,38 @@
{
"compilerOptions": {
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"strictNullChecks": true,
"noImplicitAny": false,
"strict": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"suppressImplicitAnyIndexErrors": true,
"downlevelIteration": true,
"declaration": true,
"moduleResolution": "node",
"esModuleInterop": true,
"target": "es5",
"outDir": "./dist/lib",
"lib": [
"es7",
"dom"
]
},
"formatCodeOptions": {
"indentSize": 2,
"tabSize": 2
},
"include": [
"src"
],
"exclude": [
"node_modules",
"**/node_modules/*",
"dist",
"**.txt",
"**.json"
],
"compileOnSave": false
}

116
frontend/node_modules/oblivious-set/tslint.json generated vendored Normal file
View File

@@ -0,0 +1,116 @@
{
"rulesDirectory": [],
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": false,
"deprecation": {
"severity": "warn"
},
"eofline": true,
"forin": false,
"import-blacklist": [
true,
"rxjs/Rx"
],
"import-spacing": true,
"indent": [
true,
"spaces",
4
],
"interface-over-type-literal": false,
"label-position": true,
"max-line-length": [
true,
160
],
"member-access": false,
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-arg": true,
"no-bitwise": false,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-misused-new": true,
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"prefer-const": true,
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"unified-signatures": true,
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}