mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Settings -> Account gets "Connect a device", a paired-devices list, and a remote access headers editor, so the mobile app and other browsers can sign in without typing a password and pass a reverse proxy such as Cloudflare Access. - one-time pairing codes (3 min TTL) minted by a Better Auth plugin and redeemed into a new session that records the device name - POST /api/device-pairing/links builds the ocm://link app link with the stored headers as h= parameters and a browser /pair link; plain-HTTP and loopback origins are blocked or warned about - remote access headers are stored encrypted, returned by name only, and validated (8 headers, 512-char values, 1800 encoded characters, reserved transport names blocked); a Cloudflare Access service token preset fills CF-Access-Client-Id and CF-Access-Client-Secret - login offers "Sign in with QR code" and /pair redeems a scanned code, returning to the login redirect target - revoking a device deletes its session, closes its live connections and removes its push subscriptions; the current session cannot be revoked
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { isLoopbackHost, isPrivateNetworkHost } from '@opencode-manager/shared/utils'
|
|
|
|
describe('isLoopbackHost', () => {
|
|
it.each(['localhost', 'LOCALHOST', '127.0.0.1', '127.4.5.6', '::1', '[::1]'])(
|
|
'treats %s as loopback',
|
|
(host) => {
|
|
expect(isLoopbackHost(host)).toBe(true)
|
|
},
|
|
)
|
|
|
|
it.each(['192.168.1.2', 'example.com', '100.64.0.1', '10.0.0.1'])(
|
|
'treats %s as not loopback',
|
|
(host) => {
|
|
expect(isLoopbackHost(host)).toBe(false)
|
|
},
|
|
)
|
|
})
|
|
|
|
describe('isPrivateNetworkHost', () => {
|
|
it.each([
|
|
'10.0.0.1',
|
|
'172.16.0.1',
|
|
'172.31.255.255',
|
|
'192.168.1.20',
|
|
'169.254.10.1',
|
|
'100.64.0.1',
|
|
'100.127.255.255',
|
|
'fd7a:115c:a1e0::1',
|
|
'[fd7a:115c:a1e0::1]',
|
|
'fc00::1',
|
|
])('treats %s as private', (host) => {
|
|
expect(isPrivateNetworkHost(host)).toBe(true)
|
|
})
|
|
|
|
it.each([
|
|
'172.32.0.1',
|
|
'100.128.0.1',
|
|
'8.8.8.8',
|
|
'127.0.0.1',
|
|
'::1',
|
|
'fe80::1',
|
|
'example.ts.net',
|
|
'host.local',
|
|
'256.1.1.1',
|
|
'10.0.0',
|
|
])('treats %s as public', (host) => {
|
|
expect(isPrivateNetworkHost(host)).toBe(false)
|
|
})
|
|
})
|