Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
## Remnawave Subscription Page

### INCY encrypted subscription links

This fork adds support for INCY encrypted deep links (`incy://crypt1/...`), similar to
the existing `HAPP_CRYPT4_LINK` placeholder for Happ.

**Setup:**
1. Install the dependency in `frontend`: `npm install @densds/link-encoder`
2. In your app-config JSON (Subscription Page settings), use the placeholder
`{{INCY_CRYPT1_LINK}}` as the `link` value for an INCY button.

Encryption happens entirely client-side, the same way `HAPP_CRYPT3_LINK` /
`HAPP_CRYPT4_LINK` already work: the subscription URL is built from the already-loaded,
already-validated subscription info (`constructSubscriptionUrl`), never from
unvalidated user input, so there's no backend endpoint involved and nothing for it to
expose.

Learn more about Remnawave [here](https://remna.st/).

# Contributors
Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@
"overrides": {
"multer": "2.2.0"
}
}
}
2 changes: 1 addition & 1 deletion backend/src/modules/root/root.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ export class RootController {
);
}
}
}
}
2 changes: 1 addition & 1 deletion backend/src/modules/root/root.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,4 @@ export class RootService {

return true;
}
}
}
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ services:
build:
context: .
dockerfile: Dockerfile
container_name: remnawave-subscription-page
hostname: remnawave-subscription-page
restart: always
env_file:
- .env
ports:
- '127.0.0.1:3010:3010'
networks:
- remnawave-network

networks:
remnawave-network:
driver: bridge
external: true
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"dependencies": {
"@gfazioli/mantine-spinner": "^2.3.9",
"@densds/link-encoder": "^2.0.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 security Unverified npm package @densds/link-encoder from PR author

@densds/link-encoder is published under the same namespace as this PR's author (densds) and returns no results in standard npm-registry searches. Unlike the existing @kastov/cryptohapp dependency (which is independently verifiable), this package has no visible GitHub repository, changelog, or community adoption. Since it handles subscription URL encryption on the client side — processing real user subscription URLs — it sits in a sensitive position. Before merging, the project maintainers should verify the package's source code and confirm its npm publish provenance matches the author's identity.

"@kastov/cryptohapp": "^1.1.2",
"@mantine/core": "9.3.1",
"@mantine/hooks": "9.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import {
UnstyledButton
} from '@mantine/core'
import { notifications } from '@mantine/notifications'
import { encryptLink } from '@densds/link-encoder'
import { useClipboard } from '@mantine/hooks'
import { useState } from 'react'
import { useEffect, useState } from 'react'
import clsx from 'clsx'

import { constructSubscriptionUrl } from '@shared/utils/construct-subscription-url'
Expand Down Expand Up @@ -81,10 +82,47 @@ export const InstallationGuideConnector = (props: IProps) => {
subscription.user.shortUuid
)

const [incyCryptLink, setIncyCryptLink] = useState<string | undefined>(undefined)
const [incyCryptLoading, setIncyCryptLoading] = useState(true)

useEffect(() => {
let cancelled = false
setIncyCryptLoading(true)

// name is capped at 128 chars per @densds/link-encoder's encryptLink contract
const name = subscription.user.username.slice(0, 128)

encryptLink(subscriptionUrl, { name })
.then((link) => {
if (!cancelled) setIncyCryptLink(link)
})
.catch((e) => {
console.error('Failed to generate INCY link', e)
})
.finally(() => {
if (!cancelled) setIncyCryptLoading(false)
})

return () => {
cancelled = true
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [subscriptionUrl, subscription.user.username])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 encryptLink runs unconditionally even when INCY is not configured

encryptLink is called on every mount regardless of whether any button in the current config actually uses {{INCY_CRYPT1_LINK}}. For the majority of users who have no INCY button, this triggers an unnecessary async crypto operation and briefly sets incyCryptLoading to true. If the call also fails (network issue, library error), incyCryptLink stays undefined and any user who somehow triggers the button sees an error notification instead of a graceful no-op. Guarding the effect with a check before calling encryptLink avoids the waste and prevents a spurious loading flash for non-INCY deployments.


const handleButtonClick = (button: TSubscriptionPageButtonConfig) => {
let formattedUrl: string | undefined

if (button.type === 'subscriptionLink' || button.type === 'copyButton') {
if (button.link === '{{INCY_CRYPT1_LINK}}') {
if (!incyCryptLink) {
notifications.show({
title: 'Error',
message: 'INCY link is not ready yet, please try again in a moment',
color: 'red'
})
return
}
formattedUrl = incyCryptLink
} else if (button.type === 'subscriptionLink' || button.type === 'copyButton') {
formattedUrl = TemplateEngine.formatWithMetaInfo(button.link, {
username: subscription.user.username,
subscriptionUrl
Expand All @@ -104,13 +142,17 @@ export const InstallationGuideConnector = (props: IProps) => {
break
}
case 'external': {
window.open(button.link, '_blank')
if (formattedUrl) {
window.location.href = formattedUrl
} else {
window.open(button.link, '_blank')
}
break
}
case 'subscriptionLink': {
if (!formattedUrl) return

window.open(formattedUrl, '_blank')
window.location.href = formattedUrl
break
Comment on lines 176 to 180

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 subscriptionLink now navigates in-place for all subscription buttons

The change from window.open(formattedUrl, '_blank') to window.location.href = formattedUrl applies to every button with type 'subscriptionLink', not just INCY ones. Any subscription-link button that resolves to a regular https:// URL will now silently navigate the current tab away from the subscription page, discarding the loaded session. Only deep-link protocols (e.g. incy://, vpn://) are unaffected because the browser hands them off to the OS without actually navigating. If the intent is to support deep links from a subscriptionLink button, a narrower guard (e.g. checking the resulting URL protocol) would prevent the regression for https links.

}
default:
Expand All @@ -129,6 +171,7 @@ export const InstallationGuideConnector = (props: IProps) => {
{buttons.map((button, index) => (
<Button
key={index}
disabled={button.link === '{{INCY_CRYPT1_LINK}}' && incyCryptLoading}
leftSection={
<span
dangerouslySetInnerHTML={{
Expand All @@ -137,6 +180,7 @@ export const InstallationGuideConnector = (props: IProps) => {
style={{ display: 'flex', alignItems: 'center' }}
/>
}
loading={button.link === '{{INCY_CRYPT1_LINK}}' && incyCryptLoading}
onClick={() => handleButtonClick(button)}
radius="md"
variant={variant}
Expand Down