001/* 002 * Copyright 2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.revetsec.webauthn; 018 019import com.google.errorprone.annotations.CheckReturnValue; 020import java.time.Duration; 021import java.util.Set; 022import org.jspecify.annotations.NonNull; 023 024/** 025 * Application-owned authoritative WebAuthn storage. Shared implementations must coordinate all nodes, 026 * return a complete versioned snapshot, and atomically compare every predicate before applying 027 * all mutations. A confirmed commit must be durable for restart and cross-node continuity; 028 * {@link InMemoryWebAuthnStore} is an explicitly selected, volatile single-process option only. 029 * Data and admitted time must be one coherent observation. Timed writes compare the current 030 * authority, recovery and clock tuple, every predicate, and fresh time after all waits. Ordinary 031 * reads, barriers and no-effect refusals perform no hidden reclamation or quota update. A successful 032 * mutating commit may atomically reclaim expired ceremonies outside its predicate set using the same 033 * fresh healthy admitted time and their store-visible expiry hints; application stores must provide 034 * this bounded reclamation behavior or equivalent admitted maintenance. 035 * Permanent credentials, ownership tombstones, indexes, fences and stable namespace roots are 036 * never evicted to make room. A lost acknowledgement after 037 * a possible write is UNKNOWN, never CONFLICT or UNAVAILABLE. Implementations honor the remaining 038 * positive caller-thread budget and preserve interrupt status. Revetsec cannot preempt blocked 039 * application code or provide durability through this interface alone. 040 * 041 * @since 1.0.0 042 */ 043@javax.annotation.concurrent.ThreadSafe 044@CheckReturnValue 045public interface WebAuthnStore { 046 /** 047 * Reads every requested key at one authoritative snapshot point. A missing key is represented 048 * by an explicit {@link WebAuthnStoreEntry.Absent} entry. Admission retirement is Fenced; a 049 * provider failure is Unavailable, never fabricated absence. 050 * @param keys the complete bounded read set 051 * @param remainingBudget the remaining positive operation budget 052 * @return a coherent complete snapshot, fenced result or unavailable result 053 * @since 1.0.0 054 */ 055 @NonNull WebAuthnStoreReadResult read(@NonNull Set<@NonNull WebAuthnStoreKey> keys, 056 @NonNull Duration remainingBudget); 057 058 /** 059 * Compares all snapshot versions and absences at one linearization point and applies all changes 060 * or none. Fresh healthy authority time must satisfy the original inclusive floor and exclusive 061 * expiry after all waits and before mutations. An empty mutation set is a timed predicate barrier. 062 * A known late commit stays COMMITTED with timing; an uncertain mutation is never safe to retry. 063 * @param write the complete predicate and mutation set 064 * @param remainingBudget the remaining positive operation budget 065 * @return the actual commit outcome 066 * @since 1.0.0 067 */ 068 @NonNull WebAuthnStoreCommitReceipt compareAndCommit(@NonNull WebAuthnStoreWrite write, 069 @NonNull Duration remainingBudget); 070}