Documentation
¶
Overview ¶
Package identitycapability provides the optional capability-owned PostgreSQL participants for the identity Coordinator. They never own a pool, transaction or command ledger. Issuer prepares secret custody outside transactions; Participant handles consumption metadata only. Install Migrations first.
Index ¶
- func CheckManagedEmailResendCooldown(ctx context.Context, w kernel.Work, owner kernel.FeatureExecutionContributor, ...) error
- func LockMagicLinkSupersession(ctx context.Context, w identitypostgres.Work, ...) error
- func Migrations() fs.FS
- func RetireEmailVerificationGrants(ctx context.Context, w kernel.Work, owner kernel.FeatureExecutionContributor, ...) error
- type AnonymousUpgradeScope
- type IssuancePreparationCodec
- func (c *IssuancePreparationCodec) CheckpointPreparation(ctx context.Context, p PreparedIssuance, generation uint64, ...) (wire []byte, err error)
- func (*IssuancePreparationCodec) Format(s fmt.State, _ rune)
- func (*IssuancePreparationCodec) LogValue() slog.Value
- func (*IssuancePreparationCodec) MarshalJSON() ([]byte, error)
- func (*IssuancePreparationCodec) MarshalText() ([]byte, error)
- func (c *IssuancePreparationCodec) RestorePreparation(ctx context.Context, b identity.CommandBinding, generation uint64, ...) (out PreparedIssuance, err error)
- type IssuancePreparationConfig
- type Issuer
- func (*Issuer) Descriptor() identitypostgres.ContributorDescriptor
- func (*Issuer) Format(s fmt.State, _ rune)
- func (*Issuer) MarshalJSON() ([]byte, error)
- func (i *Issuer) PersistCapabilityIssuance(ctx context.Context, w identitypostgres.CapabilityIssuanceWork) error
- func (i *Issuer) Prepare(ctx context.Context, b identity.CommandBinding, inputs []capability.Payload) (out PreparedIssuance, err error)
- func (i *Issuer) PrepareAccountLinkConsumption(ctx context.Context, command identity.Command, proof capability.Proof, ...) (kernel.CapabilityPlan, error)
- func (i *Issuer) PrepareAnonymousUpgradeConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, ...) (out kernel.CapabilityPlan, err error)
- func (i *Issuer) PrepareIdentifierConsumption(ctx context.Context, command identity.Command, proof capability.Proof, ...) (out identitypostgres.CapabilityPlan, err error)
- func (i *Issuer) PrepareMFAConsumption(ctx context.Context, b identity.CommandBinding, recipient identity.UserID, ...) (out kernel.CapabilityPlan, err error)
- func (i *Issuer) PrepareMFAContinuation(ctx context.Context, b identity.CommandBinding, input capability.Payload) (PreparedIssuance, error)
- func (i *Issuer) PrepareMagicLinkConsumption(ctx context.Context, binding identity.CommandBinding, ...) (out kernel.CapabilityPlan, err error)
- func (i *Issuer) PrepareMagicLinkProspectiveRecipient(ctx context.Context, b identity.CommandBinding, user identity.UserID, ...) (PreparedIssuance, error)
- func (i *Issuer) PrepareMagicLinkRecipient(ctx context.Context, b identity.CommandBinding, user identity.UserID, ...) (PreparedIssuance, error)
- func (i *Issuer) PrepareManagedChangeConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, ...) (kernel.CapabilityPlan, error)
- func (i *Issuer) PrepareManagedVerificationConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, ...) (kernel.CapabilityPlan, error)
- func (i *Issuer) PrepareOrganizationInvitationConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, ...) (out kernel.CapabilityPlan, err error)
- func (i *Issuer) PreparePasskeyMFAContinuation(ctx context.Context, b identity.CommandBinding, input capability.Payload) (PreparedIssuance, error)
- func (i *Issuer) PreparePasswordResetConsumption(ctx context.Context, command identity.Command, replayKeyVersion uint32) (out kernel.CapabilityPlan, err error)
- func (i *Issuer) PreparePhonePasswordResetConsumption(ctx context.Context, command identity.Command, replayKeyVersion uint32) (out kernel.CapabilityPlan, err error)
- func (i *Issuer) PreparePrivacyExportConsumption(ctx context.Context, command identity.Command, proof capability.Proof, ...) (out identitypostgres.CapabilityPlan, err error)
- func (i *Issuer) PrepareRegistration(ctx context.Context, b identity.CommandBinding, user identity.UserID, ...) (PreparedIssuance, error)
- func (i *Issuer) PrepareRegistrationVerificationConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, ...) (kernel.CapabilityPlan, error)
- func (i *Issuer) PrepareResetRecipient(ctx context.Context, b identity.CommandBinding, user identity.UserID, ...) (PreparedIssuance, error)
- func (i *Issuer) PrepareVerificationMFAContinuation(ctx context.Context, b identity.CommandBinding, input capability.Payload) (PreparedIssuance, error)
- func (i *Issuer) ReadIssuanceOrigin(ctx context.Context, pool *database.Pool, proof capability.Proof, ...) (capability.Grant, identity.CommandID, uint32, error)
- func (i *Issuer) ReadMFAMagicLinkParent(ctx context.Context, pool *database.Pool, child capability.Proof, ...) (out MFAMagicLinkParent, err error)
- func (i *Issuer) ReadMFAVerificationParent(ctx context.Context, pool *database.Pool, child capability.Proof, ...) (MFAVerificationParent, error)
- func (i *Issuer) ReadMagicLinkOrigin(ctx context.Context, pool *database.Pool, proof capability.Proof) (capability.Grant, identity.CommandID, uint32, bool, error)
- func (i *Issuer) ReadRegistrationOrigin(ctx context.Context, pool *database.Pool, proof capability.Proof) (capability.Grant, identity.CommandID, uint32, error)
- func (i *Issuer) RecoverParticipant(ctx context.Context, w identitypostgres.RecoveryWork) (identitypostgres.RecoveryStatus, error)
- func (i *Issuer) RequireVerificationMFAParent(ctx context.Context, w kernel.Work, ...) error
- func (i *Issuer) RequireVerificationMFATOTPParent(ctx context.Context, w kernel.Work, owner kernel.MFACompletionContributor, ...) error
- func (i *Issuer) RequireVerificationMFATOTPParentAttempt(ctx context.Context, w kernel.MFATOTPAttemptWork, ...) error
- func (i *Issuer) Stage(ctx context.Context, w identitypostgres.Work, p PreparedIssuance) error
- func (i *Issuer) ValidateCapabilityIssuance(b identity.CommandBinding, p identitypostgres.CapabilityIssuancePlan) error
- func (i *Issuer) ValidateIssuedProof(ctx context.Context, pool *database.Pool, proof capability.Proof, ...) (capability.Grant, identity.CommandID, uint32, error)
- func (i *Issuer) ValidateRegistrationProof(ctx context.Context, pool *database.Pool, proof capability.Proof) (capability.Grant, identity.CommandID, uint32, error)
- type IssuerConfig
- type MFAMagicLinkParent
- func (p MFAMagicLinkParent) Bindings() (MFAMagicLinkParentBindings, error)
- func (MFAMagicLinkParent) Format(s fmt.State, _ rune)
- func (MFAMagicLinkParent) LogValue() slog.Value
- func (MFAMagicLinkParent) MarshalJSON() ([]byte, error)
- func (MFAMagicLinkParent) MarshalText() ([]byte, error)
- func (p MFAMagicLinkParent) MatchPayload(v capability.Payload) error
- type MFAMagicLinkParentBindings
- type MFAVerificationParent
- func (p MFAVerificationParent) Bindings() (MFAVerificationParentBindings, error)
- func (MFAVerificationParent) Format(s fmt.State, _ rune)
- func (MFAVerificationParent) LogValue() slog.Value
- func (MFAVerificationParent) MarshalJSON() ([]byte, error)
- func (MFAVerificationParent) MarshalText() ([]byte, error)
- func (p MFAVerificationParent) MatchPayload(v capability.Payload) error
- type MFAVerificationParentBindings
- type MagicLinkSupersessionScope
- type ManagedEmailSupersessionScope
- type OrganizationInvitationScope
- type Participant
- func (p *Participant) ApplyCapability(ctx context.Context, w identitypostgres.CapabilityApplyWork) error
- func (*Participant) Descriptor() identitypostgres.ContributorDescriptor
- func (p *Participant) FinalizeCapability(ctx context.Context, w identitypostgres.CapabilityFinalizeWork) error
- func (*Participant) Format(s fmt.State, _ rune)
- func (*Participant) MarshalJSON() ([]byte, error)
- func (p *Participant) RebindCapability(ctx context.Context, w identitypostgres.CapabilityReservationWork) error
- func (p *Participant) RecoverParticipant(ctx context.Context, w identitypostgres.RecoveryWork) (identitypostgres.RecoveryStatus, error)
- func (p *Participant) ReleaseCapability(ctx context.Context, w identitypostgres.CapabilityReleaseWork) error
- func (p *Participant) ReserveCapability(ctx context.Context, w identitypostgres.CapabilityReservationWork) error
- type PreparationVerificationKey
- type PreparedIssuance
- func (PreparedIssuance) Format(s fmt.State, _ rune)
- func (PreparedIssuance) MarshalJSON() ([]byte, error)
- func (p PreparedIssuance) Plan() (identitypostgres.CapabilityIssuancePlan, error)
- func (p PreparedIssuance) TransferForDelivery(ctx context.Context, index uint16, encrypt func(context.Context, []byte) error) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckManagedEmailResendCooldown ¶
func CheckManagedEmailResendCooldown(ctx context.Context, w kernel.Work, owner kernel.FeatureExecutionContributor, scope ManagedEmailSupersessionScope, interval time.Duration) error
CheckManagedEmailResendCooldown checks the authoritative last committed family issuance using database creation time, never signed proof time or caller time. The exact registered resend Apply invocation must already hold the same family fence before account/factor/domain locks. This method reacquires it defensively and performs no mutation, proof consumption or clock renewal. Interval is an explicit startup policy, between 30 seconds and 10 minutes. Missing history, unavailable history and cooldown deny; callers must propagate every error. Work and rows remain coordinator-owned and bounded by its context/lifetime.
func LockMagicLinkSupersession ¶
func LockMagicLinkSupersession(ctx context.Context, w identitypostgres.Work, owner identitypostgres.FeatureExecutionContributor, scope MagicLinkSupersessionScope) error
LockMagicLinkSupersession acquires the original-flow transaction fence before the invoking native feature locks account, factor or browser rows. Only the exact registered request/consume Apply invocation may act. It performs no provider work and retains no handle; the coordinator owns lock release. Callers must authenticate and reconstruct scope, not accept request digests.
func Migrations ¶
Migrations returns additive forward-only migrations rooted at filenames. Use a separate migration ledger from the legacy consumption store. No legacy row is imported, reset or removed. Downgrade is unsupported because deleting retained one-time state permits replay. Application roles must not own tables or have DDL, TRUNCATE, DELETE or trigger-disable privileges. Issuance and retirement must use owned phases, never client-controlled inserts. The native Issuer owns original inserts; retention/revocation phases remain unfinished.
func RetireEmailVerificationGrants ¶
func RetireEmailVerificationGrants(ctx context.Context, w kernel.Work, owner kernel.FeatureExecutionContributor, command identity.Command) error
RetireEmailVerificationGrants revokes only unused issued/reserved verification grants for the exact removed identifier in the kernel-locked original Apply invocation. The native owner must propagate errors to abort the same Work. Live unclassified legacy grants deny removal; reserved origin/fingerprint/ generation metadata and consumed/other-target history are preserved. No transaction, lock protocol, credential, worker or recovery journal is created. Nil, foreign, unprepared, reconstructed and returned Work deny without SQL.
Types ¶
type AnonymousUpgradeScope ¶
type AnonymousUpgradeScope struct {
// SourceVersion is the original guest identity version signed into the proof.
SourceVersion uint64
// SourceSessionID identifies the original authenticated guest session.
SourceSessionID string
// TargetSessionID identifies the original authenticated permanent-user session.
TargetSessionID string
// MergeDigest binds the exact original native merge selection.
MergeDigest [32]byte
// Remember selects the signed persistent rather than session-only profile.
Remember bool
// SourceExpiresAt bounds the proof by the original guest's absolute lifetime.
SourceExpiresAt time.Time
}
AnonymousUpgradeScope contains original authenticated native preparation metadata, never HTTP assertions or current authorization. SourceVersion is positive; session IDs are exact 1..128-byte visible ASCII identifiers; MergeDigest is nonzero. SourceExpiresAt is the original guest's positive UTC expiry, at microsecond precision and within years 1..9999. Immutable copies support concurrent reads. Formatting is redacted and serialization rejects.
func (AnonymousUpgradeScope) Format ¶
func (AnonymousUpgradeScope) Format(s fmt.State, _ rune)
Format hides correlated guest, session and merge metadata.
func (AnonymousUpgradeScope) MarshalJSON ¶
func (AnonymousUpgradeScope) MarshalJSON() ([]byte, error)
MarshalJSON rejects automatic export of original trusted scope custody.
func (AnonymousUpgradeScope) MarshalText ¶
func (AnonymousUpgradeScope) MarshalText() ([]byte, error)
MarshalText rejects automatic export of original trusted scope custody.
type IssuancePreparationCodec ¶
type IssuancePreparationCodec struct {
// contains filtered or unexported fields
}
IssuancePreparationCodec owns no journal, SQL connection or remote provider. Restored custody permits staging only, never another bearer transfer.
func NewIssuancePreparationCodec ¶
func NewIssuancePreparationCodec(i *Issuer, c IssuancePreparationConfig) (*IssuancePreparationCodec, error)
NewIssuancePreparationCodec snapshots bounded local cryptographic policy.
func (*IssuancePreparationCodec) CheckpointPreparation ¶
func (c *IssuancePreparationCodec) CheckpointPreparation(ctx context.Context, p PreparedIssuance, generation uint64, encrypt func(context.Context, uint16, []byte) error) (wire []byte, err error)
CheckpointPreparation irreversibly transfers every original proof to local encrypted journal custody and optionally to synchronous delivery encryption. The callback borrows bytes for its call only, must honor cancellation and must not send or reveal before commit. Failure invalidates the entire batch. Call this instead of TransferForDelivery; do not checkpoint transferred proofs.
func (*IssuancePreparationCodec) Format ¶
func (*IssuancePreparationCodec) Format(s fmt.State, _ rune)
Format hides codec keys and deployment configuration.
func (*IssuancePreparationCodec) LogValue ¶
func (*IssuancePreparationCodec) LogValue() slog.Value
LogValue redacts codec keys and deployment configuration.
func (*IssuancePreparationCodec) MarshalJSON ¶
func (*IssuancePreparationCodec) MarshalJSON() ([]byte, error)
MarshalJSON rejects implicit codec export.
func (*IssuancePreparationCodec) MarshalText ¶
func (*IssuancePreparationCodec) MarshalText() ([]byte, error)
MarshalText rejects implicit codec export.
func (*IssuancePreparationCodec) RestorePreparation ¶
func (c *IssuancePreparationCodec) RestorePreparation(ctx context.Context, b identity.CommandBinding, generation uint64, plan identitypostgres.CapabilityIssuancePlan, wire []byte) (out PreparedIssuance, err error)
RestorePreparation authenticates the original encrypted checkpoint, binding, generation and plan using local retained keys. It performs no SQL, network, signing, entropy acquisition, delivery or consumption. Expired grants fail closed; current transaction authority remains the coordinator's concern.
type IssuancePreparationConfig ¶
type IssuancePreparationConfig struct {
// Deployment binds encrypted preparation to one trusted deployment identifier.
Deployment string
// ActiveEnvelopeKey names the retained envelope key used for new checkpoints.
ActiveEnvelopeKey string
// EnvelopeKeys holds 1..32 nonzero 32-byte encryption keys, copied on construction.
// Keep referenced keys until the original journal no longer requires recovery.
EnvelopeKeys map[string][]byte
// VerificationKeys retains 1..32 local policies for authenticating original grants.
VerificationKeys []PreparationVerificationKey
// Clock provides current trusted time locally and must support concurrent calls.
Clock func() time.Time
}
IssuancePreparationConfig selects local encrypted custody and verification. Retain referenced keys for the original journal's entire recovery lifetime.
func (IssuancePreparationConfig) Format ¶
func (IssuancePreparationConfig) Format(s fmt.State, _ rune)
Format hides envelope and verification configuration.
func (IssuancePreparationConfig) LogValue ¶
func (IssuancePreparationConfig) LogValue() slog.Value
LogValue redacts envelope and verification configuration.
func (IssuancePreparationConfig) MarshalJSON ¶
func (IssuancePreparationConfig) MarshalJSON() ([]byte, error)
MarshalJSON rejects implicit custody-configuration export.
func (IssuancePreparationConfig) MarshalText ¶
func (IssuancePreparationConfig) MarshalText() ([]byte, error)
MarshalText rejects implicit custody-configuration export.
type Issuer ¶
type Issuer struct {
// contains filtered or unexported fields
}
Issuer prepares original signed credentials before the transaction, then inserts immutable metadata solely through coordinator-issued phase custody. It owns no pool, transaction, command result or provider. Immutable instances support concurrent commands; each prepared batch and Work is serial-use.
func NewIssuer ¶
func NewIssuer(c IssuerConfig) (*Issuer, error)
NewIssuer snapshots configuration without I/O. Zero keys, duplicate key material, unknown active version or invalid crypto policy fail closed.
func (*Issuer) Descriptor ¶
func (*Issuer) Descriptor() identitypostgres.ContributorDescriptor
Descriptor identifies the separate capability.issuance v1 original producer. It does not grant permission to invoke any coordinator phase.
func (*Issuer) MarshalJSON ¶
MarshalJSON rejects serialization of signing and replay configuration.
func (*Issuer) PersistCapabilityIssuance ¶
func (i *Issuer) PersistCapabilityIssuance(ctx context.Context, w identitypostgres.CapabilityIssuanceWork) error
PersistCapabilityIssuance authenticates every frozen envelope/replay binding before absent-to-issued inserts. Primary time and all origin fields are part of the coordinator transaction. Conflict never updates or resurrects a row. The method retains no handle, calls no signer/provider and closes no transaction.
func (*Issuer) Prepare ¶
func (i *Issuer) Prepare(ctx context.Context, b identity.CommandBinding, inputs []capability.Payload) (out PreparedIssuance, err error)
Prepare creates 1..16 new random capability IDs, signs and authenticates each original envelope, and derives independent keyed replay metadata. Caller IDs, subjectless bearers, foreign subject/tenant, multiple/foreign audiences or non-one-use payloads fail. Exact purpose, resource, caveats and timestamps remain subject to core crypto policy. Whole-second UTC expiry is required. This bounded pre-transaction phase grants no authority and persists nothing. Caller input is borrowed only during the call. Failure destroys all acquired proof custody; collaborators' diagnostics/panics are redacted.
func (*Issuer) PrepareAccountLinkConsumption ¶
func (i *Issuer) PrepareAccountLinkConsumption(ctx context.Context, command identity.Command, proof capability.Proof, replayKeyVersion uint32) (kernel.CapabilityPlan, error)
PrepareAccountLinkConsumption reauthenticates the original opaque proof for one bare canonical explicit self-link command, before native counter enrichment. The root constructor owns the complete signed provider, target, actor, session, policy and mutation intent. The supplied proof must be that exact envelope under this issuer's configured verification policy. The replay-key version comes from trusted original issuance custody, not a request or the current issuance default. Original expiry is never extended.
This bounded read-only phase does not sign, transfer, reserve or consume proof, establish provider/session authority, or attach newly minted issuance. The native AccountLinkUnitOfWork and registered Participant must still match durable issuance and consume atomically with the protected mutation and all current owner checks. OAuth state-before-exchange and post-exchange issuance require their separate native composition; this method supplies neither.
Calls borrow shared proof custody and may overlap. PreparationTimeout and the earlier caller deadline bound verification. Invalid composition returns InvalidInput; invalid, foreign or expired proof returns Forbidden; unavailable verification or panic returns Unavailable. Cancellation remains classified, errors are redacted and every failure returns a zero plan.
func (*Issuer) PrepareAnonymousUpgradeConsumption ¶
func (i *Issuer) PrepareAnonymousUpgradeConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, originalEnvelope [32]byte, replayKeyVersion uint32, expected AnonymousUpgradeScope) (out kernel.CapabilityPlan, err error)
PrepareAnonymousUpgradeConsumption reauthenticates an original signed proof for identity.anonymous.upgrade / identity.anonymous.upgrade.native-v1 v1. UserID and the user ActorID identify the permanent target; the distinct RecordID identifies the guest. Supply expected scope, originalEnvelope and replayKeyVersion from authenticated original native preparation, never HTTP assertions or current-key defaults. All five signed anonymous caveats, issuer, tenant, target, guest, purpose, audience and one-use bounds must match. Signed expiry cannot exceed the original guest expiry.
This bounded read-only seam borrows concurrent proof custody and returns only the existing participant plan, preserving original replay identity, envelope fingerprint and exact signed expiry. It performs no signing, SQL, reservation, consumption, transfer or renewal. It is not target-credential proof: the native password ActionPrimarySource must separately authenticate the current target for this action. Native identity/session owners still fence current guest, target, sessions, merge, policy and expiry and consume atomically with all effects through the sole coordinator and existing capability participant.
Invalid composition returns InvalidInput; foreign or expired proof returns Forbidden; verification failure or panic returns Unavailable. Earlier caller cancellation wins. Every failure returns a zero plan and redacted typed error.
func (*Issuer) PrepareIdentifierConsumption ¶
func (i *Issuer) PrepareIdentifierConsumption(ctx context.Context, command identity.Command, proof capability.Proof, replayKeyVersion uint32) (out identitypostgres.CapabilityPlan, err error)
PrepareIdentifierConsumption authenticates the original proof with this issuer's configured verification policy and derives metadata for the exact immutable identifier command. replayKeyVersion is the trusted original issuance version, not the current issuance default or a bearer-selected value. Retain that key until its credentials and durable custody expire. The participant subsequently matches all metadata against durable issuance; this read-only preparation is neither reservation nor mutation authority. It does not consume or transfer proof custody, resign, extend expiry or open a transaction. Calls are concurrent-safe and bounded by PreparationTimeout and the caller's earlier deadline. Invalid composition returns InvalidInput; invalid/foreign/expired proof returns Forbidden; collaborator failure or panic returns Unavailable. Cancellation remains classified and redacted.
func (*Issuer) PrepareMFAConsumption ¶
func (i *Issuer) PrepareMFAConsumption(ctx context.Context, b identity.CommandBinding, recipient identity.UserID, continuation identity.CommandID, scope [32]byte, issuer string, proof capability.Proof, originalEnvelope [32]byte, replayKeyVersion uint32) (out kernel.CapabilityPlan, err error)
PrepareMFAConsumption reauthenticates the original single-use MFA child for one closed anonymous factor-completion operation. recipient, continuation, scope, issuer, originalEnvelope and replayKeyVersion are trusted original continuation/issuance custody, not request-selected authority. The signed tenant, subject, canonical child ID, resource, closed profile, scope, issuer, audience and original envelope must match. Purpose remains identity.mfa.complete rather than being rewritten to the selected factor operation. Expiry and replay identity are unchanged, including across replay-key rotation.
This bounded read-only seam neither authenticates a factor nor issues a session. It performs no SQL, signing, reservation, consumption, custody transfer, renewal or goroutine creation. The native owner must authenticate durable origin, original browser/primary/remember scope, allowed factor, current policy/account/factor authority and shared attempts. The sole coordinator and capability participant consume with replay/continuation and session effects atomically; this scalar plan is never permission to do so.
Calls may overlap and borrow the proof's shared lifetime. PreparationTimeout and the earlier caller deadline bound verification. Invalid composition returns InvalidInput; invalid/foreign/expired proof returns Forbidden; unavailable verification or collaborator panic returns Unavailable. Context errors remain typed and redacted. Every failure returns a zero plan.
func (*Issuer) PrepareMFAContinuation ¶
func (i *Issuer) PrepareMFAContinuation(ctx context.Context, b identity.CommandBinding, input capability.Payload) (PreparedIssuance, error)
PrepareMFAContinuation signs one original challenge under an anonymous magic-link consume, password-signin, username-signin or phone-password-signin command. The native owner allocates the canonical ID and freezes the full scope before this bounded call; this method preserves that ID, scope and expiry. It performs no SQL, consumption or authentication. Kernel staging still requires the same-Work native primary and exact frozen challenge scope. Retain original encrypted custody across retries; never sign replacements to resolve unknown commit. Restoration cannot renew disclosure.
func (*Issuer) PrepareMagicLinkConsumption ¶
func (i *Issuer) PrepareMagicLinkConsumption(ctx context.Context, binding identity.CommandBinding, recipient identity.UserID, identifier identity.IdentifierID, proof capability.Proof, originalEnvelope [32]byte, replayKeyVersion uint32) (out kernel.CapabilityPlan, err error)
PrepareMagicLinkConsumption reauthenticates the original one-use proof for the exact anonymous identity.magic-link.consume/magic-link-consume v1 binding. recipient and identifier are trusted original issuance selections, not a customer-selected user override. originalEnvelope and replayKeyVersion must come from authenticated durable origin custody; neither an alternate valid signature nor the current replay-key default may replace them. Tenant, signed recipient, identity.magiclink identifier resource, audience and original envelope must match. The anonymous command scope remains unchanged.
This read-only adapter seam is not login permission or a public inspection response. The native owner must additionally validate all original caveats, callback/pre-auth intent, current recipient/factor/risk policy and session effects. The existing capability participant matches durable issuance and consumes atomically in the sole coordinator transaction. No SQL, signing, reservation, consumption, renewal, transfer or goroutine occurs here.
Calls may overlap and borrow the upstream shared proof lifetime. Preparation is bounded by PreparationTimeout and the earlier caller deadline. Invalid composition returns InvalidInput; invalid proof/scope returns Forbidden; unavailable verification or collaborator panic returns Unavailable. Context errors stay classified. Every failure returns a zero plan with no secrets.
func (*Issuer) PrepareMagicLinkProspectiveRecipient ¶
func (i *Issuer) PrepareMagicLinkProspectiveRecipient(ctx context.Context, b identity.CommandBinding, user identity.UserID, input capability.Payload) (PreparedIssuance, error)
PrepareMagicLinkProspectiveRecipient signs exactly one prospective signup grant under the original anonymous request, without creating an account or proving mailbox possession. Its explicit profile binds future creation and policy; kernel staging still requires the same invocation's unused-recipient fence. Preserve returned original custody across retries and recovery. This bounded call performs no SQL or delivery and renews no stored validity.
func (*Issuer) PrepareMagicLinkRecipient ¶
func (i *Issuer) PrepareMagicLinkRecipient(ctx context.Context, b identity.CommandBinding, user identity.UserID, input capability.Payload) (PreparedIssuance, error)
PrepareMagicLinkRecipient prepares exactly one magic-link consume grant for an existing recipient under the unchanged anonymous magic-link request. This bounded pre-transaction call signs original custody but grants no current eligibility, authentication or factor permission. The kernel requires its same-invocation primary verified-email fence and exact signed recipient scope before staging. The native workflow owns original flow, callback and factor/ risk policy. Retain original custody across retries and unknown outcomes; encrypted preparation restoration never renews bearer disclosure or expiry.
func (*Issuer) PrepareManagedChangeConsumption ¶
func (i *Issuer) PrepareManagedChangeConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, envelope [32]byte, replayKeyVersion uint32) (kernel.CapabilityPlan, error)
PrepareManagedChangeConsumption authenticates only change-confirm.managed-v1 and its original management-v1 change grant. It conserves signed identifier purpose, envelope, expiry and retained replay identity. Verification-only schemas/proofs deny. Original intent/current admission and atomic old notice, primary/session effects remain the native email/kernel transaction's duty. Ownership, bounded verification and error semantics match the verification seam; no SQL, signing, consumption, session or custody transfer occurs.
func (*Issuer) PrepareManagedVerificationConsumption ¶
func (i *Issuer) PrepareManagedVerificationConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, envelope [32]byte, replayKeyVersion uint32) (kernel.CapabilityPlan, error)
PrepareManagedVerificationConsumption reauthenticates an original management-v1 link for identity.email.verification-confirm.managed-v1 version1. Signed tenant/user/resource, exact profile/caveats, original envelope and retained replay-key version must match. Signup proofs, change-confirm and alternate schemas deny. No original session is inferred or required by this seam.
The native email owner must authenticate original encrypted mailbox intent and current caller/account/factor/risk authority. Returned metadata grants no mutation authority; the existing capability participant matches durable issuance and consumes/finalizes in the sole protected coordinator transaction. Original signed purpose, expiry and replay identity are conserved unchanged. This method performs no SQL, signing, consumption, transfer or session work, owns no goroutines and is concurrent-safe. PreparationTimeout and earlier cancellation bound verification. Errors are typed/redacted; failures return zero plans. Proof custody is borrowed and must remain immutable during calls.
func (*Issuer) PrepareOrganizationInvitationConsumption ¶
func (i *Issuer) PrepareOrganizationInvitationConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, originalEnvelope [32]byte, replayKeyVersion uint32, expected OrganizationInvitationScope) (out kernel.CapabilityPlan, err error)
PrepareOrganizationInvitationConsumption reauthenticates one original opaque invitation proof for the closed organization invitation-accept command. The authenticated recipient is both UserID and ActorID; RecordID is the invitation, not the organization or capability ID. Expected scope, original envelope and replay-key version come from authenticated retained issuance, never caller claims. Signed tenant, recipient, invitation, issuer, audience, exact purpose, role, invitation version and verified-recipient identifier version must match.
This bounded read-only preparation performs no SQL, signing, reservation, consumption, delivery or renewal. It grants neither membership nor current recipient authority. The native organization owner must fence the original verified recipient, current session, organization, policy and limits in the same coordinator Work as atomic one-use consumption, membership and audit. No proof custody is transferred; concurrent calls borrow its shared lifetime.
Invalid composition returns InvalidInput; foreign or expired proof returns Forbidden; unavailable verification or collaborator panic returns Unavailable. Earlier caller cancellation wins. Every failure returns a zero plan, and retained key rotation never replaces the original replay identity or expiry.
func (*Issuer) PreparePasskeyMFAContinuation ¶
func (i *Issuer) PreparePasskeyMFAContinuation(ctx context.Context, b identity.CommandBinding, input capability.Payload) (PreparedIssuance, error)
PreparePasskeyMFAContinuation signs the original child of the explicit native UV-passkey primary profile. The self-user command retains its own ID as both record and signed correlation; this is not a general subject override. The native owner must prove actual assertion/browser/factor authority before the kernel stages the child in the same transaction. Preparation performs no SQL, authentication or session issuance. Restore original encrypted custody on retries rather than signing another child or extending its lifetime.
func (*Issuer) PreparePasswordResetConsumption ¶
func (i *Issuer) PreparePasswordResetConsumption(ctx context.Context, command identity.Command, replayKeyVersion uint32) (out kernel.CapabilityPlan, err error)
PreparePasswordResetConsumption authenticates the original opaque proof retained inside the exact password-reset input or generated command. The input form allows authoritative preparation admission before hashing; both forms produce the same original plan. No alternate proof or caller-built envelope is accepted. The signed tenant, subject and password resource must match the immutable binding. replayKeyVersion is trusted original issuance metadata from ReadIssuanceOrigin, not the current version or a client-selected default. Original envelope, expiry and replay identity are preserved under the issuer's configured signature/time/revocation policy.
Preparation is bounded by PreparationTimeout and the earlier caller deadline. It performs no SQL, signing, transfer, reservation, consumption or renewal; copies of the proof retain their upstream shared lifetime. Calls may overlap. Invalid composition returns InvalidInput, invalid scope/proof returns Forbidden, unavailable verification or collaborator panic returns Unavailable, and cancellation remains typed. Every failure returns a zero plan with no secrets.
A plan is not reset permission. The password owner must validate original durable issuance intent, closed recovery profile, current identifier/factors, risk/HIBP and verifier policy. The sole coordinator and capability participant must match durable provenance and atomically consume with password/session effects. Preparation cannot make a terminal proof usable or establish commit.
func (*Issuer) PreparePhonePasswordResetConsumption ¶
func (i *Issuer) PreparePhonePasswordResetConsumption(ctx context.Context, command identity.Command, replayKeyVersion uint32) (out kernel.CapabilityPlan, err error)
PreparePhonePasswordResetConsumption authenticates only the original signed proof retained by a sealed joint phone-reset input or generated command. The exact identity/phone native-v1 descriptor, signed password resource, tenant, user, configured audience and one-use bound must match. The original password or hash, SMS code, independent TOTP and browser cookie remain in their joint command custody; no generic command conversion or alternate proof is accepted.
replayKeyVersion is trusted original issuance metadata from ReadIssuanceOrigin, not a request-selected version or the active issuance default. Retain that key through recovery. Configured signature, time and revocation policy apply. Repeated preparation preserves the original envelope, absolute expiry and replay identity; it performs no SQL, signing, transfer, reservation or use. Calls may overlap and are bounded by PreparationTimeout and earlier deadlines. Invalid composition returns InvalidInput, invalid scope/proof Forbidden, unavailable verification or collaborator panic Unavailable, and cancellation remains typed. Every failure returns a zero plan and redacted error.
This plan is not recovery permission. The native owner must authenticate the complete original durable phone reset profile and current phone/password, browser, independent-factor and completion-risk authority. The sole identity coordinator must consume capability, OTP and risk with the canonical password replacement and required session effects. Preparation cannot establish commit, renew expired custody or make terminal evidence usable.
func (*Issuer) PreparePrivacyExportConsumption ¶
func (i *Issuer) PreparePrivacyExportConsumption(ctx context.Context, command identity.Command, proof capability.Proof, replayKeyVersion uint32) (out identitypostgres.CapabilityPlan, err error)
PreparePrivacyExportConsumption reauthenticates the exact original opaque proof for an immutable privacy request and derives the capability-owned consumption plan. replayKeyVersion is trusted retained issuance metadata, never a current default or a bearer-selected version. Configured signature, audience, time and revocation policy apply; another valid signed envelope cannot replace the command's original proof. Calls are concurrent-safe and bounded by PreparationTimeout and the caller's earlier deadline.
Preparation does not transfer, resign, renew, reserve or consume the proof, begin a transaction, or authorize a session/export. The sole coordinator must still enforce primary expiry, session/policy eligibility, exact durable issuance and atomic use with all snapshot/effect owners. Invalid composition returns InvalidInput; invalid/foreign proof returns Forbidden; verification availability failures and panics return Unavailable. Cancellation stays classified and all errors are redacted. No raw proof material is returned.
func (*Issuer) PrepareRegistration ¶
func (i *Issuer) PrepareRegistration(ctx context.Context, b identity.CommandBinding, user identity.UserID, inputs []capability.Payload) (PreparedIssuance, error)
PrepareRegistration prepares new-user verification under the unchanged original anonymous signup command. Preparation grants no creation authority; staging still requires the kernel's same-Work registration of this exact user.
func (*Issuer) PrepareRegistrationVerificationConsumption ¶
func (i *Issuer) PrepareRegistrationVerificationConsumption(ctx context.Context, binding identity.CommandBinding, proof capability.Proof, envelope [32]byte, replayKeyVersion uint32) (kernel.CapabilityPlan, error)
PrepareRegistrationVerificationConsumption reauthenticates the exact original anonymous signup proof for a current native email confirmation binding. The action is identity.email.verification-confirm, schema is identity.email.verification-confirm.native-v1 version 1, and RecordID is the signed identifier. Tenant and UserID must equal the signed target. The envelope must come from the authenticated original intent, not an alternate signature, and replayKeyVersion from original durable issuance, never an active-key default. No session caveats or rewritten proof are introduced.
Configured signature, audience, time and revocation policy apply. The original identity.identifier.verify purpose, expiry, envelope and replay identity are preserved. The owning email workflow must first authorize the full original mailbox/redirect/version commitment. This metadata alone is not that proof, current identity/session authority, a usable grant or a command receipt. The sole Coordinator must still match durable issuance, fence current account and identifier state and consume atomically with the protected mutation.
No SQL, reservation, signing, custody transfer, consumption or goroutine runs. Calls are concurrent-safe and bounded by PreparationTimeout and earlier deadlines. Invalid composition is InvalidInput; invalid proof/profile is Forbidden; verification failure/panic is Unavailable. Cancellation remains typed and redacted. Every failure returns a zero plan; no raw bearer escapes.
func (*Issuer) PrepareResetRecipient ¶
func (i *Issuer) PrepareResetRecipient(ctx context.Context, b identity.CommandBinding, user identity.UserID, input capability.Payload) (PreparedIssuance, error)
PrepareResetRecipient prepares exactly one reset-complete grant for an existing user under the unchanged anonymous password-reset-request command. The bounded, pre-transaction call grants no recovery eligibility, performs no SQL and does not prove current account, credential or factor authority. The kernel requires this exact recipient's primary fence before staging; the workflow owns the complete reset profile and current recovery-factor policy. Retain the returned original custody across retries and unknown outcomes.
func (*Issuer) PrepareVerificationMFAContinuation ¶
func (i *Issuer) PrepareVerificationMFAContinuation(ctx context.Context, b identity.CommandBinding, input capability.Payload) (PreparedIssuance, error)
PrepareVerificationMFAContinuation signs one original challenge for the explicit recipient of a separately committed registration verification. Binding retains that confirmation's command ID in RecordID, not an anonymous primary or a same-transaction consumption. Structural checks do not prove the parent or browser; the exact native owner must fence both before kernel staging. This bounded call performs no SQL, authentication or session issuance. Retain encrypted preparation across retries; restore original bytes without extending expiry or signing replacements after an unknown commit.
func (*Issuer) ReadIssuanceOrigin ¶
func (i *Issuer) ReadIssuanceOrigin(ctx context.Context, pool *database.Pool, proof capability.Proof, purpose capability.Purpose) (capability.Grant, identity.CommandID, uint32, error)
ReadIssuanceOrigin authenticates a purpose-explicit original one-use proof and matches its complete persisted issuance provenance. Purpose is trusted composition, never a bearer-selected fallback. Historical terminal state may retain provenance but grants no usable authority; signature, audience, time and configured revocation policy still apply. Missing or mismatched origins deny. Original replay versions are returned without current-key substitution.
This is a trusted adapter seam, not public inspection or workflow permission. The owning workflow must validate its closed purpose-specific payload, original encrypted intent, current account/factor/risk state and exact scope before any public response or protected consumption. No transaction, reservation, consumption, renewal, bearer transfer, callback or goroutine is created. Pool/proof are borrowed; the issuer timeout and earlier deadline bound crypto and one indexed primary read. Instances are concurrent-safe. Errors redact; every failed/cancelled call returns zero projections. Metadata is sensitive.
func (*Issuer) ReadMFAMagicLinkParent ¶
func (i *Issuer) ReadMFAMagicLinkParent(ctx context.Context, pool *database.Pool, child capability.Proof, parentID string, parentEnvelope [32]byte, parentExpiry time.Time) (out MFAMagicLinkParent, err error)
ReadMFAMagicLinkParent verifies the original MFA child and resolves its exact already-consumed magic-link parent without accepting a reusable primary bearer. Parent ID/envelope/expiry must come from the authenticated stored continuation, not client fields. The parent's finalized consumer tuple must match the child's original issuance command/fingerprint/generation. Original request provenance, tenant, subject, signature times and exclusive lifetimes are preserved; superseded/missing/foreign records deny.
The result owns no connection or transaction and grants no execution ticket. Signature/revocation verification and indexed primary reads share one issuer timeout and the earlier caller deadline. Pool/child custody are borrowed; immutable issuers permit concurrent calls. No callback, goroutine, signing, consumption, intent store or freshness renewal is created. Invalid composition returns InvalidInput; missing/foreign provenance returns Forbidden; unavailable storage/verification returns Unavailable. Cancellation remains typed. Every error returns zero custody and reveals no SQL, credential or correlated data.
func (*Issuer) ReadMFAVerificationParent ¶
func (i *Issuer) ReadMFAVerificationParent(ctx context.Context, pool *database.Pool, child capability.Proof, parentID string, parentEnvelope [32]byte, parentExpiry time.Time) (MFAVerificationParent, error)
ReadMFAVerificationParent authenticates the child and its already-consumed registration grant without recovering a reusable primary bearer. Parent identity/digest/expiry must come from the authenticated durable continuation. The signed child's correlation identifies the separate confirmation command; its exact committed journal fingerprint/generation must match consumption. The native owner separately checks the challenge journal's declared parent. Earlier caller deadlines and the issuer timeout bound all primary reads. Borrowed pool/child remain caller-owned; errors return zero redacted custody. No callback, goroutine, signing, consumption or freshness renewal occurs.
func (*Issuer) ReadMagicLinkOrigin ¶
func (i *Issuer) ReadMagicLinkOrigin(ctx context.Context, pool *database.Pool, proof capability.Proof) (capability.Grant, identity.CommandID, uint32, bool, error)
ReadMagicLinkOrigin authenticates original magic-link provenance and its exact signed supersession scope in one indexed primary read. The additional flag reports retained invalidation, not command outcome or permission to consume. Reserved/terminal provenance remains readable for retries and recovery; legacy unselected records report false. Migration 003 is required. Missing, tampered or unavailable evidence returns zero projections including the flag. Proof and pool are borrowed; bounds and cancellation match ReadIssuanceOrigin. The workflow must still reconstruct browser scope, check current authority and repeat admission/one-use in the protected transaction. No freshness renews.
func (*Issuer) ReadRegistrationOrigin ¶
func (i *Issuer) ReadRegistrationOrigin(ctx context.Context, pool *database.Pool, proof capability.Proof) (capability.Grant, identity.CommandID, uint32, error)
ReadRegistrationOrigin authenticates a registration-profile proof with this issuer's configured signature, audience, time and revocation policy, then matches its exact persisted original issuance. It returns the authenticated grant, originating command ID and original replay-key version, never a raw bearer, current-key substitution or newly signed credential. Unpublished, legacy originless, foreign-envelope and mismatched evidence deny identically.
This is a trusted native composition seam, not public scanner validation, session authority, a signup receipt or permission to consume. The origin owner must authenticate its original signup input and email intent. Confirm must still recheck current identity and capability state in the sole protected transaction. Later consuming/terminal state does not erase original provenance and is deliberately not interpreted here as usable authority or rollback.
The primary pool and proof are borrowed; no transaction, custody transfer, reservation, mutation, callback or goroutine is created. Immutable issuers permit concurrent calls. PreparationTimeout and the earlier caller deadline bound crypto and the indexed primary read. Invalid composition returns InvalidInput, unavailable verification/storage returns Unavailable, and cancellation retains its typed classification. Errors never expose SQL, credentials or correlation metadata. Successful projections remain sensitive.
func (*Issuer) RecoverParticipant ¶
func (i *Issuer) RecoverParticipant(ctx context.Context, w identitypostgres.RecoveryWork) (identitypostgres.RecoveryStatus, error)
RecoverParticipant reads original issuance evidence under the coordinator's frozen prior generation. Missing, partial or conflicting ordinary/signup rows remain unknown. Selected single-grant recipient and native anonymous- upgrade preparation profiles can prove non-commit only when neither original identity nor replay identity nor any grant of that originating command exists under the coordinator recovery fence. No expiry, timeout or consuming state is rewritten as rollback.
func (*Issuer) RequireVerificationMFAParent ¶
func (i *Issuer) RequireVerificationMFAParent(ctx context.Context, w kernel.Work, owner kernel.EmailVerificationMFAChallengeContributor, grant capability.Grant, signup identity.CommandID) error
RequireVerificationMFAParent fences the genuine registration grant consumed by the separately committed confirmation. It is read-only and available only to the exact native email challenge participant during preparation, Apply or final admission. Grant must be actual verified capability custody; original signup and confirmation come from authenticated native history, never a client assertion. The row and confirmation journal must retain their exact original fingerprint/generation. This neither consumes again nor grants factor/session authority. Locks share the caller's sole Work; every error must propagate.
func (*Issuer) RequireVerificationMFATOTPParent ¶
func (i *Issuer) RequireVerificationMFATOTPParent(ctx context.Context, w kernel.Work, owner kernel.MFACompletionContributor, command identity.Command, parent MFAVerificationParent) error
RequireVerificationMFATOTPParent repeats original parent/child custody under the exact native TOTP owner's preparation, Apply or final-check Work. Parent must come from ReadMFAVerificationParent and be matched to the owner's actual continuation before this call. This read-only fence neither authenticates a factor nor consumes the child. It locks original confirmation and challenge history and both grants until the caller's sole transaction closes; original expiry cannot be renewed. Foreign/returned handles and changed custody deny. Every error must abort the protected operation. All IO retains the earlier caller deadline and issuer timeout; rows are closed on every path.
func (*Issuer) RequireVerificationMFATOTPParentAttempt ¶
func (i *Issuer) RequireVerificationMFATOTPParentAttempt(ctx context.Context, w kernel.MFATOTPAttemptWork, owner kernel.MFATOTPAttemptContributor, parent MFAVerificationParent) error
RequireVerificationMFATOTPParentAttempt applies the same immutable parent fence in the sealed counted-attempt callback, before code comparison or debit. The live callback's frozen child and subject must match opaque parent custody. This cannot charge an attempt, consume a factor or create a session. Copies share the caller's bounded transaction lifetime and every error must propagate.
func (*Issuer) Stage ¶
func (i *Issuer) Stage(ctx context.Context, w identitypostgres.Work, p PreparedIssuance) error
Stage binds immutable original grants to this exact owner in the admitted original command. It neither signs, persists nor exposes bearer bytes.
func (*Issuer) ValidateCapabilityIssuance ¶
func (i *Issuer) ValidateCapabilityIssuance(b identity.CommandBinding, p identitypostgres.CapabilityIssuancePlan) error
ValidateCapabilityIssuance checks retained-key and metadata shape without I/O. Exact cryptographic provenance is rederived from Grants in the sealed phase.
func (*Issuer) ValidateIssuedProof ¶
func (i *Issuer) ValidateIssuedProof(ctx context.Context, pool *database.Pool, proof capability.Proof, purpose capability.Purpose) (capability.Grant, identity.CommandID, uint32, error)
ValidateIssuedProof additionally requires issued, unused state and exclusive primary expiry in the same indexed read. Repeated inspection is read-only: no reservation, consumption or execution ticket results. Reserved, terminal, expired or revoked proofs deny; the owning workflow must still recheck current eligibility and repeat admission during atomic completion. Ownership, bounds, cancellation, redaction and zero-on-error semantics match ReadIssuanceOrigin.
func (*Issuer) ValidateRegistrationProof ¶
func (i *Issuer) ValidateRegistrationProof(ctx context.Context, pool *database.Pool, proof capability.Proof) (capability.Grant, identity.CommandID, uint32, error)
ValidateRegistrationProof authenticates original registration provenance and requires an issued, unused proof whose exclusive expiry is after primary time in that same indexed read. No reservation, consumption, expiry renewal or mutation occurs. Reserved, finalized, released, expired and revoked proofs deny identically to absence. ReadRegistrationOrigin deliberately remains the separate historical reader, including after consumption.
This trusted email composition seam returns sensitive original grant metadata, not a public scanner response, mailbox ownership or permission to execute. The email owner must bind original address/redirect and current account state before returning bounded public metadata. Confirmation must repeat admission and consume atomically; validation cannot hold authority across a later call. The borrowed pool/proof, finite budget, concurrency, redaction and zero-on-error semantics are the same as ReadRegistrationOrigin. No handles or goroutines are retained and cancelled calls return no sensitive projection.
type IssuerConfig ¶
type IssuerConfig struct {
// Crypto pins the trusted issuer, signing and verification policy and local clock.
Crypto capability.ServiceConfig
// Audience is the single exact audience admitted for every prepared grant.
Audience string
// CurrentReplayKeyVersion selects a nonzero retained key for new replay bindings.
CurrentReplayKeyVersion uint32
// RetainedReplayKeys holds 1..32 distinct nonzero keys, copied at construction.
// Retain referenced versions for the full lifetime of original command recovery.
RetainedReplayKeys map[uint32][32]byte
// PreparationTimeout bounds each signing and verification phase to 1..30 seconds.
PreparationTimeout time.Duration
// RetainEmailVerificationTargets selects migration 005 and retains the
// authenticated signed Resource for identifier verification. Enable before
// issuing signup/management links when native email removal is selected.
// False preserves the existing installation and issuance SQL contract.
RetainEmailVerificationTargets bool
}
IssuerConfig pins signing/verification policy and a separate versioned replay key set. Replay keys must never be signing keys; deployment key custody owns that separation. Maps contain 1..32 nonzero unique keys and are copied. Keep every referenced version until bearer validation and retained authority no longer require it. Audience is one exact target, PreparationTimeout is 1..30s. Crypto collaborators must support concurrent bounded calls; Clock is local.
type MFAMagicLinkParent ¶
type MFAMagicLinkParent struct {
// contains filtered or unexported fields
}
MFAMagicLinkParent retains opaque canonical-payload custody from an exact consumed parent linked to an authenticated original child. It is immutable, copyable and safe for concurrent local comparisons; zero values deny. Inspection is not permission to complete MFA or issue a session. No raw primary credential is recovered, recreated, signed or retained.
func (MFAMagicLinkParent) Bindings ¶
func (p MFAMagicLinkParent) Bindings() (MFAMagicLinkParentBindings, error)
Bindings projects immutable historical routing/times, not decoded payload fields or current authority. A copied projection cannot manufacture custody.
func (MFAMagicLinkParent) Format ¶
func (MFAMagicLinkParent) Format(s fmt.State, _ rune)
Format prevents implicit disclosure of correlated parent custody.
func (MFAMagicLinkParent) LogValue ¶
func (MFAMagicLinkParent) LogValue() slog.Value
LogValue redacts parent provenance and canonical-payload custody.
func (MFAMagicLinkParent) MarshalJSON ¶
func (MFAMagicLinkParent) MarshalJSON() ([]byte, error)
MarshalJSON refuses implicit export of parent digest custody.
func (MFAMagicLinkParent) MarshalText ¶
func (MFAMagicLinkParent) MarshalText() ([]byte, error)
MarshalText refuses implicit text/map-key export of parent custody.
func (MFAMagicLinkParent) MatchPayload ¶
func (p MFAMagicLinkParent) MatchPayload(v capability.Payload) error
MatchPayload requires byte-equivalent canonical reconstruction of the entire retained parent payload under the original bounded capability format. Extra, missing or changed caveats, subject, tenant, scope, request origin or times deny. This local comparison performs no IO, consumption, signing or renewal. Success authenticates historical metadata only; protected execution must repeat its current account/factor/browser/child authority checks.
type MFAMagicLinkParentBindings ¶
type MFAMagicLinkParentBindings struct {
// TenantID is the tenant authenticated by the original consumed parent.
TenantID identity.TenantID
// UserID identifies the original parent recipient, not a caller override.
UserID identity.UserID
// CapabilityID is the original consumed magic-link credential identifier.
CapabilityID string
// RequestCommandID identifies the original request that issued the parent.
RequestCommandID identity.CommandID
// PrimaryCommandID identifies the original command that consumed the parent.
PrimaryCommandID identity.CommandID
// ReplayKeyVersion identifies the retained key authenticating original replay.
ReplayKeyVersion uint32
// IssuedAt retains the parent's original signed issuance time.
IssuedAt time.Time
// NotBefore retains the parent's original signed earliest-use time.
NotBefore time.Time
// ExpiresAt retains original expiry; reconstruction cannot renew it.
ExpiresAt time.Time
}
MFAMagicLinkParentBindings is historical original request/primary provenance. It contains no bearer, factor proof or current authorization. The owning magic-link adapter must reconstruct its entire original payload and call MatchPayload before using identifier or session metadata. The MFA workflow must still fence current authority and original browser custody atomically.
type MFAVerificationParent ¶
type MFAVerificationParent struct {
// contains filtered or unexported fields
}
MFAVerificationParent owns opaque original-payload custody. It cannot be used as a magic-link parent or manufactured from projected bindings. Zero denies; immutable copies support concurrent local matching and retain no bearer.
func (MFAVerificationParent) Bindings ¶
func (p MFAVerificationParent) Bindings() (MFAVerificationParentBindings, error)
Bindings projects exact committed-parent routing and original deadlines. Projections cannot reconstruct payload custody or authorize factor completion.
func (MFAVerificationParent) Format ¶
func (MFAVerificationParent) Format(s fmt.State, _ rune)
Format redacts correlated parent custody.
func (MFAVerificationParent) LogValue ¶
func (MFAVerificationParent) LogValue() slog.Value
LogValue redacts structured diagnostics.
func (MFAVerificationParent) MarshalJSON ¶
func (MFAVerificationParent) MarshalJSON() ([]byte, error)
MarshalJSON rejects implicit custody export.
func (MFAVerificationParent) MarshalText ¶
func (MFAVerificationParent) MarshalText() ([]byte, error)
MarshalText rejects implicit textual custody export.
func (MFAVerificationParent) MatchPayload ¶
func (p MFAVerificationParent) MatchPayload(v capability.Payload) error
MatchPayload requires exact canonical reconstruction of the original issued registration-verification grant, including all native signup/callback caveats. It performs no signing, disclosure, IO, consumption or validity renewal. The native completion owner must repeat live account, browser and factor fences.
type MFAVerificationParentBindings ¶
type MFAVerificationParentBindings struct {
// TenantID is the tenant shared by the original parent and MFA child.
TenantID identity.TenantID
// UserID is their authenticated original recipient, not current authority.
UserID identity.UserID
// CapabilityID identifies the already-consumed registration grant.
CapabilityID string
// RequestCommandID identifies the original signup issuance.
RequestCommandID identity.CommandID
// VerificationCommandID identifies the separately committed parent use.
VerificationCommandID identity.CommandID
// ChallengeCommandID identifies the subsequent pending MFA issuance.
ChallengeCommandID identity.CommandID
// ReplayKeyVersion retains the parent's original replay-key identity.
ReplayKeyVersion uint32
// IssuedAt is the original parent grant's signed issuance time.
IssuedAt time.Time
// NotBefore is its original signed lower validity bound.
NotBefore time.Time
// ExpiresAt is its original signed deadline, never renewed by this read.
ExpiresAt time.Time
}
MFAVerificationParentBindings is historical provenance for three distinct commands: original signup issuance, committed verification, and subsequent MFA challenge. It conveys no current authentication, factor or session authority.
type MagicLinkSupersessionScope ¶
type MagicLinkSupersessionScope struct {
// contains filtered or unexported fields
}
MagicLinkSupersessionScope identifies one exact original browser flow and recipient selection. It is metadata, not proof verification or authorization. Copies are immutable and safe for concurrent use; the zero value is invalid.
func MagicLinkScopeFromPayload ¶
func MagicLinkScopeFromPayload(p capability.Payload) (MagicLinkSupersessionScope, error)
MagicLinkScopeFromPayload projects bounded, exact original scope from a magic-link payload. The caller must separately authenticate the payload and reconstruct original intent. Token/command IDs, dates and authority versions are deliberately excluded: resending cannot escape its original flow by issuing a different token or observing newer authority. No strings normalize.
func (MagicLinkSupersessionScope) Digest ¶
func (s MagicLinkSupersessionScope) Digest() [32]byte
Digest returns the opaque scope identity for signed metadata and native transactional fencing. It cannot grant authority or select another tenant.
func (MagicLinkSupersessionScope) Format ¶
func (MagicLinkSupersessionScope) Format(s fmt.State, _ rune)
Format redacts scope metadata, including browser and recipient bindings.
func (MagicLinkSupersessionScope) MarshalJSON ¶
func (MagicLinkSupersessionScope) MarshalJSON() ([]byte, error)
MarshalJSON rejects serialization of opaque scope custody.
type ManagedEmailSupersessionScope ¶
type ManagedEmailSupersessionScope struct {
// contains filtered or unexported fields
}
ManagedEmailSupersessionScope identifies one exact issuer/audience, tenant, recipient, identifier and confirmation action. It is metadata, not proof or authority. Copies are immutable and safe for concurrent use; zero is invalid. A family deliberately excludes request IDs, times, key versions, callbacks and changing authority versions: a newly authorized resend must invalidate every older selected grant for that mailbox/action, not escape through new intent.
func ManagedEmailScopeFromPayload ¶
func ManagedEmailScopeFromPayload(p capability.Payload) (ManagedEmailSupersessionScope, error)
ManagedEmailScopeFromPayload projects a bounded stable mailbox family. The native owner must separately authenticate/reconstruct complete original mailbox, callback, policy, fresh primary proof and pending-identifier state. This function does not sign, normalize, read a clock/store, reserve, consume or authorize anything. Existing four-caveat management payloads can be used to compute the family; an explicitly selected fifth email.supersession caveat must exactly equal it. Registration and magic-link profiles cannot borrow it. Inputs remain borrowed/immutable. Invalid input returns zero/redacted error; no resources or goroutines are created.
func (ManagedEmailSupersessionScope) Digest ¶
func (s ManagedEmailSupersessionScope) Digest() [32]byte
Digest returns the opaque family identity for signed metadata and native transaction fencing. It grants no authority and selects no different tenant.
func (ManagedEmailSupersessionScope) Format ¶
func (ManagedEmailSupersessionScope) Format(s fmt.State, _ rune)
Format redacts correlated account and mailbox metadata.
func (ManagedEmailSupersessionScope) MarshalJSON ¶
func (ManagedEmailSupersessionScope) MarshalJSON() ([]byte, error)
MarshalJSON denies implicit scope export.
type OrganizationInvitationScope ¶
type OrganizationInvitationScope struct {
// OrganizationID identifies the organization bound by original issuance.
OrganizationID string
// InvitationVersion is the positive version signed into the invitation.
InvitationVersion uint64
// Role is the exact signed role; current role admission remains external.
Role string
// RecipientIdentifierID identifies the originally verified recipient.
RecipientIdentifierID identity.IdentifierID
// RecipientIdentifierVersion binds that recipient's original version.
RecipientIdentifierVersion uint64
}
OrganizationInvitationScope is original trusted invitation metadata, not authorization or HTTP input. Resolve it from authenticated durable invitation custody. Versions are positive; string fields are exact 1..128-byte visible ASCII identifiers. The organization owner alone decides whether that role is currently permitted. Copies are immutable and safe for concurrent reads.
func (OrganizationInvitationScope) Format ¶
func (OrganizationInvitationScope) Format(s fmt.State, _ rune)
Format hides correlated invitation and recipient metadata.
func (OrganizationInvitationScope) MarshalJSON ¶
func (OrganizationInvitationScope) MarshalJSON() ([]byte, error)
MarshalJSON rejects automatic export of trusted scope custody.
func (OrganizationInvitationScope) MarshalText ¶
func (OrganizationInvitationScope) MarshalText() ([]byte, error)
MarshalText rejects automatic export of trusted scope custody.
type Participant ¶
type Participant struct {
// contains filtered or unexported fields
}
Participant is an immutable coordinator-only one-use storage participant. Instances may serve concurrent independent commands; handles remain serial-use. The zero value is invalid. No handles, rows or runtime resources are retained. It supports reserve, takeover, provisional consumption, finalization, evidence and terminal release. Issuance, revocation and cleanup remain unfinished; execution still requires the complete identity-owned domain composition.
func NewParticipant ¶
func NewParticipant() *Participant
NewParticipant creates the stateless default-schema participant without I/O. Migration installation and permissions remain explicit composition concerns.
Example ¶
package main
import (
"fmt"
identitycapability "github.com/faustbrian/go-capability/postgres/identity"
)
func main() {
p := identitycapability.NewParticipant()
d := p.Descriptor()
fmt.Println(d.Owner, d.ContractID, d.Version)
}
Output: capability/postgres capability.one-use 1
func (*Participant) ApplyCapability ¶
func (p *Participant) ApplyCapability(ctx context.Context, w identitypostgres.CapabilityApplyWork) error
ApplyCapability provisionally consumes the exact original reservation under current-generation invocation custody. It locks before checking exclusive primary expiry and increments only below the signed maximum. It never renews expiry, releases evidence or claims a committed command. Rollback restores the original unused reservation; only the coordinator owns transaction closure.
func (*Participant) Descriptor ¶
func (*Participant) Descriptor() identitypostgres.ContributorDescriptor
Descriptor returns the immutable identity of capability.one-use v1. It grants registration identity only, never invocation or transaction authority.
func (*Participant) FinalizeCapability ¶
func (p *Participant) FinalizeCapability(ctx context.Context, w identitypostgres.CapabilityFinalizeWork) error
FinalizeCapability CASes the same consumed current-generation reservation to finalized in the protected transaction, after rechecking exclusive primary expiry under its row lock. Missing use, repeated/terminal state or changed binding conflicts. Finalization is provisional until the coordinator commits; it neither terminalizes the command ledger nor infers an unknown outcome.
func (*Participant) Format ¶
func (*Participant) Format(s fmt.State, _ rune)
Format redacts runtime participant state.
func (*Participant) MarshalJSON ¶
func (*Participant) MarshalJSON() ([]byte, error)
MarshalJSON rejects serialization of runtime composition.
func (*Participant) RebindCapability ¶
func (p *Participant) RebindCapability(ctx context.Context, w identitypostgres.CapabilityReservationWork) error
RebindCapability CAS-transfers only the exact previous reserved generation. It preserves immutable issued input and command/fingerprint; live primary expiry is required. Failed takeover leaves no participant or journal prefix.
func (*Participant) RecoverParticipant ¶
func (p *Participant) RecoverParticipant(ctx context.Context, w identitypostgres.RecoveryWork) (identitypostgres.RecoveryStatus, error)
RecoverParticipant reads retained primary evidence for the exact frozen input and previous reserved generation. Reserved or revoked with zero uses and matching original reservation linkage is negative evidence; finalized or used is committed participant evidence, never a command receipt. Missing, mismatched or other terminal evidence remains unknown. Expiry alone changes nothing. Coordinator combines all participant evidence before release.
func (*Participant) ReleaseCapability ¶
func (p *Participant) ReleaseCapability(ctx context.Context, w identitypostgres.CapabilityReleaseWork) error
ReleaseCapability terminal-releases an exact unused reserved record only with coordinator-granted unanimous non-commit authority. The transition CASes previous to recovery generation with the failure audit and aborted receipt. It never makes evidence reusable; expiry does not reactivate or erase it.
func (*Participant) ReserveCapability ¶
func (p *Participant) ReserveCapability(ctx context.Context, w identitypostgres.CapabilityReservationWork) error
ReserveCapability locks an existing issued record and binds exact command, fingerprint and generation in the coordinator's reservation transaction. It never inserts missing state or consumes a use. Expired, terminal or changed input returns a redacted Conflict. Only the exact registered instance may act.
type PreparationVerificationKey ¶
type PreparationVerificationKey struct {
// ID identifies original signing material under the codec's trusted issuer.
ID string
// HMAC supplies a nonzero 32..512-byte secret key instead of Ed25519 material.
// Construction copies it; the key must differ from replay and envelope keys.
HMAC []byte
// Ed25519 supplies a 32-byte public verification key instead of HMAC material.
Ed25519 []byte
// Disabled denies verification with this key in the constructed codec.
Disabled bool
// Revoked marks this retained key as revoked for original-envelope verification.
Revoked bool
// NotBefore optionally limits the key's earliest accepted verification time.
NotBefore time.Time
// NotAfter optionally limits the key's latest accepted verification time.
NotAfter time.Time
}
PreparationVerificationKey pins local signing-verification material and key lifecycle policy. Exactly one of HMAC or Ed25519 must be populated.
func (PreparationVerificationKey) Format ¶
func (PreparationVerificationKey) Format(s fmt.State, _ rune)
Format hides verification key material and lifecycle metadata.
func (PreparationVerificationKey) LogValue ¶
func (PreparationVerificationKey) LogValue() slog.Value
LogValue redacts verification key material and lifecycle metadata.
func (PreparationVerificationKey) MarshalJSON ¶
func (PreparationVerificationKey) MarshalJSON() ([]byte, error)
MarshalJSON rejects implicit verification-key export.
func (PreparationVerificationKey) MarshalText ¶
func (PreparationVerificationKey) MarshalText() ([]byte, error)
MarshalText rejects implicit verification-key export.
type PreparedIssuance ¶
type PreparedIssuance struct {
// contains filtered or unexported fields
}
PreparedIssuance is original request-memory custody, not authorization or a commit receipt. All copies share the proofs' one-transfer lifetime. Plan snapshots are owned; no method exposes raw bearer strings or signing keys.
func (PreparedIssuance) Format ¶
func (PreparedIssuance) Format(s fmt.State, _ rune)
Format hides prepared credential custody and immutable metadata.
func (PreparedIssuance) MarshalJSON ¶
func (PreparedIssuance) MarshalJSON() ([]byte, error)
MarshalJSON rejects serialization of prepared credential custody.
func (PreparedIssuance) Plan ¶
func (p PreparedIssuance) Plan() (identitypostgres.CapabilityIssuancePlan, error)
Plan returns a defensive metadata-only declaration. Retain the same prepared batch across retries; never sign replacement credentials after unknown commit.
func (PreparedIssuance) TransferForDelivery ¶
func (p PreparedIssuance) TransferForDelivery(ctx context.Context, index uint16, encrypt func(context.Context, []byte) error) error
TransferForDelivery irreversibly transfers one proof only to synchronous authenticated encryption admission, never to a sender or response before commit. The trusted workflow owns that destination. Aliases are invalidated before the callback and borrowed bytes cleared after all exits. It is not a synchronous reveal API, a transport receipt or permission to retry disclosure.
Source Files
¶
- consumption.go
- consumption_account_link.go
- consumption_anonymous.go
- consumption_magiclink.go
- consumption_mfa.go
- consumption_organization.go
- consumption_phone_reset.go
- consumption_reset.go
- email_retirement.go
- issuer.go
- issuer_mfa.go
- issuer_organization_recovery.go
- issuer_preparation.go
- magiclink_prospective.go
- magiclink_supersession.go
- managed_consumption.go
- managed_supersession.go
- mfa_parent.go
- mfa_verification_parent.go
- migrations.go
- participant.go
- registration_consumption.go
- registration_origin.go
- verification_mfa_completion_fence.go
- verification_mfa_fence.go