Matthew Raymer 5cf9bb89fc feat: Add comprehensive README and enhance package.json
- Create detailed README.md documenting Safari Notifications Module
- Explain project purpose: PWA abstraction for browser worker compatibility
- Document cryptographic features: JWT, NaCl encryption, DID authentication
- Add security audit checklist and development standards
- Include usage examples and API reference
- Enhance package.json with proper metadata and build scripts
- Add npm scripts: build and dev for development workflow
- Include project keywords and author information

This module handles secure notifications for Safari extensions and PWAs,
specifically designed for browser worker contexts with cryptographic
operations and IndexedDB integration.
2025-07-23 07:22:35 +00:00
2023-11-06 17:30:27 +08:00
2023-11-09 05:13:41 -05:00

Safari Notifications Module

A specialized JavaScript module designed to handle secure notifications for Safari browser extensions and Progressive Web Applications (PWAs). This module abstracts the complex cryptographic operations and IndexedDB interactions required for secure notification processing in browser worker contexts.

Overview

This project was created to separate the PWA build process from the main application, specifically addressing the need to make JavaScript code compatible with browser worker processes. The module provides secure authentication, data encryption/decryption, and notification counting functionality for Safari-based applications.

Features

🔐 Cryptographic Operations

  • JWT Token Generation: Creates secure access tokens using ES256K signing
  • Message Encryption/Decryption: Uses NaCl (TweetNaCl) for secure message handling
  • Digital Signatures: Implements ECDSA signatures with secp256k1 curve
  • Hash Functions: SHA-256 hashing for data integrity

💾 Data Management

  • IndexedDB Integration: Secure storage for settings, accounts, and contacts
  • Local Storage: Encrypted secret management
  • Database Operations: CRUD operations for user data

🔔 Notification System

  • Secure API Communication: Authenticated requests to external notification services
  • Notification Counting: Retrieves and processes notification data
  • DID-based Authentication: Decentralized identifier support

Architecture

Core Components

  1. Cryptographic Utilities (src/safari-notifications.js)

    • JWT creation and signing
    • Message encryption/decryption
    • Digital signature generation
    • Encoding/decoding utilities
  2. Data Access Layer

    • IndexedDB operations for settings, accounts, and contacts
    • Local storage management
    • Promise-based async operations
  3. Notification Service

    • Secure API communication
    • Authentication token management
    • Notification data processing

Build Configuration

The project uses Webpack with specific configurations for browser worker compatibility:

  • Target: webworker - Optimized for service worker contexts
  • Library Target: self - Exports to global scope
  • Mode: production - Optimized for deployment
  • Fallbacks: Crypto module disabled for browser compatibility

Installation

npm install

Dependencies

  • @noble/curves: Cryptographic curve operations (secp256k1)
  • @noble/hashes: Hash function implementations (SHA-256)
  • tweetnacl: High-security cryptographic library
  • tweetnacl-util: Utility functions for TweetNaCl
  • webpack: Module bundler
  • webpack-cli: Webpack command line interface

Usage

Building the Module

npm run build

This creates a bundled JavaScript file in the dist/ directory optimized for browser worker contexts.

Integration

// Import the module in your service worker or web worker
importScripts('./dist/safari-notifications.js');

// Use the exported functions
const notificationCount = await getNotificationCount();

API Reference

getNotificationCount()

Retrieves the notification count for the active DID (Decentralized Identifier).

Returns: Promise

Description
No description provided
Readme 230 KiB
Languages
JavaScript 100%