Class WebAuthnRelyingParty

java.lang.Object
com.revetsec.webauthn.WebAuthnRelyingParty

@ThreadSafe public final class WebAuthnRelyingParty extends Object
Immutable WebAuthn relying party for discoverable, user-verified passkeys and security keys. The app owns account approval, sessions, CSRF, durable storage, and the external recovery barrier. Only confirmed, admitted store transitions can produce a browser request or proof. Construction performs no application callback or storage I/O. The current browser profile requires exactly credProps: {rk: true} client-extension output during registration and an empty client-extension object during authentication. Additional outputs reject; submit the browser's unmodified JSON rather than stripping fields. Browser/provider compatibility and origin support require the documented profile checks.
Since:
1.0.0
  • Method Details

    • withRelyingPartyId

      @CheckReturnValue public static @NonNull WebAuthnRelyingParty.Builder withRelyingPartyId(@NonNull String relyingPartyId)
      Starts trusted RP configuration. The ID must be canonical lower-case DNS with at least two labels. The application must select a registrable domain it controls.
      Parameters:
      relyingPartyId - trusted RP ID
      Returns:
      builder
      Since:
      1.0.0
    • beginRegistrationResult

      Creates and commits account-approved enrollment options in an expiring ceremony. An absent account fence remains absent until the first credential completion atomically establishes its active fence and index. An existing disabled fence remains disabled.
      Parameters:
      options - approved account display data and handle
      browserBinding - application-held random browser-session binding
      Returns:
      a committed browser request or fixed failure
      Since:
      1.0.0
    • beginAuthenticationResult

      Creates and commits discoverable sign-in options, without an allowCredentials list.
      Parameters:
      browserBinding - application-held random browser-session binding
      Returns:
      a committed browser request or fixed failure
      Since:
      1.0.0
    • beginReauthenticationResult

      @CheckReturnValue public @NonNull WebAuthnAuthenticationRequestResult beginReauthenticationResult(byte @NonNull [] expectedUserHandle, @NonNull String actionPurpose, @NonNull OperationBinding browserBinding)
      Creates account-pinned reauthentication options for a specific sensitive action.
      Parameters:
      expectedUserHandle - app-approved account handle
      actionPurpose - bounded application action label
      browserBinding - application-held random browser-session binding
      Returns:
      a committed browser request or fixed failure
      Since:
      1.0.0
    • completeRegistrationResult

      @CheckReturnValue public @NonNull WebAuthnRegistrationResult completeRegistrationResult(@NonNull String ceremonyId, byte @NonNull [] responseBody, @NonNull OperationBinding browserBinding)
      Consumes a raw browser registration response under its single-use ceremony.
      Parameters:
      ceremonyId - opaque request handle
      responseBody - browser PublicKeyCredential.toJSON() bytes
      browserBinding - application-held browser-session binding
      Returns:
      verified registration only after a confirmed admitted write
      Since:
      1.0.0
    • completeAuthenticationResult

      @CheckReturnValue public @NonNull WebAuthnAuthenticationResult completeAuthenticationResult(@NonNull String ceremonyId, byte @NonNull [] responseBody, @NonNull OperationBinding browserBinding)
      Consumes a raw browser sign-in or account-pinned reauthentication response. Applications using this general result for a sensitive action must check the proof's kind, account handle and action purpose. The checked reauthentication completion method enforces those checks before returning a successful result.
      Parameters:
      ceremonyId - opaque request handle
      responseBody - browser PublicKeyCredential.toJSON() bytes
      browserBinding - application-held browser-session binding
      Returns:
      verified authentication only after a confirmed admitted write
      Since:
      1.0.0
    • completeReauthenticationResult

      @CheckReturnValue public @NonNull WebAuthnReauthenticationResult completeReauthenticationResult(byte @NonNull [] expectedUserHandle, @NonNull String actionPurpose, @NonNull String ceremonyId, byte @NonNull [] responseBody, @NonNull OperationBinding browserBinding)
      Completes a sensitive action only for the expected account and action purpose. A discoverable sign-in ceremony, or a reauthentication for another account or purpose, cannot return a successful result here. The application still authorizes the current browser session and consumes its own one-use action before applying the operation. The exact completed ceremony ID is included in the restricted proof so the application can match its original pending action. A rejected checked context may follow a known committed ceremony consumption; it does not imply that completion had no effects.
      Parameters:
      expectedUserHandle - app-approved current account handle
      actionPurpose - app-approved action label used when beginning reauthentication
      ceremonyId - opaque request handle
      responseBody - browser PublicKeyCredential.toJSON() bytes
      browserBinding - application-held browser-session binding
      Returns:
      a matching restricted reauthentication proof or fixed failure
      Since:
      1.0.0
    • listCredentialsResult

      @CheckReturnValue public @NonNull WebAuthnCredentialListResult listCredentialsResult(byte @NonNull [] approvedUserHandle)
      Lists active credential IDs for an app-approved account. The application must authorize the current session and enforce CSRF and management policy before calling this method. A listed ID is not an authentication proof.
      Parameters:
      approvedUserHandle - app-approved account handle
      Returns:
      authoritative listing or unavailable
      Since:
      1.0.0
    • removeCredentialResult

      @CheckReturnValue public @NonNull WebAuthnCredentialRemovalResult removeCredentialResult(byte @NonNull [] approvedUserHandle, byte @NonNull [] credentialId)
      Permanently revokes a credential ID belonging to an app-approved account. The application must authorize the current session and enforce CSRF and management policy. An uncertain write requires authoritative reconciliation before another management action.
      Parameters:
      approvedUserHandle - app-approved account handle
      credentialId - credential ID to revoke
      Returns:
      confirmed removal, absence or fixed failure
      Since:
      1.0.0
    • disableAccountResult

      @CheckReturnValue public @NonNull WebAuthnAccountDisableResult disableAccountResult(byte @NonNull [] approvedUserHandle)
      Permanently disables the passkey fence for an app-approved namespace/RP/account handle, including completions of pending ceremonies. There is no account-enable transition in this API. Reopening WebAuthnRecoveryGate traffic admission, rebuilding the relying party, repeating disable, or resealing records does not reenable the account. The app must authorize this action, coordinate its own account state and existing sessions, and reconcile uncertain effects. Disable retains credentials and ownership tombstones; authorized listing, removal and permanent-record reseal remain available under admission. A discoverable authentication begin has no account identity to reject; completion still enforces the disabled fence. This operation does not terminate app sessions or revoke a verification fact already returned to the application.
      Parameters:
      approvedUserHandle - app-approved account handle
      Returns:
      confirmed disabled state or fixed failure
      Since:
      1.0.0
    • resealStoreEntry

      Reseals one permanent, namespace-bound record with the current active sealing key. Use WebAuthnStoreKey.fromStoredForm(String) with a trusted complete persistence inventory to address revoked-credential tombstones as well as active records. The active account credential list alone is not a complete key-rotation inventory. The application must coordinate key rotation, retain the old key until every permanent row has been resealed, and close admission during restore or uncertain outcomes. Ceremony rows are short lived and are not eligible. Absence returns CONFLICT; an uncertain commit returns UNKNOWN and requires authoritative reconciliation before proceeding. Healthy admitted time is required before the timed attempt. This effect-only acknowledgement preserves a known COMMITTED receipt after deadline, optional-completion or permit-close failure; it releases no verification proof and performs no post-commit service-admission read.
      Parameters:
      key - privileged credential, index, account-fence or namespace-clock address
      Returns:
      the factual contextual compare-and-commit receipt
      Since:
      1.0.0
    • toString

      Redacts configuration and protocol state.
      Overrides:
      toString in class Object
      Returns:
      a fixed description
      Since:
      1.0.0