TypeScript type definitions for KaiOS. Currently supports KaiOS v2.5, the successor to Firefox OS also known as Boot2Gecko (B2G).
This package provides comprehensive TypeScript type definitions for the proprietary Web APIs available in KaiOS. These APIs give access to telephony, SMS, Bluetooth, WiFi, contacts, camera, and more.
Note: Most of these APIs are non-standard and proprietary to KaiOS platform. Many require specific permissions in your app's manifest (manifest.webapp) and are restricted to certain app types (i.e. privileged or certified).
For more information on KaiOS development, see the KaiOS Developer Portal, KaiOS.dev blog, and BananaHackers website.
NPM
npm install --save-dev kaios-types
PNPM
pnpm add kaios-types --save-dev
Bun
bun add --development kaios-types
Add the types to your tsconfig.json:
{
"compilerOptions": {
"types": ["kaios-types"]
}
}
Or use a triple-slash directive at the top of your TypeScript files:
/// <reference types="kaios-types" />
// Now KaiOS APIs are available with full type checking
const settings = navigator.mozSettings;
settings.createLock().set({ 'wifi.enabled': true });
You can also import specific types directly:
import { MozActivity, ActivityOptions } from 'kaios-types/apps/moz-activity';
import { BluetoothManager } from 'kaios-types/bluetooth/bluetooth-manager';
const activity = new MozActivity({
name: 'pick',
data: { type: 'image/jpeg' }
});
const sms = navigator.mozMobileMessage;
const request = sms.send('+1234567890', 'Hello from KaiOS!');
request.onsuccess = () => {
console.log('SMS sent successfully');
};
request.onerror = () => {
console.error('Failed to send SMS:', request.error);
};
const wifi = navigator.mozWifiManager;
// Enable WiFi
wifi.setWifiEnabled(true);
// Scan for networks
const request = wifi.getNetworks();
request.onsuccess = () => {
const networks = request.result;
networks.forEach((network) => {
console.log(`Found network: ${network.ssid}`);
});
};
const contacts = navigator.mozContacts;
const request = contacts.find({
filterBy: ['givenName'],
filterValue: 'John',
filterOp: 'contains'
});
request.onsuccess = () => {
const cursor = request.result;
cursor.forEach((contact) => {
console.log(`Contact: ${contact.givenName} ${contact.familyName}`);
});
};
const volumeManager = navigator.volumeManager;
// Increase volume
volumeManager.requestUp();
// Decrease volume
volumeManager.requestDown();
// Show volume UI
volumeManager.requestShow();
For detailed API documentation and usage guidelines, see:
Contributions are welcome! Please feel free to submit issues or pull requests.