|
| 1 | +# TAP JSON Schemas |
| 2 | + |
| 3 | +This directory contains JSON Schema definitions for all Transaction Authorization Protocol (TAP) message types and data structures. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The schemas are organized into three main categories: |
| 8 | + |
| 9 | +- **`/common`** - Base type definitions (CAIP types, DID types, base structures) |
| 10 | +- **`/data-structures`** - Reusable data structures (Party, Agent, Policy, etc.) |
| 11 | +- **`/messages`** - Message type schemas for all TAP messages |
| 12 | + |
| 13 | +All schemas are publicly accessible via GitHub Pages at: |
| 14 | +- Base URL: `https://taips.tap.rsvp/schemas/` |
| 15 | +- Example: `https://taips.tap.rsvp/schemas/messages/transfer.json` |
| 16 | + |
| 17 | +## Schema Standards |
| 18 | + |
| 19 | +All schemas follow: |
| 20 | +- JSON Schema draft 2020-12 |
| 21 | +- Use `$id` for unique identification |
| 22 | +- Include detailed descriptions |
| 23 | +- Reference common definitions to avoid duplication |
| 24 | + |
| 25 | +## Message Types |
| 26 | + |
| 27 | +The following TAP message types have schemas defined: |
| 28 | + |
| 29 | +### Transaction Messages |
| 30 | +- `transfer.json` - Initiates a virtual asset transfer |
| 31 | +- `payment.json` - Payment request with optional invoice |
| 32 | + |
| 33 | +### Authorization Flow |
| 34 | +- `authorize.json` - Authorization request/response |
| 35 | +- `settle.json` - Settlement confirmation |
| 36 | +- `reject.json` - Transaction rejection |
| 37 | +- `cancel.json` - Transaction cancellation |
| 38 | +- `revert.json` - Transaction reversal request |
| 39 | + |
| 40 | +### Agent Management |
| 41 | +- `update-agent.json` - Update agent details |
| 42 | +- `update-party.json` - Update party information |
| 43 | +- `add-agents.json` - Add new agents |
| 44 | +- `replace-agent.json` - Replace existing agent |
| 45 | +- `remove-agent.json` - Remove agent from transaction |
| 46 | + |
| 47 | +### Relationship & Policy |
| 48 | +- `confirm-relationship.json` - Confirm party-agent relationship |
| 49 | +- `update-policies.json` - Update agent policies |
| 50 | + |
| 51 | +### Connection Management |
| 52 | +- `connect.json` - Establish TAP connection |
| 53 | +- `authorization-required.json` - Request authorization |
| 54 | +- `out-of-band-invitation.json` - Out-of-band connection invitation |
| 55 | + |
| 56 | +## Validation |
| 57 | + |
| 58 | +To validate test vectors against schemas: |
| 59 | + |
| 60 | +```bash |
| 61 | +# Install dependencies |
| 62 | +npm install |
| 63 | + |
| 64 | +# Run validation |
| 65 | +npm run validate |
| 66 | +``` |
| 67 | + |
| 68 | +The validation script will: |
| 69 | +1. Load all schemas |
| 70 | +2. Validate test vectors from `/test-vectors` |
| 71 | +3. Report validation results |
| 72 | + |
| 73 | +## Usage Example |
| 74 | + |
| 75 | +```javascript |
| 76 | +const Ajv = require('ajv'); |
| 77 | +const addFormats = require('ajv-formats'); |
| 78 | +const transferSchema = require('./messages/transfer.json'); |
| 79 | + |
| 80 | +const ajv = new Ajv(); |
| 81 | +addFormats(ajv); |
| 82 | + |
| 83 | +const validate = ajv.compile(transferSchema); |
| 84 | +const valid = validate(transferMessage); |
| 85 | + |
| 86 | +if (!valid) { |
| 87 | + console.log(validate.errors); |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +## Schema Development |
| 92 | + |
| 93 | +When creating or modifying schemas: |
| 94 | + |
| 95 | +1. Follow the existing pattern and structure |
| 96 | +2. Use `$ref` to reference common definitions |
| 97 | +3. Include comprehensive descriptions |
| 98 | +4. Test against relevant test vectors |
| 99 | +5. Ensure TypeScript types match the schema |
| 100 | + |
| 101 | +## References |
| 102 | + |
| 103 | +- [JSON Schema Specification](https://json-schema.org/) |
| 104 | +- [TAP Documentation](https://github.com/TransactionAuthorizationProtocol/TAIPs) |
| 105 | +- [CAIP Standards](https://github.com/ChainAgnostic/CAIPs) |
0 commit comments