Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
dist/
publishers/
.codex
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ This repo contains the first working RefHub browser extension prototype describe
- shows a popup preview with page type, DOI, source, and normalized item fields
- lets the user configure a RefHub API key
- lists writable vaults from RefHub and saves a single item with `POST /api/v1/vaults/:vaultId/items`
- detects whether the RefHub account behind the configured API key has linked Google Drive storage
- when Drive storage is linked and a `pdf_url` is available, asks the backend to copy the PDF into the managed Drive folder during save
- opens the matching RefHub route after save: `/public/:slug` for public vaults, `/vault/:id` for private or shared vaults
- reports clear setup, extraction, auth, and save errors

Expand Down Expand Up @@ -106,6 +108,7 @@ Important setup details:

- Release builds already bundle the production RefHub API and app URLs.
- Current frontend key-creation path is `/profile-edit` → `api_keys`.
- Current Google Drive link path is `/profile-edit` → `storage`.
- The extension only surfaces writable vaults (`owner` or `editor` access).

Required API-key scopes:
Expand Down
12 changes: 12 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "refhub-browser-extension-prototype",
"version": "1.0.0",
"version": "2.0.0",
"private": true,
"description": "refhub browser extension prototype",
"scripts": {
"build": "node scripts/build.mjs",
"build:dev": "REFHUB_ALLOW_CUSTOM_URLS=1 node scripts/build.mjs",
"build:local": "REFHUB_API_BASE_URL=http://localhost:8888 REFHUB_ALLOW_CUSTOM_URLS=1 node scripts/build.mjs",
"clean": "node scripts/build.mjs --clean"
}
}
Binary file added refhub-chrome-2.0.0.zip
Binary file not shown.
Binary file removed refhub-chrome.zip
Binary file not shown.
Binary file added refhub-firefox-2.0.0.zip
Binary file not shown.
Binary file removed refhub-firefox.zip
Binary file not shown.
20 changes: 10 additions & 10 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(__dirname, "..");
const srcDir = path.join(rootDir, "src");
const distDir = path.join(rootDir, "dist");

// Read version from package.json
const packageJson = JSON.parse(await readFile(path.join(rootDir, "package.json"), "utf8"));
const version = packageJson.version;
const PRODUCTION_API_BASE_URL = "https://refhub-api.netlify.app";
const PRODUCTION_APP_BASE_URL = "https://refhub.io";
const buildDefaults = {
Expand Down Expand Up @@ -72,11 +76,11 @@ async function writeManifest(targetDir, manifest) {
function createBaseManifest() {
return {
manifest_version: 3,
name: "refhub ext",
version: "0.1.0",
name: "refhub",
version: version,
description: "capture and save to your refhub vault.",
action: {
default_title: "refhub Capture",
default_title: "refhub",
default_popup: "popup.html",
default_icon: {
16: "icons/refhub-16.png",
Expand All @@ -96,7 +100,7 @@ function createBaseManifest() {
type: "module",
},
options_page: "options.html",
permissions: ["activeTab", "storage", "scripting"],
permissions: ["activeTab", "storage", "scripting", "cookies"],
host_permissions: buildHostPermissions(),
web_accessible_resources: [
{
Expand All @@ -120,7 +124,7 @@ function createFirefoxManifest() {
},
browser_specific_settings: {
gecko: {
id: "refhub-capture-prototype@refhub.io",
id: "refhub@refhub.io",
strict_min_version: "140.0",
data_collection_permissions: {
required: ["none"],
Expand All @@ -139,9 +143,5 @@ function createFirefoxManifest() {
}

function buildHostPermissions() {
if (buildDefaults.allowCustomUrls) {
return ["https://*/*", "http://localhost/*", "http://127.0.0.1/*"];
}

return [`${buildDefaults.apiBaseUrl}/*`];
return ["https://*/*", "http://*/*"];
}
67 changes: 67 additions & 0 deletions scripts/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
DIST_DIR="$ROOT_DIR/dist"

# Read version from package.json
VERSION=$(node -p "require('$ROOT_DIR/package.json').version" 2>/dev/null || echo "0.0.0")

# --local → point at http://localhost:8888 (dev backend)
LOCAL=0
for arg in "$@"; do [[ "$arg" == "--local" ]] && LOCAL=1; done

if [[ $LOCAL -eq 1 ]]; then
export REFHUB_API_BASE_URL="http://localhost:8888"
export REFHUB_ALLOW_CUSTOM_URLS="1"
ZIP_SUFFIX="-local"
else
ZIP_SUFFIX=""
fi

CHROME_ZIP="$ROOT_DIR/refhub-chrome-$VERSION${ZIP_SUFFIX}.zip"
FIREFOX_ZIP="$ROOT_DIR/refhub-firefox-$VERSION${ZIP_SUFFIX}.zip"

# ── helpers ──────────────────────────────────────────────────────────────────

info() { printf '\033[1;34m==> \033[0m%s\n' "$*"; }
success() { printf '\033[1;32m✓ \033[0m%s\n' "$*"; }
die() { printf '\033[1;31mERROR: \033[0m%s\n' "$*" >&2; exit 1; }

command -v node >/dev/null 2>&1 || die "node is required but not found"
command -v zip >/dev/null 2>&1 || die "zip is required but not found"

make_zip() {
local archive="$1" src_dir="$2"
(cd "$src_dir" && zip -r --quiet "$archive" .)
}

# ── build ─────────────────────────────────────────────────────────────────────

API_TARGET="${REFHUB_API_BASE_URL:-https://refhub-api.netlify.app}"
info "Building extension (v$VERSION) → $API_TARGET"
cd "$ROOT_DIR"
node scripts/build.mjs

[[ -d "$DIST_DIR/chrome" ]] || die "Chrome dist missing: $DIST_DIR/chrome"
[[ -d "$DIST_DIR/firefox" ]] || die "Firefox dist missing: $DIST_DIR/firefox"

# ── zip chrome ────────────────────────────────────────────────────────────────

info "Packaging Chrome → $(basename "$CHROME_ZIP")"
rm -f "$CHROME_ZIP"
make_zip "$CHROME_ZIP" "$DIST_DIR/chrome"
success "$(basename "$CHROME_ZIP") ($(du -sh "$CHROME_ZIP" | cut -f1))"

# ── zip firefox ───────────────────────────────────────────────────────────────

info "Packaging Firefox → $(basename "$FIREFOX_ZIP")"
rm -f "$FIREFOX_ZIP"
make_zip "$FIREFOX_ZIP" "$DIST_DIR/firefox"
success "$(basename "$FIREFOX_ZIP") ($(du -sh "$FIREFOX_ZIP" | cut -f1))"

# ── done ──────────────────────────────────────────────────────────────────────

printf '\n\033[1mDone.\033[0m Packages written to:\n'
printf ' %s\n' "$CHROME_ZIP"
printf ' %s\n' "$FIREFOX_ZIP"
Loading