chore: updated comments to use Better Comments syntax

This commit is contained in:
Jonathan Barrow
2024-04-14 19:41:47 -04:00
parent 6d3f516612
commit 82d353357b
27 changed files with 145 additions and 145 deletions

View File

@@ -17,7 +17,7 @@ import { DiscordConnectionData } from '@/types/services/api/discord-connection-d
const connection_string = config.mongoose.connection_string;
const options = config.mongoose.options;
// TODO: Extend this later with more settings
// TODO - Extend this later with more settings
const discordConnectionSchema = joi.object({
id: joi.string()
});
@@ -116,7 +116,7 @@ export async function getPNIDByTokenAuth(token: string): Promise<HydratedPNIDDoc
return pnid;
} catch (error: any) {
// TODO: Handle error
// TODO - Handle error
LOG_ERROR(error);
return null;
}
@@ -157,7 +157,7 @@ export async function getPNIDProfileJSONByPID(pid: number): Promise<PNIDProfile
}
return {
//accounts: {}, // * We need to figure this out, no idea what these values mean or what they do
// *accounts: {}, // * We need to figure this out, no idea what these values mean or what they do
active_flag: pnid.flags.active ? 'Y' : 'N',
birth_date: pnid.birthdate,
country: pnid.country,

View File

@@ -18,7 +18,7 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
!requestParams.titleid ||
!requestParams.servertype
) {
response.status(200).send(nascError('null').toString()); // This is what Nintendo sends
response.status(200).send(nascError('null').toString()); // * This is what Nintendo sends
return;
}
@@ -49,7 +49,7 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
}
if (action !== 'LOGIN' && action !== 'SVCLOC') {
response.status(200).send(nascError('null').toString()); // This is what Nintendo sends
response.status(200).send(nascError('null').toString()); // * This is what Nintendo sends
return;
}
@@ -164,13 +164,13 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
if (titleID === '0004013000003202') {
if (password && !pid && !pidHmac) {
// Register new user
// * Register new user
const session = await databaseConnection().startSession();
await session.startTransaction();
try {
// Create new NEX account
// * Create new NEX account
nexAccount = new NEXAccount({
device_type: '3ds',
password
@@ -196,7 +196,7 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
await nexAccount.save({ session });
// Set password
// * Set password
if (!device) {
device = new Device({
@@ -219,7 +219,7 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
await session.abortTransaction();
// 3DS expects 200 even on error
// * 3DS expects 200 even on error
response.status(200).send(nascError('102').toString());
return;
} finally {
@@ -235,8 +235,8 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
return next();
}
// https://www.adminsub.net/mac-address-finder/nintendo
// Saves us from doing an OUI lookup each time
// * https://www.adminsub.net/mac-address-finder/nintendo
// * Saves us from doing an OUI lookup each time
const NINTENDO_VENDER_OUIS = [
'ECC40D', 'E84ECE', 'E0F6B5', 'E0E751', 'E00C7F', 'DC68EB',
'D86BF7', 'D4F057', 'CCFB65', 'CC9E00', 'B8AE6E', 'B88AEC',
@@ -262,10 +262,10 @@ const NINTENDO_VENDER_OUIS = [
'001AE9', '0019FD', '00191D', '0017AB', '001656', '0009BF'
];
// TODO: Make something better
// TODO - Make something better
const MAC_REGEX = /^[0-9a-fA-F]{12}$/;
// Maybe should later parse more data out
// * Maybe should later parse more data out
function validNintendoMACAddress(macAddress: string): boolean {
if (!NINTENDO_VENDER_OUIS.includes(macAddress.substring(0, 6).toUpperCase())) {
return false;

View File

@@ -34,7 +34,7 @@ function XMLMiddleware(request: express.Request, response: express.Response, nex
request.body = request.body.toObject();
request.body = mapToObject(request.body);
} catch (error) {
// TODO: This is not a real error code, check to see if better one exists
// TODO - This is not a real error code, check to see if better one exists
return response.status(401).send(xmlbuilder.create({
errors: {
error: {

View File

@@ -35,11 +35,11 @@ export const DeviceSchema = new Schema<IDevice, DeviceModel, IDeviceMethods>({
linked_pids: [Number],
access_level: {
type: Number,
default: 0 // 0: standard, 1: tester, 2: mod?, 3: dev
default: 0 // * 0: standard, 1: tester, 2: mod?, 3: dev
},
server_access_level: {
type: String,
default: 'prod' // everyone is in production by default
default: 'prod' // * everyone is in production by default
},
certificate_hash: String
});

View File

@@ -6,7 +6,7 @@ const NEXAccountSchema = new Schema<INEXAccount, NEXAccountModel, INEXAccountMet
device_type: {
type: String,
enum: [
// Only track the family here not the model
// * Only track the family here not the model
'wiiu',
'3ds',
]
@@ -19,11 +19,11 @@ const NEXAccountSchema = new Schema<INEXAccount, NEXAccountModel, INEXAccountMet
owning_pid: Number,
access_level: {
type: Number,
default: 0 // 0: standard, 1: tester, 2: mod?, 3: dev
default: 0 // * 0: standard, 1: tester, 2: mod?, 3: dev
},
server_access_level: {
type: String,
default: 'prod' // everyone is in production by default
default: 'prod' // * everyone is in production by default
},
friend_code: String
});
@@ -39,7 +39,7 @@ NEXAccountSchema.plugin(uniqueValidator, { message: '{PATH} already in use.' });
and the next few accounts counting down seem to be admin, service and internal test accounts
*/
NEXAccountSchema.method('generatePID', async function generatePID(): Promise<void> {
const min = 1000000000; // The console (WiiU) seems to not accept PIDs smaller than this
const min = 1000000000; // * The console (WiiU) seems to not accept PIDs smaller than this
const max = 1799999999;
const pid = Math.floor(Math.random() * (max - min + 1) + min);

View File

@@ -33,11 +33,11 @@ const PNIDSchema = new Schema<IPNID, PNIDModel, IPNIDMethods>({
},
access_level: {
type: Number,
default: 0 // 0: standard, 1: tester, 2: mod?, 3: dev
default: 0 // * 0: standard, 1: tester, 2: mod?, 3: dev
},
server_access_level: {
type: String,
default: 'prod' // everyone is in production by default
default: 'prod' // * everyone is in production by default
},
pid: {
type: Number,
@@ -89,7 +89,7 @@ const PNIDSchema = new Schema<IPNID, PNIDModel, IPNIDMethods>({
off_device: Boolean
},
devices: [DeviceSchema],
identification: { // user identification tokens
identification: { // * user identification tokens
email_code: {
type: String,
unique: true
@@ -133,7 +133,7 @@ PNIDSchema.plugin(uniqueValidator, {message: '{PATH} already in use.'});
and the next few accounts counting down seem to be admin, service and internal test accounts
*/
PNIDSchema.method('generatePID', async function generatePID(): Promise<void> {
const min = 1000000000; // The console (WiiU) seems to not accept PIDs smaller than this
const min = 1000000000; // * The console (WiiU) seems to not accept PIDs smaller than this
const max = 1799999999;
const pid = Math.floor(Math.random() * (max - min + 1) + min);
@@ -150,9 +150,9 @@ PNIDSchema.method('generatePID', async function generatePID(): Promise<void> {
});
PNIDSchema.method('generateEmailValidationCode', async function generateEmailValidationCode(): Promise<void> {
// WiiU passes the PID along with the email code
// Does not actually need to be unique to all users
const code = Math.random().toFixed(6).split('.')[1]; // Dirty one-liner to generate numbers of 6 length and padded 0
// * WiiU passes the PID along with the email code
// * Does not actually need to be unique to all users
const code = Math.random().toFixed(6).split('.')[1]; // * Dirty one-liner to generate numbers of 6 length and padded 0
this.identification.email_code = code;
});

View File

@@ -41,7 +41,7 @@ const CTR_LFCS_B_PUB = Buffer.from([
0xAF, 0x07, 0xEB, 0x9C, 0xBF, 0xA9, 0xC9
]);
// Signature options
// * Signature options
const SIGNATURE_SIZES = {
RSA_4096_SHA1: <SignatureSize>{
SIZE: 0x200,
@@ -201,10 +201,10 @@ class NintendoCertificate {
this.valid = publicKey.verify(this._certificateBody, this.signature);
}
// Huge thanks to Myria for helping get ECDSA working
// with Nodes native crypto module and getting the keys
// from bytes to PEM!
// https://github.com/Myriachan
// * Huge thanks to Myria for helping get ECDSA working
// * with Nodes native crypto module and getting the keys
// * from bytes to PEM!
// * https://github.com/Myriachan
_verifySignatureECDSA(): void {
const pem = this.consoleType === 'wiiu' ? WIIU_DEVICE_PUB_PEM : CTR_DEVICE_PUB_PEM;
const key = {

View File

@@ -27,9 +27,9 @@ import { config } from '@/config-manager';
const app = express();
// START APPLICATION
// * START APPLICATION
// Create router
// * Create router
LOG_INFO('Setting up Middleware');
app.use(morgan('dev'));
app.use(express.json());
@@ -38,7 +38,7 @@ app.use(express.urlencoded({
}));
app.use(xmlparser);
// import the servers into one
// * import the servers into one
app.use(conntest);
app.use(cbvc);
app.use(nnas);
@@ -48,7 +48,7 @@ app.use(api);
app.use(localcdn);
app.use(assets);
// 404 handler
// * 404 handler
LOG_INFO('Creating 404 status handler');
app.use((request: express.Request, response: express.Response): void => {
const url = fullUrl(request);
@@ -75,7 +75,7 @@ app.use((request: express.Request, response: express.Response): void => {
}).end());
});
// non-404 error handler
// * non-404 error handler
LOG_INFO('Creating non-404 status handler');
app.use((error: any, request: express.Request, response: express.Response, _next: express.NextFunction): void => {
const status = error.status || 500;
@@ -96,7 +96,7 @@ app.use((error: any, request: express.Request, response: express.Response, _next
});
async function main(): Promise<void> {
// Starts the server
// * Starts the server
LOG_INFO('Starting server');
await connectDatabase();

View File

@@ -6,7 +6,7 @@ import { LOG_INFO } from '@/logger';
import { V1 } from '@/services/api/routes';
// Router to handle the subdomain restriction
// * Router to handle the subdomain restriction
const api = express.Router();
LOG_INFO('[USER API] Importing middleware');
@@ -14,7 +14,7 @@ api.use(APIMiddleware);
api.use(cors());
api.options('*', cors());
// Setup routes
// * Setup routes
LOG_INFO('[USER API] Applying imported routes');
api.use('/v1/connections', V1.CONNECTIONS);
api.use('/v1/email', V1.EMAIL);
@@ -25,10 +25,10 @@ api.use('/v1/reset-password', V1.RESET_PASSWORD);
api.use('/v1/user', V1.USER);
// Main router for endpoints
// * Main router for endpoints
const router = express.Router();
// Create subdomains
// * Create subdomains
LOG_INFO('[USER API] Creating \'api\' subdomain');
router.use(subdomain('api', api));

View File

@@ -22,7 +22,7 @@ const PNID_PUNCTUATION_START_REGEX = /^[_\-.]/;
const PNID_PUNCTUATION_END_REGEX = /[_\-.]$/;
const PNID_PUNCTUATION_DUPLICATE_REGEX = /[_\-.]{2,}/;
// This sucks
// * This sucks
const PASSWORD_WORD_OR_NUMBER_REGEX = /(?=.*[a-zA-Z])(?=.*\d).*/;
const PASSWORD_WORD_OR_PUNCTUATION_REGEX = /(?=.*[a-zA-Z])(?=.*[_\-.]).*/;
const PASSWORD_NUMBER_OR_PUNCTUATION_REGEX = /(?=.*\d)(?=.*[_\-.]).*/;
@@ -250,7 +250,7 @@ router.post('/', async (request: express.Request, response: express.Response): P
return;
}
const miiNameBuffer = Buffer.from(miiName, 'utf16le'); // UTF8 to UTF16
const miiNameBuffer = Buffer.from(miiName, 'utf16le'); // * UTF8 to UTF16
if (miiNameBuffer.length > 0x14) {
response.status(400).json({
@@ -282,11 +282,11 @@ router.post('/', async (request: express.Request, response: express.Response): P
await nexAccount.generatePID();
await nexAccount.generatePassword();
// Quick hack to get the PIDs to match
// TODO: Change this maybe?
// NN with a NNID will always use the NNID PID
// even if the provided NEX PID is different
// To fix this we make them the same PID
// * Quick hack to get the PIDs to match
// TODO - Change this maybe?
// * NN with a NNID will always use the NNID PID
// * even if the provided NEX PID is different
// * To fix this we make them the same PID
nexAccount.owning_pid = nexAccount.pid;
await nexAccount.save({ session });
@@ -301,40 +301,40 @@ router.post('/', async (request: express.Request, response: express.Response): P
username: username,
usernameLower: username.toLowerCase(),
password: passwordHash,
birthdate: '1990-01-01', // TODO: Change this
gender: 'M', // TODO: Change this
country: 'US', // TODO: Change this
language: 'en', // TODO: Change this
birthdate: '1990-01-01', // TODO - Change this
gender: 'M', // TODO - Change this
country: 'US', // TODO - Change this
language: 'en', // TODO - Change this
email: {
address: email.toLowerCase(),
primary: true, // TODO: Change this
parent: true, // TODO: Change this
reachable: false, // TODO: Change this
validated: false, // TODO: Change this
primary: true, // TODO - Change this
parent: true, // TODO - Change this
reachable: false, // TODO - Change this
validated: false, // TODO - Change this
id: crypto.randomBytes(4).readUInt32LE()
},
region: 0x310B0000, // TODO: Change this
region: 0x310B0000, // TODO - Change this
timezone: {
name: 'America/New_York', // TODO: Change this
offset: -14400 // TODO: Change this
name: 'America/New_York', // TODO - Change this
offset: -14400 // TODO - Change this
},
mii: {
name: miiName,
primary: true, // TODO: Change this
primary: true, // TODO - Change this
data: mii.encode().toString('base64'),
id: crypto.randomBytes(4).readUInt32LE(),
hash: crypto.randomBytes(7).toString('hex'),
image_url: '', // deprecated, will be removed in the future
image_url: '', // * deprecated, will be removed in the future
image_id: crypto.randomBytes(4).readUInt32LE()
},
flags: {
active: true, // TODO: Change this
marketing: true, // TODO: Change this
off_device: true // TODO: Change this
active: true, // TODO - Change this
marketing: true, // TODO - Change this
off_device: true // TODO - Change this
},
identification: {
email_code: 1, // will be overwritten before saving
email_token: '' // will be overwritten before saving
email_code: 1, // * will be overwritten before saving
email_token: '' // * will be overwritten before saving
}
});

View File

@@ -6,7 +6,7 @@ import { Token } from '@/types/common/token';
const router = express.Router();
// This sucks
// * This sucks
const PASSWORD_WORD_OR_NUMBER_REGEX = /(?=.*[a-zA-Z])(?=.*\d).*/;
const PASSWORD_WORD_OR_PUNCTUATION_REGEX = /(?=.*[a-zA-Z])(?=.*[_\-.]).*/;
const PASSWORD_NUMBER_OR_PUNCTUATION_REGEX = /(?=.*\d)(?=.*[_\-.]).*/;

View File

@@ -1,21 +1,21 @@
// handles serving assets
// * handles serving assets
import path from 'node:path';
import express from 'express';
import subdomain from 'express-subdomain';
import { LOG_INFO } from '@/logger';
// Router to handle the subdomain restriction
// * Router to handle the subdomain restriction
const assets = express.Router();
// Setup public folder
// * Setup public folder
LOG_INFO('[assets] Setting up public folder');
assets.use(express.static(path.join(__dirname, '../../assets')));
// Main router for endpoints
// * Main router for endpoints
const router = express.Router();
// Create subdomains
// * Create subdomains
LOG_INFO('[conntest] Creating \'assets\' subdomain');
router.use(subdomain('assets', assets));

View File

@@ -1,13 +1,13 @@
// handles CBVC (CTR Browser Version Check?) endpoints
// * handles CBVC (CTR Browser Version Check?) endpoints
import express from 'express';
import subdomain from 'express-subdomain';
import { LOG_INFO } from '@/logger';
// Router to handle the subdomain restriction
// * Router to handle the subdomain restriction
const cbvc = express.Router();
// Setup route
// * Setup route
LOG_INFO('[cbvc] Applying imported routes');
cbvc.get('/:consoleType/:unknown/:region', (request: express.Request, response: express.Response): void => {
response.set('Content-Type', 'text/plain');
@@ -21,10 +21,10 @@ cbvc.get('/:consoleType/:unknown/:region', (request: express.Request, response:
response.send('0');
});
// Main router for endpoints
// * Main router for endpoints
const router = express.Router();
// Create subdomains
// * Create subdomains
LOG_INFO('[cbvc] Creating \'cbvc\' subdomain');
router.use(subdomain('cbvc.cdn', cbvc));

View File

@@ -1,20 +1,20 @@
// handles conntest endpoints
// * handles conntest endpoints
import express from 'express';
import subdomain from 'express-subdomain';
import { LOG_INFO } from '@/logger';
// Router to handle the subdomain restriction
// * Router to handle the subdomain restriction
const conntest = express.Router();
// Setup route
// * Setup route
LOG_INFO('[conntest] Applying imported routes');
conntest.get('/', (request: express.Request, response: express.Response): void => {
response.set('Content-Type', 'text/html');
response.set('X-Organization', 'Nintendo');
response.send(`
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-// *W3C// *DTD XHTML 1.0 Transitional// *EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>HTML Page</title>
@@ -26,10 +26,10 @@ This is test.html page
`);
});
// Main router for endpoints
// * Main router for endpoints
const router = express.Router();
// Create subdomains
// * Create subdomains
LOG_INFO('[conntest] Creating \'conntest\' subdomain');
router.use(subdomain('conntest', conntest));

View File

@@ -4,17 +4,17 @@ import { LOG_INFO } from '@/logger';
import upload from '@/services/datastore/routes/upload';
// Router to handle the subdomain
// * Router to handle the subdomain
const datastore = express.Router();
// Setup routes
// * Setup routes
LOG_INFO('[DATASTORE] Applying imported routes');
datastore.use(upload);
// Main router for endpoints
// * Main router for endpoints
const router = express.Router();
// Create subdomains
// * Create subdomains
LOG_INFO('[DATASTORE] Creating \'datastore\' subdomain');
router.use(subdomain('datastore', datastore));

View File

@@ -75,7 +75,7 @@ router.post('/upload', multipartParser, async (request: express.Request, respons
const date = request.files.date.toString();
const signature = request.files.signature.toString();
// Signatures only good for 1 minute
// * Signatures only good for 1 minute
const minute = 1000 * 60;
const minuteAgo = Date.now() - minute;

View File

@@ -21,7 +21,7 @@ const PNID_PUNCTUATION_START_REGEX = /^[_\-.]/;
const PNID_PUNCTUATION_END_REGEX = /[_\-.]$/;
const PNID_PUNCTUATION_DUPLICATE_REGEX = /[_\-.]{2,}/;
// This sucks
// * This sucks
const PASSWORD_WORD_OR_NUMBER_REGEX = /(?=.*[a-zA-Z])(?=.*\d).*/;
const PASSWORD_WORD_OR_PUNCTUATION_REGEX = /(?=.*[a-zA-Z])(?=.*[_\-.]).*/;
const PASSWORD_NUMBER_OR_PUNCTUATION_REGEX = /(?=.*\d)(?=.*[_\-.]).*/;
@@ -146,11 +146,11 @@ export async function register(request: RegisterRequest): Promise<DeepPartial<Lo
await nexAccount.generatePID();
await nexAccount.generatePassword();
// Quick hack to get the PIDs to match
// TODO: Change this maybe?
// NN with a NNID will always use the NNID PID
// even if the provided NEX PID is different
// To fix this we make them the same PID
// * Quick hack to get the PIDs to match
// TODO - Change this maybe?
// * NN with a NNID will always use the NNID PID
// * even if the provided NEX PID is different
// * To fix this we make them the same PID
nexAccount.owning_pid = nexAccount.pid;
await nexAccount.save({ session });
@@ -165,40 +165,40 @@ export async function register(request: RegisterRequest): Promise<DeepPartial<Lo
username: username,
usernameLower: username.toLowerCase(),
password: passwordHash,
birthdate: '1990-01-01', // TODO: Change this
gender: 'M', // TODO: Change this
country: 'US', // TODO: Change this
language: 'en', // TODO: Change this
birthdate: '1990-01-01', // TODO - Change this
gender: 'M', // TODO - Change this
country: 'US', // TODO - Change this
language: 'en', // TODO - Change this
email: {
address: email.toLowerCase(),
primary: true, // TODO: Change this
parent: true, // TODO: Change this
reachable: false, // TODO: Change this
validated: false, // TODO: Change this
primary: true, // TODO - Change this
parent: true, // TODO - Change this
reachable: false, // TODO - Change this
validated: false, // TODO - Change this
id: crypto.randomBytes(4).readUInt32LE()
},
region: 0x310B0000, // TODO: Change this
region: 0x310B0000, // TODO - Change this
timezone: {
name: 'America/New_York', // TODO: Change this
offset: -14400 // TODO: Change this
name: 'America/New_York', // TODO - Change this
offset: -14400 // TODO - Change this
},
mii: {
name: miiName,
primary: true, // TODO: Change this
primary: true, // TODO - Change this
data: mii.encode().toString('base64'),
id: crypto.randomBytes(4).readUInt32LE(),
hash: crypto.randomBytes(7).toString('hex'),
image_url: '', // deprecated, will be removed in the future
image_url: '', // * deprecated, will be removed in the future
image_id: crypto.randomBytes(4).readUInt32LE()
},
flags: {
active: true, // TODO: Change this
marketing: true, // TODO: Change this
off_device: true // TODO: Change this
active: true, // TODO - Change this
marketing: true, // TODO - Change this
off_device: true // TODO - Change this
},
identification: {
email_code: 1, // will be overwritten before saving
email_token: '' // will be overwritten before saving
email_code: 1, // * will be overwritten before saving
email_token: '' // * will be overwritten before saving
}
});

View File

@@ -6,7 +6,7 @@ import { getPNIDByPID } from '@/database';
import type { Empty } from '@pretendonetwork/grpc/api/google/protobuf/empty';
import type { Token } from '@/types/common/token';
// This sucks
// * This sucks
const PASSWORD_WORD_OR_NUMBER_REGEX = /(?=.*[a-zA-Z])(?=.*\d).*/;
const PASSWORD_WORD_OR_PUNCTUATION_REGEX = /(?=.*[a-zA-Z])(?=.*[_\-.]).*/;
const PASSWORD_NUMBER_OR_PUNCTUATION_REGEX = /(?=.*\d)(?=.*[_\-.]).*/;

View File

@@ -1,4 +1,4 @@
// handles NASC endpoints
// * handles NASC endpoints
import express from 'express';
import subdomain from 'express-subdomain';
@@ -7,20 +7,20 @@ import { LOG_INFO } from '@/logger';
import ac from '@/services/nasc/routes/ac';
// Router to handle the subdomain restriction
// * Router to handle the subdomain restriction
const nasc = express.Router();
LOG_INFO('[NASC] Importing middleware');
nasc.use(NASCMiddleware);
// Setup routes
// * Setup routes
LOG_INFO('[NASC] Applying imported routes');
nasc.use('/ac', ac);
// Main router for endpoints
// * Main router for endpoints
const router = express.Router();
// Create subdomains
// * Create subdomains
LOG_INFO('[NASC] Creating \'nasc\' subdomain');
router.use(subdomain('nasc', nasc));

View File

@@ -23,7 +23,7 @@ router.post('/', async (request: express.Request, response: express.Response): P
return;
}
// TODO: REMOVE AFTER PUBLIC LAUNCH
// TODO - REMOVE AFTER PUBLIC LAUNCH
// * LET EVERYONE IN THE `test` FRIENDS SERVER
// * THAT WAY EVERYONE CAN GET AN ASSIGNED PID
let serverAccessLevel = 'test';

View File

@@ -1,4 +1,4 @@
// handles "account.nintendo.net" endpoints
// * handles "account.nintendo.net" endpoints
import express from 'express';
import subdomain from 'express-subdomain';
@@ -16,7 +16,7 @@ import people from '@/services/nnas/routes/people';
import provider from '@/services/nnas/routes/provider';
import support from '@/services/nnas/routes/support';
// Router to handle the subdomain restriction
// * Router to handle the subdomain restriction
const nnas = express.Router();
LOG_INFO('[NNAS] Importing middleware');
@@ -24,7 +24,7 @@ nnas.use(clientHeaderCheck);
nnas.use(cemuMiddleware);
nnas.use(pnidMiddleware);
// Setup routes
// * Setup routes
LOG_INFO('[NNAS] Applying imported routes');
nnas.use('/v1/api/admin', admin);
nnas.use('/v1/api/content', content);
@@ -35,10 +35,10 @@ nnas.use('/v1/api/people', people);
nnas.use('/v1/api/provider', provider);
nnas.use('/v1/api/support', support);
// Main router for endpoints
// * Main router for endpoints
const router = express.Router();
// Create subdomains
// * Create subdomains
LOG_INFO('[NNAS] Creating \'account\' subdomain');
router.use(subdomain('account', nnas));

View File

@@ -132,8 +132,8 @@ router.get('/time_zones/:countryCode/:language', (request: express.Request, resp
response.set('X-Nintendo-Date', new Date().getTime().toString());
/*
// Old method. Crashes WiiU when sending a list with over 32 entries, but otherwise works
// countryTimezones is "countries-and-timezones" module
// * Old method. Crashes WiiU when sending a list with over 32 entries, but otherwise works
// * countryTimezones is "countries-and-timezones" module
const country = countryTimezones.getCountry(countryCode);
const timezones = country.timezones.map((timezone, index) => {

View File

@@ -51,7 +51,7 @@ router.get('/:username', async (request: express.Request, response: express.Resp
*/
router.post('/', ratelimit, deviceCertificateMiddleware, async (request: express.Request, response: express.Response): Promise<void> => {
if (!request.certificate || !request.certificate.valid) {
// TODO: Change this to a different error
// TODO - Change this to a different error
response.status(400).send(xmlbuilder.create({
error: {
cause: 'Bad Request',
@@ -95,11 +95,11 @@ router.post('/', ratelimit, deviceCertificateMiddleware, async (request: express
await nexAccount.generatePID();
await nexAccount.generatePassword();
// Quick hack to get the PIDs to match
// TODO: Change this maybe?
// NN with a NNID will always use the NNID PID
// even if the provided NEX PID is different
// To fix this we make them the same PID
// * Quick hack to get the PIDs to match
// TODO - Change this maybe?
// * NN with a NNID will always use the NNID PID
// * even if the provided NEX PID is different
// * To fix this we make them the same PID
nexAccount.owning_pid = nexAccount.pid;
await nexAccount.save({ session });
@@ -156,7 +156,7 @@ router.post('/', ratelimit, deviceCertificateMiddleware, async (request: express
data: person.mii.data,
id: crypto.randomBytes(4).readUInt32LE(),
hash: crypto.randomBytes(7).toString('hex'),
image_url: '', // deprecated, will be removed in the future
image_url: '', // * deprecated, will be removed in the future
image_id: crypto.randomBytes(4).readUInt32LE()
},
flags: {
@@ -165,8 +165,8 @@ router.post('/', ratelimit, deviceCertificateMiddleware, async (request: express
off_device: person.off_device_flag === 'Y'
},
identification: {
email_code: 1, // will be overwritten before saving
email_token: '' // will be overwritten before saving
email_code: 1, // * will be overwritten before saving
email_token: '' // * will be overwritten before saving
}
});
@@ -265,9 +265,9 @@ router.post('/@me/devices', async (request: express.Request, response: express.R
response.set('Server', 'Nintendo 3DS (http)');
response.set('X-Nintendo-Date', new Date().getTime().toString());
// We don't care about the device attributes
// The console ignores them and PNIDs are not tied to consoles anyway
// So the server also ignores them and does not save the ones posted here
// * We don't care about the device attributes
// * The console ignores them and PNIDs are not tied to consoles anyway
// * So the server also ignores them and does not save the ones posted here
// TODO - CHANGE THIS. WE NEED TO SAVE CONSOLE DETAILS !!!
@@ -652,8 +652,8 @@ router.get('/@me/emails', async (request: express.Request, response: express.Res
parent: pnid.email.parent ? 'Y' : 'N',
primary: pnid.email.primary ? 'Y' : 'N',
reachable: pnid.email.reachable ? 'Y' : 'N',
type: 'DEFAULT', // what is this?
updated_by: 'USER', // need to actually update this
type: 'DEFAULT', // * what is this?
updated_by: 'USER', // * need to actually update this
validated: pnid.email.validated ? 'Y' : 'N',
validated_date: pnid.email.validated_date,
}

View File

@@ -214,7 +214,7 @@ router.get('/nex_token/@me', async (request: express.Request, response: express.
const tokenOptions = {
system_type: server.device,
token_type: 0x3, // nex token,
token_type: 0x3, // * nex token,
pid: pnid.pid,
access_level: pnid.access_level,
title_id: BigInt(parseInt(titleID, 16)),

View File

@@ -48,7 +48,7 @@ export interface IPNID {
off_device: boolean;
};
devices: Types.DocumentArray<IDevice>;
identification: { // user identification tokens
identification: { // * user identification tokens
email_code: string;
email_token: string;
access_token: {

View File

@@ -1,7 +1,7 @@
import { YesNoBoolString } from '@/types/common/yes-no-bool-string';
export interface PNIDProfile {
//accounts: {}; // * We need to figure this out; no idea what these values mean or what they do
// *accounts: {}; // * We need to figure this out; no idea what these values mean or what they do
active_flag: YesNoBoolString;
birth_date: string;
country: string;

View File

@@ -209,7 +209,7 @@ export async function sendForgotPasswordEmail(pnid: mongoose.HydratedDocument<IP
pid: pnid.pid,
access_level: pnid.access_level,
title_id: BigInt(0),
expire_time: BigInt(Date.now() + (24 * 60 * 60 * 1000)) // Only valid for 24 hours
expire_time: BigInt(Date.now() + (24 * 60 * 60 * 1000)) // * Only valid for 24 hours
};
const tokenBuffer = await generateToken(config.aes_key, tokenOptions);