Live video on the AT Protocol
1import { schemas } from "streamplace";
2
3// Content warnings derived from lexicon schema
4export const CONTENT_WARNINGS = (() => {
5 // Find the content warnings schema
6 const contentWarningsSchema = schemas.find(
7 (schema) => schema.id === "place.stream.metadata.contentWarnings",
8 );
9 if (!contentWarningsSchema?.defs) {
10 throw new Error(
11 "Could not find place.stream.metadata.contentWarnings schema",
12 );
13 }
14
15 const contentWarningConstants = [
16 { constant: "place.stream.metadata.contentWarnings#death", label: "Death" },
17 {
18 constant: "place.stream.metadata.contentWarnings#drugUse",
19 label: "Drug Use",
20 },
21 {
22 constant: "place.stream.metadata.contentWarnings#fantasyViolence",
23 label: "Fantasy Violence",
24 },
25 {
26 constant: "place.stream.metadata.contentWarnings#flashingLights",
27 label: "Flashing Lights",
28 },
29 {
30 constant: "place.stream.metadata.contentWarnings#language",
31 label: "Language",
32 },
33 {
34 constant: "place.stream.metadata.contentWarnings#nudity",
35 label: "Nudity",
36 },
37 {
38 constant: "place.stream.metadata.contentWarnings#PII",
39 label: "Personally Identifiable Information",
40 },
41 {
42 constant: "place.stream.metadata.contentWarnings#sexuality",
43 label: "Sexuality",
44 },
45 {
46 constant: "place.stream.metadata.contentWarnings#suffering",
47 label: "Upsetting or Disturbing",
48 },
49 {
50 constant: "place.stream.metadata.contentWarnings#violence",
51 label: "Violence",
52 },
53 ];
54
55 return contentWarningConstants.map(({ constant, label }) => {
56 // Extract the key from the constant by splitting on '#'
57 const key = constant.split("#")[1];
58 const def = contentWarningsSchema.defs[key];
59 const description = def?.description || `Description for ${label}`;
60 return {
61 value: constant,
62 label: label,
63 description: description,
64 };
65 });
66})();
67
68// License options derived from lexicon schema
69export const LICENSE_OPTIONS = (() => {
70 // Find the content rights schema
71 const contentRightsSchema = schemas.find(
72 (schema) => schema.id === "place.stream.metadata.contentRights",
73 );
74 if (!contentRightsSchema?.defs) {
75 throw new Error(
76 "Could not find place.stream.metadata.contentRights schema",
77 );
78 }
79
80 const licenseConstants = [
81 {
82 constant: "place.stream.metadata.contentRights#all-rights-reserved",
83 label: "All Rights Reserved",
84 },
85 {
86 constant: "place.stream.metadata.contentRights#cc0_1__0",
87 label: "CC0 (Public Domain) 1.0",
88 },
89 {
90 constant: "place.stream.metadata.contentRights#cc-by_4__0",
91 label: "CC BY 4.0",
92 },
93 {
94 constant: "place.stream.metadata.contentRights#cc-by-sa_4__0",
95 label: "CC BY-SA 4.0",
96 },
97 {
98 constant: "place.stream.metadata.contentRights#cc-by-nc_4__0",
99 label: "CC BY-NC 4.0",
100 },
101 {
102 constant: "place.stream.metadata.contentRights#cc-by-nc-sa_4__0",
103 label: "CC BY-NC-SA 4.0",
104 },
105 {
106 constant: "place.stream.metadata.contentRights#cc-by-nd_4__0",
107 label: "CC BY-ND 4.0",
108 },
109 {
110 constant: "place.stream.metadata.contentRights#cc-by-nc-nd_4__0",
111 label: "CC BY-NC-ND 4.0",
112 },
113 ];
114
115 const options = licenseConstants.map(({ constant, label }) => {
116 // Extract the key from the constant by splitting on '#'
117 const key = constant.split("#")[1];
118 const def = contentRightsSchema.defs[key];
119 const description = def?.description || `Description for ${label}`;
120 return {
121 value: constant,
122 label: label,
123 description: description,
124 };
125 });
126
127 // Add custom license option
128 options.push({
129 value: "custom",
130 label: "Custom License",
131 description:
132 "Custom license. Define your own terms for how others can use, adapt, or share your content.",
133 });
134
135 return options;
136})();
137
138// License URL labels for C2PA manifests
139export const LICENSE_URL_LABELS: Record<string, string> = {
140 "http://creativecommons.org/publicdomain/zero/1.0/":
141 "CC0 - Public Domain 1.0",
142 "http://creativecommons.org/licenses/by/4.0/": "CC BY - Attribution 4.0",
143 "http://creativecommons.org/licenses/by-sa/4.0/":
144 "CC BY-SA - Attribution ShareAlike 4.0",
145 "http://creativecommons.org/licenses/by-nc/4.0/":
146 "CC BY-NC - Attribution NonCommercial 4.0",
147 "http://creativecommons.org/licenses/by-nc-sa/4.0/":
148 "CC BY-NC-SA - Attribution NonCommercial ShareAlike 4.0",
149 "http://creativecommons.org/licenses/by-nd/4.0/":
150 "CC BY-ND - Attribution NoDerivatives 4.0",
151 "http://creativecommons.org/licenses/by-nc-nd/4.0/":
152 "CC BY-NC-ND - Attribution NonCommercial NoDerivatives 4.0",
153 "All rights reserved": "All Rights Reserved",
154} as const;
155
156// C2PA warning labels for content warnings
157export const C2PA_WARNING_LABELS: Record<string, string> = {
158 "cwarn:death": "Death",
159 "cwarn:drugUse": "Drug Use",
160 "cwarn:fantasyViolence": "Fantasy Violence",
161 "cwarn:flashingLights": "Flashing Lights",
162 "cwarn:language": "Language",
163 "cwarn:nudity": "Nudity",
164 "cwarn:PII": "Personally Identifiable Information",
165 "cwarn:sexuality": "Sexuality",
166 "cwarn:suffering": "Upsetting or Disturbing",
167 "cwarn:violence": "Violence",
168 // Also support lexicon constants for backward compatibility
169 "place.stream.metadata.contentWarnings#death": "Death",
170 "place.stream.metadata.contentWarnings#drugUse": "Drug Use",
171 "place.stream.metadata.contentWarnings#fantasyViolence": "Fantasy Violence",
172 "place.stream.metadata.contentWarnings#flashingLights": "Flashing Lights",
173 "place.stream.metadata.contentWarnings#language": "Language",
174 "place.stream.metadata.contentWarnings#nudity": "Nudity",
175 "place.stream.metadata.contentWarnings#PII":
176 "Personally Identifiable Information",
177 "place.stream.metadata.contentWarnings#sexuality": "Sexuality",
178 "place.stream.metadata.contentWarnings#suffering": "Upsetting or Disturbing",
179 "place.stream.metadata.contentWarnings#violence": "Violence",
180} as const;