open-index/open-npm huggingface dataset:
npm package: @hazae41/uncopy
Description: Zero-copy bytes
Author: hazae41
Latest version: 1.0.5

# Uncopy

Zero-copy bytes

```bash
npm i @hazae41/uncopy
```

[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/uncopy)

## Features
- 100% TypeScript and ESM
- Rust-like patterns
npm package: @hazae41/wasm
Description: WebAssembly Binary Format (.wasm) decoder-modifier-encoder for TypeScript
Author: hazae41
Latest version: 1.0.0

# WASM

WebAssembly Binary Format (.wasm) decoder-modifier-encoder for TypeScript

```bash
npm install @hazae41/wasm
```

```bash
deno install jsr:@hazae41/wasm
```

[**📦 NPM**](https://www.npmjs.com/package/@hazae41/wasm) • [**📦 JSR**](https://jsr.io/@hazae41/wasm)

## Features

### Current features
- 100% TypeScript and ESM
- No external dependencies
- Rust-like patterns
- No validation done
- Easily edit .wasm
- Latest specification

## Usage 

```tsx
import * as Wasm from "@hazae41/wasm"
import { Readable, Writable } from "@hazae41/binary"
import { readFileSync, writeFileSync } from "node:fs"

const module = Readable.readFromBytesOrThrow(Wasm.Module, readFileSync("./mod.wasm"))

const imports = module.body.sections.find(section => section.kind === Wasm.ImportSection.kind)! as Wasm.ImportSection

console.log(imports) // Show all imports

const start = module.body.sections.find(section => section.kind === Wasm.StartSection.kind)! as Wasm.StartSection

start.funcidx = 3 // Change start function

writeFileSync("./mod.wasm", Writable.writeToBytesOrThrow(module))
```
npm package: @hazae41/webauthnstorage
Description: Deterministic storage using WebAuthn
Author: hazae41
Latest version: 1.0.3

# WebAuthnStorage

Deterministic storage using WebAuthn

```bash
npm install @hazae41/webauthnstorage
```

[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/webauthnstorage)

## About

Use WebAuthn as a authentication-protected storage of arbitrary bytes

This WON'T use any cryptoprocessor (HSM, Secure Enclave) as it stores the bytes in `userHandle` (probably on disk)

This is only used to prevent unauthenticated access to the stored values

Supply-chain attacks, phishing, misclick, phone-left-on-the-table attack would still require user authentication before accessing the data

## Features

### Current features
- 100% TypeScript and ESM
- No external dependencies
- Battle-tested on many browsers

## Usage

```tsx
import { webAuthnStorage } from "@hazae41/webauthnstorage"

async function create() {
  /**
   * Generate a new private key
   */
  const bytes = crypto.getRandomValues(new Uint8Array(32))

  /**
   * Store the private key into authenticated storage
   */
  const handle = await webAuthnStorage.create("My Private Key", bytes)
  
  /**
   * Store the handle to the private key into some unauthenticated storage
   */
  const cache = await caches.open("my-storage")
  const request = new Request("my-private-key")
  const response = new Response(handle)
  await cache.put(request, response)
}

async function get() {
  /**
   * Retrieve the handle to the private key from some unauthenticated storage
   */
  const cache = await caches.open("my-storage")
  const request = new Request("my-private-key")
  const response = await cache.match(request)
  const handle = new Uint8Array(await response.arrayBuffer())

  /**
   * Retrieve the private key from authenticated storage
   */
  const bytes = await webAuthnStorage.get(handle)
}
```

## Limitations

### Storage size

Values must have a maximum length of 64 bytes

https://github.com/w3c/webauthn/issues/1302

I recommend only storing private keys, signatures, and identifiers

### User interation

This requires user interaction on most browsers

e.g. You have to create and get when the user clicks a button

```tsx
const [handle, setHandle] = useState<Uint8Array>()

const onCreateClick = useCallback(async () => {
  const bytes = crypto.getRandomValues(new Uint8Array(32))
  const handle = await webAuthnStorage.create("My Private Key", bytes)

  setHandle(handle)
}, [])

const onGetClick = useCallback(async () => {
  const bytes = await webAuthnStorage.get(handle)

  console.log(bytes)
}, [handle])

return <>
  <button onClick={onCreateClick}>
    Create
  </button>
  <button onClick={onGetClick}>
    Get
  </button>
</>
```
npm package: @hazae41/worker-online-polyfill
Description: Polyfill for online and offline events on WebWorkers
Author: hazae41
Latest version: 1.0.0

# WebWorkers "online" and "offline" events polyfill

Polyfill for `online` and `offline` events on WebWorkers

https://issues.chromium.org/issues/40155587

```bash
npm i @hazae41/worker-online-polyfill
```

[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/worker-online-polyfill) • [**Deno Module 🦖**](https://deno.land/x/worker_online_polyfill)

## Features
- ESModules and CommonJS
- No external dependency

## Usage

### How?

ESModules 

```tsx
import "@hazae41/worker-online-polyfill"
```

CommonJS

```tsx
require("@hazae41/worker-online-polyfill")
```

Deno

```tsx
import "https://deno.land/x/worker_online_polyfill/src/mod.ts"
```

### Where? 

You can import the polyfill **in your worker entry file** or **in a specific file**

```tsx
import "@hazae41/worker-online-polyfill"

self.addEventListener("online", () => console.log("online"))
self.addEventListener("offline", () => console.log("offline"))
```
npm package: @hazae41/x25519
Description: X25519 adapter for WebAssembly and JS implementations
Author: hazae41
Latest version: 2.2.11

# X25519

X25519 adapter for WebAssembly and JS implementations

```bash
npm i @hazae41/x25519
```

[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/x25519)

## Features

### Current features
- 100% TypeScript and ESM
- No external dependencies

## Usage

### Native (WebCrypto)

https://github.com/tQsW/webcrypto-curve25519/blob/master/explainer.md

```typescript
import { X25519 } from "@hazae41/x25519"

X25519.set(await X25519.fromNative())
```

### WebAssembly

```bash
npm i @hazae41/x25519.wasm
```

```typescript
import { X25519 } from "@hazae41/x25519"
import { X25519Wasm } from "@hazae41/x25519.wasm"

await X25519Wasm.initBundled()

X25519.set(await X25519.fromNativeOrWasm(X25519Wasm))
```

### Noble (JavaScript)

```bash
npm i @noble/curves
```

```typescript
import { X25519 } from "@hazae41/x25519"
import * as Ed25519Noble from "@noble/curves/ed25519"

X25519.set(await X25519.fromNativeOrNoble(Ed25519Noble))
```