@opentusk/shared
v0.6.3
Published
Shared types, constants, and utilities for the [OpenTusk](https://opentusk.ai) platform. Used internally by `@opentusk/sdk`, `@opentusk/cli`, the API server, and the background worker.
Readme
@opentusk/shared
Shared types, constants, and utilities for the OpenTusk platform. Used internally by @opentusk/sdk, @opentusk/cli, the API server, and the background worker.
Install
npm install @opentusk/sharedModules
Import individual modules via subpath exports:
import { PLANS, getPlanConfig } from '@opentusk/shared/plans.js';
import { formatBytes, formatDate } from '@opentusk/shared/format.js';
import { computeWebhookSignature, verifyWebhookSignature } from '@opentusk/shared/webhooks.js';
import { createLogger } from '@opentusk/shared/logger.js';
import { resolveWalrusConfig } from '@opentusk/shared/walrus-networks.js';Types
Domain types shared across all packages:
import type {
PlanTier,
VaultVisibility,
FileStatus,
SubscriptionStatus,
WebhookEvent,
DeliveryStatus,
WebhookPayload,
} from '@opentusk/shared/types.js';Plans
Plan configuration and limits:
import { PLANS, getPlanConfig } from '@opentusk/shared/plans.js';
const plan = getPlanConfig('developer');
// { tier: 'developer', maxVaults: 25, maxFileSizeBytes: 104857600, ... }Format
Formatting utilities:
import { formatBytes } from '@opentusk/shared/format.js';
formatBytes(1048576); // "1.00 MB"Webhooks
Webhook signature computation and verification (HMAC-SHA256):
import { computeWebhookSignature, verifyWebhookSignature } from '@opentusk/shared/webhooks.js';
const signature = computeWebhookSignature(payload, secret);
const isValid = verifyWebhookSignature(payload, signature, secret);Logger
Structured pino logging with environment-aware defaults:
import { createLogger } from '@opentusk/shared/logger.js';
const logger = createLogger('my-service');
logger.info({ userId, action: 'upload' }, 'File uploaded');Walrus Networks
Walrus and Sui network configuration:
import { resolveWalrusConfig } from '@opentusk/shared/walrus-networks.js';
const config = resolveWalrusConfig('production');
// { suiNetwork: 'mainnet', suiRpcUrl: '...', aggregatorUrl: '...' }