mirror of
https://github.com/PretendoNetwork/BOSS.git
synced 2026-08-20 16:14:08 -05:00
Added npdi service
This commit is contained in:
BIN
cdn/content/decrypted/rjVlM7hUXPxmYQJh/Festival.byaml
Normal file
BIN
cdn/content/decrypted/rjVlM7hUXPxmYQJh/Festival.byaml
Normal file
Binary file not shown.
BIN
cdn/content/decrypted/rjVlM7hUXPxmYQJh/HapTexture.bfres
Normal file
BIN
cdn/content/decrypted/rjVlM7hUXPxmYQJh/HapTexture.bfres
Normal file
Binary file not shown.
BIN
cdn/content/decrypted/rjVlM7hUXPxmYQJh/PanelTexture.bfres
Normal file
BIN
cdn/content/decrypted/rjVlM7hUXPxmYQJh/PanelTexture.bfres
Normal file
Binary file not shown.
Binary file not shown.
21
encrypt-contents.js
Normal file
21
encrypt-contents.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const BOSS = require('boss-js');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const crypto = require('crypto');
|
||||
require('dotenv').config();
|
||||
|
||||
// PROVIDE THESE KEYS YOURSELF
|
||||
const { BOSS_AES_KEY, BOSS_HMAC_KEY } = process.env;
|
||||
|
||||
const decryptedFilePath = path.normalize(path.resolve(__dirname, process.argv[2]));
|
||||
const encryptedFolderName = path.basename(path.dirname(decryptedFilePath));
|
||||
const encryptedFolderPath = path.normalize(path.resolve(decryptedFilePath, '../../../encrypted', encryptedFolderName));
|
||||
|
||||
fs.ensureDirSync(encryptedFolderPath);
|
||||
|
||||
const encryptedContents = BOSS.encryptWiiU(decryptedFilePath, BOSS_AES_KEY, BOSS_HMAC_KEY);
|
||||
const hash = crypto.createHash('md5').update(encryptedContents).digest('hex');
|
||||
|
||||
const encryptedFilePath = path.normalize(path.resolve(encryptedFolderPath, hash));
|
||||
|
||||
fs.writeFileSync(encryptedFilePath, encryptedContents);
|
||||
@@ -10,6 +10,7 @@ const app = express();
|
||||
|
||||
const nptsService = require('./services/npts');
|
||||
const npplService = require('./services/nppl');
|
||||
const npdiService = require('./services/npdi');
|
||||
|
||||
// START APPLICATION
|
||||
app.set('etag', false);
|
||||
@@ -25,6 +26,7 @@ app.use(express.urlencoded({
|
||||
|
||||
app.use(nptsService);
|
||||
app.use(npplService);
|
||||
app.use(npdiService);
|
||||
|
||||
// 404 handler
|
||||
logger.info('Creating 404 status handler');
|
||||
|
||||
31
src/services/npdi.js
Normal file
31
src/services/npdi.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const express = require('express');
|
||||
const subdomain = require('express-subdomain');
|
||||
|
||||
// Router to handle the subdomain restriction
|
||||
const npdi = express.Router();
|
||||
|
||||
// Setup routes
|
||||
npdi.get('/p01/data/1/:titleHash/:fileVersion/:fileHash', (request, response) => {
|
||||
const { titleHash, fileHash } = request.params;
|
||||
const contentPath = path.normalize(`${__dirname}/../../cdn/content/encrypted/${titleHash}/${fileHash}`);
|
||||
|
||||
if (fs.existsSync(contentPath)) {
|
||||
response.set('Content-Type', 'applicatoin/octet-stream');
|
||||
response.set('Content-Disposition', 'attachment');
|
||||
response.set('Content-Transfer-Encoding', 'binary');
|
||||
response.set('Content-Type', 'applicatoin/octet-stream');
|
||||
response.sendFile(contentPath);
|
||||
} else {
|
||||
response.sendStatus(404);
|
||||
}
|
||||
});
|
||||
|
||||
// Main router for endpoints
|
||||
const router = express.Router();
|
||||
|
||||
// Create subdomain
|
||||
router.use(subdomain('npdi.app', npdi));
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user