chore: remove boss-js, switch to boss-crypto

This commit is contained in:
mrjvs
2025-09-16 18:22:23 +02:00
parent 6d7bab5536
commit 6418d5fa58
5 changed files with 4 additions and 57 deletions

10
package-lock.json generated
View File

@@ -13,7 +13,6 @@
"@pretendonetwork/boss-crypto": "^1.0.0",
"@pretendonetwork/grpc": "^1.0.6",
"@typegoose/auto-increment": "^3.6.1",
"boss-js": "github:PretendoNetwork/boss-js",
"commander": "^14.0.0",
"dicer": "^0.3.1",
"dotenv": "^16.4.7",
@@ -4302,11 +4301,6 @@
"node": ">= 0.8"
}
},
"node_modules/boss-js": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/PretendoNetwork/boss-js.git#fb870d45a680388af4416c499e5ebffeccb8e0c5",
"license": "ISC"
},
"node_modules/bowser": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz",
@@ -12777,10 +12771,6 @@
}
}
},
"boss-js": {
"version": "git+ssh://git@github.com/PretendoNetwork/boss-js.git#fb870d45a680388af4416c499e5ebffeccb8e0c5",
"from": "boss-js@github:PretendoNetwork/boss-js"
},
"bowser": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz",

View File

@@ -17,7 +17,6 @@
"@pretendonetwork/boss-crypto": "^1.0.0",
"@pretendonetwork/grpc": "^1.0.6",
"@typegoose/auto-increment": "^3.6.1",
"boss-js": "github:PretendoNetwork/boss-js",
"commander": "^14.0.0",
"dicer": "^0.3.1",
"dotenv": "^16.4.7",

View File

@@ -2,7 +2,7 @@ import path from 'path';
import fs from 'fs/promises';
import { Command } from 'commander';
import { xml2js } from 'xml-js';
import BOSS from 'boss-js';
import { decryptWiiU } from '@pretendonetwork/boss-crypto';
import { getCliContext } from './utils';
import { seedFolder } from './root';
import type { CliContext } from './utils';
@@ -27,7 +27,7 @@ export async function uploadFileIfChanged(ops: UploadFileOptions): Promise<void>
// File is encrypted, let's decrypt before processing
console.log(`${ops.dataId}: File is encrypted, decrypting...`);
const keys = ops.ctx.getWiiUKeys();
const decryptedContents = BOSS.decryptWiiU(fileContents, keys.aesKey, keys.hmacKey);
const decryptedContents = decryptWiiU(fileContents, keys.aesKey, keys.hmacKey);
fileContents = decryptedContents.content;
}

View File

@@ -1,42 +0,0 @@
declare module 'boss-js' {
export type EncryptionInput = Buffer | string;
export type EncryptionKey = Buffer | string;
export type DecryptionResultWiiu = {
hash_type: number;
iv: Buffer<ArrayBuffer>;
hmac: Buffer<ArrayBuffer>;
content: Buffer<ArrayBuffer>;
};
export type DecryptionResult3ds = {
hash_type: number;
release_date: bigint;
iv: Buffer<ArrayBuffer>;
content_header_hash: Buffer<ArrayBuffer>;
content_header_hash_signature: Buffer<ArrayBuffer>;
payload_content_header_hash: Buffer<ArrayBuffer>;
payload_content_header_hash_signature: Buffer<ArrayBuffer>;
program_id: Buffer<ArrayBuffer>;
content_datatype: number;
ns_data_id: number;
content: Buffer<ArrayBuffer>;
};
export type EncryptionOptions3ds = {
program_id?: string;
title_id?: number;
content_datatype: number;
ns_data_id: number;
};
export function encrypt(input: EncryptionInput, version: number, aesKey: string, options: EncryptionOptions3ds): Buffer<ArrayBuffer>;
export function encrypt(input: EncryptionInput, version: number, aesKey: string, hmacKey: string): Buffer<ArrayBuffer>;
export function decrypt(input: EncryptionInput, aesKey: EncryptionKey, hmacKey?: string): DecryptionResultWiiu | DecryptionResult3ds;
export function encryptWiiU(input: EncryptionInput, aesKey: string, hmacKey: string): Buffer<ArrayBuffer>;
export function decryptWiiU(input: EncryptionInput, aesKey: string, hmacKey: string): DecryptionResultWiiu;
export function encrypt3DS(input: EncryptionInput, aesKey: EncryptionKey, options: EncryptionOptions3ds): Buffer<ArrayBuffer>;
export function decrypt3DS(input: EncryptionInput, aesKey: EncryptionKey): DecryptionResult3ds;
}

View File

@@ -3,10 +3,10 @@
import path from 'path';
import crypto from 'crypto';
import readline from 'readline';
import BOSS from 'boss-js';
import fs from 'fs-extra';
import dotenv from 'dotenv';
import xml from 'xml-js';
import { encryptWiiU } from '@pretendonetwork/boss-crypto';
dotenv.config();
@@ -105,7 +105,7 @@ for (const title of titles) {
await backupFile(decryptedFilePath);
await fs.copyFile(sourceFile, decryptedFilePath);
const encryptedContents = BOSS.encryptWiiU(decryptedFilePath, PN_BOSS_CONFIG_BOSS_WIIU_AES_KEY, PN_BOSS_CONFIG_BOSS_WIIU_HMAC_KEY);
const encryptedContents = encryptWiiU(decryptedFilePath, PN_BOSS_CONFIG_BOSS_WIIU_AES_KEY, PN_BOSS_CONFIG_BOSS_WIIU_HMAC_KEY);
const hash = crypto.createHash('md5').update(encryptedContents).digest('hex');
console.log(`Hash for title ${title} is ${hash}`);