mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-02 07:23:38 +00:00
Moved v3 code from NginxProxyManager/nginx-proxy-manager-3 to NginxProxyManager/nginx-proxy-manager
This commit is contained in:
74
frontend/src/modules/Acmesh.ts
Normal file
74
frontend/src/modules/Acmesh.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
/* eslint @typescript-eslint/naming-convention: off */
|
||||
export const acmeshProviders: any = {
|
||||
dns_cf: "Cloudflare",
|
||||
dns_dp: "DNSPod.cn",
|
||||
dns_cx: "CloudXNS.com",
|
||||
dns_gd: "GoDaddy.com",
|
||||
dns_pdns: "PowerDNS",
|
||||
dns_nsupdate: "nsupdate",
|
||||
dns_lua: "LuaDNS",
|
||||
dns_me: "DNSMadeEasy",
|
||||
dns_aws: "Amazon Route53",
|
||||
dns_ali: "Aliyun",
|
||||
dns_ispconfig: "ISPConfig",
|
||||
dns_ad: "Alwaysdata",
|
||||
dns_linode_v4: "Linode",
|
||||
dns_freedns: "FreeDNS",
|
||||
dns_cyon: "cyon.ch",
|
||||
dns_do: "Domain-Offensive",
|
||||
dns_gandi_livedns: "Gandi LiveDNS",
|
||||
dns_knot: "Knot",
|
||||
dns_dgon: "DigitalOcean",
|
||||
dns_cloudns: "ClouDNS.net",
|
||||
dns_infoblox: "Infoblox",
|
||||
dns_vscale: "VSCALE",
|
||||
dns_dynu: "Dynu",
|
||||
dns_dnsimple: "DNSimple",
|
||||
dns_nsone: "NS1.com",
|
||||
dns_duckdns: "DuckDNS.org",
|
||||
dns_namecom: "Name.com",
|
||||
dns_dyn: "Dyn",
|
||||
dns_yandex: "pdd.yandex.ru",
|
||||
dns_he: "Hurricane Electric",
|
||||
dns_unoeuro: "UnoEuro",
|
||||
dns_inwx: "INWX",
|
||||
dns_servercow: "Servercow",
|
||||
dns_namesilo: "Namesilo.com",
|
||||
dns_autodns: "autoDNS",
|
||||
dns_azure: "Azure",
|
||||
dns_selectel: "Selectel",
|
||||
dns_zonomi: "zonomi.com",
|
||||
dns_dreamhost: "DreamHost",
|
||||
dns_da: "DirectAdmin",
|
||||
dns_kinghost: "KingHost",
|
||||
dns_zilore: "Zilore",
|
||||
dns_loopia: "Loopia",
|
||||
dns_acmedns: "ACME DNS",
|
||||
dns_tele3: "TELE3",
|
||||
dns_euserv: "Euserv.eu",
|
||||
dns_dpi: "DNSPod.com",
|
||||
dns_gcloud: "Google Cloud",
|
||||
dns_conoha: "ConoHa",
|
||||
dns_netcup: "netcup",
|
||||
dns_gdnsdk: "GratisDNS.dk",
|
||||
dns_namecheap: "Namecheap",
|
||||
dns_mydnsjp: "MyDNS.JP",
|
||||
dns_hostingde: "hosting.de",
|
||||
dns_neodigit: "Neodigit.net",
|
||||
dns_exoscale: "Exoscale",
|
||||
dns_active24: "Active24",
|
||||
dns_doapi: "do.de",
|
||||
dns_nw: "Nexcess",
|
||||
dns_rackspace: "Rackspace",
|
||||
dns_online: "Online.net",
|
||||
dns_mydevil: "MyDevil.net",
|
||||
dns_cn: "Core-Networks",
|
||||
// more, from #68 on this: https://github.com/acmesh-official/acme.sh/wiki/dnsapi
|
||||
};
|
||||
|
||||
export default function getNiceDNSProvider(acmeshName: string) {
|
||||
if (typeof acmeshProviders[acmeshName] !== "undefined") {
|
||||
return acmeshProviders[acmeshName];
|
||||
}
|
||||
return acmeshName;
|
||||
}
|
84
frontend/src/modules/AuthStore.ts
Normal file
84
frontend/src/modules/AuthStore.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import { TokenResponse } from "api/npm";
|
||||
|
||||
export const TOKEN_KEY = "authentications";
|
||||
|
||||
export class AuthStore {
|
||||
// Get all tokens from stack
|
||||
get tokens() {
|
||||
const t = localStorage.getItem(TOKEN_KEY);
|
||||
let tokens = [];
|
||||
if (t !== null) {
|
||||
try {
|
||||
tokens = JSON.parse(t);
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
// Get last token from stack
|
||||
get token() {
|
||||
const t = this.tokens;
|
||||
if (t.length) {
|
||||
return t[t.length - 1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get expires from last token
|
||||
get expires() {
|
||||
const t = this.token;
|
||||
if (t && typeof t.expires !== "undefined") {
|
||||
const expires = Number(t.expires);
|
||||
if (expires && !isNaN(expires)) {
|
||||
return expires;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Filter out invalid tokens and return true if we find one that is valid
|
||||
hasActiveToken() {
|
||||
const t = this.tokens;
|
||||
if (!t.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const now = Math.round(new Date().getTime() / 1000);
|
||||
const oneMinuteBuffer = 60;
|
||||
for (let i = t.length - 1; i >= 0; i--) {
|
||||
const valid = t[i].expires - oneMinuteBuffer > now;
|
||||
if (valid) {
|
||||
return true;
|
||||
} else {
|
||||
this.drop();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set a single token on the stack
|
||||
set({ token, expires }: TokenResponse) {
|
||||
localStorage.setItem(TOKEN_KEY, JSON.stringify([{ token, expires }]));
|
||||
}
|
||||
|
||||
// Add a token to the stack
|
||||
add({ token, expires }: TokenResponse) {
|
||||
const t = this.tokens;
|
||||
t.push({ token, expires });
|
||||
localStorage.setItem(TOKEN_KEY, t);
|
||||
}
|
||||
|
||||
// Drop a token from the stack
|
||||
drop() {
|
||||
const t = this.tokens;
|
||||
localStorage.setItem(TOKEN_KEY, t.splice(-1, 1));
|
||||
}
|
||||
|
||||
clear() {
|
||||
localStorage.removeItem(TOKEN_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
export default new AuthStore();
|
63
frontend/src/modules/Validations.tsx
Normal file
63
frontend/src/modules/Validations.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
import { intl } from "locale";
|
||||
|
||||
const validateString = (minLength = 0, maxLength = 0) => {
|
||||
if (minLength <= 0 && maxLength <= 0) {
|
||||
// this doesn't require translation
|
||||
console.error(
|
||||
"validateString() must be called with a min or max or both values in order to work!",
|
||||
);
|
||||
}
|
||||
|
||||
return (value: string): string | undefined => {
|
||||
if (minLength && !value.length) {
|
||||
return intl.formatMessage({ id: "form.required" });
|
||||
}
|
||||
if (minLength && value.length < minLength) {
|
||||
return intl.formatMessage(
|
||||
{ id: "form.min-length" },
|
||||
{ count: minLength },
|
||||
);
|
||||
}
|
||||
if (maxLength && value.length > maxLength) {
|
||||
return intl.formatMessage(
|
||||
{ id: "form.max-length" },
|
||||
{ count: maxLength },
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const validateNumber = (min = -1, max = -1) => {
|
||||
if (min === -1 && max === -1) {
|
||||
// this doesn't require translation
|
||||
console.error(
|
||||
"validateNumber() must be called with a min or max or both values in order to work!",
|
||||
);
|
||||
}
|
||||
|
||||
return (value: string): string | undefined => {
|
||||
const int: number = +value;
|
||||
if (min > -1 && !int) {
|
||||
return intl.formatMessage({ id: "form.required" });
|
||||
}
|
||||
if (min > -1 && int < min) {
|
||||
return intl.formatMessage({ id: "form.min-int" }, { count: min });
|
||||
}
|
||||
if (max > -1 && int > max) {
|
||||
return intl.formatMessage({ id: "form.max-int" }, { count: max });
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const validateEmail = () => {
|
||||
return (value: string): string | undefined => {
|
||||
if (!value.length) {
|
||||
return intl.formatMessage({ id: "form.required" });
|
||||
}
|
||||
if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(value)) {
|
||||
return intl.formatMessage({ id: "form.invalid-email" });
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export { validateEmail, validateNumber, validateString };
|
Reference in New Issue
Block a user