Skip to content

Types

Complete reference for all TypeScript types exported by Node-APK.

Main Types

ResourceValue

typescript
type ResourceValue = number | string | boolean | null;

Represents a possible value from the resource table.

TypeDescription
numberInteger or reference to another resource
stringString value
booleanBoolean value (from res/values/bools.xml)
nullNull or undefined value

LabelOptions

typescript
interface LabelOptions {
  /** Preferred locale for the label (e.g., "en", "fr", "zh") */
  locale?: string;
}

Options for Apk.getLabel() method.


IconOptions

typescript
interface IconOptions {
  /** Preferred icon density */
  density?: IconDensity;
}

Options for Apk.getLauncherIcon() method.


IconDensity

typescript
type IconDensity = 
  | "mdpi"     // Medium density (~160 dpi)
  | "hdpi"     // High density (~240 dpi)
  | "xhdpi"    // Extra high density (~320 dpi)
  | "xxhdpi"   // Extra extra high density (~480 dpi)
  | "xxxhdpi"  // Extra extra extra high density (~640 dpi)
  | "nodpi"    // No scaling
  | "anydpi";  // Vector/adaptive icons

Icon density values for resource resolution.


BufferLoader

typescript
type BufferLoader = () => Promise<Buffer>;

Function type for asynchronously loading a buffer.

Enums

ChunkType

typescript
enum ChunkType {
  NULL = 0x0000,
  STRING_POOL = 0x0001,
  TABLE = 0x0002,
  XML = 0x0003,
  XML_START_NAMESPACE = 0x0100,
  XML_END_NAMESPACE = 0x0101,
  XML_START_ELEMENT = 0x0102,
  XML_END_ELEMENT = 0x0103,
  XML_CDATA = 0x0104,
  XML_RESOURCE_MAP = 0x0180,
  TABLE_PACKAGE = 0x0200,
  TABLE_TYPE = 0x0201,
  TABLE_TYPE_SPEC = 0x0202,
  TABLE_LIBRARY = 0x0203,
}

Binary chunk types used in Android resource files.

Class Types

Manifest

typescript
class Manifest {
  readonly package: string;
  readonly versionCode: number;
  readonly versionName: string;
  readonly applicationLabel: string | number;
  readonly applicationIcon: number;
  readonly permissions: Iterable<string>;
  readonly receivers: Iterable<Receiver>;
  readonly raw: XmlElement;
}

Receiver

typescript
class Receiver {
  readonly name: string;
  readonly permission: string;
  readonly exported: boolean;
  readonly raw: XmlElement;
}

Certificate

typescript
class Certificate {
  readonly serial: string;
  readonly validFrom: Date;
  readonly validUntil: Date;
  readonly issuer: Map<string, string>;
  readonly subject: Map<string, string>;
  readonly bytes: Buffer;
  readonly parent?: Certificate;
  readonly chain: Certificate[];
  
  static fromPkcs7(buffer: Buffer): Certificate[];
  static fromDer(...certificates: Buffer[]): Certificate[];
}

Resources

typescript
class Resources {
  resolve(id: number): Resource[];
}

Resource

typescript
class Resource {
  readonly value: ResourceValue;
  readonly locale?: Locale;
}

Locale

typescript
class Locale {
  readonly language?: string;  // Two-letter code (e.g., "en")
  readonly country?: string;   // Two-letter code (e.g., "US")
}

XmlElement

typescript
class XmlElement {
  readonly tag: string;
  readonly attributes: Record<string, unknown>;
  readonly children: Record<string, XmlElement[]>;
  
  toString(): string;
}

Source

typescript
class Source {
  constructor(buffer: Buffer);
  
  readUByte(): number;
  readUShort(): number;
  readUInt(): number;
  readInt(): number;
  readUtf8String(size: number): string;
  readUtf16String(size: number): string;
  source(size: number): Source;
  getCursorAndMove(offset: number): number;
  moveAt(position: number): void;
  stream(size: number): Readable;
  
  readonly cursor: number;
  readonly buffer: Buffer;
}

ZipEntry

typescript
class ZipEntry {
  static lookup(loader: BufferLoader, key: string): Promise<ZipEntry>;
  static index(loader: BufferLoader): Promise<Map<string, ZipEntry>>;
  
  readonly name: string;
  readonly compressedSize: number;
  readonly unCompressedSize: number;
  
  stream(): Readable;
}

Chunk

typescript
class Chunk {
  constructor(source: Source, chunkType?: ChunkType);
  
  readonly type: number;
  readonly headerSize: number;
  readonly chunkSize: number;
  readonly headerSource: Source;
  readonly chunkSource: Source;
}

StringPool

typescript
class StringPool {
  constructor(chunk: Chunk);
  
  readonly stringCount: number;
  readonly styleCount: number;
  readonly flags: number;
  readonly stringsStart: number;
  readonly stylesStart: number;
  readonly values: string[];
}

Utility Functions

parseResourceValue

typescript
function parseResourceValue(
  source: Source, 
  stringPool: StringPool
): ResourceValue;

Parses a typed resource value from binary data.

Import Examples

Named Imports

typescript
import { 
  Apk, 
  Manifest, 
  Certificate,
  Resources,
  type ResourceValue,
  type LabelOptions,
  type IconOptions,
} from "node-apk";

Type-Only Imports

typescript
import type { 
  ResourceValue, 
  LabelOptions, 
  IconOptions,
  IconDensity,
} from "node-apk";

Re-Exporting Types

typescript
export type { 
  ResourceValue, 
  LabelOptions,
  IconOptions,
  IconDensity,
} from "node-apk";

Released under the MIT License.