Compare commits

...

2 Commits

Author SHA1 Message Date
msramalho
27310c2911 fixes issue with api requests 2024-02-21 12:25:05 +00:00
msramalho
eb973ba42d v0.9.1 fixes to bad parsing in ssl certificates 2024-02-20 19:31:19 +00:00
3 changed files with 19 additions and 11 deletions

View File

@@ -23,8 +23,7 @@ class AAApiDb(Database):
def configs() -> dict: def configs() -> dict:
return { return {
"api_endpoint": {"default": None, "help": "API endpoint where calls are made to"}, "api_endpoint": {"default": None, "help": "API endpoint where calls are made to"},
"api_secret": {"default": None, "help": "API Basic authentication secret [deprecating soon]"}, "api_token": {"default": None, "help": "API Bearer token."},
"api_token": {"default": None, "help": "API Bearer token, to be preferred over secret (Basic auth) going forward"},
"public": {"default": False, "help": "whether the URL should be publicly available via the API"}, "public": {"default": False, "help": "whether the URL should be publicly available via the API"},
"author_id": {"default": None, "help": "which email to assign as author"}, "author_id": {"default": None, "help": "which email to assign as author"},
"group_id": {"default": None, "help": "which group of users have access to the archive in case public=false as author"}, "group_id": {"default": None, "help": "which group of users have access to the archive in case public=false as author"},
@@ -59,7 +58,7 @@ class AAApiDb(Database):
logger.debug(f"saving archive of {item.get_url()} to the AA API.") logger.debug(f"saving archive of {item.get_url()} to the AA API.")
payload = {'result': item.to_json(), 'public': self.public, 'author_id': self.author_id, 'group_id': self.group_id, 'tags': list(self.tags)} payload = {'result': item.to_json(), 'public': self.public, 'author_id': self.author_id, 'group_id': self.group_id, 'tags': list(self.tags)}
headers = {"Authorization": f"Bearer {self.api_secret}"} headers = {"Authorization": f"Bearer {self.api_token}"}
response = requests.post(os.path.join(self.api_endpoint, "submit-archive"), json=payload, headers=headers) response = requests.post(os.path.join(self.api_endpoint, "submit-archive"), json=payload, headers=headers)
if response.status_code == 200: if response.status_code == 200:

View File

@@ -177,14 +177,23 @@
} }
async function run() { async function run() {
await PreviewCertificates(); let setupFunctions = [
await PreviewText(); previewCertificates,
await enableCopyLogic(); previewText,
await enableCollapsibleLogic(); enableCopyLogic,
await setupSafeView(); enableCollapsibleLogic,
setupSafeView
];
setupFunctions.forEach(async f => {
try {
await f();
} catch (e) {
console.error(`Error in ${f.name}: ${e}`);
}
});
} }
async function PreviewCertificates() { async function previewCertificates() {
await Promise.all( await Promise.all(
Array.from(document.querySelectorAll(".pem-certificate")).map(async el => { Array.from(document.querySelectorAll(".pem-certificate")).map(async el => {
let certificate = await (await fetch(el.getAttribute("pem"))).text(); let certificate = await (await fetch(el.getAttribute("pem"))).text();
@@ -202,7 +211,7 @@
console.log("certificate preview done"); console.log("certificate preview done");
} }
async function PreviewText() { async function previewText() {
await Promise.all( await Promise.all(
Array.from(document.querySelectorAll(".text-preview")).map(async el => { Array.from(document.querySelectorAll(".text-preview")).map(async el => {
let textContent = await (await fetch(el.getAttribute("url"))).text(); let textContent = await (await fetch(el.getAttribute("url"))).text();

View File

@@ -3,7 +3,7 @@ _MAJOR = "0"
_MINOR = "9" _MINOR = "9"
# On main and in a nightly release the patch should be one ahead of the last # On main and in a nightly release the patch should be one ahead of the last
# released build. # released build.
_PATCH = "0" _PATCH = "2"
# This is mainly for nightly builds which have the suffix ".dev$DATE". See # This is mainly for nightly builds which have the suffix ".dev$DATE". See
# https://semver.org/#is-v123-a-semantic-version for the semantics. # https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = "" _SUFFIX = ""