@byok-sdk/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ import { type ActivityAppendInput, type ActivityStore, type ActivityTail, type PresenceHint, type PresenceHintInput, type PresenceStore } from '../presence';
2
+ import type { Clock } from '../stores';
3
+ import { type TenantId } from '../tenant';
4
+ export declare class InMemoryPresenceStore implements PresenceStore {
5
+ #private;
6
+ constructor(clock: Clock);
7
+ publish(tenant: TenantId, input: PresenceHintInput): Promise<PresenceHint>;
8
+ read(tenant: TenantId, deviceId: string): Promise<PresenceHint | undefined>;
9
+ list(tenant: TenantId): Promise<readonly PresenceHint[]>;
10
+ }
11
+ export declare class InMemoryActivityStore implements ActivityStore {
12
+ #private;
13
+ constructor(clock: Clock);
14
+ append(tenant: TenantId, input: ActivityAppendInput): Promise<ActivityTail>;
15
+ read(tenant: TenantId, taskId: string): Promise<ActivityTail | undefined>;
16
+ }
@@ -0,0 +1,18 @@
1
+ import type { ObjectStore } from '../blob';
2
+ import type { MailboxUsageDeltaInput, StorageFinalizeInput, StorageFinalizeResult, StorageReservation, StorageReservationInput, StorageStatus, QuotaStore, TenantStorageEntitlement, TenantStorageEntitlementInput, TenantStorageUsage } from '../quota';
3
+ import type { Clock } from '../stores';
4
+ import { type TenantId } from '../tenant';
5
+ export declare class InMemoryQuotaStore implements QuotaStore {
6
+ #private;
7
+ constructor(clock: Clock, objects: ObjectStore);
8
+ readEntitlement(tenant: TenantId): Promise<TenantStorageEntitlement | undefined>;
9
+ writeEntitlement(tenant: TenantId, input: TenantStorageEntitlementInput): Promise<TenantStorageEntitlement>;
10
+ readUsage(tenant: TenantId): Promise<TenantStorageUsage>;
11
+ readStatus(tenant: TenantId): Promise<StorageStatus>;
12
+ readReservation(tenant: TenantId, reservationId: string): Promise<StorageReservation | undefined>;
13
+ reserve(tenant: TenantId, input: StorageReservationInput): Promise<StorageReservation>;
14
+ finalizeReservation(tenant: TenantId, input: StorageFinalizeInput): Promise<StorageFinalizeResult>;
15
+ abortReservation(tenant: TenantId, reservationId: string): Promise<StorageReservation>;
16
+ expireReservations(tenant: TenantId): Promise<readonly StorageReservation[]>;
17
+ applyMailboxDelta(tenant: TenantId, input: MailboxUsageDeltaInput): Promise<TenantStorageUsage>;
18
+ }
@@ -0,0 +1,11 @@
1
+ import type { Clock } from '../stores';
2
+ import { type TenantId } from '../tenant';
3
+ import type { SnapshotWriteInput, TerminalWriteInput, TruthManifestEntry, TruthManifestQuery, TruthRecord, TruthRecordSelector, TruthStore } from '../truth';
4
+ export declare class InMemoryTruthStore implements TruthStore {
5
+ #private;
6
+ constructor(clock: Clock);
7
+ writeTerminal(tenant: TenantId, input: TerminalWriteInput): Promise<TruthRecord>;
8
+ writeSnapshot(tenant: TenantId, input: SnapshotWriteInput): Promise<TruthRecord>;
9
+ getRecord(tenant: TenantId, selector: TruthRecordSelector): Promise<TruthRecord | undefined>;
10
+ listManifest(tenant: TenantId, query: TruthManifestQuery): Promise<readonly TruthManifestEntry[]>;
11
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * `@byok-sdk/core` — platform contracts.
3
+ *
4
+ * What this package exports is deliberately narrow: contracts, schemas, errors,
5
+ * and one in-memory reference implementation. No HTTP, no crypto, no SQL, no
6
+ * `@byok-sdk/protocol` (that edge would make a future `keys → core` dependency drag
7
+ * the wire protocol along with it, §12.1), and no `node:` import (a Workers
8
+ * composition has to be able to load this).
9
+ *
10
+ * `src/__tests__/constraints.test.ts` asserts every one of those properties
11
+ * against the source, including this export list.
12
+ */
13
+ export { tenantId, isTenantId, tenantKey, TENANT_ID_MAX_LENGTH, TENANT_KEY_SEPARATOR, } from './tenant';
14
+ export type { TenantId } from './tenant';
15
+ export { PRINCIPAL_KINDS, isDevicePrincipal, isControlPlanePrincipal, principalTenant, } from './principals';
16
+ export type { ControlPlanePrincipal, DevicePrincipal, Principal, PrincipalKind, } from './principals';
17
+ export { ByokCoreError, CoreConflictError, CORE_ERROR_CODES, isCoreError, isCoreConflictError } from './errors';
18
+ export type { CoreErrorCode } from './errors';
19
+ export { CANONICAL_TIMESTAMP_PATTERN, assertCanonicalTimestamp, isCanonicalTimestamp, } from './time';
20
+ export { MAILBOX_MESSAGE_STATES } from './mailbox';
21
+ export type { MailboxAdvanceCursorInput, MailboxAppendInput, MailboxCursorState, MailboxMessage, MailboxMessageState, MailboxPage, MailboxReadQuery, MailboxRetentionInput, MailboxRetentionResult, MailboxStore, } from './mailbox';
22
+ export { BOARD_STATUSES, BOARD_TRANSITIONS, isLegalBoardTransition } from './board';
23
+ export type { BoardAssignee, BoardClaimInput, BoardItem, BoardItemInput, BoardListQuery, BoardPage, BoardStatus, BoardStatusUpdateInput, BoardStore, BoardUnclaimInput, } from './board';
24
+ export { TRUTH_RECORD_KINDS } from './truth';
25
+ export type { SnapshotWriteInput, TerminalWriteInput, TruthBodyRef, TruthManifestEntry, TruthManifestQuery, TruthRecord, TruthRecordKind, TruthRecordSelector, TruthStore, } from './truth';
26
+ export { PRESENCE_LEVELS, DEFAULT_ACTIVITY_CAPACITY } from './presence';
27
+ export type { ActivityAppendInput, ActivityEntry, ActivityStore, ActivityTail, PresenceHint, PresenceHintInput, PresenceLevel, PresenceStore, } from './presence';
28
+ export { CONTENT_HASH_PATTERN, OBJECT_STATES, OBJECT_STATE_TRANSITIONS, contentHash, isContentHash, isLegalObjectTransition, tenantObjectKey, } from './blob';
29
+ export type { ContentHash, ObjectCommitInput, ObjectListQuery, ObjectManifestEntry, ObjectManifestInput, ObjectReference, ObjectReferenceInput, ObjectState, ObjectStore, } from './blob';
30
+ export { STORAGE_ERROR_CODES, STORAGE_ERROR_HTTP_STATUS, STORAGE_RESERVATION_STATES, STORAGE_WRITE_KINDS, STORAGE_WRITE_POSTURES, } from './quota';
31
+ export type { MailboxUsageDeltaInput, QuotaStore, StorageErrorCode, StorageFinalizeInput, StorageFinalizeResult, StorageReservation, StorageReservationInput, StorageReservationState, StorageStatus, StorageWriteKind, StorageWritePosture, TenantStorageEntitlement, TenantStorageEntitlementInput, TenantStorageUsage, } from './quota';
32
+ export { CAPABILITY_DECLARATION_SCHEMA_ID, CAPABILITY_NAME_PATTERN, CapabilityDeclarationSchema, assertCapability, hasCapability, parseCapabilityDeclaration, } from './capabilities';
33
+ export type { CapabilityDeclaration } from './capabilities';
34
+ export { CORE_STORE_NAMES } from './stores';
35
+ export type { Clock, CoreStoreName, CoreStores, MutableClock } from './stores';
36
+ export { CORE_PORT_INTERFACES, CORE_PORT_METHODS } from './ports-contract';
37
+ export { DEVICE_PROOF_ALGORITHMS, DEVICE_PROOF_DOMAIN_PREFIX, DEVICE_PROOF_SCHEMA_ID, DEVICE_PROOF_VERSION, DeviceProofEnvelopeV1Schema, DeviceProofProtectedClaimsSchema, canonicalizeJson, canonicalizeJsonBytes, deviceProofCanonicalClaims, deviceProofCanonicalJson, deviceProofSigningInput, parseDeviceProofEnvelope, } from './attestation';
38
+ export type { DeviceProofAlgorithm, DeviceProofEnvelopeV1, DeviceProofProtectedClaims, DeviceProofVerifier, DeviceProofVerifyInput, JsonObject, JsonPrimitive, JsonValue, } from './attestation';
39
+ export { IN_MEMORY_CLOCK_EPOCH, InMemoryActivityStore, InMemoryBoardStore, InMemoryMailboxStore, InMemoryObjectStore, InMemoryPresenceStore, InMemoryQuotaStore, InMemoryTruthStore, createInMemoryCoreStores, createInMemoryCoreCompositionWithClock, createMutableClock, } from './in-memory/index';
40
+ export type { InMemoryCoreComposition, InMemoryCoreOptions } from './in-memory/index';