@byok-sdk/cloud 0.10.2 → 0.12.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.
@@ -13,7 +13,7 @@
13
13
  * claims never sit in handler scope as a tenant a handler could substitute;
14
14
  * - a device resolves to a row (the pre-tenant lookup, §6.2's pinned wire
15
15
  * contract), and unknown/revoked collapse to one answer;
16
- * - nonce issue/validate/consume and token minting take that ROW, so the
16
+ * - nonce issue/atomic-consume and token minting take that ROW, so the
17
17
  * tenant they act on is the row's, by construction.
18
18
  */
19
19
  import type { Clock, TenantId } from '@byok-sdk/core';
@@ -52,9 +52,8 @@ export interface AuthPlane {
52
52
  /** The pre-tenant device lookup §6.2's wire contract forces. `undefined` for unknown AND revoked alike — no existence oracle. */
53
53
  resolveDevice(deviceId: string): Promise<DeviceRecord | undefined>;
54
54
  issueNonce(device: DeviceRecord): Promise<string>;
55
- validateNonce(device: DeviceRecord, nonce: string): Promise<boolean>;
56
- /** Burn the nonce. Called only on a fully verified request (§6.2). */
57
- consumeNonce(device: DeviceRecord, nonce: string): Promise<void>;
55
+ /** Atomically consume the nonce after signature verification (§6.2). */
56
+ consumeNonceIfValid(device: DeviceRecord, nonce: string): Promise<boolean>;
58
57
  /** Domain-separated (`byok-nonce-v1\n`) — see `verify.ts`. A raw signature over the bare nonce is invalid, with no second accepted form. */
59
58
  verifySignature(device: DeviceRecord, nonce: string, signature: string): Promise<boolean>;
60
59
  mintAccessToken(device: DeviceRecord): Promise<MintedAccessToken>;
@@ -31,6 +31,8 @@ export declare const BLOB_RESERVATION_TTL_MS: number;
31
31
  */
32
32
  export interface BlobContentRouteDeps {
33
33
  readonly contentProxy: BlobContentProxy;
34
+ /** Absolute ceiling independent of an untrusted Content-Length header. */
35
+ readonly maxUploadBytes: number;
34
36
  }
35
37
  export declare function createBlobHandler(deps: BlobRouteDeps): (c: Context) => Promise<Response>;
36
38
  export declare function finalizeBlobHandler(deps: BlobRouteDeps): (c: Context) => Promise<Response>;
@@ -11,9 +11,9 @@
11
11
  * that hands back the same cursor replays the same page forever.
12
12
  * - **The ack is monotonic.** A cursor at or below what the device already
13
13
  * acked carries no new information and is not an ack attempt; only a
14
- * strictly higher one advances. The store's own
15
- * `mailbox_cursor_regression` guard stays the authority on going backwards
16
- * (asserted directly in `src/__tests__/mailbox-cursor.test.ts`).
14
+ * strictly higher one advances. The store stays the authority on both
15
+ * bounds: it rejects regression and refuses any cursor beyond the highest
16
+ * one this route recorded immediately before returning it.
17
17
  * - **The hold.** An empty poll is held open instead of answered immediately,
18
18
  * so an idle daemon is not a busy-loop. The hold is a bounded re-read, not a
19
19
  * registered waiter: a waiter map is exactly the cross-request state a
package/dist/inbound.d.ts CHANGED
@@ -40,10 +40,12 @@ export declare function handleAgentMessagePublish(stores: TenantStores, deviceId
40
40
  }) => Promise<{
41
41
  readonly outcome: 'accepted' | 'held' | 'refused';
42
42
  readonly reasonCode?: string;
43
- }>) | undefined): Promise<{
43
+ }>) | undefined, alreadyDeduplicated: boolean): Promise<{
44
44
  readonly outcome: InboundOutcome;
45
45
  readonly disposition?: AgentMessageDispositionPayload;
46
46
  }>;
47
+ /** Reads only a terminal immutable admission; pending rows have no disposition to acknowledge. */
48
+ export declare function readAgentMessageDisposition(stores: TenantStores, deviceId: string, taskId: string, payload: AgentMessagePublishPayload): Promise<AgentMessageDispositionPayload | undefined>;
47
49
  /** Receipt key a task's terminal is recorded under — the idempotency seam S3b's journal will share. */
48
50
  export declare function terminalReceiptKey(taskId: string): string;
49
- export declare function handleInboundEnvelope(stores: TenantStores, deviceId: string, envelope: Envelope, activityBounds?: ActivityBounds): Promise<InboundOutcome>;
51
+ export declare function handleInboundEnvelope(stores: TenantStores, deviceId: string, envelope: Envelope, activityBounds?: ActivityBounds, agentMessageConsume?: Parameters<typeof handleAgentMessagePublish>[4]): Promise<InboundOutcome>;
package/dist/index.d.ts CHANGED
@@ -63,8 +63,8 @@ export { DEFAULT_MAX_TRUTH_REQUEST_BYTES, DEVICE_PROOF_HEADER, MAX_DEVICE_PROOF_
63
63
  export type { PreparedTruthWrite, TruthBodyInput, TruthCommitInput, TruthCommitResponse, TruthCommitResult, TruthCommitter, TruthObjectDownloads, TruthRecordMetadata, TruthWriteRequest, } from './truth/contract';
64
64
  export { TruthCommitError, isTruthCommitError } from './truth/errors';
65
65
  export type { TruthCommitErrorCode } from './truth/errors';
66
- export { BLOB_READ_ERROR_CODES, CLOUD_STORE_NAMES, TASK_ATTEMPT_STATUSES } from './stores/ports';
66
+ export { BLOB_READ_ERROR_CODES, CLOUD_STORE_NAMES, TASK_ATTEMPT_STATUSES, } from './stores/ports';
67
67
  export { CLOUD_PORT_INTERFACES, CLOUD_PORT_METHODS } from './stores/ports-contract';
68
- export type { BlobContent, BlobContentProxy, BlobDeclaration, BlobObservation, BlobReadErrorCode, BlobReadResult, BlobWriteResult, CloudBlobStore, CloudStoreName, CloudStores, DeviceDirectory, DeviceRecord, DeviceRegistration, InboundDedupStore, InboundRateLimiter, NonceStore, PairingCodeClaims, PairingCodeInfo, PairingCodeIssueInput, PairingCodeStore, ProofRequestReceipt, ProofRequestReceiptInput, ProofRequestReceiptStore, RequestReceipt, RequestReceiptStore, TaskAttempt, TaskAttemptStatus, TaskAttemptStore, AgentRef, AgentEgressRecord, AgentEgressStore, TaskCancellationMutation, TaskCancellationRequest, TaskCancellationStore, } from './stores/ports';
68
+ export type { BlobContent, BlobContentProxy, BlobDeclaration, BlobObservation, BlobReadErrorCode, BlobReadResult, BlobWriteResult, CloudBlobStore, CloudStoreName, CloudStores, DeviceDirectory, DeviceRecord, DeviceRegistration, InboundDedupStore, InboundRateLimiter, NonceStore, PairingCodeClaims, PairingCodeInfo, PairingCodeIssueInput, PairingCodeStore, PairingEnrollment, PairingEnrollmentInput, ProofRequestReceipt, ProofRequestReceiptInput, ProofRequestReceiptStore, RequestReceipt, RequestReceiptStore, TaskAttempt, TaskAttemptStatus, TaskAttemptStore, AgentRef, AgentEgressRecord, AgentEgressStore, AgentMessageAdmission, TaskCancellationMutation, TaskCancellationRequest, TaskCancellationStore, } from './stores/ports';
69
69
  export { AllowAllRateLimiter, BLOB_URL_TTL_MS, DEDUP_RING_CAPACITY, InMemoryBlobContentProxy, InMemoryCloudBlobStore, InMemoryActivityStore, InMemoryDeviceDirectory, InMemoryInboundDedupStore, InMemoryNonceStore, InMemoryPairingCodeStore, InMemoryRequestReceiptStore, InMemoryAgentEgressStore, InMemoryProofRequestReceiptStore, InMemoryTaskAttemptStore, InMemoryTaskCancellationStore, NONCE_TTL_MS, createInMemoryBlobs, createInMemoryCloudStores, } from './stores/in-memory/index';
70
70
  export type { InMemoryBlobStoreOptions, InMemoryBlobs, InMemoryCloudComposition, } from './stores/in-memory/index';