Skip to content

@alneas/universal-storage API Reference

Computes SHA-256 hex string synchronously.

export function sha256Hex(data: Uint8Array | ArrayBuffer | string): string
Parameter Type Required Description
data `string ArrayBuffer Uint8Array`
  • Type: string

Computes pure SHA-256 digest synchronously.

export function sha256Bytes(data: Uint8Array | ArrayBuffer | string): Uint8Array
Parameter Type Required Description
data `string ArrayBuffer Uint8Array`
  • Type: Uint8Array<ArrayBufferLike>

Computes pure HMAC-SHA256 signature synchronously.

export function hmacSha256(
key: Uint8Array | ArrayBuffer | string,
data: Uint8Array | ArrayBuffer | string,
): Uint8Array
Parameter Type Required Description
key `string ArrayBuffer Uint8Array`
data `string ArrayBuffer Uint8Array`
  • Type: Uint8Array<ArrayBufferLike>

Computes HMAC-SHA256 signature returning hex string synchronously.

export function hmacSha256Hex(
key: Uint8Array | ArrayBuffer | string,
data: Uint8Array | ArrayBuffer | string,
): string
Parameter Type Required Description
key `string ArrayBuffer Uint8Array`
data `string ArrayBuffer Uint8Array`
  • Type: string

Encodes a UTF-8 string to base64 using Web standards (works in Browser, Workers, Node).

export function base64EncodeUtf8(str: string): string
Parameter Type Required Description
str string Yes
  • Type: string

Decodes a base64 string to a UTF-8 string using Web standards.

export function base64DecodeUtf8(base64: string): string
Parameter Type Required Description
base64 string Yes
  • Type: string

Common runtime client for S3, R2, and OCI. Always uses standard fetch + SigV4. Installing an unrelated SDK never changes behavior.

class S3CompatibleRuntime

Generate a signed download URL without an SDK.

export function presignS3GetUrl(config: S3RuntimeConfig, key: string, options?: StorageURLOptions): string
Parameter Type Required Description
config S3RuntimeConfig Yes
key string Yes
options `StorageURLOptions undefined` Optional
  • Type: string

Generate a signed PUT URL. Upload the bytes with HTTP PUT to this exact URL.

export function presignS3PutUrl(config: S3RuntimeConfig, key: string, options?: Pick<StorageURLOptions, 'expiresIn'>): string
Parameter Type Required Description
config S3RuntimeConfig Yes
key string Yes
options `Pick<StorageURLOptions, “expiresIn”> undefined` Optional
  • Type: string

Interface S3RuntimeConfig

interface S3RuntimeConfig

Interface S3PutInput

interface S3PutInput

Storage adapter for AWS S3.

Supports Object Lock (WORM) for original document retention under compliance requirements.

  • Object Lock (Compliance/Governance) support
  • Automatic SHA-256 hash calculation and metadata storage
  • Signed URL generation
  • Tag-based metadata storage
class S3StorageAdapter
```typescript
const storage = new S3StorageAdapter({
region: 'ap-northeast-1',
bucket: 'my-compliance-bucket',
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
objectLockEnabled: true,
defaultRetentionDays: 2555, // 7 years
});
// Upload with Object Lock
await storage.upload('invoices/inv-001.pdf', pdfBuffer);
// Generate signed URL
const url = await storage.getUrl('invoices/inv-001.pdf', { expiresIn: 3600 });
---