-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.py
More file actions
310 lines (207 loc) · 7.06 KB
/
types.py
File metadata and controls
310 lines (207 loc) · 7.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
"""
Type definitions for the Capture SDK.
"""
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
# Flexible file input type - SDK handles all conversions internally
FileInput = str | Path | bytes | bytearray
"""
Supported file input types:
- str: File path
- Path: pathlib.Path object
- bytes: Binary data
- bytearray: Mutable binary data
"""
@dataclass
class CaptureOptions:
"""Configuration options for the Capture client."""
token: str
"""Authentication token for API access."""
testnet: bool = False
"""Use testnet environment (default: False)."""
base_url: str | None = None
"""Custom base URL (overrides testnet setting)."""
@dataclass
class SignOptions:
"""Options for signing asset registration.
Provide either a ``private_key`` (held in memory only for the duration of
the signing operation) **or** a ``signer`` callback together with an
``address`` so that the private key never enters this process at all.
"""
private_key: str | None = None
"""Ethereum private key for EIP-191 signing (with or without 0x prefix)."""
signer: Callable[[str], str] | None = None
"""Custom signer callback – receives the hex-encoded integrity hash and
must return an EIP-191 signature hex string. Use this to keep the private
key entirely out of the SDK process."""
address: str | None = None
"""Ethereum address that corresponds to the ``signer`` callback.
Required when ``signer`` is provided."""
@dataclass
class RegisterOptions:
"""Options for registering a new asset."""
filename: str | None = None
"""Filename (required for bytes/bytearray inputs)."""
caption: str | None = None
"""Brief description of the asset."""
headline: str | None = None
"""Asset title (max 25 characters)."""
public_access: bool = True
"""Pin to public IPFS gateway (default: True)."""
sign: SignOptions | None = None
"""Optional signing configuration."""
@dataclass
class UpdateOptions:
"""Options for updating an existing asset."""
caption: str | None = None
"""Updated description."""
headline: str | None = None
"""Updated title (max 25 characters)."""
commit_message: str | None = None
"""Description of the changes."""
custom_metadata: dict[str, str | int | float | bool] | None = None
"""Custom metadata fields (values must be str, int, float, or bool; max 10 KB serialized)."""
@dataclass
class Asset:
"""Registered asset information."""
nid: str
"""Numbers ID (NID) - unique identifier."""
filename: str
"""Original filename."""
mime_type: str
"""MIME type of the asset."""
caption: str | None = None
"""Asset description."""
headline: str | None = None
"""Asset title."""
@dataclass
class Commit:
"""A single commit in the asset's history."""
asset_tree_cid: str
"""CID of the asset tree at this commit."""
tx_hash: str
"""Blockchain transaction hash."""
author: str
"""Original creator's address."""
committer: str
"""Address that made this commit."""
timestamp: int
"""Unix timestamp of the commit."""
action: str
"""Description of the action."""
@dataclass
class License:
"""License information for an asset."""
name: str | None = None
"""License name (e.g., 'CC BY 4.0')."""
document: str | None = None
"""URL to the license document."""
@dataclass
class AssetTree:
"""
Merged asset tree containing full provenance data.
Follows the Numbers Protocol AssetTree specification.
See: https://docs.numbersprotocol.io/introduction/numbers-protocol/defining-web3-assets/assettree
"""
asset_cid: str | None = None
"""Asset content identifier (IPFS CID)."""
asset_sha256: str | None = None
"""SHA-256 hash of the asset file."""
creator_name: str | None = None
"""Creator's name."""
creator_wallet: str | None = None
"""Creator's wallet address."""
created_at: int | None = None
"""Unix timestamp when asset was created."""
location_created: str | None = None
"""Location where asset was created."""
caption: str | None = None
"""Asset description/abstract."""
headline: str | None = None
"""Asset title."""
license: License | None = None
"""License information."""
mime_type: str | None = None
"""MIME type (encodingFormat)."""
nft_record: str | None = None
"""NFT record CID (if asset has been minted as NFT)."""
used_by: str | None = None
"""URL of website that uses the asset."""
integrity_cid: str | None = None
"""IPFS CID of the integrity proof."""
digital_source_type: str | None = None
"""Digital source type (e.g., digitalCapture, trainedAlgorithmicMedia)."""
mining_preference: str | None = None
"""Mining/indexing preference."""
generated_by: str | None = None
"""AI/algorithm information for generated content."""
extra: dict[str, Any] = field(default_factory=dict)
"""Additional fields from commits."""
# Internal types
@dataclass
class IntegrityProof:
"""Integrity proof for asset registration."""
proof_hash: str
asset_mime_type: str
created_at: int
@dataclass
class AssetSignature:
"""Signature data for asset registration."""
proof_hash: str
provider: str
signature: str
public_key: str
integrity_sha: str
# Verify Engine types
@dataclass
class AssetSearchOptions:
"""Options for searching similar assets."""
file_url: str | None = None
"""URL of the file to search."""
file: FileInput | None = None
"""File to search (path, Path, bytes, or bytearray)."""
nid: str | None = None
"""Numbers ID of an existing asset to search."""
threshold: float | None = None
"""Similarity threshold (0-1, lower means more similar)."""
sample_count: int | None = None
"""Number of results to return."""
@dataclass
class SimilarMatch:
"""A similar asset match from the search results."""
nid: str
"""Numbers ID of the matched asset."""
distance: float
"""Distance score (lower means more similar)."""
@dataclass
class AssetSearchResult:
"""Result of an asset search operation."""
precise_match: str
"""NID of the exact match (empty if none)."""
input_file_mime_type: str
"""MIME type of the input file."""
similar_matches: list[SimilarMatch]
"""List of similar asset matches."""
order_id: str
"""Order ID for the search transaction."""
@dataclass
class NftRecord:
"""An NFT record from the NFT search results."""
token_id: str
"""NFT token ID."""
contract: str
"""Smart contract address."""
network: str
"""Blockchain network (e.g., 'ethereum', 'polygon')."""
owner: str | None = None
"""Owner's wallet address."""
@dataclass
class NftSearchResult:
"""Result of an NFT search operation."""
records: list[NftRecord]
"""List of NFT records found."""
order_id: str
"""Order ID for the search transaction."""