@dcl/content-validator 7.0.3 → 7.0.4-21033738415.commit-de1f4ed
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,35 +4,233 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://coveralls.io/github/decentraland/content-validator?branch=main)
|
|
6
6
|
|
|
7
|
-
Contains all validations to
|
|
7
|
+
Decentraland entity deployment validation library for Catalyst servers. Contains all validations to ensure only valid and authorized content is deployed to the [Decentraland content network](https://docs.decentraland.org/contributor/content/entities/).
|
|
8
|
+
|
|
9
|
+
## Table of Contents
|
|
10
|
+
|
|
11
|
+
- [@dcl/content-validator](#dclcontent-validator)
|
|
12
|
+
- [Table of Contents](#table-of-contents)
|
|
13
|
+
- [Features](#features)
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Design Guidelines](#design-guidelines)
|
|
16
|
+
- [Validation Types](#validation-types)
|
|
17
|
+
- [Size Limits (ADR-51)](#size-limits-adr-51)
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [Basic Usage](#basic-usage)
|
|
20
|
+
- [Access Validation Strategies](#access-validation-strategies)
|
|
21
|
+
- [On-Chain Validation](#on-chain-validation)
|
|
22
|
+
- [Subgraph Validation](#subgraph-validation)
|
|
23
|
+
- [Getting Started](#getting-started)
|
|
24
|
+
- [Development](#development)
|
|
25
|
+
- [Debugging Tests](#debugging-tests)
|
|
26
|
+
- [Adding New Entity Types](#adding-new-entity-types)
|
|
27
|
+
- [Project Structure](#project-structure)
|
|
28
|
+
- [External Dependencies](#external-dependencies)
|
|
29
|
+
- [Versioning and Publishing](#versioning-and-publishing)
|
|
30
|
+
- [AI Agent Context](#ai-agent-context)
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- **Entity Structure Validation** - Validates JSON structure, required fields, and content references for all Decentraland entity types
|
|
35
|
+
- **Access Permission Checking** - Verifies deployer ownership via blockchain (on-chain) or The Graph (subgraph)
|
|
36
|
+
- **IPFS Content Integrity** - Ensures content file hashes are valid IPFS CIDs and files exist
|
|
37
|
+
- **Size Enforcement** - Enforces max size limits per entity type following ADR-51 specifications
|
|
38
|
+
- **Metadata Schema Validation** - Validates metadata against `@dcl/schemas` definitions
|
|
39
|
+
- **Signature Authentication** - Verifies AuthChain signatures for entity authenticity
|
|
40
|
+
- **Multi-Entity Support** - Validates scenes, profiles, wearables, emotes, stores, and outfits
|
|
41
|
+
- **Dual Access Strategies** - Supports both on-chain and subgraph-based ownership verification
|
|
42
|
+
- **Legacy Compatibility** - Maintains backwards compatibility with legacy content migrations
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm i @dcl/content-validator
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Design Guidelines
|
|
51
|
+
|
|
52
|
+
- Validate as early as possible to prevent invalid content from being stored
|
|
53
|
+
- Provide clear, actionable error messages for deployment failures
|
|
54
|
+
- Support both on-chain and subgraph-based access verification
|
|
55
|
+
- Maintain backwards compatibility with legacy content migrations
|
|
56
|
+
- Ensure all validation functions are stateless where possible
|
|
57
|
+
|
|
58
|
+
Implementation decisions:
|
|
59
|
+
|
|
60
|
+
- The library exports a `createValidator` factory function as the main entry point
|
|
61
|
+
- Validation functions return `{ ok: boolean, errors?: string[] }` responses
|
|
62
|
+
- Access checking supports two strategies: on-chain (direct blockchain) and subgraph (The Graph)
|
|
63
|
+
- Size limits are defined per entity type following [ADR-51](https://adr.decentraland.org/adr/ADR-51)
|
|
64
|
+
|
|
65
|
+
## Validation Types
|
|
66
|
+
|
|
67
|
+
The validator performs the following checks on entity deployments:
|
|
68
|
+
|
|
69
|
+
| Validation | Description |
|
|
70
|
+
|------------|-------------|
|
|
71
|
+
| **Entity Structure** | Validates JSON structure, required fields, and content references |
|
|
72
|
+
| **IPFS Hashing** | Ensures content file hashes are valid IPFS CIDs |
|
|
73
|
+
| **Metadata Schema** | Validates metadata against `@dcl/schemas` definitions |
|
|
74
|
+
| **Signature** | Verifies AuthChain signatures for entity authenticity |
|
|
75
|
+
| **Size** | Enforces max size limits per entity type (see below) |
|
|
76
|
+
| **Access** | Verifies deployer owns the entity pointers (LAND, NFTs, names) |
|
|
77
|
+
| **Content** | Ensures all referenced content files exist and are accessible |
|
|
78
|
+
| **Entity-Specific** | Additional validations per type (wearables, emotes, profiles, scenes, outfits) |
|
|
79
|
+
|
|
80
|
+
### Size Limits (ADR-51)
|
|
81
|
+
|
|
82
|
+
| Entity Type | Max Size | Notes |
|
|
83
|
+
|-------------|----------|-------|
|
|
84
|
+
| Scene | 15 MB | Per parcel |
|
|
85
|
+
| Profile | 2 MB | |
|
|
86
|
+
| Wearable | 3 MB | |
|
|
87
|
+
| Wearable (Skin) | 9 MB | Special category |
|
|
88
|
+
| Emote | 3 MB | |
|
|
89
|
+
| Store | 1 MB | |
|
|
90
|
+
| Outfits | 1 MB | |
|
|
91
|
+
|
|
92
|
+
## Usage
|
|
93
|
+
|
|
94
|
+
### Basic Usage
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { createValidator, ContentValidatorComponents, DeploymentToValidate } from '@dcl/content-validator'
|
|
98
|
+
|
|
99
|
+
// Create validator with required components
|
|
100
|
+
const validator = createValidator({
|
|
101
|
+
logs: logsComponent,
|
|
102
|
+
externalCalls: {
|
|
103
|
+
isContentStoredAlready: async (hashes) => { /* ... */ },
|
|
104
|
+
fetchContentFileSize: async (hash) => { /* ... */ },
|
|
105
|
+
validateSignature: async (entityId, auditInfo, timestamp) => { /* ... */ },
|
|
106
|
+
ownerAddress: (auditInfo) => { /* ... */ },
|
|
107
|
+
isAddressOwnedByDecentraland: (address) => { /* ... */ },
|
|
108
|
+
calculateFilesHashes: async (files) => { /* ... */ }
|
|
109
|
+
},
|
|
110
|
+
accessValidateFn: accessValidator // on-chain or subgraph-based
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
// Validate a deployment
|
|
114
|
+
const deployment: DeploymentToValidate = {
|
|
115
|
+
entity: { /* entity data */ },
|
|
116
|
+
files: new Map([/* content files */]),
|
|
117
|
+
auditInfo: { authChain: [/* auth chain */] }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const result = await validator(deployment)
|
|
121
|
+
if (!result.ok) {
|
|
122
|
+
console.error('Validation failed:', result.errors)
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Access Validation Strategies
|
|
127
|
+
|
|
128
|
+
The library supports two access validation strategies:
|
|
129
|
+
|
|
130
|
+
#### On-Chain Validation
|
|
131
|
+
|
|
132
|
+
Direct blockchain queries for ownership verification:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { createOnChainAccessCheckValidateFns, createOnChainClient } from '@dcl/content-validator'
|
|
136
|
+
|
|
137
|
+
const validateFns = createOnChainAccessCheckValidateFns({
|
|
138
|
+
logs,
|
|
139
|
+
externalCalls,
|
|
140
|
+
client: createOnChainClient({ logs, L1, L2 }),
|
|
141
|
+
L1: { checker, collections, thirdParty, blockSearch },
|
|
142
|
+
L2: { checker, collections, thirdParty, blockSearch }
|
|
143
|
+
})
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Subgraph Validation
|
|
147
|
+
|
|
148
|
+
Uses The Graph for ownership queries (more efficient for bulk queries):
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { createSubgraphAccessCheckValidateFns, createTheGraphClient } from '@dcl/content-validator'
|
|
152
|
+
|
|
153
|
+
const validateFns = createSubgraphAccessCheckValidateFns({
|
|
154
|
+
logs,
|
|
155
|
+
externalCalls,
|
|
156
|
+
theGraphClient: createTheGraphClient({ logs, subGraphs }),
|
|
157
|
+
subGraphs,
|
|
158
|
+
tokenAddresses: { land: '0x...', estate: '0x...' }
|
|
159
|
+
})
|
|
160
|
+
```
|
|
8
161
|
|
|
9
162
|
## Getting Started
|
|
10
163
|
|
|
164
|
+
### Development
|
|
165
|
+
|
|
11
166
|
Install dependencies and run tests:
|
|
12
167
|
|
|
168
|
+
```bash
|
|
169
|
+
yarn
|
|
170
|
+
yarn build
|
|
171
|
+
yarn test
|
|
13
172
|
```
|
|
14
|
-
> yarn
|
|
15
|
-
> yarn build
|
|
16
|
-
> yarn test
|
|
17
|
-
```
|
|
18
173
|
|
|
19
|
-
### Debugging
|
|
174
|
+
### Debugging Tests
|
|
175
|
+
|
|
176
|
+
If you are using VS Code, install the recommended extensions and debug tests using the Jest extension which adds UI support.
|
|
177
|
+
|
|
178
|
+
## Adding New Entity Types
|
|
20
179
|
|
|
21
|
-
|
|
180
|
+
Before adding any validation for new entities:
|
|
181
|
+
|
|
182
|
+
1. **Create entity schema** on [@dcl/schemas](https://github.com/decentraland/common-schemas)
|
|
183
|
+
2. **Add entity type and schema** on [catalyst-commons](https://github.com/decentraland/catalyst-commons/)
|
|
184
|
+
3. **Add access checker** in [access/index.ts](./src/validations/access/index.ts) and implement entity-specific validation
|
|
185
|
+
4. **Add size limit** in [ADR51.ts](./src/validations/ADR51.ts)
|
|
186
|
+
5. **Verify URN resolution** - if required, add a new resolver in [@dcl/urn-resolver](https://github.com/decentraland/urn-resolver)
|
|
187
|
+
|
|
188
|
+
## Project Structure
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
src/
|
|
192
|
+
├── index.ts # Main entry point, createValidator factory
|
|
193
|
+
├── types.ts # Core types (DeploymentToValidate, ValidationResponse, etc.)
|
|
194
|
+
├── utils.ts # Utility functions
|
|
195
|
+
└── validations/
|
|
196
|
+
├── index.ts # Validation function aggregator
|
|
197
|
+
├── access/ # Access permission validators
|
|
198
|
+
│ ├── common/ # Shared access validation logic
|
|
199
|
+
│ ├── on-chain/ # Direct blockchain access checking
|
|
200
|
+
│ └── subgraph/ # The Graph-based access checking
|
|
201
|
+
├── items/ # Item-specific validations
|
|
202
|
+
│ ├── emotes.ts
|
|
203
|
+
│ └── wearables.ts
|
|
204
|
+
├── ADR45.ts # ADR-45 validation rules
|
|
205
|
+
├── ADR51.ts # Size limits per entity type
|
|
206
|
+
├── content.ts # Content file validation
|
|
207
|
+
├── entity-structure.ts # Entity JSON structure validation
|
|
208
|
+
├── ipfs-hashing.ts # IPFS hash validation
|
|
209
|
+
├── metadata-schema.ts # Metadata schema validation
|
|
210
|
+
├── outfits.ts # Outfits-specific validation
|
|
211
|
+
├── profile.ts # Profile-specific validation
|
|
212
|
+
├── scene.ts # Scene-specific validation
|
|
213
|
+
├── signature.ts # AuthChain signature validation
|
|
214
|
+
├── size.ts # Entity size validation
|
|
215
|
+
└── timestamps.ts # Important timestamp constants
|
|
216
|
+
```
|
|
22
217
|
|
|
23
|
-
##
|
|
218
|
+
## External Dependencies
|
|
24
219
|
|
|
25
|
-
|
|
220
|
+
| Dependency | Purpose |
|
|
221
|
+
|------------|---------|
|
|
222
|
+
| `@dcl/schemas` | Entity type definitions and validation schemas |
|
|
223
|
+
| `@dcl/urn-resolver` | URN parsing and validation for items |
|
|
224
|
+
| `@dcl/block-indexer` | Blockchain block search for timestamp-based queries |
|
|
225
|
+
| `@dcl/hashing` | IPFS content hashing |
|
|
226
|
+
| `@well-known-components/thegraph-component` | The Graph subgraph queries |
|
|
26
227
|
|
|
27
|
-
|
|
228
|
+
## Versioning and Publishing
|
|
28
229
|
|
|
29
|
-
|
|
230
|
+
Versions are handled manually using GitHub releases and semver.
|
|
30
231
|
|
|
31
|
-
|
|
32
|
-
2. Add entity type and schema on [catalyst-commons](https://github.com/decentraland/catalyst-commons/).
|
|
33
|
-
3. Add entity type and access checker in [access.ts](./src/validations/access-checker/access.ts).
|
|
34
|
-
a. Verify entity pointers can be resolved. If required add a new resolver in [@dcl/urn-resolver](https://github.com/decentraland/urn-resolver).
|
|
232
|
+
Main branch is automatically published to the `@next` dist tag to test integrations before final releases happen.
|
|
35
233
|
|
|
36
234
|
## AI Agent Context
|
|
37
235
|
|
|
38
|
-
For detailed AI Agent context, see [docs/ai-agent-context.md](docs/ai-agent-context.md).
|
|
236
|
+
For detailed AI Agent context including service purpose, key capabilities, technology stack, and validation details, see [docs/ai-agent-context.md](./docs/ai-agent-context.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/content-validator",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.4-21033738415.commit-de1f4ed",
|
|
4
4
|
"description": "Catalyst content validations",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"files": [
|
|
54
54
|
"dist"
|
|
55
55
|
],
|
|
56
|
-
"commit": "
|
|
56
|
+
"commit": "de1f4ed5a60480b608ab32ee78807527ee9d328a"
|
|
57
57
|
}
|