mirror of
https://github.com/lawrencehook/remove-youtube-suggestions.git
synced 2026-07-25 06:54:31 +00:00
2fe77faf0f
Squashed commit of the following: commit53a18e7987Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Mar 1 16:56:50 2026 -0500 Hide donate link for premium users instead of showing dead label Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commite2732dee6fAuthor: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Mar 1 16:50:33 2026 -0500 Fix fast-xml-parser vulnerability via npm override and update @aws-sdk/client-ses Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commit281c0f1103Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Mar 1 16:46:31 2026 -0500 Add "Active" sidebar tab and soften selected sidebar styling Adds "all" and "active" tabs at the top of the sidebar. "Active" shows all currently-enabled options in one place; "all" explicitly resets to the default view. Also lightens the sidebar selected state from solid black to a subtle tint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commit56b119ed98Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 22 05:01:00 2026 -0500 Cache grandfathered emails in memory at startup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commitafed16a38aAuthor: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 22 04:47:51 2026 -0500 Add tests for cache TTL and webhook ordering race condition Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commit361a8caf84Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 22 04:34:00 2026 -0500 Harden license cache: 10s TTL and skip incomplete subscription.created Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commitd857ae8c26Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sat Feb 21 18:24:33 2026 -0500 Update README: replace donations blurb with premium link Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commitc473314ca5Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat Feb 21 18:22:39 2026 -0500 Bump fast-xml-parser and @aws-sdk/xml-builder in /server (#201) Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) and [@aws-sdk/xml-builder](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/packages-internal/xml-builder). These dependencies needed to be updated together. Updates `fast-xml-parser` from 5.3.4 to 5.3.6 - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.3.4...v5.3.6) Updates `@aws-sdk/xml-builder` from 3.972.4 to 3.972.5 - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/packages-internal/xml-builder/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/HEAD/packages-internal/xml-builder) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.3.6 dependency-type: indirect - dependency-name: "@aws-sdk/xml-builder" dependency-version: 3.972.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit49e1a5d9baAuthor: Lawrence Hook <lawrencehook@gmail.com> Date: Sat Feb 21 17:30:29 2026 -0500 Fix license cache not updating after checkout The checkout.session.completed webhook only sent a welcome email but did not update the subscription cache, so users kept getting cached free status after paying. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commitc5734518c4Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 15 19:10:05 2026 -0500 Remove TESTING.md and DEPLOYMENT.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commit6ed3ad0291Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 15 19:08:03 2026 -0500 Remove obsolete docs and update TODO for YouTube DOM change Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commit83693504e3Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 15 18:54:29 2026 -0500 update versions commit27a6ae6f18Merge:3f4b42bd6e642bAuthor: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 15 18:53:37 2026 -0500 Merge branch 'released' commit3f4b42b2deAuthor: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 15 18:49:28 2026 -0500 Update qs to 6.14.2 to fix low-severity DoS vulnerability Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commit8825666512Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 15 18:45:37 2026 -0500 Merge the monetization feature branch. Add RYS Premium subscription system Introduce optional paid tier with sign-in, Stripe billing, and premium feature gating. Core features remain free. Includes Node.js server for auth, payments, and license management. Extension changes: - Sign-in flow with magic link email - Premium/upgrade/account modals with branded UI - Premium feature gating (60+ advanced settings) - Password lock and scheduling (premium) - Fix "hide all but first row" for YouTube's new flat homepage DOM - Hide sidebar ad panels by default - Enable "Hide all Shorts" by default Server: - Magic link auth with rate limiting - Stripe checkout, webhooks, and billing portal - JWT-based license tokens - AWS SES transactional emails (welcome, sign-in, cancellation) - Grandfathered donor support Also adds CI workflow, server test suite, and extension unit tests. commita76f69804bAuthor: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 8 20:45:35 2026 -0500 update description in README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commitb5d1384ca8Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 8 20:44:26 2026 -0500 update "Why I made it" section in README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> commit18b64708b6Author: Lawrence Hook <lawrencehook@gmail.com> Date: Sun Feb 8 20:14:23 2026 -0500 update version to 4.3.71
134 lines
4.4 KiB
JavaScript
134 lines
4.4 KiB
JavaScript
const { describe, it, before, after, beforeEach } = require('node:test');
|
|
const assert = require('node:assert');
|
|
const request = require('supertest');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// Setup must be required first
|
|
const { cleanTestData, testDataDir } = require('./setup');
|
|
|
|
// Mock the email service
|
|
const emailService = require('../src/services/email');
|
|
emailService.sendMagicLinkEmail = async () => ({ MessageId: 'test' });
|
|
|
|
// Mock Stripe service
|
|
const stripeService = require('../src/services/stripe');
|
|
let mockPremiumStatus = { premium: false, expiresAt: null };
|
|
stripeService.checkPremiumStatus = async () => mockPremiumStatus;
|
|
|
|
const { app } = require('../src/index');
|
|
const storage = require('../src/storage');
|
|
const config = require('../src/config');
|
|
const { generateSessionToken } = require('../src/services/jwt');
|
|
const jwt = require('jsonwebtoken');
|
|
|
|
// Helper to decode license token from response
|
|
function decodeLicenseToken(response) {
|
|
const token = response.body.license_token;
|
|
if (!token) return null;
|
|
return jwt.verify(token, config.JWT_SECRET);
|
|
}
|
|
|
|
describe('License Routes', () => {
|
|
beforeEach(() => {
|
|
cleanTestData();
|
|
storage.ensureDirectories();
|
|
mockPremiumStatus = { premium: false, expiresAt: null };
|
|
});
|
|
|
|
after(() => {
|
|
cleanTestData();
|
|
});
|
|
|
|
describe('GET /license/check', () => {
|
|
it('should require authentication', async () => {
|
|
const res = await request(app).get('/license/check');
|
|
|
|
assert.strictEqual(res.status, 401);
|
|
});
|
|
|
|
it('should reject invalid token', async () => {
|
|
const res = await request(app)
|
|
.get('/license/check')
|
|
.set('Authorization', 'Bearer invalid-token');
|
|
|
|
assert.strictEqual(res.status, 401);
|
|
});
|
|
|
|
it('should return license token with non-premium for user without subscription', async () => {
|
|
const token = generateSessionToken('free@example.com');
|
|
|
|
const res = await request(app)
|
|
.get('/license/check')
|
|
.set('Authorization', `Bearer ${token}`);
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
assert.ok(res.body.license_token);
|
|
|
|
const decoded = decodeLicenseToken(res);
|
|
assert.strictEqual(decoded.premium, false);
|
|
assert.strictEqual(decoded.grandfathered, false);
|
|
assert.strictEqual(decoded.email, 'free@example.com');
|
|
});
|
|
|
|
it('should return license token with premium for user with active subscription', async () => {
|
|
mockPremiumStatus = {
|
|
premium: true,
|
|
expiresAt: '2025-12-31T00:00:00Z',
|
|
};
|
|
|
|
const token = generateSessionToken('premium@example.com');
|
|
|
|
const res = await request(app)
|
|
.get('/license/check')
|
|
.set('Authorization', `Bearer ${token}`);
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
assert.ok(res.body.license_token);
|
|
|
|
const decoded = decodeLicenseToken(res);
|
|
assert.strictEqual(decoded.premium, true);
|
|
assert.strictEqual(decoded.grandfathered, false);
|
|
assert.strictEqual(decoded.email, 'premium@example.com');
|
|
});
|
|
|
|
it('should return license token with premium and grandfathered for grandfathered user', async () => {
|
|
// Set up grandfathered file
|
|
const grandfatheredFile = path.join(testDataDir, config.GRANDFATHERED_FILE);
|
|
fs.writeFileSync(grandfatheredFile, 'donor@example.com\n');
|
|
storage.loadGrandfatheredEmails();
|
|
|
|
const token = generateSessionToken('donor@example.com');
|
|
|
|
const res = await request(app)
|
|
.get('/license/check')
|
|
.set('Authorization', `Bearer ${token}`);
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
assert.ok(res.body.license_token);
|
|
|
|
const decoded = decodeLicenseToken(res);
|
|
assert.strictEqual(decoded.premium, true);
|
|
assert.strictEqual(decoded.grandfathered, true);
|
|
assert.strictEqual(decoded.email, 'donor@example.com');
|
|
});
|
|
|
|
it('should handle grandfathered check case-insensitively', async () => {
|
|
const grandfatheredFile = path.join(testDataDir, config.GRANDFATHERED_FILE);
|
|
fs.writeFileSync(grandfatheredFile, 'Donor@Example.com\n');
|
|
storage.loadGrandfatheredEmails();
|
|
|
|
// Token with lowercase email
|
|
const token = generateSessionToken('donor@example.com');
|
|
|
|
const res = await request(app)
|
|
.get('/license/check')
|
|
.set('Authorization', `Bearer ${token}`);
|
|
|
|
const decoded = decodeLicenseToken(res);
|
|
assert.strictEqual(decoded.premium, true);
|
|
assert.strictEqual(decoded.grandfathered, true);
|
|
});
|
|
});
|
|
});
|