@inner-dj/server 0.2.1 → 0.2.3

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/lib/src/config.js CHANGED
@@ -46,20 +46,20 @@ export async function getConfig(cfgPath) {
46
46
  const cfg = await parseConfig(p);
47
47
  const pub = getBoolean('PUBLIC', cfg, 'public', false);
48
48
  return {
49
- port: notStupidParseInt(process.env['PORT'] ?? cfg.port ?? 8080),
50
- trustProxy: joinIfArray(process.env['TRUSTPROXY'] ?? cfg.trustProxy),
49
+ port: notStupidParseInt(process.env['PORT'] ?? cfg?.port ?? 8080),
50
+ trustProxy: joinIfArray(process.env['TRUSTPROXY'] ?? cfg?.trustProxy),
51
51
  secure: getBoolean('SECURE', cfg, 'secure', true),
52
52
  public: pub,
53
- sessionSecret: process.env['SESSIONSECRET'] ?? cfg.sessionSecret ?? throwNewError('sessionSecret is required'),
54
- userOtp: pub ? '' : (process.env['USEROTP'] ?? cfg.userOtp) || generateTotpSecret('userOtp'),
55
- adminOtp: process.env['ADMINOTP'] ?? cfg.adminOtp ?? generateTotpSecret('adminOtp'),
56
- cookieTTL: notStupidParseInt(process.env['COOKIETTL'] ?? cfg.cookieTTL ?? 1000 * 60 * 60 * 24 * 30),
57
- jwtSecret: process.env['JWTSECRET'] ?? cfg.jwtSecret ?? throwNewError('jwtSecret is required'),
58
- db: SessionStore.getConfig(path.dirname(p), cfg.db),
59
- discord: InnerDJDiscordBot.getConfig(cfg.discord),
60
- twilio: TwilioReceiver.getConfig(cfg.twilio),
61
- cookies: process.env['COOKIES'] ?? cfg.cookies,
62
- limiter: setDefaultLimits(cfg.limiter || {}),
53
+ sessionSecret: process.env['SESSIONSECRET'] ?? cfg?.sessionSecret ?? throwNewError('sessionSecret is required'),
54
+ userOtp: pub ? '' : (process.env['USEROTP'] ?? cfg?.userOtp) || generateTotpSecret('userOtp'),
55
+ adminOtp: process.env['ADMINOTP'] ?? cfg?.adminOtp ?? generateTotpSecret('adminOtp'),
56
+ cookieTTL: notStupidParseInt(process.env['COOKIETTL'] ?? cfg?.cookieTTL ?? 1000 * 60 * 60 * 24 * 30),
57
+ jwtSecret: process.env['JWTSECRET'] ?? cfg?.jwtSecret ?? throwNewError('jwtSecret is required'),
58
+ db: SessionStore.getConfig(path.dirname(p), cfg?.db),
59
+ discord: InnerDJDiscordBot.getConfig(cfg?.discord),
60
+ twilio: TwilioReceiver.getConfig(cfg?.twilio),
61
+ cookies: process.env['COOKIES'] ?? cfg?.cookies,
62
+ limiter: setDefaultLimits(cfg?.limiter || {}),
63
63
  };
64
64
  }
65
65
  //# sourceMappingURL=config.js.map
@@ -0,0 +1,17 @@
1
+ import { type ServerConfig } from '../config.js';
2
+ import { type Web } from '../web.js';
3
+ export interface iReceiverConfig {
4
+ enabled: boolean;
5
+ }
6
+ export interface iReceiverStatic<T extends iReceiverConfig> {
7
+ new (config: ServerConfig, web: Web): iReceiver;
8
+ getConfig(cfg?: Partial<T>): T;
9
+ }
10
+ export declare abstract class iReceiver {
11
+ protected config: ServerConfig;
12
+ private web;
13
+ constructor(config: ServerConfig, web: Web);
14
+ request: (url: string) => Promise<boolean>;
15
+ start: () => void;
16
+ close: () => void;
17
+ }
@@ -0,0 +1,18 @@
1
+ ;
2
+ export class iReceiver {
3
+ config;
4
+ web;
5
+ constructor(config, web) {
6
+ this.config = config;
7
+ this.web = web;
8
+ }
9
+ request = (url) => {
10
+ return this.web.sendPayload({
11
+ type: 'queue',
12
+ body: url
13
+ });
14
+ };
15
+ start = () => { };
16
+ close = () => { };
17
+ }
18
+ //# sourceMappingURL=ireceiver.js.map
@@ -0,0 +1,10 @@
1
+ import { iReceiver, type iReceiverConfig } from './ireceiver.js';
2
+ export interface SmtpReceiverConfig extends iReceiverConfig {
3
+ port: number;
4
+ }
5
+ export declare class SmtpReceiver extends iReceiver {
6
+ private smtp;
7
+ static getConfig(cfg?: Partial<SmtpReceiverConfig>): SmtpReceiverConfig;
8
+ start: () => void;
9
+ close: () => void;
10
+ }
@@ -0,0 +1,38 @@
1
+ import { SMTPServer } from "smtp-server";
2
+ import { notStupidParseInt } from 'inner-dj-common';
3
+ import { iReceiver } from './ireceiver.js';
4
+ import { getBoolean } from '../config.js';
5
+ export class SmtpReceiver extends iReceiver {
6
+ smtp = null;
7
+ static getConfig(cfg) {
8
+ return {
9
+ enabled: getBoolean('SMTPENABLED', cfg, 'enabled', false),
10
+ port: notStupidParseInt(process.env['SMTPPORT'] ?? cfg?.port ?? 4650),
11
+ };
12
+ }
13
+ start = () => {
14
+ if (this.smtp) {
15
+ return;
16
+ }
17
+ const server = this.smtp = new SMTPServer({
18
+ secure: true,
19
+ name: 'Inner DJ request inbox',
20
+ size: 255,
21
+ authOptional: false,
22
+ disabledCommands: ['AUTH'],
23
+ onData: (stream, _session, callback) => {
24
+ const body = stream.read();
25
+ console.log(body);
26
+ callback(null, "Message queued");
27
+ }
28
+ });
29
+ server.listen(this.config.smtpConfig.port);
30
+ console.log(`SmtpReceiver listening on port ${this.config.smtpConfig.port}`);
31
+ };
32
+ close = () => {
33
+ this.smtp?.close();
34
+ this.smtp = null;
35
+ };
36
+ }
37
+ SmtpReceiver;
38
+ //# sourceMappingURL=smtp-receiver.js.map
package/lib/src/web.js CHANGED
@@ -235,6 +235,15 @@ export class Web extends EventEmitter {
235
235
  }
236
236
  });
237
237
  });
238
+ app.get('/about', (_, res) => {
239
+ res.render('about', {
240
+ page: {
241
+ title: 'About Inner DJ',
242
+ titlesuffix: 'Open Source Notice',
243
+ description: 'Legal stuff'
244
+ }
245
+ });
246
+ });
238
247
  const requireAdmin = (req, res, next) => {
239
248
  if (req.session.admin !== true) {
240
249
  res.redirect('/?override=1');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inner-dj/server",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "server component of inner-dj",
5
5
  "keywords": [
6
6
  "jukebox",
@@ -39,15 +39,16 @@
39
39
  "assets/",
40
40
  "views/",
41
41
  "lib/src",
42
- "!lib/**/*.js.map"
42
+ "!lib/**/*.js.map",
43
+ "LICENSE"
43
44
  ],
44
45
  "dependencies": {
45
- "better-sqlite3": "^12.10.0",
46
+ "better-sqlite3": "^13.0.3",
46
47
  "bulma": "^1.0.4",
47
48
  "content-disposition": "2.0.1",
48
49
  "ejs": "^6.0.1",
49
50
  "express": "^5.2.1",
50
- "express-rate-limit": "^8.5.2",
51
+ "express-rate-limit": "^8.6.2",
51
52
  "express-session": "^1.19.0",
52
53
  "express-ws": "^5.0.2",
53
54
  "get-youtube-id-ng": "1.0.1",
@@ -55,13 +56,13 @@
55
56
  "otplib": "^13.4.1",
56
57
  "qr-creator": "^1.0.0",
57
58
  "yaml": "^2.9.0",
58
- "@inner-dj/common": "0.2.0",
59
- "@inner-dj/twilio-receiver": "0.2.1",
60
- "@inner-dj/discord-receiver": "0.2.0"
59
+ "@inner-dj/common": "0.2.3",
60
+ "@inner-dj/discord-receiver": "0.2.3",
61
+ "@inner-dj/twilio-receiver": "0.2.3"
61
62
  },
62
63
  "devDependencies": {
63
64
  "@sindresorhus/tsconfig": "8.1.0",
64
- "@types/better-sqlite3": "^7.6.13",
65
+ "@types/better-sqlite3": "^9.6.0",
65
66
  "@types/express": "^5.0.6",
66
67
  "@types/express-session": "^1.19.0",
67
68
  "@types/express-ws": "^3.0.6",
@@ -69,10 +70,12 @@
69
70
  "@types/node": "^24.12.4",
70
71
  "@types/ws": "^8.18.1",
71
72
  "forking-build-shit": "1.1.3",
73
+ "npm-attribution-generator": "^2.0.0",
72
74
  "typescript": "^7.0.2"
73
75
  },
74
76
  "scripts": {
75
- "build": "tsc && chmod +x lib/src/main.js && cp node_modules/otplib/dist/index.global.js scripts/otplib.js && cp node_modules/qr-creator/dist/qr-creator.min.js scripts/ && build-shit",
77
+ "attribution": "generate-attribution && mv oss-attribution/attribution.txt ./views/attribution.ejs ; rm -rf ./oss-attribution",
78
+ "build": "tsc && chmod +x lib/src/main.js && cp node_modules/otplib/dist/index.global.js scripts/otplib.js && cp node_modules/qr-creator/dist/qr-creator.min.js scripts/ && build-shit && pnpm run attribution",
76
79
  "start": "./lib/src/main.js"
77
80
  }
78
81
  }
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
3
+
4
+ <head>
5
+ <%- include("head", locals) %>
6
+ </head>
7
+
8
+ <body class="preload">
9
+ <div class="mt-5">
10
+ <div class="container">
11
+ <h1 class="title is-1">About Inner DJ Web</h1>
12
+ <pre>
13
+ <%- include("attribution") %>
14
+ </pre>
15
+ </div>
16
+ </div>
17
+ </body>
18
+
19
+ </html>