Accept 16-character subscription secrets for gateway presence
This commit is contained in:
@@ -27,7 +27,7 @@ function subscriptionSecret(subscriptionUrl) {
|
|||||||
pathSegments.at(-1),
|
pathSegments.at(-1),
|
||||||
]
|
]
|
||||||
.map((value) => String(value || '').trim())
|
.map((value) => String(value || '').trim())
|
||||||
.filter((value) => value.length >= 24);
|
.filter((value) => value.length >= 16);
|
||||||
if (!candidates.length) return '';
|
if (!candidates.length) return '';
|
||||||
|
|
||||||
url.hash = '';
|
url.hash = '';
|
||||||
|
|||||||
@@ -52,6 +52,13 @@ test('Gateway presence is authenticated by the shared subscription secret', asyn
|
|||||||
nonce,
|
nonce,
|
||||||
}).available, false);
|
}).available, false);
|
||||||
|
|
||||||
|
assert.equal(buildGatewayPresence({
|
||||||
|
appMode: 'gateway',
|
||||||
|
subscriptionUrl: 'https://subscription.example/0123456789abcdef',
|
||||||
|
gatewayId: 'gateway-1',
|
||||||
|
nonce,
|
||||||
|
}).available, true);
|
||||||
|
|
||||||
const sharedPublicValue = 'https://public.example/sing-box-configuration-v1';
|
const sharedPublicValue = 'https://public.example/sing-box-configuration-v1';
|
||||||
const firstUrl = `${subscriptionUrl}?redirect=${encodeURIComponent(sharedPublicValue)}`;
|
const firstUrl = `${subscriptionUrl}?redirect=${encodeURIComponent(sharedPublicValue)}`;
|
||||||
const secondUrl = `https://subscription.example/fedcba9876543210fedcba9876543210?redirect=${encodeURIComponent(sharedPublicValue)}`;
|
const secondUrl = `https://subscription.example/fedcba9876543210fedcba9876543210?redirect=${encodeURIComponent(sharedPublicValue)}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user