Skip to main content

MandaitorClient

@mandaitor/sdk


@mandaitor/sdk / MandaitorClient

Class: MandaitorClient

Defined in: @mandaitor/sdk/dist/client.d.ts:41

HTTP client for the Mandaitor Delegation Mandate Registry API.

Wraps the REST API with typed methods for the full mandate lifecycle (create, verify, revoke, suspend, approve), audit-event retrieval, evidence packs, EUDI Wallet sessions, identity-provider configuration, and OAuth 2.0 token exchange. Requests carry the tenant-scoped bearer credential and are automatically retried on 5xx/429 responses with exponential backoff.

Example​

const client = new MandaitorClient({
apiKey: process.env.MANDAITOR_API_KEY!,
tenantId: "tnt_example_prod",
});
const result = await client.verify({
delegate_subject_id: "agent:example:validate-v2",
action: "construction.validation.approve",
resource: "construction:project:proj_123/plan.pdf",
});

Constructors​

Constructor​

new MandaitorClient(config): MandaitorClient

Defined in: @mandaitor/sdk/dist/client.d.ts:43

Parameters​

config​

MandaitorClientConfig

Returns​

MandaitorClient

Methods​

approveMandate()​

approveMandate(mandateId, reason?): Promise<Mandate>

Defined in: @mandaitor/sdk/dist/client.d.ts:62

Approve a mandate that is PENDING_APPROVAL, transitioning it to ACTIVE.

Parameters​

mandateId​

string

reason?​

string

Returns​

Promise<Mandate>


createMandate()​

createMandate(req): Promise<Mandate>

Defined in: @mandaitor/sdk/dist/client.d.ts:46

Create a new delegation mandate. Starts ACTIVE unless require_approval is set.

Parameters​

req​

CreateMandateRequest

Returns​

Promise<Mandate>


getAuditEvents()​

getAuditEvents(mandateId, options?): Promise<PaginatedResponse<AuditEvent>>

Defined in: @mandaitor/sdk/dist/client.d.ts:127

Parameters​

mandateId​

string

options?​
cursor?​

string

limit?​

number

Returns​

Promise<PaginatedResponse<AuditEvent>>

Deprecated​

Use getMandateEvents instead.


getEudiSessionStatus()​

getEudiSessionStatus(sessionId): Promise<EudiSessionStatus>

Defined in: @mandaitor/sdk/dist/client.d.ts:185

Poll the status of an EUDI Wallet verification session. Returns the resolved identity when the session is completed.

Parameters​

sessionId​

string

Returns​

Promise<EudiSessionStatus>


getEvent()​

getEvent(eventId, mandateId): Promise<AuditEvent>

Defined in: @mandaitor/sdk/dist/client.d.ts:139

Fetch a single audit event by ID, scoped to its mandate.

Parameters​

eventId​

string

mandateId​

string

Returns​

Promise<AuditEvent>


getEvidencePack()​

getEvidencePack(mandateId, eventId?): Promise<EvidencePack>

Defined in: @mandaitor/sdk/dist/client.d.ts:167

Export a court-ready evidence pack for a mandate. Contains the mandate snapshot, hash-chained event log, proof tokens, case_log_hash, and issuer DID reference for independent verification.

Parameters​

mandateId​

string

The mandate to export evidence for

eventId?​

string

Optional: scope the pack to a specific verification event

Returns​

Promise<EvidencePack>


getIdpConfig()​

getIdpConfig(): Promise<TenantIdpConfig>

Defined in: @mandaitor/sdk/dist/client.d.ts:189

Get the identity provider configuration for this tenant.

Returns​

Promise<TenantIdpConfig>


getMandate()​

getMandate(mandateId): Promise<Mandate>

Defined in: @mandaitor/sdk/dist/client.d.ts:48

Fetch a single mandate by its ID.

Parameters​

mandateId​

string

Returns​

Promise<Mandate>


getMandateEvents()​

getMandateEvents(mandateId, params?): Promise<PaginatedResponse<AuditEvent>>

Defined in: @mandaitor/sdk/dist/client.d.ts:122

List the hash-chained audit events for a single mandate, with cursor pagination.

Parameters​

mandateId​

string

params?​
cursor?​

string

limit?​

number

Returns​

Promise<PaginatedResponse<AuditEvent>>


getMandateInstruction()​

getMandateInstruction(mandateId): Promise<InstructionResponse>

Defined in: @mandaitor/sdk/dist/client.d.ts:158

Retrieve the decrypted instruction for a mandate.

Security note: Calling this endpoint creates an INSTRUCTION_REVEALED audit event. The instruction text is encrypted at rest and only decrypted on demand. Use sparingly — every call is logged.

Parameters​

mandateId​

string

The mandate whose instruction to reveal

Returns​

Promise<InstructionResponse>

The decrypted instruction with metadata

Throws​

If the mandate has no VUI or does not exist

Example​

const instruction = await client.getMandateInstruction("mnd_abc123");
console.log(instruction.instruction_text); // "Bestelle Büromaterial bis 500€"
console.log(instruction.instruction_channel); // "chat"

initiateEudiSession()​

initiateEudiSession(presentationDefinitionId?, options?): Promise<EudiSessionResponse>

Defined in: @mandaitor/sdk/dist/client.d.ts:178

Initiate an EUDI Wallet verification session. Returns a session with QR code and deep link URIs for the wallet flow.

Parameters​

presentationDefinitionId?​

string

Optional: which PID attributes to request (defaults to "mandaitor-pid-standard")

options?​
mandateDraft?​

CreateMandateRequest

The createMandate request the session is to back (SEC-043): the session is bound to its digest, and backs that mandate alone. Without it, the session backs nothing.

Returns​

Promise<EudiSessionResponse>


listEvents()​

listEvents(params?): Promise<PaginatedResponse<AuditEvent>>

Defined in: @mandaitor/sdk/dist/client.d.ts:132

List audit events across the tenant, optionally filtered by mandate or event type.

Parameters​

params?​
cursor?​

string

event_type?​

string

limit?​

number

mandate_id?​

string

Returns​

Promise<PaginatedResponse<AuditEvent>>


listMandates()​

listMandates(params?): Promise<PaginatedResponse<Mandate>>

Defined in: @mandaitor/sdk/dist/client.d.ts:50

List mandates for the tenant, optionally filtered by status, with cursor pagination.

Parameters​

params?​
cursor?​

string

limit?​

number

status?​

string

Returns​

Promise<PaginatedResponse<Mandate>>


reactivateMandate()​

reactivateMandate(mandateId): Promise<Mandate>

Defined in: @mandaitor/sdk/dist/client.d.ts:60

Reactivate a previously suspended mandate, returning it to ACTIVE.

Parameters​

mandateId​

string

Returns​

Promise<Mandate>


redeemDecision()​

redeemDecision(decisionId, request): Promise<DecisionRedemption>

Defined in: @mandaitor/sdk/dist/client.d.ts:120

Redeem an ALLOW's authorization, once, immediately before acting on it. The digest is computed here from request, the operation about to be performed, never taken from the answer: Mandaitor refuses the redemption unless it decided exactly this request. A 409 (ALREADY_REDEEMED, DIGEST_MISMATCH, AUTHORIZATION_EXPIRED, MANDATE_NOT_ACTIVE, AGENT_NOT_ACTIVE) means do not act, also when an earlier attempt's answer was lost: ask for a new decision.

Parameters​

decisionId​

string

request​

Pick<DecisionRequest, "agent" | "action" | "resource" | "facts" | "audience">

Returns​

Promise<DecisionRedemption>


rejectMandate()​

rejectMandate(mandateId, reason?): Promise<Mandate>

Defined in: @mandaitor/sdk/dist/client.d.ts:64

Reject a mandate that is PENDING_APPROVAL, so it never becomes active.

Parameters​

mandateId​

string

reason?​

string

Returns​

Promise<Mandate>


requestDecision()​

requestDecision(request): Promise<Decision>

Defined in: @mandaitor/sdk/dist/client.d.ts:110

Ask for a decision on one operation the enforcement point is about to perform for an agent, on the facts it read from its own system. An ALLOW carries an authorization for exactly this request, valid five minutes; DENY and REQUIRE_APPROVAL carry none, and no approval is raised. Nothing may be done on an ALLOW until redeemDecision succeeds.

Parameters​

request​

DecisionRequest

Returns​

Promise<Decision>


revokeMandate()​

revokeMandate(mandateId, reason?): Promise<Mandate>

Defined in: @mandaitor/sdk/dist/client.d.ts:56

Permanently revoke a mandate. Terminal state — a revoked mandate cannot be reactivated.

Parameters​

mandateId​

string

reason?​

string

Returns​

Promise<Mandate>


suspendMandate()​

suspendMandate(mandateId, reason?): Promise<Mandate>

Defined in: @mandaitor/sdk/dist/client.d.ts:58

Temporarily suspend a mandate. Can be reactivated later via reactivateMandate.

Parameters​

mandateId​

string

reason?​

string

Returns​

Promise<Mandate>


updateIdpConfig()​

updateIdpConfig(config): Promise<TenantIdpConfig>

Defined in: @mandaitor/sdk/dist/client.d.ts:193

Update the identity provider configuration.

Parameters​

config​

TenantIdpConfigUpdate

Returns​

Promise<TenantIdpConfig>


verify()​

verify(req): Promise<VerifyResponse>

Defined in: @mandaitor/sdk/dist/client.d.ts:69

Verify that a delegate is authorized for an action on a resource. Returns an ALLOW/DENY decision with an audit event ID. This is the core hot-path call.

Parameters​

req​

VerifyRequest

Returns​

Promise<VerifyResponse>


verifyWithDrift()​

verifyWithDrift(req, options): Promise<VerifyResponseWithSemantics>

Defined in: @mandaitor/sdk/dist/client.d.ts:102

Experimental

Verify an action with drift detection signals.

Returns advisory semantic signals alongside the verification decision. Drift signals NEVER affect the ALLOW/DENY decision.

Parameters​

req​

VerifyRequest

options​

VerifyOptions

Returns​

Promise<VerifyResponseWithSemantics>

Example​

const result = await client.verifyWithDrift(
{ delegate_subject_id: "agent:v2", action: "approve", resource: "proj/*" },
{ drift: true },
);
if (result.semantic_signals?.drift_score?.drift_detected) {
console.warn("Drift detected!", result.semantic_signals.drift_score);
}

verifyWithPoM()​

verifyWithPoM(req, options): Promise<VerifyResponseWithPoM>

Defined in: @mandaitor/sdk/dist/client.d.ts:84

Verify an action and optionally request a Proof-of-Mandate VC.

Parameters​

req​

VerifyRequest

options​

VerifyOptions

Returns​

Promise<VerifyResponseWithPoM>

Example​

const result = await client.verifyWithPoM(
{ delegate_subject_id: "agent:v2", action: "approve", resource: "proj/*" },
{ pom: "sd-jwt-vc" },
);
if (result.proof_of_mandate) {
console.log(result.proof_of_mandate.compact); // SD-JWT string
}