# @provenanceauth/rails/a2a

@provenanceauth/rails/a2a in the Rails: 11 methods. `@provenanceauth/rails/a2a`, handing a Provenance grant to another agent over A2A.

## Methods

### [delegationExtension](https://provenanceauth.com/docs/sdks/rails/a2a/delegation-extension.md)

```ts
delegationExtension(params: DelegationExtensionParams, opts?: { required?: boolean }): AgentExtension
```

The extension entry for a receiver's Agent Card `capabilities.extensions`.

### [readDelegationExtension](https://provenanceauth.com/docs/sdks/rails/a2a/read-delegation-extension.md)

```ts
readDelegationExtension(card: unknown): { params: DelegationExtensionParams; required: boolean } | { params: null; reason: string }
```

The receiver's declared params, read from its Agent Card: the extension entry with a P-256 public holder key, or `null` with why (the card doesn't list it, or the key isn't usable).

### [delegationRequested](https://provenanceauth.com/docs/sdks/rails/a2a/delegation-requested.md)

```ts
delegationRequested(header: string | string[] | null | undefined): boolean
```

Whether an `A2A-Extensions` header value (or values) turns this extension on.

### [withDelegation](https://provenanceauth.com/docs/sdks/rails/a2a/with-delegation.md)

```ts
withDelegation<M extends A2AMessage>(message: M, data: DelegationMessageData): M
```

The message with the grant attached under the extension URI, and the URI listed in `extensions`.

### [readDelegation](https://provenanceauth.com/docs/sdks/rails/a2a/read-delegation.md)

```ts
readDelegation(message: unknown): DelegationMessageData | null
```

The grant a message carries under the extension URI, or null (absent, or not a token string).

### [needMoreStatus](https://provenanceauth.com/docs/sdks/rails/a2a/need-more-status.md)

```ts
needMoreStatus(need: DelegationNeed, text: string, ids: { messageId: string; contextId?: string; taskId?: string }): A2ATaskStatus
```

The status a receiver answers with when its grant is too small: auth required, naming what it needs.

### [readNeed](https://provenanceauth.com/docs/sdks/rails/a2a/read-need.md)

```ts
readNeed(status: unknown): DelegationNeed | null
```

What an auth-required status says the receiver needs, or null (another state, or no need under the URI).

### [receiptMetadata](https://provenanceauth.com/docs/sdks/rails/a2a/receipt-metadata.md)

```ts
receiptMetadata(receipt: DelegationReceipt, metadata?: Record<string, unknown>): Record<string, unknown>
```

An artifact's metadata with the receipt under the extension URI.

### [readReceipt](https://provenanceauth.com/docs/sdks/rails/a2a/read-receipt.md)

```ts
readReceipt(artifact: unknown): DelegationReceipt | null
```

The receipt an artifact carries, or null.

### [acceptDelegation](https://provenanceauth.com/docs/sdks/rails/a2a/accept-delegation.md)

```ts
acceptDelegation(message: unknown, opts: AcceptGrantOptions): Promise<DelegationVerdict>
```

The receiver's check of a message's grant: it is present, checks against the JWKS (signature, expiry, `need`), is bound to this receiver's own key (`cnf.jkt` is its thumbprint: a grant bound to anyone else, or a bearer grant, is refused), and, when the receiver checks online or the grant says `status_check: "online"`, its chain is live.

### [acceptGrant](https://provenanceauth.com/docs/sdks/rails/a2a/accept-grant.md)

```ts
acceptGrant(data: DelegationMessageData | null, opts: AcceptGrantOptions): Promise<DelegationVerdict>
```

The receiver's check of a grant it was handed, whatever carried it (A2A metadata here, MCP `_meta` in `@provenanceauth/rails/mcp`): see.
