Compare commits
No commits in common. "91fe66b202b89267488ffd879c01afa6b88a31f0" and "f7dd1e4a58dcce3b1c856dbb44ea5e51084a4c07" have entirely different histories.
91fe66b202
...
f7dd1e4a58
@ -1,6 +1,7 @@
|
|||||||
import { AbstractUser } from "../src/server/interfaces/index.js";
|
import { AbstractUser } from "../src/server/interfaces/index.js";
|
||||||
|
import { ObjectId } from 'mongodb';
|
||||||
import { LoggerClientOptions } from '@navy.gif/logger';
|
import { LoggerClientOptions } from '@navy.gif/logger';
|
||||||
import { MariaOptions, MongoOptions, ObjectId } from '@navy.gif/wrappers';
|
import { MariaOptions, MongoOptions } from '@navy.gif/wrappers';
|
||||||
import { Request as ExpressRequest, Response as ExpressResponse, NextFunction } from "express";
|
import { Request as ExpressRequest, Response as ExpressResponse, NextFunction } from "express";
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import { UploadedFile } from "express-fileupload";
|
import { UploadedFile } from "express-fileupload";
|
||||||
@ -166,9 +167,3 @@ export type EndpointOptions = {
|
|||||||
auth?: MiddlewareFunction | true | null,
|
auth?: MiddlewareFunction | true | null,
|
||||||
loadOrder?: number
|
loadOrder?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RegistrationInvite = {
|
|
||||||
code: string,
|
|
||||||
validFor: number,
|
|
||||||
created: number
|
|
||||||
}
|
|
@ -15,7 +15,7 @@
|
|||||||
"@navy.gif/commandparser": "^1.4.5",
|
"@navy.gif/commandparser": "^1.4.5",
|
||||||
"@navy.gif/logger": "^2.3.3",
|
"@navy.gif/logger": "^2.3.3",
|
||||||
"@navy.gif/passport-discord": "^0.2.2-b",
|
"@navy.gif/passport-discord": "^0.2.2-b",
|
||||||
"@navy.gif/wrappers": "^1.3.12",
|
"@navy.gif/wrappers": "^1.3.11",
|
||||||
"@types/cors": "^2.8.13",
|
"@types/cors": "^2.8.13",
|
||||||
"@types/express-fileupload": "^1.4.1",
|
"@types/express-fileupload": "^1.4.1",
|
||||||
"@types/express-session": "^1.17.7",
|
"@types/express-session": "^1.17.7",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { OptionType, ArgsResult } from '@navy.gif/commandparser';
|
import { OptionType, CommandOptionDefinition, ArgsResult } from '@navy.gif/commandparser';
|
||||||
import BaseCommand from '../BaseCommand.js';
|
import BaseCommand from '../BaseCommand.js';
|
||||||
import Controller from '../Controller.js';
|
import Controller from '../Controller.js';
|
||||||
import { IPCMessage, SignupCode } from '../../../@types/Other.js';
|
import { IPCMessage, SignupCode } from '../../../@types/Other.js';
|
||||||
@ -12,13 +12,13 @@ class CreateCommand extends BaseCommand {
|
|||||||
name: 'registration-code',
|
name: 'registration-code',
|
||||||
aliases: [ 'code' ],
|
aliases: [ 'code' ],
|
||||||
type: OptionType.SUB_COMMAND,
|
type: OptionType.SUB_COMMAND,
|
||||||
options: [{
|
options: [ {
|
||||||
name: 'amount',
|
name: 'amount',
|
||||||
flag: true,
|
flag: true,
|
||||||
type: OptionType.INTEGER,
|
type: OptionType.INTEGER,
|
||||||
valueOptional: true,
|
valueOptional: true,
|
||||||
defaultValue: 1
|
defaultValue: 1
|
||||||
}]
|
} as CommandOptionDefinition ]
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,13 +37,8 @@ class CreateCommand extends BaseCommand {
|
|||||||
const response = await shard.send(msg, true);
|
const response = await shard.send(msg, true);
|
||||||
if (!response)
|
if (!response)
|
||||||
return 'Did not get a response from shard';
|
return 'Did not get a response from shard';
|
||||||
|
const code = response.code as SignupCode;
|
||||||
const codes = response.codes as SignupCode[];
|
return `Code ${code.code}, valid until ${new Date(code.created + code.validFor).toUTCString()}`;
|
||||||
let out = `Created codes, valid until ${new Date(codes[0].created + codes[0].validFor).toUTCString()}:\n`;
|
|
||||||
for (const invite of codes)
|
|
||||||
out += `${invite.code}\n`;
|
|
||||||
|
|
||||||
return out;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import { Authenticator, RateLimiter } from './middleware/index.js';
|
|||||||
import { UserDatabaseInterface } from './interfaces/index.js';
|
import { UserDatabaseInterface } from './interfaces/index.js';
|
||||||
import { ExternalProfile, OAuthProvider, Request, Response, ServerOptions, SessionLimit } from '../../@types/Server.js';
|
import { ExternalProfile, OAuthProvider, Request, Response, ServerOptions, SessionLimit } from '../../@types/Server.js';
|
||||||
import { MongoMemory } from './database/index.js';
|
import { MongoMemory } from './database/index.js';
|
||||||
import { IPCMessage, SignupCode } from '../../@types/Other.js';
|
import { IPCMessage } from '../../@types/Other.js';
|
||||||
import { DoneCallback } from 'passport';
|
import { DoneCallback } from 'passport';
|
||||||
|
|
||||||
// const pkg = JSON.parse(readFileSync('../../package.json', { encoding: 'utf8' }));
|
// const pkg = JSON.parse(readFileSync('../../package.json', { encoding: 'utf8' }));
|
||||||
@ -292,13 +292,8 @@ class Server extends EventEmitter {
|
|||||||
if (!process.send)
|
if (!process.send)
|
||||||
throw new Error('Missing process.send???');
|
throw new Error('Missing process.send???');
|
||||||
if (msg.type === 'reqregcode') {
|
if (msg.type === 'reqregcode') {
|
||||||
const codes: SignupCode[] = [];
|
|
||||||
const amount = msg.amount as number;
|
|
||||||
for (let i = 0; i < amount; i++) {
|
|
||||||
const code = await this.users.createRegistrationCode();
|
const code = await this.users.createRegistrationCode();
|
||||||
codes.push(code);
|
process.send({ _id: msg._id, code });
|
||||||
}
|
|
||||||
process.send({ _id: msg._id, codes });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,18 +366,6 @@ class Server extends EventEmitter {
|
|||||||
return this.#_port;
|
return this.#_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
get mongodb () {
|
|
||||||
return this.#_mongodb;
|
|
||||||
}
|
|
||||||
|
|
||||||
get memoryStoreProvider () {
|
|
||||||
return this.#_memoryStoreProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
get mariadb () {
|
|
||||||
return this.#_mariadb;
|
|
||||||
}
|
|
||||||
|
|
||||||
get users () {
|
get users () {
|
||||||
return this.#_userDatabase;
|
return this.#_userDatabase;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
|
// const { Collection } = require("@discordjs/collection");
|
||||||
|
// const { ObjectId } = require("mongodb");
|
||||||
|
|
||||||
|
// const { UserDatabaseInterface, Entity } = require("../interfaces/");
|
||||||
|
// const { User, UserApplication, Role } = require("../structures");
|
||||||
|
// const { Util } = require("../../util");
|
||||||
|
|
||||||
import { Collection } from '@discordjs/collection';
|
import { Collection } from '@discordjs/collection';
|
||||||
|
import { ObjectId, Document } from 'mongodb';
|
||||||
|
|
||||||
import { LoggerClient } from '@navy.gif/logger';
|
import { LoggerClient } from '@navy.gif/logger';
|
||||||
import { MongoDB, ObjectId, Document } from '@navy.gif/wrappers';
|
import { MongoDB } from '@navy.gif/wrappers';
|
||||||
|
|
||||||
import Server from "../Server.js";
|
import Server from "../Server.js";
|
||||||
import { Entity, UserDatabaseInterface } from "../interfaces/index.js";
|
import { Entity, UserDatabaseInterface } from "../interfaces/index.js";
|
||||||
import { Role, User, UserApplication } from "../structures/index.js";
|
import { Role, User, UserApplication } from "../structures/index.js";
|
||||||
import { ApplicationData, ExternalProfile, RoleData, UserData } from '../../../@types/Server.js';
|
import { ApplicationData, ExternalProfile, RoleData, UserData } from '../../../@types/Server.js';
|
||||||
import { Util } from '../../util/index.js';
|
import { Util } from '../../util/index.js';
|
||||||
import { SignupCode } from '../../../@types/Other.js';
|
|
||||||
|
|
||||||
type UserDBOptions = {
|
type UserDBOptions = {
|
||||||
userCollection?: string,
|
userCollection?: string,
|
||||||
@ -373,7 +380,7 @@ class UserDatabase implements UserDatabaseInterface {
|
|||||||
* @param {number} [validFor=1] Amount of days the code is valid
|
* @param {number} [validFor=1] Amount of days the code is valid
|
||||||
* @memberof UserDatabase
|
* @memberof UserDatabase
|
||||||
*/
|
*/
|
||||||
async createRegistrationCode (validFor = 1): Promise<SignupCode> {
|
async createRegistrationCode (validFor = 1) {
|
||||||
const string = Util.randomString();
|
const string = Util.randomString();
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const obj = { code: string, validFor: validFor * 24 * 60 * 60 * 1000, created: now };
|
const obj = { code: string, validFor: validFor * 24 * 60 * 60 * 1000, created: now };
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
|
// const { ObjectId } = require("mongodb");
|
||||||
|
// const { PermissionManager } = require("../../util");
|
||||||
|
// const UserDatabaseInterface = require("./UserDatabaseInterface");
|
||||||
|
import { ObjectId } from 'mongodb';
|
||||||
import { PermissionManager } from '../../util/index.js';
|
import { PermissionManager } from '../../util/index.js';
|
||||||
import UserDatabaseInterface from './UserDatabaseInterface.js';
|
import UserDatabaseInterface from './UserDatabaseInterface.js';
|
||||||
import Server from '../Server.js';
|
import Server from '../Server.js';
|
||||||
import { EntityData, EntityJson, Permissions } from '../../../@types/Server.js';
|
import { EntityData, EntityJson, Permissions } from '../../../@types/Server.js';
|
||||||
import { ObjectId } from '@navy.gif/wrappers';
|
|
||||||
|
|
||||||
// API entity superclass
|
// API entity superclass
|
||||||
class Entity {
|
class Entity {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { DeleteResult } from "@navy.gif/wrappers";
|
import { DeleteResult } from 'mongodb';
|
||||||
import { SignupCode } from "../../../@types/Other.js";
|
import { SignupCode } from "../../../@types/Other.js";
|
||||||
import { ApplicationData, ExternalProfile, RoleData } from "../../../@types/Server.js";
|
import { ApplicationData, ExternalProfile, RoleData } from "../../../@types/Server.js";
|
||||||
import { Role, User, UserApplication } from "../structures/index.js";
|
import { Role, User, UserApplication } from "../structures/index.js";
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// const { AbstractUser } = require("../interfaces");
|
// const { AbstractUser } = require("../interfaces");
|
||||||
// const { ObjectId } = require("mongodb");
|
// const { ObjectId } = require("mongodb");
|
||||||
|
|
||||||
import { ObjectId } from "@navy.gif/wrappers";
|
|
||||||
import { ApplicationData } from "../../../@types/Server.js";
|
import { ApplicationData } from "../../../@types/Server.js";
|
||||||
import Server from "../Server.js";
|
import Server from "../Server.js";
|
||||||
import { AbstractUser } from "../interfaces/index.js";
|
import { AbstractUser } from "../interfaces/index.js";
|
||||||
|
import { ObjectId } from 'mongodb';
|
||||||
|
|
||||||
class UserApplication extends AbstractUser {
|
class UserApplication extends AbstractUser {
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ class PermissionManager {
|
|||||||
const resolveables = perm.split(':');
|
const resolveables = perm.split(':');
|
||||||
let selector = null;
|
let selector = null;
|
||||||
|
|
||||||
|
|
||||||
if (typeof perms.developer === 'number' && perms.developer > 0
|
if (typeof perms.developer === 'number' && perms.developer > 0
|
||||||
|| typeof perms.developer === 'object' && typeof perms.developer.default === 'number' && perms.developer?.default > 0)
|
|| typeof perms.developer === 'object' && typeof perms.developer.default === 'number' && perms.developer?.default > 0)
|
||||||
return true;
|
return true;
|
||||||
|
10
yarn.lock
10
yarn.lock
@ -1773,15 +1773,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@navy.gif/wrappers@npm:^1.3.12":
|
"@navy.gif/wrappers@npm:^1.3.11":
|
||||||
version: 1.3.12
|
version: 1.3.11
|
||||||
resolution: "@navy.gif/wrappers@npm:1.3.12"
|
resolution: "@navy.gif/wrappers@npm:1.3.11"
|
||||||
dependencies:
|
dependencies:
|
||||||
amqp-connection-manager: ^4.1.12
|
amqp-connection-manager: ^4.1.12
|
||||||
amqplib: ^0.10.3
|
amqplib: ^0.10.3
|
||||||
mongodb: ^5.2.0
|
mongodb: ^5.2.0
|
||||||
mysql: ^2.18.1
|
mysql: ^2.18.1
|
||||||
checksum: 4e95129ff4dfb43037ebb47d55ab16be730cbf43030c5b75e1adc7f92251f92e8abc689ebe429ae3b60f2efc5761c3c78e617e72470c68fc9818bd431a0f4de3
|
checksum: e0170f5e0d78e77e464781f6c00fb979fa86a4360faea31df832b64b78799182234656b97098bb8e1c8b2ca0ef5558e477f59c6cb51d1dce01ab8d2c6547dc4a
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -7038,7 +7038,7 @@ __metadata:
|
|||||||
"@navy.gif/commandparser": ^1.4.5
|
"@navy.gif/commandparser": ^1.4.5
|
||||||
"@navy.gif/logger": ^2.3.3
|
"@navy.gif/logger": ^2.3.3
|
||||||
"@navy.gif/passport-discord": ^0.2.2-b
|
"@navy.gif/passport-discord": ^0.2.2-b
|
||||||
"@navy.gif/wrappers": ^1.3.12
|
"@navy.gif/wrappers": ^1.3.11
|
||||||
"@types/cors": ^2.8.13
|
"@types/cors": ^2.8.13
|
||||||
"@types/express-fileupload": ^1.4.1
|
"@types/express-fileupload": ^1.4.1
|
||||||
"@types/express-session": ^1.17.7
|
"@types/express-session": ^1.17.7
|
||||||
|
Loading…
Reference in New Issue
Block a user