@alneas/universal-storage API Reference
@alneas/universal-storage API Reference
Section titled “@alneas/universal-storage API Reference”FUNCTION sha256Hex
Section titled “FUNCTION sha256Hex”Computes SHA-256 hex string synchronously.
export function sha256Hex(data: Uint8Array | ArrayBuffer | string): stringParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
data |
`string | ArrayBuffer | Uint8Array |
Returns
Section titled “Returns”- Type:
string
FUNCTION sha256Bytes
Section titled “FUNCTION sha256Bytes”Computes pure SHA-256 digest synchronously.
export function sha256Bytes(data: Uint8Array | ArrayBuffer | string): Uint8ArrayParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
data |
`string | ArrayBuffer | Uint8Array |
Returns
Section titled “Returns”- Type:
Uint8Array<ArrayBufferLike>
FUNCTION hmacSha256
Section titled “FUNCTION hmacSha256”Computes pure HMAC-SHA256 signature synchronously.
export function hmacSha256( key: Uint8Array | ArrayBuffer | string, data: Uint8Array | ArrayBuffer | string,): Uint8ArrayParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
key |
`string | ArrayBuffer | Uint8Array |
data |
`string | ArrayBuffer | Uint8Array |
Returns
Section titled “Returns”- Type:
Uint8Array<ArrayBufferLike>
FUNCTION hmacSha256Hex
Section titled “FUNCTION hmacSha256Hex”Computes HMAC-SHA256 signature returning hex string synchronously.
export function hmacSha256Hex( key: Uint8Array | ArrayBuffer | string, data: Uint8Array | ArrayBuffer | string,): stringParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
key |
`string | ArrayBuffer | Uint8Array |
data |
`string | ArrayBuffer | Uint8Array |
Returns
Section titled “Returns”- Type:
string
FUNCTION base64EncodeUtf8
Section titled “FUNCTION base64EncodeUtf8”Encodes a UTF-8 string to base64 using Web standards (works in Browser, Workers, Node).
export function base64EncodeUtf8(str: string): stringParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
str |
string |
Yes |
Returns
Section titled “Returns”- Type:
string
FUNCTION base64DecodeUtf8
Section titled “FUNCTION base64DecodeUtf8”Decodes a base64 string to a UTF-8 string using Web standards.
export function base64DecodeUtf8(base64: string): stringParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
base64 |
string |
Yes |
Returns
Section titled “Returns”- Type:
string
CLASS S3CompatibleRuntime
Section titled “CLASS S3CompatibleRuntime”Common runtime client for S3, R2, and OCI. Always uses standard fetch + SigV4. Installing an unrelated SDK never changes behavior.
class S3CompatibleRuntimeFUNCTION presignS3GetUrl
Section titled “FUNCTION presignS3GetUrl”Generate a signed download URL without an SDK.
export function presignS3GetUrl(config: S3RuntimeConfig, key: string, options?: StorageURLOptions): stringParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
config |
S3RuntimeConfig |
Yes | |
key |
string |
Yes | |
options |
`StorageURLOptions | undefined` | Optional |
Returns
Section titled “Returns”- Type:
string
FUNCTION presignS3PutUrl
Section titled “FUNCTION presignS3PutUrl”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'>): stringParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
config |
S3RuntimeConfig |
Yes | |
key |
string |
Yes | |
options |
`Pick<StorageURLOptions, “expiresIn”> | undefined` | Optional |
Returns
Section titled “Returns”- Type:
string
INTERFACE S3RuntimeConfig
Section titled “INTERFACE S3RuntimeConfig”Interface S3RuntimeConfig
interface S3RuntimeConfigINTERFACE S3PutInput
Section titled “INTERFACE S3PutInput”Interface S3PutInput
interface S3PutInputCLASS S3StorageAdapter
Section titled “CLASS S3StorageAdapter”Storage adapter for AWS S3.
Supports Object Lock (WORM) for original document retention under compliance requirements.
Features
Section titled “Features”- Object Lock (Compliance/Governance) support
- Automatic SHA-256 hash calculation and metadata storage
- Signed URL generation
- Tag-based metadata storage
class S3StorageAdapterExample
Section titled “Example”```typescriptconst 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 Lockawait storage.upload('invoices/inv-001.pdf', pdfBuffer);
// Generate signed URLconst url = await storage.getUrl('invoices/inv-001.pdf', { expiresIn: 3600 });---