Skip to content

Commit

Permalink
Merge pull request #1 from PretendoNetwork/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbarrow committed Jul 8, 2024
2 parents 0cff403 + 010b91d commit c446520
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,49 @@
npm i @pretendonetwork/nintendo-files
```

## Usage
This package makes use of the [`"exports"` entry point](https://nodejs.org/api/packages.html#package-entry-points). 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.

```ts
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.

```ts
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)
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pretendonetwork/nintendo-files",
"version": "1.0.0",
"version": "1.0.2",
"description": "TypeScript library for interacting with several Nintendo file formats across various consoles.",
"scripts": {
"lint": "npx eslint .",
Expand All @@ -23,6 +23,9 @@
"image-encode": "^1.3.1",
"node-rsa": "^1.1.1"
},
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/index.js",
Expand Down

0 comments on commit c446520

Please sign in to comment.