@fnndsc/porter 0.2.0
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.
- package/README.md +19 -0
- package/dist/app.d.ts +97 -0
- package/dist/app.js +338 -0
- package/dist/app.js.map +1 -0
- package/dist/config.d.ts +65 -0
- package/dist/config.js +95 -0
- package/dist/config.js.map +1 -0
- package/dist/cube/auth.d.ts +37 -0
- package/dist/cube/auth.js +42 -0
- package/dist/cube/auth.js.map +1 -0
- package/dist/door.d.ts +29 -0
- package/dist/door.js +23 -0
- package/dist/door.js.map +1 -0
- package/dist/greeter.d.ts +45 -0
- package/dist/greeter.js +148 -0
- package/dist/greeter.js.map +1 -0
- package/dist/host/processHost.d.ts +86 -0
- package/dist/host/processHost.js +261 -0
- package/dist/host/processHost.js.map +1 -0
- package/dist/host/sessionHost.d.ts +103 -0
- package/dist/host/sessionHost.js +2 -0
- package/dist/host/sessionHost.js.map +1 -0
- package/dist/porter.d.ts +2 -0
- package/dist/porter.js +72 -0
- package/dist/porter.js.map +1 -0
- package/dist/registry.d.ts +58 -0
- package/dist/registry.js +107 -0
- package/dist/registry.js.map +1 -0
- package/dist/sweep.d.ts +31 -0
- package/dist/sweep.js +31 -0
- package/dist/sweep.js.map +1 -0
- package/package.json +52 -0
package/dist/sweep.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The idle sweep: sessions nobody is on, ended after a day.
|
|
3
|
+
*
|
|
4
|
+
* A session with no wire open and nothing through the door for the idle
|
|
5
|
+
* span is ended — the process, never the identity's state directory, so
|
|
6
|
+
* the next login boots warm. The registry forgets it; a cookie that still
|
|
7
|
+
* names it sends its browser back through the door, where the password is
|
|
8
|
+
* checked again and the session started again.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { SessionHost } from './host/sessionHost.js';
|
|
13
|
+
import type { SessionRegistry, SessionEntry } from './registry.js';
|
|
14
|
+
/**
|
|
15
|
+
* Ends every idle session once.
|
|
16
|
+
*
|
|
17
|
+
* @param registry - Who is on what, and since when.
|
|
18
|
+
* @param host - Where sessions run.
|
|
19
|
+
* @param idleMs - The span after which a session with nobody on it is ended.
|
|
20
|
+
* @param log - Told each session ended.
|
|
21
|
+
* @returns The keys ended.
|
|
22
|
+
*/
|
|
23
|
+
export declare function idleSweep_run(registry: SessionRegistry, host: Pick<SessionHost, 'evict'>, idleMs: number, log?: (line: string) => void): Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* The idle entries, for a listing or a test, without ending anything.
|
|
26
|
+
*
|
|
27
|
+
* @param registry - Who is on what.
|
|
28
|
+
* @param idleMs - The span.
|
|
29
|
+
* @returns The entries idle longer than the span.
|
|
30
|
+
*/
|
|
31
|
+
export declare function idle_list(registry: SessionRegistry, idleMs: number): SessionEntry[];
|
package/dist/sweep.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ends every idle session once.
|
|
3
|
+
*
|
|
4
|
+
* @param registry - Who is on what, and since when.
|
|
5
|
+
* @param host - Where sessions run.
|
|
6
|
+
* @param idleMs - The span after which a session with nobody on it is ended.
|
|
7
|
+
* @param log - Told each session ended.
|
|
8
|
+
* @returns The keys ended.
|
|
9
|
+
*/
|
|
10
|
+
export async function idleSweep_run(registry, host, idleMs, log = () => undefined) {
|
|
11
|
+
const ended = [];
|
|
12
|
+
for (const entry of registry.idle_list(idleMs)) {
|
|
13
|
+
const idleFor = Math.round((Date.now() - entry.activeAt) / 60_000);
|
|
14
|
+
await host.evict(entry.identity);
|
|
15
|
+
registry.forget(entry.key);
|
|
16
|
+
ended.push(entry.key);
|
|
17
|
+
log(`ended ${entry.user}'s session after ${idleFor} min idle; the state directory stays`);
|
|
18
|
+
}
|
|
19
|
+
return ended;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The idle entries, for a listing or a test, without ending anything.
|
|
23
|
+
*
|
|
24
|
+
* @param registry - Who is on what.
|
|
25
|
+
* @param idleMs - The span.
|
|
26
|
+
* @returns The entries idle longer than the span.
|
|
27
|
+
*/
|
|
28
|
+
export function idle_list(registry, idleMs) {
|
|
29
|
+
return registry.idle_list(idleMs);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=sweep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweep.js","sourceRoot":"","sources":["../src/sweep.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAyB,EACzB,IAAgC,EAChC,MAAc,EACd,MAA8B,GAAS,EAAE,CAAC,SAAS;IAEnD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/C,MAAM,OAAO,GAAW,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC;QAC3E,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACjC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtB,GAAG,CAAC,SAAS,KAAK,CAAC,IAAI,oBAAoB,OAAO,sCAAsC,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,QAAyB,EAAE,MAAc;IACjE,OAAO,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fnndsc/porter",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "PORTER: the mise display manager — logs an operator in, finds or starts their calypso, and shows them to argus",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/porter.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"porter": "dist/porter.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rm -fr dist && tsc && chmod +x ./dist/porter.js",
|
|
12
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules --disable-warning=ExperimentalWarning' jest --coverage",
|
|
13
|
+
"start": "node dist/porter.js"
|
|
14
|
+
},
|
|
15
|
+
"author": "Rudolph Pienaar",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@fastify/cookie": "^11.1.2",
|
|
19
|
+
"@fastify/formbody": "^9.0.0",
|
|
20
|
+
"@fastify/reply-from": "^12.6.5",
|
|
21
|
+
"@fnndsc/calypso": "^0.16.0",
|
|
22
|
+
"@fnndsc/chell": "^5.9.0",
|
|
23
|
+
"@fnndsc/menu": "^0.10.0",
|
|
24
|
+
"fastify": "^5.12.5",
|
|
25
|
+
"ws": "^8.18.0",
|
|
26
|
+
"zod": "^3.23.8"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@jest/globals": "^30.2.0",
|
|
30
|
+
"@types/jest": "^30.0.0",
|
|
31
|
+
"@types/node": "^22.0.0",
|
|
32
|
+
"@types/ws": "^8.5.12",
|
|
33
|
+
"jest": "^30.2.0",
|
|
34
|
+
"ts-jest": "^29.4.5",
|
|
35
|
+
"typescript": "^5.0.0"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/FNNDSC/mise.git",
|
|
43
|
+
"directory": "apps/porter"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"chris",
|
|
47
|
+
"mise",
|
|
48
|
+
"porter",
|
|
49
|
+
"login",
|
|
50
|
+
"display-manager"
|
|
51
|
+
]
|
|
52
|
+
}
|