diff --git a/package-lock.json b/package-lock.json index 095f457..3225cc0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 66ff6ef..33344d2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/cli/seed.cmd.ts b/src/cli/seed.cmd.ts index 9594bdb..4b1d929 100644 --- a/src/cli/seed.cmd.ts +++ b/src/cli/seed.cmd.ts @@ -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 // 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; } diff --git a/src/types/boss-js.d.ts b/src/types/boss-js.d.ts deleted file mode 100644 index 50a45eb..0000000 --- a/src/types/boss-js.d.ts +++ /dev/null @@ -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; - hmac: Buffer; - content: Buffer; - }; - - export type DecryptionResult3ds = { - hash_type: number; - release_date: bigint; - iv: Buffer; - content_header_hash: Buffer; - content_header_hash_signature: Buffer; - payload_content_header_hash: Buffer; - payload_content_header_hash_signature: Buffer; - program_id: Buffer; - content_datatype: number; - ns_data_id: number; - content: Buffer; - }; - - 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; - export function encrypt(input: EncryptionInput, version: number, aesKey: string, hmacKey: string): Buffer; - export function decrypt(input: EncryptionInput, aesKey: EncryptionKey, hmacKey?: string): DecryptionResultWiiu | DecryptionResult3ds; - - export function encryptWiiU(input: EncryptionInput, aesKey: string, hmacKey: string): Buffer; - export function decryptWiiU(input: EncryptionInput, aesKey: string, hmacKey: string): DecryptionResultWiiu; - - export function encrypt3DS(input: EncryptionInput, aesKey: EncryptionKey, options: EncryptionOptions3ds): Buffer; - export function decrypt3DS(input: EncryptionInput, aesKey: EncryptionKey): DecryptionResult3ds; -} diff --git a/update-rotation.mjs b/update-rotation.mjs index aaf9ae0..6569fa1 100644 --- a/update-rotation.mjs +++ b/update-rotation.mjs @@ -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}`);