Skip to content

Commit

Permalink
pin axios-jwt, see jetbridge/axios-jwt#57
Browse files Browse the repository at this point in the history
  • Loading branch information
molly committed Jan 31, 2024
1 parent 214c638 commit 7261494
Show file tree
Hide file tree
Showing 27 changed files with 141 additions and 224 deletions.
15 changes: 9 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ module.exports = {
env: {
commonjs: true,
es6: true,
webextensions: true,
webextensions: true
},
extends: ["eslint:recommended", "prettier", "react-app"],
plugins: ["prettier"],
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
SharedArrayBuffer: "readonly"
},
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2018
},
rules: {
"prettier/prettier": ["error", { tabWidth: 2, useTabs: false }],
"require-await": ["error"],
"prettier/prettier": [
"error",
{ tabWidth: 2, useTabs: false, trailingComma: "none" }
],
"require-await": ["error"]
},
ignorePatterns: ["build/"],
ignorePatterns: ["build/"]
};
5 changes: 3 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"tabWidth": 2,
"useTabs": false
}
"useTabs": false,
"trailingComma": "none"
}
97 changes: 10 additions & 87 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"@mui/lab": "^5.0.0-alpha.163",
"@mui/material": "^5.15.7",
"axios": "^1.6.7",
"axios-cache-interceptor": "^1.5.1",
"axios-jwt": "^4.0.0",
"axios-jwt": "^3.0.0",
"luxon": "^3.4.4",
"mongodb": "^6.3.0",
"prop-types": "^15.8.1",
Expand Down
28 changes: 14 additions & 14 deletions public/scrape.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
name = node.name[0];
}
return normalizeString(name, {
titlecase: !hasLowercaseCharacters(name),
titlecase: !hasLowercaseCharacters(name)
});
}
return null;
Expand All @@ -67,7 +67,7 @@
// Title
if (schema.headline) {
results.title = normalizeString(schema.headline, {
titlecase: !hasLowercaseCharacters(schema.headline),
titlecase: !hasLowercaseCharacters(schema.headline)
});
}

Expand All @@ -86,11 +86,11 @@
// Work
if (schema.publisher?.name) {
results.work = normalizeString(schema.publisher.name, {
titlecase: !hasLowercaseCharacters(schema.publisher.name),
titlecase: !hasLowercaseCharacters(schema.publisher.name)
});
} else if (schema.isPartOf?.name) {
results.work = normalizeString(schema.isPartOf.name, {
titlecase: !hasLowercaseCharacters(schema.isPartOf.name),
titlecase: !hasLowercaseCharacters(schema.isPartOf.name)
});
}

Expand Down Expand Up @@ -118,7 +118,7 @@
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null,
null
).singleNodeValue;

let schema = JSON.parse(schemaNode.innerHTML);
Expand All @@ -136,7 +136,7 @@
"report",
"scholarlyarticle",
"blog",
"webpage",
"webpage"
]) {
const result = schema.find((s) => {
return s["@type"].toLowerCase() === type;
Expand All @@ -163,15 +163,15 @@
if (!("title" in results)) {
let title;
const titleTag = document.querySelector(
'meta[property="og:title"], meta[property="twitter:title"], meta[name="twitter:title"]',
'meta[property="og:title"], meta[property="twitter:title"], meta[name="twitter:title"]'
);
if (titleTag) {
title = titleTag.getAttribute("content");
} else {
title = document.title;
}
results.title = normalizeString(title, {
titlecase: !hasLowercaseCharacters(title),
titlecase: !hasLowercaseCharacters(title)
});
}

Expand All @@ -187,25 +187,25 @@
}
}
results.author = normalizeString(author, {
titlecase: !hasLowercaseCharacters(author),
titlecase: !hasLowercaseCharacters(author)
});
}

if (!("work" in results)) {
const publisherTag = document.querySelector(
'meta[property="og:site_name"]',
'meta[property="og:site_name"]'
);
if (publisherTag) {
const publisher = publisherTag.getAttribute("content");
results.work = normalizeString(publisher, {
titlecase: !hasLowercaseCharacters(publisher),
titlecase: !hasLowercaseCharacters(publisher)
});
}
}

if (!("date" in results)) {
let dateTag = document.querySelector(
'meta[name="article.updated"], meta[itemProp="dateModified"], meta[name="article.published"], meta[itemProp="datePublished"], meta[itemProp="dateLastPubbed"]',
'meta[name="article.updated"], meta[itemProp="dateModified"], meta[name="article.published"], meta[itemProp="datePublished"], meta[itemProp="dateLastPubbed"]'
);
if (dateTag) {
results.date = getDateFromIsoString(dateTag.getAttribute("content"));
Expand All @@ -219,7 +219,7 @@

if (!("summary" in results)) {
const summaryTag = document.querySelector(
'meta[name="article.summary"], meta[property="og:description"], meta[name="twitter:description"]',
'meta[name="article.summary"], meta[property="og:description"], meta[name="twitter:description"]'
);
if (summaryTag) {
results.summary = normalizeString(summaryTag.getAttribute("content"));
Expand All @@ -232,7 +232,7 @@
) {
const languageNames = new Intl.DisplayNames(["en"], { type: "language" });
results.parenthetical = `in ${languageNames.of(
document.documentElement.lang.toUpperCase(),
document.documentElement.lang.toUpperCase()
)}`;
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const signin = async (username, password) => {
const response = await client.post(`/auth/signin`, { username, password });
setAuthTokens({
accessToken: response.data.accessToken,
refreshToken: response.data.refreshToken,
refreshToken: response.data.refreshToken
});
return { user: response.data.username, error: false };
} catch (err) {
Expand Down
15 changes: 3 additions & 12 deletions src/api/client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { applyAuthTokenInterceptor } from "axios-jwt";
import { setupCache, buildMemoryStorage } from "axios-cache-interceptor";
import axios from "axios";

const API_URL =
Expand All @@ -10,21 +9,13 @@ const API_URL =
const authInterceptorConfig = {
requestRefresh: async (refreshToken) => {
const response = await axios.post(`${API_URL}/auth/refresh`, {
refreshToken,
refreshToken
});
return response.data.accessToken;
},
}
};

const cacheInterceptorConfig = {
storage: buildMemoryStorage(),
etag: true,
interpretHeader: true,
};

export const axiosInstance = setupCache(
axios.create({ baseURL: API_URL }, cacheInterceptorConfig),
);
export const axiosInstance = axios.create({ baseURL: API_URL });

applyAuthTokenInterceptor(axiosInstance, authInterceptorConfig);

Expand Down
4 changes: 2 additions & 2 deletions src/api/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const addEntry = async (type, entry) => {
return {
error: {
message: err.response?.data?.message,
status: err.response?.status,
},
status: err.response?.status
}
};
}
};
Loading

0 comments on commit 7261494

Please sign in to comment.