Loading...
private.me Docs
Get Shared
PRIVATE.ME PLATFORM

Shared: Shared Types and Utilities

Foundational package providing Result<T,E> discriminated unions, ok()/err() constructors, TLV type codes, and 140+ TypeScript interfaces covering every domain in the PRIVATE.ME ecosystem.

Core / Foundation AVAILABLE NOW XorIDA Powered
Section 01

The Problem

Multi-package ecosystems need consistent type definitions. Type mismatches between packages cause silent runtime errors. No standard error handling pattern leads to inconsistent failure modes.

When packages define their own types independently, subtle incompatibilities emerge at integration boundaries. A "Share" type in one package may differ from the "Share" type in another by a single field, causing silent data loss or corruption at runtime despite successful TypeScript compilation.

Without a standard error handling pattern, some packages throw exceptions, others return null, and still others use custom error objects. Callers cannot predict failure modes, leading to unhandled errors in production and inconsistent user experiences across the platform.

The Old Way

Package A Share { idx } Package B Share { index } Package C throws Error TYPE MISMATCH + UNHANDLED ERRORS Silent runtime failures at integration boundaries
Section 02

The PRIVATE.ME Solution

A single source of truth for every type, constant, and error pattern in the PRIVATE.ME ecosystem. Result<T,E> discriminated unions enforce exhaustive error handling at compile time.

All 65 packages in the ecosystem import their shared types from @private.me/shared. When a type changes, it changes everywhere simultaneously. No drift, no mismatches, no silent incompatibilities. TypeScript strict mode catches any integration issues at compile time, not runtime.

The Result<T,E> pattern replaces thrown exceptions with discriminated unions. Every function returns either { ok: true, value: T } or { ok: false, error: E }. Callers must handle both cases. The compiler enforces this. Unhandled errors become impossible.

The New Way

@private.me/shared 140+ interfaces, Result<T,E> Package A Same types Package B Same types Package C Same types COMPILE-TIME SAFETY ACROSS 65 PACKAGES
Section 03

How It Works

The shared package provides three layers: type definitions (interfaces and enums), utility constructors (ok/err/uuid), and domain constants (TLV codes, magic numbers, thresholds).

Types Layer Share, Result, ContactInfo, 140+ interfaces Utilities Layer ok(), err(), generateUUID(), encoding helpers Constants Layer TLV codes, IDA5 magic, error codes, thresholds
Key Design Properties
Single source of truth: Every type used across 65 packages is defined exactly once. Compile-time safety: TypeScript strict mode catches type mismatches before code runs. Result<T,E> pattern: No thrown exceptions in library code. Every failure path is explicitly typed and must be handled by the caller.
Section 04

Use Cases

🛡
Error Handling
Type-Safe Error Handling

Result<T,E> with ok()/err() constructors. Discriminated unions force exhaustive error handling at compile time. No unhandled exceptions possible in library code.

Result<T,E>
📋
Constants
Shared Constants and Enums

TLV type codes, IDA5 magic number (0x49444135), error code enumerations, and threshold constants used consistently across the entire platform.

single source
🔗
Integration
Cross-Package Compatibility

Share, ContactInfo, DeviceInfo, and 140+ other interfaces ensure that data flows between packages without type mismatches or silent field drops.

140+ interfaces
📦
Serialization
Standard TLV Serialization

TLV (Type-Length-Value) codes for binary serialization of shares, metadata, and protocol messages. Consistent encoding across all transport channels.

TLV codes
Section 05

Integration

Quick Start
import { ok, err, type Result } from '@private.me/shared';

// Type-safe error handling
function processShare(data: Uint8Array): Result<Share, ShareError> {
  if (data.length === 0) {
    return err({ code: 'EMPTY_DATA', message: 'No data' });
  }
  return ok({ index: 0, data, hmac: computeHmac(data) });
}

// Caller MUST handle both cases
const result = processShare(input);
if (result.ok) {
  console.log(result.value); // Share
} else {
  console.log(result.error); // ShareError
}
ok<T>(value: T): Result<T, never>
Wraps a success value in a Result discriminated union. The ok property is true and the value property contains the result. Type-narrowing works automatically in if/else branches.
err<E>(error: E): Result<never, E>
Wraps an error value in a Result discriminated union. The ok property is false and the error property contains the failure reason. Forces callers to handle the error case explicitly.
Section 06

Security Properties

PropertyMechanismGuarantee
Type SafetyTypeScript strict modeCompile-time mismatch detection
Error HandlingResult<T,E> discriminated unionNo unhandled exceptions
ConsistencySingle source of truthNo type drift across 65 packages
SerializationTLV type codesDeterministic binary encoding
Supply ChainZero external dependenciesNo transitive attack surface
140+
Interfaces
64
Dependent packages
0
Dependencies
strict
TypeScript mode

© 2026 StandardClouds Inc. dba PRIVATE.ME. All rights reserved.

VERIFIABLE WITHOUT CODE EXPOSURE

Ship Proofs, Not Source

Shared generates cryptographic proofs of correct execution without exposing proprietary algorithms. Verify integrity using zero-knowledge proofs — no source code required.

XPROVE CRYPTOGRAPHIC PROOF
Download proofs:

Verify proofs online →

Use Cases

🏛️
REGULATORY
FDA / SEC Submissions
Prove algorithm correctness for shared utilities without exposing trade secrets or IP.
Zero IP Exposure
🏦
FINANCIAL
Audit Without Access
External auditors verify common type definitions without accessing source code or production systems.
FINRA / SOX Compliant
🛡️
DEFENSE
Classified Verification
Security clearance holders verify shared utilities correctness without clearance for source code.
CMMC / NIST Ready
🏢
ENTERPRISE
Procurement Due Diligence
Prove security + correctness during RFP evaluation without NDA or code escrow.
No NDA Required

Deployment Options

📦

SDK Integration

Embed directly in your application. Runs in your codebase with full programmatic control.

  • npm install @private.me/shared
  • TypeScript/JavaScript SDK
  • Full source access
  • Enterprise support available
Get Started →
🏢

On-Premise Upon Request

Enterprise CLI for compliance, air-gap, or data residency requirements.

  • Complete data sovereignty
  • Air-gap capable deployment
  • Custom SLA + dedicated support
  • Professional services included
Request Quote →

Enterprise On-Premise Deployment

While Shared is primarily delivered as SaaS or SDK, we build dedicated on-premise infrastructure for customers with:

  • Regulatory mandates — HIPAA, SOX, FedRAMP, CMMC requiring self-hosted processing
  • Air-gapped environments — SCIF, classified networks, offline operations
  • Data residency requirements — EU GDPR, China data laws, government mandates
  • Custom integration needs — Embed in proprietary platforms, specialized workflows

Includes: Enterprise CLI, Docker/Kubernetes orchestration, RBAC, audit logging, and dedicated support.

Contact sales for assessment and pricing →