-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconstants.dart
More file actions
150 lines (106 loc) · 4.31 KB
/
constants.dart
File metadata and controls
150 lines (106 loc) · 4.31 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
// ! CID types
// These bytes are carefully selected to make the base58 and base32 representations of different CID types
// easy to distinguish and not collide with anything on https://github.com/multiformats/multicodec
import 'dart:typed_data';
const cidTypeRaw = 0x26;
const cidTypeMetadataMedia = 0xc5;
// const cidTypeMetadataFile = 0xc6;
const cidTypeMetadataDirectory = 0x5d;
const cidTypeMetadataWebApp = 0x59;
const cidTypeResolver = 0x25;
const cidTypeUserIdentity = 0x77;
const cidTypeBridge = 0x3a;
// format for dynamic encrypted CID
// type algo key resolver_type mkey_ed255 pubkey
// in entry: encrypt(RAW CID or MEDIA or SOMETHING)
/// Used for immutable encrypted files and metadata formats, key can never be re-used
///
/// Used for file versions in Vup
const cidTypeEncryptedStatic = 0xae;
/// Used for encrypted files with update support
///
/// can point to resolver CID, Stream CID, Directory Metadata or Media Metadata object
// const cidTypeEncryptedDynamic = 0xad;
const cidTypeEncryptedMutable = 0x5e;
const registryS5CIDByte = 0x5a;
const registryS5EncryptedByte = 0x5e;
// ! some multicodec bytes
// BLAKE3 with default output size of 256 bits
const mhashBlake3Default = 0x1f;
const mkeyEd25519 = 0xed;
const encryptionAlgorithmXChaCha20Poly1305 = 0xa6;
const encryptionAlgorithmXChaCha20Poly1305NonceSize = 24;
const encryptionAlgorithmXChaCha20Poly1305KeySize = 32;
final contentPackFileHeader = Uint8List.fromList(
[0x5f, 0x26, 0x73, 0x35],
);
// ! metadata files
// used as the first byte of metadata files
const metadataMagicByte = 0x5f;
// types for metadata files
const metadataTypeMedia = 0x02;
const metadataTypeWebApp = 0x03;
const metadataTypeDirectory = 0x04;
const metadataTypeProofs = 0x05;
const metadataTypeUserIdentity = 0x07;
const parentLinkTypeUserIdentity = 1;
const parentLinkTypeBoard = 5;
const parentLinkTypeBridgeUser = 10;
const registryMaxDataSize = 64;
// ! user identity
const authPayloadVersion1 = 0x01;
const userIdentityLinkProfile = 0x00;
const userIdentityLinkPublicFileSystem = 0x01;
// const userIdentityLinkFollowingList = 0x02;
// ! p2p protocol message types
const protocolMethodHandshakeOpen = 1;
const protocolMethodHandshakeDone = 2;
const protocolMethodSignedMessage = 10;
const protocolMethodHashQuery = 4;
const protocolMethodAnnouncePeers = 8;
const protocolMethodRegistryQuery = 13; // 0x0d
const recordTypeStorageLocation = 0x05; // cache until TTL
const recordTypeRegistryEntry = 0x07; // permanent
const recordTypeStreamMessage = 0x08; // temporary?
const protocolMethodMessageQuery = 0x49; // 0x0e
// ! Some optional metadata extensions (same for files, media files and directories)
// List<String>, license identifier from https://spdx.org/licenses/
const metadataExtensionLicenses = 11;
// List<Uint8List>, multicoded pubkey that references a registry entry that contains donation links and addresses
const metadataExtensionDonationKeys = 12;
// map string->map, external ids of this object by their wikidata property id.
const metadataExtensionWikidataClaims = 13;
// List<String>, for example [en, de, de-DE]
const metadataExtensionLanguages = 14;
// List<String>,
const metadataExtensionSourceUris = 15;
// Resolver CID, can be used to update this post. can also be used to "delete" a post.
const metadataExtensionUpdateCID = 16;
// List<CID>, lists previous versions of this post
const metadataExtensionPreviousVersions = 17;
// unix timestamp in milliseconds
const metadataExtensionTimestamp = 18;
const metadataExtensionTags = 19;
const metadataExtensionCategories = 20;
// video, podcast, book, audio, music, ...
const metadataExtensionViewTypes = 21;
const metadataExtensionBasicMediaMetadata = 22;
const metadataExtensionBridge = 23;
const metadataExtensionOriginalTimestamp = 24;
// List<Uint8List>
const metadataExtensionRoutingHints = 25;
// TODO comment to / reply to (use parents)
// TODO mentions (use new extension field)
// TODO Reposts (just link the original item)
// ! media details
const metadataMediaDetailsDuration = 10;
const metadataMediaDetailsIsLive = 11;
const metadataMediaDetailsWasLive = 12;
// ! metadata proofs
const metadataProofTypeSignature = 1;
const metadataProofTypeTimestamp = 2;
/// ! storage locations
const storageLocationTypeArchive = 0;
const storageLocationTypeFile = 3;
const storageLocationTypeFull = 5;
const storageLocationTypeBridge = 7;