open-index/open-npm huggingface dataset:
npm package: @secure-input/core
Description: Framework-agnostic input obfuscation library with WASM encryption
Author: Suneth Chathuranga
Latest version: 0.2.1

# @secure-input/core

Framework-agnostic input obfuscation library with WASM encryption.

## Installation

```bash
npm install @secure-input/core
```

## Usage

```typescript
import { SecureInput } from "@secure-input/core";

// Create instance
const secureInput = new SecureInput({
  onEncrypt: (encrypted) => {
    console.log("Encrypted:", encrypted);
  },
  onError: (error) => {
    console.error("Error:", error);
  },
  debug: true,
});

// Encrypt a value
const encrypted = await secureInput.encrypt("COUPON2024");

// Decrypt a value
const decrypted = await secureInput.decrypt(encrypted);

// Clean up
secureInput.destroy();
```

## API

### `new SecureInput(config?)`

Create a new SecureInput instance.

**Config options:**

- `key?: Uint8Array` - Custom 32-byte encryption key (optional, random generated if not provided)
- `onEncrypt?: (encrypted: string) => void` - Callback when encryption completes
- `onError?: (error: Error) => void` - Error handler
- `debug?: boolean` - Enable debug logging

### `encrypt(value: string): Promise<string>`

Encrypt a string value. Returns base64-encoded ciphertext.

### `decrypt(encrypted: string): Promise<string>`

Decrypt a base64-encoded ciphertext.

### `destroy(): void`

Terminate the worker and clean up resources.

## Size

~15KB gzipped (including worker)
npm package: @secure-input/react
Description: React hooks and components for secure-input library
Author: Suneth Chathuranga
Latest version: 0.2.1

# @secure-input/react

React hooks and components for the secure-input library.

## Installation

```bash
npm install @secure-input/react
```

## Usage

### SecureInput Component

```tsx
import { SecureInput } from "@secure-input/react";

function CouponForm() {
  const handleSubmit = async (encryptedValue: string) => {
    // Send encrypted value to server
    const response = await fetch("/api/validate-coupon", {
      method: "POST",
      headers: { "Content-Type": "text/plain" },
      body: encryptedValue,
    });

    const result = await response.json();
    console.log("Coupon valid:", result.valid);
  };

  return (
    <SecureInput
      placeholder="Enter coupon code"
      onEncryptedSubmit={handleSubmit}
      showStatus={true}
    />
  );
}
```

### useSecureInput Hook

```tsx
import { useSecureInput } from "@secure-input/react";
import { useState } from "react";

function CustomForm() {
  const [input, setInput] = useState("");
  const { encrypt, isReady, error } = useSecureInput();

  const handleSubmit = async (e) => {
    e.preventDefault();
    if (isReady) {
      const encrypted = await encrypt(input);
      console.log("Encrypted:", encrypted);
    }
  };

  return (
    <form onSubmit={handleSubmit}>
      <input
        value={input}
        onChange={(e) => setInput(e.target.value)}
        disabled={!isReady}
      />
      <button type="submit" disabled={!isReady}>
        Submit
      </button>
      {error && <p>Error: {error.message}</p>}
    </form>
  );
}
```

## API

### `<SecureInput>` Component

**Props:**

- `onEncryptedSubmit?: (encrypted: string) => void | Promise<void>` - Called when form is submitted with encrypted value
- `onChange?: (value: string) => void` - Called when input changes (plain text)
- `placeholder?: string` - Input placeholder text
- `className?: string` - CSS class name
- `name?: string` - Input name attribute
- `showStatus?: boolean` - Show encryption status (default: true)
- `inputProps?: React.InputHTMLAttributes<HTMLInputElement>` - Additional input props
- All `UseSecureInputOptions`

### `useSecureInput(options?)` Hook

**Options:**

- `autoInit?: boolean` - Auto-initialize on mount (default: true)
- `key?: Uint8Array` - Custom encryption key
- `debug?: boolean` - Enable debug logging

**Returns:**

- `encrypt: (value: string) => Promise<string>` - Encrypt a value
- `decrypt: (encrypted: string) => Promise<string>` - Decrypt a value
- `isReady: boolean` - Whether encryption is ready
- `encryptedValue: string | null` - Latest encrypted value
- `error: Error | null` - Latest error
- `initialize: () => Promise<void>` - Manually initialize

## Size

~5KB gzipped (excluding dependencies)
npm package: @secure-input/wasm
Description: WASM encryption module for secure-input library
Author: Suneth Chathuranga
Latest version: 0.2.3

# @secure-input/wasm

WebAssembly encryption module for the secure-input library.

Uses ChaCha20Poly1305 authenticated encryption compiled from Rust to WASM for maximum performance and security.

## Size

~10KB gzipped

## Usage

This package is typically not used directly. It's a dependency of `@secure-input/core`.

## Build

Requires Rust and wasm-pack:

```bash
cargo install wasm-pack
pnpm build
```