oc · docs
documentation

@orangecheck/gate


@orangecheck/gate / GateOptions

Interface: GateOptions

Defined in: types.ts:47

Config for a single gated route.

You MUST pick exactly one of address / attestationId / identity — that's the field the gate uses to look the subject up.

Properties

PropertyTypeDescriptionDefined in
<a id="property-address"></a> address?SubjectSourcePull a Bitcoin address from the request.types.ts:54
<a id="property-attestationid"></a> attestationId?SubjectSourcePull an attestation ID (SHA-256 hex) from the request.types.ts:56
<a id="property-cachemax"></a> cacheMax?numberMax cache entries. Default 1_000.types.ts:66
<a id="property-cachettlms"></a> cacheTtlMs?numberIn-process cache TTL for lookup results. Default 60_000 ms.types.ts:64
<a id="property-exposesubject"></a> exposeSubject?booleanInclude the resolved subject / subjectKind in the default 403 body. Default false — echoing a cookie-bound address discloses it to anyone who can hit the endpoint. Flip to true only when the subject was already caller-supplied (e.g., from: 'header').types.ts:104
<a id="property-failopen"></a> failOpen?booleanIf the upstream fails (relays throw, or the signature verified but no Esplora endpoint answered), let the request through. Default false: degraded mode should be explicit. A lookup the gate abandons at its own lookupTimeoutMs is not an outage and is never let through.types.ts:74
<a id="property-identity"></a> identity?SubjectSourcePull an identity binding from the request in protocol:identifier form, e.g. github:alice.types.ts:61
<a id="property-lookuptimeoutms"></a> lookupTimeoutMs?numberHard deadline for the upstream lookup. The default outlasts the SDK's own worst case (two relay fan-outs plus two Esplora tries), about 19s. Beyond it the gate returns lookup_timeout, which fails closed even with failOpen. Set it lower only if you prefer a fast "no" to a slow "yes".types.ts:85
<a id="property-mindays"></a> minDays?numberMinimum days unspent. Default 0.types.ts:51
<a id="property-minsats"></a> minSats?numberMinimum sats bonded. Default 0 (any proof passes on stake).types.ts:49
<a id="property-onblocked"></a> onBlocked?(req: MinimalReq, res: MinimalRes, decision: GateDecision) => voidCustom "blocked" handler. If omitted, the gate sends a 403 JSON body.types.ts:114
<a id="property-ondecision"></a> onDecision?(req: MinimalReq, decision: GateDecision) => voidCalled with the decision before the response is sent. Use for logging.types.ts:109
<a id="property-relays"></a> relays?string[]Override the Nostr relays used for discovery.types.ts:77
<a id="property-trustunsafesources"></a> trustUnsafeSources?booleanheader / query / cookie / body subject sources are untrusted by default — anyone can set them. Passing trustUnsafeSources: true acknowledges that your application verified the address some other way (e.g., from a signed session cookie), or that you're OK with letting callers self-declare. The gate will still log a startup warning unless this flag is set on an explicitly-untrusted source. Custom from functions are always considered trusted (you wrote them).types.ts:96