repoburg 1.3.311 → 1.3.313

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/agent-pane/frontend/dist/assets/{TerminalView-CdL80e84.js → TerminalView-Xaq6tVfx.js} +1 -1
  2. package/agent-pane/frontend/dist/assets/index-B8vQbeJk.js +841 -0
  3. package/agent-pane/frontend/dist/index.html +1 -1
  4. package/daemon/dist/api/auth.js +27 -63
  5. package/daemon/dist/auth/accountServer.js +11 -0
  6. package/daemon/dist/auth/authManager.js +27 -30
  7. package/daemon/dist/auth/deviceLogin.js +122 -0
  8. package/daemon/dist/auth/deviceLogin.spec.js +74 -0
  9. package/daemon/dist/index.js +0 -3
  10. package/daemon/dist/middleware/checkRemoteAuth.js +10 -25
  11. package/daemon/dist/middleware/checkRemoteAuth.spec.js +5 -21
  12. package/daemon/dist/remote/orchestrator.js +29 -2
  13. package/daemon/dist/remote/orchestrator.spec.js +49 -2
  14. package/daemon/dist/remote/provisioner.js +9 -38
  15. package/daemon/dist/remote/provisioner.spec.js +5 -86
  16. package/daemon/dist/remote/routes.js +2 -5
  17. package/daemon/dist/remote/routes.spec.js +1 -8
  18. package/daemon/dist/remote/tunnel-state.spec.js +0 -2
  19. package/package.json +1 -1
  20. package/platform-cli.js +4 -2
  21. package/tabtape/extension/dist/build-info.json +3 -3
  22. package/tabtape/extension/dist/manifest.json +1 -1
  23. package/tabtape/ui/dist/build-info.json +3 -3
  24. package/agent-pane/frontend/dist/assets/index-NpywVkQl.js +0 -841
  25. package/daemon/dist/middleware/corsOrigin.js +0 -53
  26. package/daemon/dist/middleware/corsOrigin.spec.js +0 -46
  27. package/daemon/dist/remote/access-jwt.js +0 -67
  28. package/daemon/dist/remote/access-jwt.spec.js +0 -94
  29. package/daemon/dist/remote/edge-gate-move.js +0 -40
  30. package/daemon/dist/remote/edge-gate-move.spec.js +0 -44
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.corsOrigin = corsOrigin;
4
- exports.setExtraOriginsForTest = setExtraOriginsForTest;
5
- /**
6
- * CORS origin allowlist for the daemon.
7
- *
8
- * Spec: the daemon serves the embedded agent-pane to local tooling
9
- * (vite dev servers, daemon-desktop) and, once a tunnel is provisioned, to
10
- * `*.repoburg.com` machine hostnames. Everything else is rejected — the
11
- * previous `origin: '*'` with `credentials: true` is an open API surface.
12
- *
13
- * Allowed:
14
- * - no Origin header (same-origin / non-browser clients such as curl)
15
- * - http://localhost:<any> and http://127.0.0.1:<any>
16
- * - https://<anything>.repoburg.com (tunnel machine hostnames)
17
- * - extra origins from REPOBURG_ALLOWED_ORIGINS (comma-separated)
18
- */
19
- const REPORG_HOSTNAME_SUFFIX = '.repoburg.com';
20
- const extraOrigins = (process.env.REPOBURG_ALLOWED_ORIGINS ?? '')
21
- .split(',')
22
- .map((value) => value.trim())
23
- .filter(Boolean);
24
- function isLocalOrigin(origin) {
25
- return (origin.protocol === 'http:' &&
26
- (origin.hostname === 'localhost' || origin.hostname === '127.0.0.1'));
27
- }
28
- function isTunnelOrigin(origin) {
29
- return origin.protocol === 'https:' && origin.hostname.endsWith(REPORG_HOSTNAME_SUFFIX);
30
- }
31
- /** CORS origin callback. `false` = do not emit CORS headers for this origin. */
32
- function corsOrigin(origin, callback) {
33
- // Same-origin requests and non-browser clients send no Origin header.
34
- if (origin === undefined) {
35
- callback(null, true);
36
- return;
37
- }
38
- let parsed;
39
- try {
40
- parsed = new URL(origin);
41
- }
42
- catch {
43
- callback(null, false);
44
- return;
45
- }
46
- const allowed = isLocalOrigin(parsed) || isTunnelOrigin(parsed) || extraOrigins.includes(origin);
47
- callback(null, allowed);
48
- }
49
- /** Exposed for tests. */
50
- function setExtraOriginsForTest(origins) {
51
- extraOrigins.length = 0;
52
- extraOrigins.push(...origins);
53
- }
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const corsOrigin_1 = require("./corsOrigin");
4
- function evaluate(origin) {
5
- let result = false;
6
- (0, corsOrigin_1.corsOrigin)(origin, (err, allow) => {
7
- if (err)
8
- throw err;
9
- result = !!allow;
10
- });
11
- return result;
12
- }
13
- describe('corsOrigin', () => {
14
- afterEach(() => (0, corsOrigin_1.setExtraOriginsForTest)([]));
15
- it('allows requests without an Origin header (same-origin / curl)', () => {
16
- expect(evaluate(undefined)).toBe(true);
17
- });
18
- it('allows localhost and 127.0.0.1 on any port', () => {
19
- expect(evaluate('http://localhost:3000')).toBe(true);
20
- expect(evaluate('http://localhost:9998')).toBe(true);
21
- expect(evaluate('http://127.0.0.1:5173')).toBe(true);
22
- });
23
- it('allows tunnel machine hostnames under repoburg.com (https only)', () => {
24
- expect(evaluate('https://workstation.repoburg.com')).toBe(true);
25
- expect(evaluate('https://a-b.repoburg.com')).toBe(true);
26
- });
27
- it('rejects unknown origins', () => {
28
- expect(evaluate('https://evil.example.com')).toBe(false);
29
- expect(evaluate('http://evil.com')).toBe(false);
30
- });
31
- it('rejects repoburg.com hostnames over http (tunnels are https)', () => {
32
- expect(evaluate('http://workstation.repoburg.com')).toBe(false);
33
- });
34
- it('rejects lookalike suffixes', () => {
35
- expect(evaluate('https://workstation.repoburg.com.evil.com')).toBe(false);
36
- expect(evaluate('https://evilrepoburg.com')).toBe(false);
37
- });
38
- it('rejects malformed origins', () => {
39
- expect(evaluate('not a url')).toBe(false);
40
- });
41
- it('allows extra origins configured via env list', () => {
42
- (0, corsOrigin_1.setExtraOriginsForTest)(['https://staging.example.com']);
43
- expect(evaluate('https://staging.example.com')).toBe(true);
44
- expect(evaluate('https://other.example.com')).toBe(false);
45
- });
46
- });
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.teamJwks = teamJwks;
37
- exports.verifyAccessJwt = verifyAccessJwt;
38
- /**
39
- * CF Access JWT verification for requests arriving through the tunnel.
40
- *
41
- * Spec: when the machine has a tunnel AND Cloudflare Access is configured
42
- * (team domain + application AUD stored in remote.json), every /api/* and
43
- * /ws request must carry a valid `Cf-Access-Jwt-Assertion` header signed by
44
- * the team's Cloudflare Zero Trust org. Without Access configured, the
45
- * loopback binding remains the security boundary (tunnel traffic is
46
- * Edge-protected by the user's Access policy once set up).
47
- */
48
- const jose = __importStar(require("jose"));
49
- /** Build (and cache) the JWKS for a team's public Access signing keys. */
50
- function teamJwks(teamDomain) {
51
- const url = new URL(`https://${teamDomain}/cdn-cgi/access/certs`);
52
- return jose.createRemoteJWKSet(url);
53
- }
54
- /** Verify a Cloudflare Access JWT against the team's keys. */
55
- async function verifyAccessJwt(assertion, config, options = {}) {
56
- const jwks = options.jwks ?? teamJwks(config.teamDomain);
57
- const { payload } = await jose.jwtVerify(assertion, jwks, {
58
- issuer: `https://${config.teamDomain}`,
59
- audience: config.aud,
60
- });
61
- // CF Access JWTs carry the identity email in `email`; older docs/flows used
62
- // `common_name`. Accept either so pinning matches real edge-issued tokens.
63
- const identity = payload.common_name ?? payload.email;
64
- if (options.ownerEmail && identity !== options.ownerEmail) {
65
- throw new Error(`Access token email does not match the machine owner (${identity} !== ${options.ownerEmail}).`);
66
- }
67
- }
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const access_jwt_1 = require("./access-jwt");
37
- const jose = __importStar(require("jose"));
38
- /**
39
- * Real-crypto tests: sign actual Access-style JWTs with an injected HMAC key
40
- * and verify the email-pinning logic on top of signature/iss/aud checks.
41
- */
42
- const SECRET = new TextEncoder().encode('test-secret-for-specs-only');
43
- const CONFIG = { teamDomain: 'team.cloudflareaccess.com', aud: 'aud-tag' };
44
- const jwks = (async () => SECRET);
45
- async function makeAssertion(claims) {
46
- return new jose.SignJWT(claims)
47
- .setProtectedHeader({ alg: 'HS256' })
48
- .setIssuer('https://team.cloudflareaccess.com')
49
- .setAudience('aud-tag')
50
- .setExpirationTime('2h')
51
- .sign(SECRET);
52
- }
53
- describe('verifyAccessJwt', () => {
54
- it('accepts a valid token signed by the team', async () => {
55
- const assertion = await makeAssertion({ common_name: 'owner@repoburg.com' });
56
- await expect((0, access_jwt_1.verifyAccessJwt)(assertion, CONFIG, { jwks })).resolves.toBeUndefined();
57
- });
58
- it('accepts any identity when no owner email is pinned (optional check)', async () => {
59
- const assertion = await makeAssertion({ common_name: 'someone-else@evil.com' });
60
- await expect((0, access_jwt_1.verifyAccessJwt)(assertion, CONFIG, { jwks })).resolves.toBeUndefined();
61
- });
62
- it('rejects a wrong-email token when the owner email is pinned', async () => {
63
- const assertion = await makeAssertion({ common_name: 'hacker@evil.com' });
64
- await expect((0, access_jwt_1.verifyAccessJwt)(assertion, CONFIG, { jwks, ownerEmail: 'owner@repoburg.com' })).rejects.toThrow(/does not match the machine owner/);
65
- });
66
- it('accepts the pinned owner email', async () => {
67
- const assertion = await makeAssertion({ common_name: 'owner@repoburg.com' });
68
- await expect((0, access_jwt_1.verifyAccessJwt)(assertion, CONFIG, { jwks, ownerEmail: 'owner@repoburg.com' })).resolves.toBeUndefined();
69
- });
70
- it('matches the pinned owner email via the email claim (real CF Access format)', async () => {
71
- // Live-verified 2026-09: CF Access JWTs carry `email`, NOT `common_name`.
72
- const assertion = await makeAssertion({ email: 'owner@repoburg.com' });
73
- await expect((0, access_jwt_1.verifyAccessJwt)(assertion, CONFIG, { jwks, ownerEmail: 'owner@repoburg.com' })).resolves.toBeUndefined();
74
- });
75
- it('rejects a wrong email claim when the owner email is pinned', async () => {
76
- const assertion = await makeAssertion({ email: 'hacker@evil.com' });
77
- await expect((0, access_jwt_1.verifyAccessJwt)(assertion, CONFIG, { jwks, ownerEmail: 'owner@repoburg.com' })).rejects.toThrow(/does not match the machine owner/);
78
- });
79
- it('rejects a token with neither email nor common_name when pinned', async () => {
80
- const assertion = await makeAssertion({ sub: '99dd1943-5978-589e-9dd0-884f0c79e926' });
81
- await expect((0, access_jwt_1.verifyAccessJwt)(assertion, CONFIG, { jwks, ownerEmail: 'owner@repoburg.com' })).rejects.toThrow(/does not match the machine owner/);
82
- });
83
- it('rejects tokens with a wrong issuer or audience', async () => {
84
- const wrongIss = await new jose.SignJWT({ common_name: 'owner@repoburg.com' })
85
- .setProtectedHeader({ alg: 'HS256' })
86
- .setIssuer('https://other-team.cloudflareaccess.com')
87
- .setAudience('aud-tag')
88
- .setExpirationTime('2h')
89
- .sign(SECRET);
90
- await expect((0, access_jwt_1.verifyAccessJwt)(wrongIss, CONFIG, { jwks })).rejects.toThrow();
91
- const wrongAud = await makeAssertion({ common_name: 'owner@repoburg.com' });
92
- await expect((0, access_jwt_1.verifyAccessJwt)(wrongAud, { teamDomain: 'team.cloudflareaccess.com', aud: 'other-aud' }, { jwks })).rejects.toThrow();
93
- });
94
- });
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.scheduleEdgeGateMove = scheduleEdgeGateMove;
4
- /**
5
- * Moves this machine's tunnel from Cloudflare Access to the account server's
6
- * edge gate (MUH-108), in the background: soon after the daemon starts, then
7
- * every few hours until it worked (no device token yet, account server
8
- * unreachable). A tunnel without Access fields has nothing to move.
9
- */
10
- const provisioner_1 = require("./provisioner");
11
- const FIRST_TRY_MS = 15000;
12
- const RETRY_MS = 6 * 60 * 60 * 1000;
13
- /** Starts the attempts; the returned function stops them. Timers never keep the process alive. */
14
- function scheduleEdgeGateMove(deps = {}) {
15
- const move = deps.move ?? (() => (0, provisioner_1.moveTunnelToEdgeGate)());
16
- const log = deps.log ?? ((message) => console.log(message));
17
- let timer = null;
18
- let stopped = false;
19
- const attempt = async () => {
20
- try {
21
- if (await move())
22
- log('[remote] Tunnel moved from Cloudflare Access to the Repoburg sign-in gate.');
23
- return; // moved, or nothing to move
24
- }
25
- catch (error) {
26
- log(`[remote] Could not move the tunnel to the Repoburg sign-in gate yet: ${error.message}`);
27
- }
28
- if (!stopped) {
29
- timer = setTimeout(() => void attempt(), deps.retryMs ?? RETRY_MS);
30
- timer.unref();
31
- }
32
- };
33
- timer = setTimeout(() => void attempt(), deps.firstTryMs ?? FIRST_TRY_MS);
34
- timer.unref();
35
- return () => {
36
- stopped = true;
37
- if (timer)
38
- clearTimeout(timer);
39
- };
40
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const edge_gate_move_1 = require("./edge-gate-move");
4
- jest.useFakeTimers();
5
- const flush = async () => {
6
- for (let i = 0; i < 5; i++)
7
- await Promise.resolve();
8
- };
9
- describe('scheduleEdgeGateMove', () => {
10
- it('tries soon after start and stops once moved or nothing to move', async () => {
11
- const move = jest.fn(async () => true);
12
- const log = jest.fn();
13
- (0, edge_gate_move_1.scheduleEdgeGateMove)({ move, log, firstTryMs: 1000, retryMs: 5000 });
14
- expect(move).not.toHaveBeenCalled();
15
- await jest.advanceTimersByTimeAsync(1000);
16
- expect(move).toHaveBeenCalledTimes(1);
17
- expect(log).toHaveBeenCalledWith(expect.stringMatching(/moved from Cloudflare Access/));
18
- await jest.advanceTimersByTimeAsync(20000);
19
- expect(move).toHaveBeenCalledTimes(1);
20
- });
21
- it('tries again later while it fails, until it works', async () => {
22
- const move = jest
23
- .fn()
24
- .mockRejectedValueOnce(new Error('Not logged in'))
25
- .mockRejectedValueOnce(new Error('offline'))
26
- .mockResolvedValue(true);
27
- (0, edge_gate_move_1.scheduleEdgeGateMove)({ move, log: jest.fn(), firstTryMs: 1000, retryMs: 5000 });
28
- await jest.advanceTimersByTimeAsync(1000);
29
- await jest.advanceTimersByTimeAsync(5000);
30
- await jest.advanceTimersByTimeAsync(5000);
31
- await flush();
32
- expect(move).toHaveBeenCalledTimes(3);
33
- await jest.advanceTimersByTimeAsync(50000);
34
- expect(move).toHaveBeenCalledTimes(3);
35
- });
36
- it('stops when told to', async () => {
37
- const move = jest.fn().mockRejectedValue(new Error('offline'));
38
- const stop = (0, edge_gate_move_1.scheduleEdgeGateMove)({ move, log: jest.fn(), firstTryMs: 1000, retryMs: 5000 });
39
- await jest.advanceTimersByTimeAsync(1000);
40
- stop();
41
- await jest.advanceTimersByTimeAsync(50000);
42
- expect(move).toHaveBeenCalledTimes(1);
43
- });
44
- });