Complete Email Sortierer implementation with Appwrite and Stripe integration

This commit is contained in:
knso committed 2026-01-14 20:02:16 +01:00
commit 95349af50b
3355 files changed
+644802

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
export type ITrie = [0 | 1 | 2, { [label: string]: ITrie}];
export const exceptions: ITrie = (function() {
const _0: ITrie = [1,{}],_1: ITrie = [0,{"city":_0}];
const exceptions: ITrie = [0,{"ck":[0,{"www":_0}],"jp":[0,{"kawasaki":_1,"kitakyushu":_1,"kobe":_1,"nagoya":_1,"sapporo":_1,"sendai":_1,"yokohama":_1}]}];
return exceptions;
})();
export const rules: ITrie = (function() {
const _2: ITrie = [1,{}],_3: ITrie = [2,{}],_4: ITrie = [1,{"com":_2,"edu":_2,"gov":_2,"net":_2,"org":_2}],_5: ITrie = [1,{"com":_2,"edu":_2,"gov":_2,"mil":_2,"net":_2,"org":_2}],_6: ITrie = [0,{"*":_3}],_7: ITrie = [2,{"s":_6}],_8: ITrie = [0,{"relay":_3}],_9: ITrie = [2,{"id":_3}],_10: ITrie = [1,{"gov":_2}],_11: ITrie = [0,{"airflow":_6,"lambda-url":_3,"transfer-webapp":_3}],_12: ITrie = [0,{"airflow":_6,"transfer-webapp":_3}],_13: ITrie = [0,{"transfer-webapp":_3,"transfer-webapp-fips":_3}],_14: ITrie = [0,{"notebook":_3,"studio":_3}],_15: ITrie = [0,{"labeling":_3,"notebook":_3,"studio":_3}],_16: ITrie = [0,{"notebook":_3}],_17: ITrie = [0,{"labeling":_3,"notebook":_3,"notebook-fips":_3,"studio":_3}],_18: ITrie = [0,{"notebook":_3,"notebook-fips":_3,"studio":_3,"studio-fips":_3}],_19: ITrie = [0,{"shop":_3}],_20: ITrie = [0,{"*":_2}],_21: ITrie = [1,{"co":_3}],_22: ITrie = [0,{"objects":_3}],_23: ITrie = [2,{"nodes":_3}],_24: ITrie = [0,{"my":_3}],_25: ITrie = [0,{"s3":_3,"s3-accesspoint":_3,"s3-website":_3}],_26: ITrie = [0,{"s3":_3,"s3-accesspoint":_3}],_27: ITrie = [0,{"direct":_3}],_28: ITrie = [0,{"webview-assets":_3}],_29: ITrie = [0,{"vfs":_3,"webview-assets":_3}],_30: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_25,"s3":_3,"s3-accesspoint":_3,"s3-object-lambda":_3,"s3-website":_3,"aws-cloud9":_28,"cloud9":_29}],_31: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_26,"s3":_3,"s3-accesspoint":_3,"s3-object-lambda":_3,"s3-website":_3,"aws-cloud9":_28,"cloud9":_29}],_32: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_25,"s3":_3,"s3-accesspoint":_3,"s3-object-lambda":_3,"s3-website":_3,"analytics-gateway":_3,"aws-cloud9":_28,"cloud9":_29}],_33: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_25,"s3":_3,"s3-accesspoint":_3,"s3-object-lambda":_3,"s3-website":_3}],_34: ITrie = [0,{"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-fips":_3,"s3-website":_3}],_35: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_34,"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-fips":_3,"s3-object-lambda":_3,"s3-website":_3,"aws-cloud9":_28,"cloud9":_29}],_36: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_34,"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-deprecated":_3,"s3-fips":_3,"s3-object-lambda":_3,"s3-website":_3,"analytics-gateway":_3,"aws-cloud9":_28,"cloud9":_29}],_37: ITrie = [0,{"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-fips":_3}],_38: ITrie = [0,{"execute-api":_3,"emrappui-prod":_3,"emrnotebooks-prod":_3,"emrstudio-prod":_3,"dualstack":_37,"s3":_3,"s3-accesspoint":_3,"s3-accesspoint-fips":_3,"s3-fips":_3,"s3-object-lambda":_3,"s3-website":_3}],_39: ITrie = [0,{"auth":_3}],_40: ITrie = [0,{"auth":_3,"auth-fips":_3}],_41: ITrie = [0,{"auth-fips":_3}],_42: ITrie = [0,{"apps":_3}],_43: ITrie = [0,{"paas":_3}],_44: ITrie = [2,{"eu":_3}],_45: ITrie = [0,{"app":_3}],_46: ITrie = [0,{"site":_3}],_47: ITrie = [1,{"com":_2,"edu":_2,"net":_2,"org":_2}],_48: ITrie = [0,{"j":_3}],_49: ITrie = [0,{"dyn":_3}],_50: ITrie = [2,{"web":_3}],_51: ITrie = [1,{"co":_2,"com":_2,"edu":_2,"gov":_2,"net":_2,"org":_2}],_52: ITrie = [0,{"p":_3}],_53: ITrie = [0,{"user":_3}],_54: ITrie = [0,{"cdn":_3}],_55: ITrie = [2,{"raw":_6}],_56: ITrie = [0,{"cust":_3,"reservd":_3}],_57: ITrie = [0,{"cust":_3}],_58: ITrie = [0,{"s3":_3}],_59: ITrie = [1,{"biz":_2,"com":_2,"edu":_2,"gov":_2,"info":_2,"net":_2,"org":_2}],_60: ITrie = [0,{"ipfs":_3}],_61: ITrie = [1,{"framer":_3}],_62: ITrie = [0,{"forgot":_3}],_63: ITrie = [1,{"gs":_2}],_64: ITrie = [0,{"nes":_2}],_65: ITrie = [1,{"k12":_2,"cc":_2,"lib":_2}],_66: ITrie = [1,{"cc":_2}],_67: ITrie = [1,{"cc":_2,"lib":_2}];
const rules: ITrie = [0,{"ac":[1,{"com":_2,"edu":_2,"gov":_2,"mil":_2,"net":_2,"org":_2,"drr":_3,"feedback":_3,"forms":_3}],"ad":_2,"ae":[1,{"ac":_2,"co":_2,"gov":_2,"mil":_2,"net":_2,"org":_2,"sch":_2}],"aero":[1,{"airline":_2,"airport":_2,"accident-investigation":_2,"accident-prevention":_2,"aerobatic":_2,"aeroclub":_2,"aerodrome":_2,"agents":_2,"air-surveillance":_2,"air-traffic-control":_2,"aircraft":_2,"airtraffic":_2,"ambulance":_2,"association":_2,"author":_2,"ballooning":_2,"broker":_2,"caa":_2,"cargo":_2,"catering":_2,"certification":_2,"championship":_2,"charter":_2,"civilaviation":_2,"club":_2,"conference":_2,"consultant":_2,"consulting":_2,"control":_2,"council":_2,"crew":_2,"design":_2,"dgca":_2,"educator":_2,"emergency":_2,"engine":_2,"engineer":_2,"entertainment":_2,"equipment":_2,"exchange":_2,"express":_2,"federation":_2,"flight":_2,"freight":_2,"fuel":_2,"gliding":_2,"government":_2,"groundhandling":_2,"group":_2,"hanggliding":_2,"homebuilt":_2,"insurance":_2,"journal":_2,"journalist":_2,"leasing":_2,"logistics":_2,"magazine":_2,"maintenance":_2,"marketplace":_2,"media":_2,"microlight":_2,"modelling":_2,"navigation":_2,"parachuting":_2,"paragliding":_2,"passenger-association":_2,"pilot":_2,"press":_2,"production":_2,"recreation":_2,"repbody":_2,"res":_2,"research":_2,"rotorcraft":_2,"safety":_2,"scientist":_2,"services":_2,"show":_2,"skydiving":_2,"software":_2,"student":_2,"taxi":_2,"trader":_2,"trading":_2,"trainer":_2,"union":_2,"workinggroup":_2,"works":_2}],"af":_4,"ag":[1,{"co":_2,"com":_2,"net":_2,"nom":_2,"org":_2,"obj":_3}],"ai":[1,{"com":_2,"net":_2,"off":_2,"org":_2,"uwu":_3,"framer":_3}],"al":_5,"am":[1,{"co":_2,"com":_2,"commune":_2,"net":_2,"org":_2,"radio":_3}],"ao":[1,{"co":_2,"ed":_2,"edu":_2,"gov":_2,"gv":_2,"it":_2,"og":_2,"org":_2,"pb":_2}],"aq":_2,"ar":[1,{"bet":_2,"com":_2,"coop":_2,"edu":_2,"gob":_2,"gov":_2,"int":_2,"mil":_2,"musica":_2,"mutual":_2,"net":_2,"org":_2,"seg":_2,"senasa":_2,"tur":_2}],"arpa":[1,{"e164":_2,"home":_2,"in-addr":_2,"ip6":_2,"iris":_2,"uri":_2,"urn":_2}],"as":_10,"asia":[1,{"cloudns":_3,"daemon":_3,"dix":_3}],"at":[1,{"4":_3,"ac":[1,{"sth":_2}],"co":_2,"gv":_2,"or":_2,"funkfeuer":[0,{"wien":_3}],"futurecms":[0,{"*":_3,"ex":_6,"in":_6}],"futurehosting":_3,"futuremailing":_3,"ortsinfo":[0,{"ex":_6,"kunden":_6}],"biz":_3,"info":_3,"123webseite":_3,"priv":_3,"my":_3,"myspreadshop":_3,"12hp":_3,"2ix":_3,"4lima":_3,"lima-city":_3}],"au":[1,{"asn":_2,"com":[1,{"cloudlets":[0,{"mel":_3}],"myspreadshop":_3}],"edu":[1,{"act":_2,"catholic":_2,"nsw":_2,"nt":_2,"qld":_2,"sa":_2,"tas":_2,"vic":_2,"wa":_2}],"gov":[1,{"qld":_2,"sa":_2,"tas":_2,"vic":_2,"wa":_2}],"id":_2,"net":_2,"org":_2,"conf":_2,"oz":_2,"act":_2,"nsw":_2,"nt":_2,"qld":_2,"sa":_2,"tas":_2,"vic":_2,"wa":_2,"hrsn":[0,{"vps":_3}]}],"aw":[1,{"com":_2}],"ax":_2,"az":[1,{"biz":_2,"co":_2,"com":_2,"edu":_2,"gov":_2,"info":_2,"int":_2,"mil":_2,"name":_2,"net":_2,"org":_2,"pp":_2,"pro":_2}],"ba":[1,{"com":_2,"edu":_2,"gov":_2,"mil":_2,"net":_2,"org":_2,"brendly":_19,"rs":_3}],"bb":[1,{"biz":_2,"co":_2,"com":_2,"edu":_2,"gov":_2,"info":_2,"net":_2,"org":_2,"store":_2,"tv":_2}],"bd":[1,{"ac":_2,"ai":_2,"co":_2,"com":_2,"edu":_2,"gov":_2,"id":_2,"info":_2,"it":_2,"mil":_2,"net":_2,"org":_2,"sch":_2,"tv":_2}],"be":[1,{"ac":_2,"cloudns":_3,"webhosting":_3,"interhostsolutions":[0,{"cloud":_3}],"kuleuven":[0,{"ezproxy":_3}],"123website":_3,"myspreadshop":_3,"transurl":_6}],"bf":_10,"bg":[1,{"0":_2,"1":_2,"2":_2,"3":_2,"4":_2,"5":_2,"6":_2,"7":_2,"8":_2,"9":_2,"a":_2,"b":_2,"c":_2,"d":_2,"e":_2,"f":_2,"g":_2,"h":_2,"i":_2,"j":_2,"k":_2,"l":_2,"m":_2,"n":_2,"o":_2,"p":_2,"q":_2,"r":_2,"s":_2,"t":_2,"u":_2,"v":_2,"w":_2,"x":_2,"y":_2,"z":_2,"barsy":_3}],"bh":_4,"bi":[1,{"co":_2,"com":_2,"edu":_2,"or":_2,"org":_2}],"biz":[1,{"activetrail":_3,"cloud-ip":_3,"cloudns":_3,"jozi":_3,"dyndns":_3,"for-better":_3,"for-more":_3,"for-some":_3,"for-the":_3,"selfip":_3,"webhop":_3,"orx":_3,"mmafan":_3,"myftp":_3,"no-ip":_3,"dscloud":_3}],"bj":[1,{"africa":_2,"agro":_2,"architectes":_2,"assur":_2,"avocats":_2,"co":_2,"com":_2,"eco":_2,"econo":_2,"edu":_2,"info":_2,"loisirs":_2,"money":_2,"net":_2,"org":_2,"ote":_2,"restaurant":_2,"resto":_2,"tourism":_2,"univ":_2}],"bm":_4,"bn":[1,{"com":_2,"edu":_2,"gov":_2,"net":_2,"org":_2,"co":_3}],"bo":[1,{"com":_2,"edu":_2,"gob":_2,"int":_2,"mil":_2,"net":_2,"org":_2,"tv":_2,"web":_2,"academia":_2,"agro":_2,"arte":_2,"blog":_2,"bolivia":_2,"ciencia":_2,"cooperativa":_2,"democracia":_2,"deporte":_2,"ecologia":_2,"economia":_2,"empresa":_2,"indigena":_2,"industria":_2,"info":_2,"medicina":_2,"movimiento":_2,"musica":_2,"natural":_2,"nombre":_2,"noticias":_2,"patria":_2,"plurinacional":_2,"politica":_2,"profesional":_2,"pueblo":_2,"revista":_2,"salud":_2,"tecnologia":_2,"tksat":_2,"transporte":_2,"wiki":_2}],"br":[1,{"9guacu":_2,"abc":_2,"adm":_2,"adv":_2,"agr":_2,"aju":_2,"am":_2,"anani":_2,"aparecida":_2,"api":_2,"app":_2,"arq":_2,"art":_2,"ato":_2,"b":_2,"barueri":_2,"belem":_2,"beLine truncated
return rules;
})();
+110
View File
@@ -0,0 +1,110 @@
import {
fastPathLookup,
IPublicSuffix,
ISuffixLookupOptions,
} from 'tldts-core';
import { exceptions, ITrie, rules } from './data/trie';
// Flags used to know if a rule is ICANN or Private
const enum RULE_TYPE {
ICANN = 1,
PRIVATE = 2,
}
interface IMatch {
index: number;
isIcann: boolean;
isPrivate: boolean;
}
/**
* Lookup parts of domain in Trie
*/
function lookupInTrie(
parts: string[],
trie: ITrie,
index: number,
allowedMask: number,
): IMatch | null {
let result: IMatch | null = null;
let node: ITrie | undefined = trie;
while (node !== undefined) {
// We have a match!
if ((node[0] & allowedMask) !== 0) {
result = {
index: index + 1,
isIcann: node[0] === RULE_TYPE.ICANN,
isPrivate: node[0] === RULE_TYPE.PRIVATE,
};
}
// No more `parts` to look for
if (index === -1) {
break;
}
const succ: { [label: string]: ITrie } = node[1];
node = Object.prototype.hasOwnProperty.call(succ, parts[index]!)
? succ[parts[index]!]
: succ['*'];
index -= 1;
}
return result;
}
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
export default function suffixLookup(
hostname: string,
options: ISuffixLookupOptions,
out: IPublicSuffix,
): void {
if (fastPathLookup(hostname, options, out)) {
return;
}
const hostnameParts = hostname.split('.');
const allowedMask =
(options.allowPrivateDomains ? RULE_TYPE.PRIVATE : 0) |
(options.allowIcannDomains ? RULE_TYPE.ICANN : 0);
// Look for exceptions
const exceptionMatch = lookupInTrie(
hostnameParts,
exceptions,
hostnameParts.length - 1,
allowedMask,
);
if (exceptionMatch !== null) {
out.isIcann = exceptionMatch.isIcann;
out.isPrivate = exceptionMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(exceptionMatch.index + 1).join('.');
return;
}
// Look for a match in rules
const rulesMatch = lookupInTrie(
hostnameParts,
rules,
hostnameParts.length - 1,
allowedMask,
);
if (rulesMatch !== null) {
out.isIcann = rulesMatch.isIcann;
out.isPrivate = rulesMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(rulesMatch.index).join('.');
return;
}
// No match found...
// Prevailing rule is '*' so we consider the top-level domain to be the
// public suffix of `hostname` (e.g.: 'example.org' => 'org').
out.isIcann = false;
out.isPrivate = false;
out.publicSuffix = hostnameParts[hostnameParts.length - 1] ?? null;
}