npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pretendonetwork/nintendo-files

v1.0.2

Published

TypeScript library for interacting with several Nintendo file formats across various consoles.

Downloads

2

Readme

Nintendo File Formats

TypeScript library for interacting with several Nintendo file formats across various consoles.

Installation

npm i @pretendonetwork/nintendo-files

Usage

This package makes use of the "exports" entry point. Ensure your tsconfig.json is configured for this.

Each file type may be imported both individually through separate import paths, or as named exports from the package root.

import BYAML from '@pretendonetwork/nintendo-files/byaml';
import BYML from '@pretendonetwork/nintendo-files/byml'; // Alias of byaml export
import Certificate from '@pretendonetwork/nintendo-files/certificate';
import CIA from '@pretendonetwork/nintendo-files/cia';
import MSBT from '@pretendonetwork/nintendo-files/msbt';
import SMDH from '@pretendonetwork/nintendo-files/smdh';
import Ticket from '@pretendonetwork/nintendo-files/ticket';
import TMD from '@pretendonetwork/nintendo-files/tmd';

import {
	BYAML,
	BYML, // Alias of byaml export
	Certificate,
	CIA,
	MSBT,
	SMDH,
	Ticket,
	TMD
} from '@pretendonetwork/nintendo-files';

In order to parse each file, call one of the provided parser methods. Methods exist both as instance and static methods for convenience. Each method is designed for parse the data from various data sources. Each class has the same common parser methods. For file specific methods and fields, see the classes type defs.

import CIA from '@pretendonetwork/nintendo-files/cia';

let cia: CIA;

cia = CIA.fromFile(fs.openSync('./nimbus.cia')); // Open file `fd`
cia = CIA.fromFile('./nimbus.cia'); // File path on disk
cia = CIA.fromBuffer(Buffer.from('...')); // Data as a buffer
cia = CIA.fromString('...'); // Base64 encoded data string
cia = CIA.fromFileStream(stream); // Mostly used for internal use. Accepts a FileStream from this library

Some classes support encoding the data back into a buffer. This is done through a bytes() method on each class. See below for a list of file type support.

Supported files (parsing)

  • [x] CIA. Does not decrypt contents
  • [x] Certificates. Signature verification works, just not on illegitimate signatures (homebrew, forged tickets, etc)
  • [x] SMDH. All data is extracted, but some pieces (like several sections of Application Settings) are left as Buffer blobs
  • [x] TMD
  • [x] Ticket. Does not decrypt title key
  • [ ] Encrypted title parts (.app files)
  • [ ] Title hashes (.h3 files)
  • [ ] Mii data
  • [x] MSBT. Parses:
    • [x] LBL1
    • [x] ATR1
    • [x] TXT2
    • [x] NLI1
    • [ ] TSY1
  • [x] BYML/BYAML
  • [ ] SARC
  • [ ] SZS (Yaz0)

Supported files (encoding)

  • [ ] CIA. Does not decrypt contents
  • [x] Certificates. Signature verification works, just not on illegitimate signatures (homebrew, forged tickets, etc)
  • [ ] SMDH. All data is extracted, but some pieces (like several sections of Application Settings) are left as Buffer blobs
  • [x] TMD
  • [x] Ticket. Does not decrypt title key
  • [ ] Encrypted title parts (.app files)
  • [ ] Title hashes (.h3 files)
  • [ ] Mii data
  • [ ] MSBT
  • [ ] BYML/BYAML
  • [ ] SARC
  • [ ] SZS (Yaz0)

Example

import fs from 'node:fs';
import CIA from '@pretendonetwork/nintendo-files/cia';

const cia = CIA.fromFile(`${__dirname}/nimbus.cia`);

console.log(cia.CACertificate.verifySignature(cia.TMDCertificate)); // true. Certificates are signed by Nintendo, and should always pass
console.log(cia.CACertificate.verifySignature(cia.ticketCertificate)); // true. Certificates are signed by Nintendo, and should always pass
console.log(cia.TMDCertificate.verifySignature(cia.TMD)); // false. Example Nimbus is a homebrew title, not signed by Nintendo. Nintendo signatures return true
console.log(cia.ticketCertificate.verifySignature(cia.ticket)); // false. Example Nimbus is a homebrew title, not signed by Nintendo. Nintendo signatures return true

if (cia.meta) {
	const largeIconData = cia.meta.iconData.exportLargeImage();
	fs.writeFileSync('./icon-large.png', largeIconData); // 48x48px SMDH icon from the CIA meta section

	console.log(cia.meta.iconData.getEnglishApplicationTitle());
	//{
	//	descriptionShort: 'Nimbus',
	//	descriptionLong: 'Nimbus',
	//	publisher: 'Zaksabeast, shutterbug2000'
	//}
}