Skip to content

Commit

Permalink
1.0.2 improvements to logic handling of personal access tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
TfT Hacker committed Aug 31, 2024
1 parent 60c83d0 commit cccbb21
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 30 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.0.2

### Fix

- Improved the update logic to better handle when a personal access token has failed.
- chore: update all dependencies.

# 1.0.1

### New
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Learn more about BRAT in the DOCUMENTATION found at: https://tfthacker.com/BRAT

You might also be interested in a few products I have made for Obsidian:

- [Canvas Candy](https://tfthacker.com/canvas-candy) - The Canvas Candy Vault is a set of tools specially designed for use with the canvas feature of Obsidian. With over 40+ decorations, you can add new dimensions to the cards on your canvas.
- [JournalCraft](https://tfthacker.com/jco) - A curated collection of 10 powerful journaling templates designed to enhance your journaling experience. Whether new to journaling or looking to step up your game, JournalCraft has something for you.
- [Cornell Notes Learning Vault](https://tfthacker.com/cornell-notes) - This vault teaches you how to use the Cornell Note-Taking System in your Obsidian vault. It includes learning material, samples, and Obsidian configuration files to enable Cornell Notes in your vault.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian42-brat",
"name": "BRAT",
"version": "1.0.1",
"version": "1.0.2",
"minAppVersion": "1.4.16",
"description": "Easily install a beta version of a plugin for testing.",
"author": "TfTHacker",
Expand Down
52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "obsidian42-brat",
"version": "1.0.1",
"version": "1.0.2",
"description": "Obsidian42 - Beta Reviewer's Autoupdate Tool.",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "node esbuild.config.mjs production",
"build": "node esbuild.config.mjs production ",
"version": "node version-bump.mjs",
"githubaction": "node version-github-action.mjs",
"lint:check": "eslint --ext .ts,.tsx .",
Expand All @@ -20,40 +20,40 @@
"url": "git://github.com/TfTHacker/obsidian42-brat.git"
},
"devDependencies": {
"typescript": "5.4.3",
"tslib": "^2.6.2",
"@types/node": "^20.12.4",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"@typescript-eslint/utils": "^7.5.0",
"builtin-modules": "3.3.0",
"esbuild": "0.20.2",
"typescript": "5.5.4",
"tslib": "^2.7.0",
"@types/node": "^22.5.1",
"@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.3.0",
"@typescript-eslint/utils": "^8.3.0",
"builtin-modules": "4.0.0",
"esbuild": "0.23.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-css": "^0.9.2",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-css": "^0.10.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsonc": "^2.15.0",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-mdx": "^3.1.5",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-tsdoc": "^0.3.0",
"eslint-plugin-yml": "^1.14.0",
"@html-eslint/eslint-plugin": "^0.24.0",
"@html-eslint/parser": "^0.24.0",
"husky": "^9.0.11",
"jsdom": "^24.0.0",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"remark-preset-lint-consistent": "^5.1.2",
"remark-preset-lint-markdown-style-guide": "^5.1.3",
"remark-preset-lint-recommended": "^6.1.3",
"@html-eslint/eslint-plugin": "^0.26.0",
"@html-eslint/parser": "^0.26.0",
"husky": "^9.1.5",
"jsdom": "^25.0.0",
"lint-staged": "^15.2.9",
"prettier": "^3.3.3",
"remark-preset-lint-consistent": "^6.0.0",
"remark-preset-lint-markdown-style-guide": "^6.0.0",
"remark-preset-lint-recommended": "^7.0.0",
"remark-preset-prettier": "^2.0.1",
"ts-node": "^10.9.2",
"typedoc": "^0.25.12",
"typedoc": "^0.26.6",
"@types/obsidian-typings": "github:Fevol/obsidian-typings",
"obsidian": "1.5.7"
"obsidian": "1.6.6"
},
"dependencies": {
"obsidian-daily-notes-interface": "^0.9.4"
Expand Down
29 changes: 28 additions & 1 deletion src/features/githubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,38 @@ export const grabManifestJsonFromRepository = async (
(rootManifest ? '/HEAD/manifest.json' : '/HEAD/manifest-beta.json');
if (debugLogging)
console.log('grabManifestJsonFromRepository manifestJsonPath', manifestJsonPath);

// Function to check if the token is valid
const isTokenValid = async (token: string): Promise<boolean> => {
try {
await request({
url: 'https://api.github.com/user',
method: 'GET',
headers: {
'Authorization': `token ${token}`,
'User-Agent': 'request',
'accept': 'application/vnd.github.v3+json',
},
});
return true;
} catch (error) {
if (debugLogging) console.log('Token validation error:', error);
return false;
}
};

// Check if the token is valid
let tokenValid = false;
if (personalAccessToken) {
tokenValid = await isTokenValid(personalAccessToken);
if (debugLogging) console.log('Token valid:', tokenValid);
}

try {
const response: string = await request({
url: manifestJsonPath,
headers:
personalAccessToken ?
tokenValid ?
{
Authorization: `Token ${personalAccessToken}`,
}
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"0.6.37": "1.1.16",
"0.8.0": "1.4.16",
"1.0.0": "1.4.16",
"1.0.1": "1.4.16"
"1.0.1": "1.4.16",
"1.0.2": "1.4.16"
}

0 comments on commit cccbb21

Please sign in to comment.