c2pa-react-cawg-component 0.1.14 → 0.1.16
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 +22 -0
- package/dist/c2pa-react-cawg-component.css +1 -1
- package/dist/c2pa-react-cawg-component.js +380 -90
- package/dist/c2pa-react-cawg-component.umd.cjs +1 -1
- package/dist/components/Cawg/Cawg.d.ts +17 -0
- package/dist/components/Cawg/helper/describeCawg.d.ts +7 -0
- package/dist/components/Cawg/helper/getBestUserName.d.ts +3 -1
- package/dist/components/Cawg/helper/getCawgCredentials.d.ts +48 -0
- package/dist/components/Cawg/levels/L3/CAWGL3.d.ts +5 -1
- package/dist/components/Cawg/levels/L3/CredentialSection.d.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,6 +89,28 @@ import { CAWGManifest } from "c2pa-react-cawg-component";
|
|
|
89
89
|
|
|
90
90
|
Clicking "More Info" advances from level 1 → 2 → 3. Clicking "Small View" at level 3 returns to level 1.
|
|
91
91
|
|
|
92
|
+
### `createCAWGManifest(options)`
|
|
93
|
+
|
|
94
|
+
Returns a configured CAWG plugin. `CAWGManifest` is `createCAWGManifest()` with the defaults.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { createCAWGManifest } from "c2pa-react-cawg-component";
|
|
98
|
+
|
|
99
|
+
const CAWGWithCredentials = createCAWGManifest({
|
|
100
|
+
showCredentials: true,
|
|
101
|
+
onIssuerClick: (did) => console.log("look up", did),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
<C2paManifest manifest={verificationOutcome} plugin={[CAWGWithCredentials]} />
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
| Option | Default | Effect |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `showCredentials` | `false` | Adds a **Credential** section to level 3 for each identity assertion backed by a W3C verifiable credential: identity claims aggregation (`cawg.identity_claims_aggregation`) or verifiable credential binding (`cawg.verifiable_credential_binding`). Each credential shows its issuer, type, validity period, subjects, asset binding, revocation status and schema, with a toggle to the raw credential JSON. X.509 identities (`cawg.x509.cose`) have no credential document and aren't listed. |
|
|
110
|
+
| `onIssuerClick` | none | Called with the issuer's DID when it's clicked. Without it, the issuer is plain text. |
|
|
111
|
+
|
|
112
|
+
The credentials come from c2pa-rs's decoded identity assertions (`core.decode_identity_assertions`). The validity badge only compares the current time with `validFrom`/`validUntil`; the credential's validation status codes come from the SDK. `getCawgCredentials(manifest)` returns the same data for custom displays.
|
|
113
|
+
|
|
92
114
|
## Trust registry (TRQP)
|
|
93
115
|
|
|
94
116
|
Level 2 and level 3 render a `TrustBadge` next to verified identities, showing whether the manifest's issuer is recognized by a [TRQP](https://creator-assertions.github.io/) trust registry.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.cawg-card{background:#fff;border-radius:12px;width:95%;padding:16px;display:inline-block;box-shadow:0 4px 20px #00000014}.cawg-container{align-items:center;gap:16px;display:flex}.cawg-square{background-color:gold;border-radius:4px;flex-shrink:0;justify-content:center;align-items:center;width:48px;height:48px;display:flex}.cawg-logo-text{color:#000;letter-spacing:-.5px;font-size:18px;font-weight:700}.cawg-media-title{color:#333;letter-spacing:-.3px;font-size:20px;font-weight:600}.cawg-claim-generator,.cawg-creators-name{color:#666;font-size:14px}.cawg-thumbnail{object-fit:cover;border-radius:4px;width:48px;height:48px}.cawg-button{color:#666;cursor:pointer;background:#fff;border:2px solid #666;border-radius:999px;width:100%;height:42px;font-size:16px;font-weight:700;transition:background-color .16s,border-color .16s,color .16s,box-shadow .16s}.cawg-button:hover{color:#fff;background:#111;border-color:#111;box-shadow:0 4px 12px #00000024}.cawg-button:focus-visible{outline-offset:3px;outline:3px solid #11111140}.cawg-section-title{color:#333;margin-bottom:6px;font-size:16px;font-weight:600}.cawg-key-value{margin-top:16px}.cawg-key-value-label{color:#64748b;text-transform:uppercase;letter-spacing:.025em;margin-bottom:4px;font-size:14px;font-weight:600}.cawg-key-value-value{color:#1e293b;word-break:break-word;overflow-wrap:break-word;font-size:16px;line-height:1.5}.cawg-divider{background:#e2e8f0;height:1px;margin:16px 0}.cawg-roles{flex-wrap:wrap;gap:6px;margin-top:12px;display:flex}.cawg-role-badge{color:#475569;letter-spacing:.02em;background:#f0f4f8;border:1px solid #cbd5e1;border-radius:999px;align-items:center;padding:2px 10px;font-size:12px;font-weight:600;display:inline-flex}.cawg-identity-list{flex-direction:column;gap:8px;margin-top:10px;display:flex}.cawg-identity-item{background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;align-items:flex-start;padding:10px 12px;display:flex}.cawg-identity-type-label{color:#64748b;text-transform:uppercase;letter-spacing:.06em;margin-bottom:2px;font-size:11px;font-weight:700}.cawg-identity-name{color:#1e293b;font-size:14px;font-weight:600}.cawg-identity-provider{color:#64748b;margin-top:1px;font-size:13px}.cawg-identity-link{color:#3b82f6;word-break:break-all;margin-top:2px;font-size:12px;text-decoration:none;display:block}.cawg-identity-link:hover{text-decoration:underline}.cawg-identity-meta{color:#94a3b8;margin-top:3px;font-size:11px}.cawg-training-list{flex-direction:column;gap:6px;margin-top:10px;display:flex}.cawg-training-item{background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;justify-content:space-between;align-items:flex-start;gap:8px;padding:8px 12px;display:flex}.cawg-training-label{color:#374151;font-size:13px;font-weight:500}.cawg-constraint-info{color:#92400e;margin-top:3px;font-size:12px;font-style:italic}.cawg-use-badge{letter-spacing:.04em;text-transform:uppercase;border-radius:999px;flex-shrink:0;padding:2px 8px;font-size:11px;font-weight:700}.cawg-use-allowed{color:#166534;background:#dcfce7}.cawg-use-not-allowed{color:#991b1b;background:#fee2e2}.cawg-use-constrained{color:#854d0e;background:#fef9c3}.cawg-trust-status{margin-top:4px}.cawg-trust-badge{letter-spacing:.04em;text-transform:uppercase;white-space:nowrap;border-radius:999px;align-items:center;padding:2px 10px;font-size:11px;font-weight:700;display:inline-flex}.cawg-trust-pending{color:#64748b;background:#f1f5f9}.cawg-trust-verified{color:#166534;background:#dcfce7}.cawg-trust-unverified{color:#991b1b;background:#fee2e2}.cawg-trust-meta{color:#94a3b8;margin-top:4px;font-size:12px}.cawg-trust-message{color:#991b1b;margin-top:4px;font-size:12px}.cawg-trust-icon{object-fit:cover;border-radius:4px;flex-shrink:0;width:20px;height:20px;margin-right:8px}
|
|
1
|
+
.cawg-card{box-sizing:border-box;background:#fff;border-radius:12px;width:95%;padding:16px;display:inline-block;box-shadow:0 4px 20px #00000014}.cawg-container{align-items:center;gap:16px;display:flex}.cawg-square{background-color:gold;border-radius:4px;flex-shrink:0;justify-content:center;align-items:center;width:48px;height:48px;display:flex}.cawg-logo-text{color:#000;letter-spacing:-.5px;font-size:18px;font-weight:700}.cawg-media-title{color:#333;letter-spacing:-.3px;font-size:20px;font-weight:600}.cawg-claim-generator,.cawg-creators-name{color:#666;font-size:14px}.cawg-thumbnail{object-fit:cover;border-radius:4px;width:48px;height:48px}.cawg-button{color:#666;cursor:pointer;background:#fff;border:2px solid #666;border-radius:999px;width:100%;height:42px;font-size:16px;font-weight:700;transition:background-color .16s,border-color .16s,color .16s,box-shadow .16s}.cawg-button:hover{color:#fff;background:#111;border-color:#111;box-shadow:0 4px 12px #00000024}.cawg-button:focus-visible{outline-offset:3px;outline:3px solid #11111140}.cawg-section-title{color:#333;margin-bottom:6px;font-size:16px;font-weight:600}.cawg-key-value{margin-top:16px}.cawg-key-value-label{color:#64748b;text-transform:uppercase;letter-spacing:.025em;margin-bottom:4px;font-size:14px;font-weight:600}.cawg-key-value-value{color:#1e293b;word-break:break-word;overflow-wrap:break-word;font-size:16px;line-height:1.5}.cawg-divider{background:#e2e8f0;height:1px;margin:16px 0}.cawg-roles{flex-wrap:wrap;gap:6px;margin-top:12px;display:flex}.cawg-role-badge{color:#475569;letter-spacing:.02em;background:#f0f4f8;border:1px solid #cbd5e1;border-radius:999px;align-items:center;padding:2px 10px;font-size:12px;font-weight:600;display:inline-flex}.cawg-identity-list{flex-direction:column;gap:8px;margin-top:10px;display:flex}.cawg-identity-item{background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;align-items:flex-start;padding:10px 12px;display:flex}.cawg-identity-type-label{color:#64748b;text-transform:uppercase;letter-spacing:.06em;margin-bottom:2px;font-size:11px;font-weight:700}.cawg-identity-name{color:#1e293b;font-size:14px;font-weight:600}.cawg-identity-provider{color:#64748b;margin-top:1px;font-size:13px}.cawg-identity-link{color:#3b82f6;word-break:break-all;margin-top:2px;font-size:12px;text-decoration:none;display:block}.cawg-identity-link:hover{text-decoration:underline}.cawg-identity-meta{color:#94a3b8;margin-top:3px;font-size:11px}.cawg-training-list{flex-direction:column;gap:6px;margin-top:10px;display:flex}.cawg-training-item{background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;justify-content:space-between;align-items:flex-start;gap:8px;padding:8px 12px;display:flex}.cawg-training-label{color:#374151;font-size:13px;font-weight:500}.cawg-constraint-info{color:#92400e;margin-top:3px;font-size:12px;font-style:italic}.cawg-use-badge{letter-spacing:.04em;text-transform:uppercase;border-radius:999px;flex-shrink:0;padding:2px 8px;font-size:11px;font-weight:700}.cawg-use-allowed{color:#166534;background:#dcfce7}.cawg-use-not-allowed{color:#991b1b;background:#fee2e2}.cawg-use-constrained{color:#854d0e;background:#fef9c3}.cawg-trust-status{margin-top:4px}.cawg-trust-badge{letter-spacing:.04em;text-transform:uppercase;white-space:nowrap;border-radius:999px;align-items:center;padding:2px 10px;font-size:11px;font-weight:700;display:inline-flex}.cawg-trust-pending{color:#64748b;background:#f1f5f9}.cawg-trust-verified{color:#166534;background:#dcfce7}.cawg-trust-unverified{color:#991b1b;background:#fee2e2}.cawg-trust-meta{color:#94a3b8;margin-top:4px;font-size:12px}.cawg-trust-message{color:#991b1b;margin-top:4px;font-size:12px}.cawg-trust-icon{object-fit:cover;border-radius:4px;flex-shrink:0;width:20px;height:20px;margin-right:8px}.cawg-credential-list{flex-direction:column;gap:8px;display:flex}.cawg-credential{border:1px solid #e2e8f0;border-radius:8px;min-width:0;padding:10px 12px}.cawg-credential>summary{cursor:pointer;color:#1e293b;flex-wrap:wrap;align-items:center;gap:8px;font-weight:600;display:flex}.cawg-credential-badge{border-radius:999px;padding:1px 8px;font-size:12px;font-weight:500}.cawg-credential-badge-ok{color:#166534;background:#dcfce7}.cawg-credential-badge-warn{color:#92400e;background:#fef3c7}.cawg-credential-tabs{gap:6px;margin-top:10px;display:flex}.cawg-credential-tab{font:inherit;color:#334155;cursor:pointer;background:#fff;border:1px solid #cbd5e1;border-radius:6px;padding:2px 10px;font-size:13px}.cawg-credential-tab[aria-selected=true]{color:#2563eb;border-color:#2563eb}.cawg-credential-raw{white-space:pre-wrap;word-break:break-all;background:#f8fafc;border:1px solid #e2e8f0;border-radius:6px;max-height:320px;margin:10px 0 0;padding:8px;font-size:12px;overflow:auto}.cawg-credential-subjects{color:#1e293b;overflow-wrap:anywhere;margin:0;padding-left:18px;font-size:15px}.cawg-credential-link{font:inherit;color:#2563eb;cursor:pointer;text-align:left;overflow-wrap:anywhere;word-break:break-all;background:0 0;border:none;padding:0;text-decoration:underline}
|
|
2
2
|
/*$vite$:1*/
|
|
@@ -34,10 +34,10 @@ var o = "<svg width=\"34\" height=\"34\" viewBox=\"0 0 34 34\" fill=\"none\" xml
|
|
|
34
34
|
case "cawg.affiliation": return 1e6;
|
|
35
35
|
default: return 1e5;
|
|
36
36
|
}
|
|
37
|
-
}, l = ["cawg.affiliation"], u = (e) => {
|
|
38
|
-
if (typeof e == "object" && !Array.isArray(e) && (e = [e]), !e || e.length === 0) return "Unknown";
|
|
39
|
-
let
|
|
40
|
-
return !
|
|
37
|
+
}, l = ["cawg.affiliation"], u = (e, t) => {
|
|
38
|
+
if (e && typeof e == "object" && !Array.isArray(e) && (e = [e]), !e || e.length === 0) return t?.["dc:creator"] ? t["dc:creator"] : "Unknown";
|
|
39
|
+
let n = e.sort((e, t) => c(e.type) - c(t.type))[0];
|
|
40
|
+
return !n || l.includes(n.type) ? "Unknown" : n.name;
|
|
41
41
|
}, d = (e) => {
|
|
42
42
|
if (e) return e.signer_payload ?? e.c2paAsset;
|
|
43
43
|
};
|
|
@@ -126,7 +126,7 @@ var v = "Identity Unable to be Verified by Trust Registry", y = {
|
|
|
126
126
|
"cawg.translator": "Translator"
|
|
127
127
|
};
|
|
128
128
|
function b({ className: e, manifest: t, moreInfo: n }) {
|
|
129
|
-
let r = t.title, o = t.claimGenerator ?? t.claimGeneratorInfo?.[0]?.name ?? "Unknown", c = u(t.assertions?.["cawg.identity"]?.verifiedIdentities), l = o.split(" ").filter(Boolean).map((e) => e[0].toUpperCase()).join("") || "?", f = t.assertions?.["cawg.identity"], p = d(f), m = p?.role ?? [], { status: h, results: g } = _(p?.trust_registry ?? []), b = g.filter((e) => !e.hide), x = h === "done" && b.some((e) => !e.authorized);
|
|
129
|
+
let r = t.title, o = t.claimGenerator ?? t.claimGeneratorInfo?.[0]?.name ?? "Unknown", c = u(t.assertions?.["cawg.identity"]?.verifiedIdentities, t.assertions?.["cawg.metadata"]), l = o.split(" ").filter(Boolean).map((e) => e[0].toUpperCase()).join("") || "?", f = t.assertions?.["cawg.identity"], p = d(f), m = p?.role ?? [], { status: h, results: g } = _(p?.trust_registry ?? []), b = g.filter((e) => !e.hide), x = h === "done" && b.some((e) => !e.authorized);
|
|
130
130
|
return /* @__PURE__ */ a("div", {
|
|
131
131
|
className: `cawg-card ${e ?? ""}`,
|
|
132
132
|
children: [
|
|
@@ -322,7 +322,7 @@ function D({ entries: e, variant: t = "compact", queryFn: n }) {
|
|
|
322
322
|
}
|
|
323
323
|
//#endregion
|
|
324
324
|
//#region src/components/Cawg/levels/L2/CAWGL2.tsx
|
|
325
|
-
var
|
|
325
|
+
var ee = {
|
|
326
326
|
"cawg.creator": "Creator",
|
|
327
327
|
"cawg.contributor": "Contributor",
|
|
328
328
|
"cawg.editor": "Editor",
|
|
@@ -330,27 +330,27 @@ var O = {
|
|
|
330
330
|
"cawg.publisher": "Publisher",
|
|
331
331
|
"cawg.sponsor": "Sponsor",
|
|
332
332
|
"cawg.translator": "Translator"
|
|
333
|
-
},
|
|
333
|
+
}, O = {
|
|
334
334
|
"cawg.document_verification": "ID Verified",
|
|
335
335
|
"cawg.web_site": "Website",
|
|
336
336
|
"cawg.affiliation": "Affiliation",
|
|
337
337
|
"cawg.social_media": "Social Media",
|
|
338
338
|
"cawg.crypto_wallet": "Crypto Wallet"
|
|
339
|
-
},
|
|
339
|
+
}, k = {
|
|
340
340
|
"cawg.data_mining": "Data Mining",
|
|
341
341
|
"cawg.ai_inference": "AI Inference",
|
|
342
342
|
"cawg.ai_training": "AI Training",
|
|
343
343
|
"cawg.ai_generative_training": "AI Generative Training"
|
|
344
|
-
},
|
|
344
|
+
}, A = {
|
|
345
345
|
allowed: "cawg-use-badge cawg-use-allowed",
|
|
346
346
|
notAllowed: "cawg-use-badge cawg-use-not-allowed",
|
|
347
347
|
constrained: "cawg-use-badge cawg-use-constrained"
|
|
348
|
-
},
|
|
348
|
+
}, te = {
|
|
349
349
|
allowed: "Allowed",
|
|
350
350
|
notAllowed: "Not Allowed",
|
|
351
351
|
constrained: "Constrained"
|
|
352
352
|
};
|
|
353
|
-
function
|
|
353
|
+
function ne(e) {
|
|
354
354
|
try {
|
|
355
355
|
return new Date(e).toLocaleDateString(void 0, {
|
|
356
356
|
year: "numeric",
|
|
@@ -361,11 +361,11 @@ function N(e) {
|
|
|
361
361
|
return e;
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function j(e) {
|
|
365
365
|
return Array.isArray(e) ? e.filter((e) => typeof e == "string").join(", ") : typeof e == "string" ? e : "";
|
|
366
366
|
}
|
|
367
|
-
function
|
|
368
|
-
let o = t.title, c = (t.claimGenerator ?? t.claimGeneratorInfo?.[0]?.name ?? "Unknown").split(" ").filter(Boolean).map((e) => e[0].toUpperCase()).join("") || "?", l = u(t.assertions?.["cawg.identity"]?.verifiedIdentities), f = t.assertions?.["cawg.identity"], p = d(f), m = p?.role ?? [], h = f?.verifiedIdentities ?? [], g = p?.trust_registry ?? [], _ = t.assertions?.["cawg.training-mining"]?.entries ?? {}, v = t.assertions?.["cawg.metadata"], y =
|
|
367
|
+
function M({ className: e, manifest: t, moreInfo: n }) {
|
|
368
|
+
let o = t.title, c = (t.claimGenerator ?? t.claimGeneratorInfo?.[0]?.name ?? "Unknown").split(" ").filter(Boolean).map((e) => e[0].toUpperCase()).join("") || "?", l = u(t.assertions?.["cawg.identity"]?.verifiedIdentities, t.assertions?.["cawg.metadata"]), f = t.assertions?.["cawg.identity"], p = d(f), m = p?.role ?? [], h = f?.verifiedIdentities ?? [], g = p?.trust_registry ?? [], _ = t.assertions?.["cawg.training-mining"]?.entries ?? {}, v = t.assertions?.["cawg.metadata"], y = j(v?.["dc:creator"]), b = v?.["xmp:CreateDate"];
|
|
369
369
|
return /* @__PURE__ */ a("div", {
|
|
370
370
|
className: `cawg-card ${e ?? ""}`,
|
|
371
371
|
children: [
|
|
@@ -400,7 +400,7 @@ function F({ className: e, manifest: t, moreInfo: n }) {
|
|
|
400
400
|
className: "cawg-roles",
|
|
401
401
|
children: m.map((e) => /* @__PURE__ */ i("span", {
|
|
402
402
|
className: "cawg-role-badge",
|
|
403
|
-
children:
|
|
403
|
+
children: ee[e] ?? e
|
|
404
404
|
}, e))
|
|
405
405
|
}),
|
|
406
406
|
h.length > 0 && /* @__PURE__ */ a(r, { children: [
|
|
@@ -429,7 +429,7 @@ function F({ className: e, manifest: t, moreInfo: n }) {
|
|
|
429
429
|
children: [
|
|
430
430
|
/* @__PURE__ */ i("div", {
|
|
431
431
|
className: "cawg-identity-type-label",
|
|
432
|
-
children:
|
|
432
|
+
children: O[n] ?? n
|
|
433
433
|
}),
|
|
434
434
|
r && /* @__PURE__ */ i("div", {
|
|
435
435
|
className: "cawg-identity-name",
|
|
@@ -471,10 +471,10 @@ function F({ className: e, manifest: t, moreInfo: n }) {
|
|
|
471
471
|
className: "cawg-training-item",
|
|
472
472
|
children: [/* @__PURE__ */ i("span", {
|
|
473
473
|
className: "cawg-training-label",
|
|
474
|
-
children:
|
|
474
|
+
children: k[e] ?? e
|
|
475
475
|
}), /* @__PURE__ */ i("span", {
|
|
476
|
-
className:
|
|
477
|
-
children:
|
|
476
|
+
className: A[t.use] ?? "cawg-use-badge",
|
|
477
|
+
children: te[t.use] ?? t.use
|
|
478
478
|
})]
|
|
479
479
|
}, e))
|
|
480
480
|
})
|
|
@@ -502,7 +502,7 @@ function F({ className: e, manifest: t, moreInfo: n }) {
|
|
|
502
502
|
children: "Date Created"
|
|
503
503
|
}), /* @__PURE__ */ i("div", {
|
|
504
504
|
className: "cawg-key-value-value",
|
|
505
|
-
children:
|
|
505
|
+
children: ne(b)
|
|
506
506
|
})]
|
|
507
507
|
})
|
|
508
508
|
] }),
|
|
@@ -518,8 +518,239 @@ function F({ className: e, manifest: t, moreInfo: n }) {
|
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
520
|
//#endregion
|
|
521
|
+
//#region src/components/Cawg/helper/getCawgCredentials.ts
|
|
522
|
+
var N = {
|
|
523
|
+
"cawg.identity_claims_aggregation": "Identity claims aggregation",
|
|
524
|
+
"cawg.verifiable_credential_binding": "Verifiable credential binding"
|
|
525
|
+
}, re = /^cawg\.identity(__\d+)?$/, P = (e) => typeof e == "object" && !!e && !Array.isArray(e), F = (e) => (Array.isArray(e) ? e : e === void 0 ? [] : [e]).filter(P), I = (e) => typeof e == "string" ? e : void 0;
|
|
526
|
+
function L(e) {
|
|
527
|
+
let t = I((P(e.signer_payload) ? e.signer_payload : P(e.c2paAsset) ? e.c2paAsset : void 0)?.sig_type);
|
|
528
|
+
return t && t in N ? t : void 0;
|
|
529
|
+
}
|
|
530
|
+
function R(e, t) {
|
|
531
|
+
let n = L(t);
|
|
532
|
+
if (!n) return;
|
|
533
|
+
let r = P(t.issuer) ? {
|
|
534
|
+
id: I(t.issuer.id) ?? "",
|
|
535
|
+
name: I(t.issuer.name)
|
|
536
|
+
} : { id: I(t.issuer) ?? "" };
|
|
537
|
+
if (!r.id) return;
|
|
538
|
+
let i = n === "cawg.verifiable_credential_binding";
|
|
539
|
+
return {
|
|
540
|
+
label: e,
|
|
541
|
+
sigType: n,
|
|
542
|
+
issuer: r,
|
|
543
|
+
types: (Array.isArray(t.type) ? t.type : [t.type]).filter((e) => typeof e == "string"),
|
|
544
|
+
validFrom: I(t.validFrom) ?? I(t.issuanceDate),
|
|
545
|
+
validUntil: I(t.validUntil) ?? I(t.expirationDate),
|
|
546
|
+
subjects: F(i ? t.credentialSubject : t.verifiedIdentities),
|
|
547
|
+
bindings: i ? F(t.termsOfUse).filter((e) => e.type === "C2PAAssetBinding") : F(t.c2paAsset),
|
|
548
|
+
status: F(t.credentialStatus),
|
|
549
|
+
schemas: F(t.credentialSchema).map((e) => ({
|
|
550
|
+
id: I(e.id) ?? "",
|
|
551
|
+
type: I(e.type)
|
|
552
|
+
})).filter((e) => e.id),
|
|
553
|
+
raw: t
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
function z(e) {
|
|
557
|
+
return Object.entries(e.assertions ?? {}).filter(([e, t]) => re.test(e) && P(t)).sort(([e], [t]) => e.localeCompare(t, void 0, { numeric: !0 })).map(([e, t]) => R(e, t)).filter((e) => e !== void 0);
|
|
558
|
+
}
|
|
559
|
+
function B(e, t = 48) {
|
|
560
|
+
return e.length > t ? `${e.slice(0, t - 15)}…${e.slice(-12)}` : e;
|
|
561
|
+
}
|
|
562
|
+
//#endregion
|
|
563
|
+
//#region src/components/Cawg/levels/L3/CredentialSection.tsx
|
|
564
|
+
function V({ manifest: e, onIssuerClick: t }) {
|
|
565
|
+
let n = z(e);
|
|
566
|
+
return n.length === 0 ? null : /* @__PURE__ */ a(r, { children: [
|
|
567
|
+
/* @__PURE__ */ i("div", { className: "cawg-divider" }),
|
|
568
|
+
/* @__PURE__ */ i("div", {
|
|
569
|
+
className: "cawg-section-title",
|
|
570
|
+
children: n.length === 1 ? "Credential" : `Credentials (${n.length})`
|
|
571
|
+
}),
|
|
572
|
+
/* @__PURE__ */ i("div", {
|
|
573
|
+
className: "cawg-credential-list",
|
|
574
|
+
children: n.map((e) => /* @__PURE__ */ i(G, {
|
|
575
|
+
credential: e,
|
|
576
|
+
onIssuerClick: t
|
|
577
|
+
}, e.label))
|
|
578
|
+
})
|
|
579
|
+
] });
|
|
580
|
+
}
|
|
581
|
+
function H(e) {
|
|
582
|
+
if (!e) return;
|
|
583
|
+
let t = new Date(e);
|
|
584
|
+
return Number.isNaN(t.getTime()) ? e : t.toLocaleString(void 0, {
|
|
585
|
+
dateStyle: "medium",
|
|
586
|
+
timeStyle: "short"
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
function U(e) {
|
|
590
|
+
let t = Date.now(), n = e.validFrom ? Date.parse(e.validFrom) : NaN, r = e.validUntil ? Date.parse(e.validUntil) : NaN;
|
|
591
|
+
if (!Number.isNaN(n) && t < n) return {
|
|
592
|
+
label: "Not yet valid",
|
|
593
|
+
className: "cawg-credential-badge-warn"
|
|
594
|
+
};
|
|
595
|
+
if (!Number.isNaN(r) && t > r) return {
|
|
596
|
+
label: "Expired",
|
|
597
|
+
className: "cawg-credential-badge-warn"
|
|
598
|
+
};
|
|
599
|
+
if (!Number.isNaN(n)) return {
|
|
600
|
+
label: "In validity period",
|
|
601
|
+
className: "cawg-credential-badge-ok"
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
function W(e) {
|
|
605
|
+
let t = (t) => typeof e[t] == "string" ? e[t] : void 0, n = t("name") ?? t("username") ?? t("address") ?? t("uri");
|
|
606
|
+
return [t("type"), n].filter(Boolean).join(" · ") || t("id") || "Subject";
|
|
607
|
+
}
|
|
608
|
+
function G({ credential: e, onIssuerClick: t }) {
|
|
609
|
+
let [o, s] = n(!1), c = U(e), l = e.bindings.flatMap((e) => {
|
|
610
|
+
let t = e.referencedAssertions ?? e.referenced_assertions;
|
|
611
|
+
return Array.isArray(t) ? t : [];
|
|
612
|
+
}), u = e.bindings.flatMap((e) => Array.isArray(e.role) ? e.role : []), d = B(e.issuer.id), f = e.issuer.name ? `${e.issuer.name} (${d})` : d;
|
|
613
|
+
return /* @__PURE__ */ a("details", {
|
|
614
|
+
className: "cawg-credential",
|
|
615
|
+
children: [
|
|
616
|
+
/* @__PURE__ */ a("summary", { children: [/* @__PURE__ */ i("span", {
|
|
617
|
+
className: "cawg-credential-kind",
|
|
618
|
+
children: N[e.sigType]
|
|
619
|
+
}), c && /* @__PURE__ */ i("span", {
|
|
620
|
+
className: `cawg-credential-badge ${c.className}`,
|
|
621
|
+
children: c.label
|
|
622
|
+
})] }),
|
|
623
|
+
/* @__PURE__ */ a("div", {
|
|
624
|
+
className: "cawg-credential-tabs",
|
|
625
|
+
role: "tablist",
|
|
626
|
+
children: [/* @__PURE__ */ i("button", {
|
|
627
|
+
role: "tab",
|
|
628
|
+
"aria-selected": !o,
|
|
629
|
+
className: "cawg-credential-tab",
|
|
630
|
+
onClick: () => s(!1),
|
|
631
|
+
children: "Summary"
|
|
632
|
+
}), /* @__PURE__ */ i("button", {
|
|
633
|
+
role: "tab",
|
|
634
|
+
"aria-selected": o,
|
|
635
|
+
className: "cawg-credential-tab",
|
|
636
|
+
onClick: () => s(!0),
|
|
637
|
+
children: "Raw JSON"
|
|
638
|
+
})]
|
|
639
|
+
}),
|
|
640
|
+
o ? /* @__PURE__ */ i("pre", {
|
|
641
|
+
className: "cawg-credential-raw",
|
|
642
|
+
children: JSON.stringify(e.raw, null, 2)
|
|
643
|
+
}) : /* @__PURE__ */ a(r, { children: [
|
|
644
|
+
/* @__PURE__ */ a("div", {
|
|
645
|
+
className: "cawg-key-value",
|
|
646
|
+
children: [/* @__PURE__ */ i("div", {
|
|
647
|
+
className: "cawg-key-value-label",
|
|
648
|
+
children: "Issuer"
|
|
649
|
+
}), /* @__PURE__ */ i("div", {
|
|
650
|
+
className: "cawg-key-value-value",
|
|
651
|
+
children: t ? /* @__PURE__ */ i("button", {
|
|
652
|
+
className: "cawg-credential-link",
|
|
653
|
+
onClick: () => t(e.issuer.id),
|
|
654
|
+
title: `Look up ${e.issuer.id}`,
|
|
655
|
+
"aria-label": e.issuer.id,
|
|
656
|
+
children: f
|
|
657
|
+
}) : /* @__PURE__ */ i("span", {
|
|
658
|
+
title: e.issuer.id,
|
|
659
|
+
children: f
|
|
660
|
+
})
|
|
661
|
+
})]
|
|
662
|
+
}),
|
|
663
|
+
/* @__PURE__ */ a("div", {
|
|
664
|
+
className: "cawg-key-value",
|
|
665
|
+
children: [/* @__PURE__ */ i("div", {
|
|
666
|
+
className: "cawg-key-value-label",
|
|
667
|
+
children: "Type"
|
|
668
|
+
}), /* @__PURE__ */ i("div", {
|
|
669
|
+
className: "cawg-key-value-value",
|
|
670
|
+
children: e.types.join(", ")
|
|
671
|
+
})]
|
|
672
|
+
}),
|
|
673
|
+
(e.validFrom || e.validUntil) && /* @__PURE__ */ a("div", {
|
|
674
|
+
className: "cawg-key-value",
|
|
675
|
+
children: [/* @__PURE__ */ i("div", {
|
|
676
|
+
className: "cawg-key-value-label",
|
|
677
|
+
children: "Validity"
|
|
678
|
+
}), /* @__PURE__ */ a("div", {
|
|
679
|
+
className: "cawg-key-value-value",
|
|
680
|
+
children: [
|
|
681
|
+
e.validFrom && /* @__PURE__ */ a(r, { children: ["From ", H(e.validFrom)] }),
|
|
682
|
+
e.validFrom && e.validUntil && /* @__PURE__ */ i("br", {}),
|
|
683
|
+
e.validUntil && /* @__PURE__ */ a(r, { children: ["Until ", H(e.validUntil)] })
|
|
684
|
+
]
|
|
685
|
+
})]
|
|
686
|
+
}),
|
|
687
|
+
e.subjects.length > 0 && /* @__PURE__ */ a("div", {
|
|
688
|
+
className: "cawg-key-value",
|
|
689
|
+
children: [/* @__PURE__ */ a("div", {
|
|
690
|
+
className: "cawg-key-value-label",
|
|
691
|
+
children: [
|
|
692
|
+
e.sigType === "cawg.identity_claims_aggregation" ? "Verified identities" : "Subjects",
|
|
693
|
+
" (",
|
|
694
|
+
e.subjects.length,
|
|
695
|
+
")"
|
|
696
|
+
]
|
|
697
|
+
}), /* @__PURE__ */ i("ul", {
|
|
698
|
+
className: "cawg-credential-subjects",
|
|
699
|
+
children: e.subjects.map((e, t) => /* @__PURE__ */ i("li", { children: W(e) }, t))
|
|
700
|
+
})]
|
|
701
|
+
}),
|
|
702
|
+
/* @__PURE__ */ a("div", {
|
|
703
|
+
className: "cawg-key-value",
|
|
704
|
+
children: [/* @__PURE__ */ i("div", {
|
|
705
|
+
className: "cawg-key-value-label",
|
|
706
|
+
children: "Asset binding"
|
|
707
|
+
}), /* @__PURE__ */ a("div", {
|
|
708
|
+
className: "cawg-key-value-value",
|
|
709
|
+
children: [
|
|
710
|
+
l.length,
|
|
711
|
+
" referenced assertion",
|
|
712
|
+
l.length === 1 ? "" : "s",
|
|
713
|
+
u.length > 0 && /* @__PURE__ */ a(r, { children: [" · role ", u.join(", ")] })
|
|
714
|
+
]
|
|
715
|
+
})]
|
|
716
|
+
}),
|
|
717
|
+
/* @__PURE__ */ a("div", {
|
|
718
|
+
className: "cawg-key-value",
|
|
719
|
+
children: [/* @__PURE__ */ i("div", {
|
|
720
|
+
className: "cawg-key-value-label",
|
|
721
|
+
children: "Status"
|
|
722
|
+
}), /* @__PURE__ */ i("div", {
|
|
723
|
+
className: "cawg-key-value-value",
|
|
724
|
+
children: e.status.length ? e.status.map((e) => [e.type, e.statusPurpose].filter(Boolean).join(" · ")).join("; ") : "No revocation status published"
|
|
725
|
+
})]
|
|
726
|
+
}),
|
|
727
|
+
e.schemas.length > 0 && /* @__PURE__ */ a("div", {
|
|
728
|
+
className: "cawg-key-value",
|
|
729
|
+
children: [/* @__PURE__ */ i("div", {
|
|
730
|
+
className: "cawg-key-value-label",
|
|
731
|
+
children: "Schema"
|
|
732
|
+
}), /* @__PURE__ */ i("div", {
|
|
733
|
+
className: "cawg-key-value-value",
|
|
734
|
+
children: e.schemas.map((e) => /* @__PURE__ */ a("div", { children: [/* @__PURE__ */ i("a", {
|
|
735
|
+
href: e.id,
|
|
736
|
+
target: "_blank",
|
|
737
|
+
rel: "noopener noreferrer",
|
|
738
|
+
className: "cawg-identity-link",
|
|
739
|
+
children: e.id
|
|
740
|
+
}), e.type && /* @__PURE__ */ a(r, { children: [
|
|
741
|
+
" (",
|
|
742
|
+
e.type,
|
|
743
|
+
")"
|
|
744
|
+
] })] }, e.id))
|
|
745
|
+
})]
|
|
746
|
+
})
|
|
747
|
+
] })
|
|
748
|
+
]
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
//#endregion
|
|
521
752
|
//#region src/components/Cawg/levels/L3/CAWGL3.tsx
|
|
522
|
-
var
|
|
753
|
+
var K = {
|
|
523
754
|
"cawg.creator": "Creator",
|
|
524
755
|
"cawg.contributor": "Contributor",
|
|
525
756
|
"cawg.editor": "Editor",
|
|
@@ -527,31 +758,31 @@ var I = {
|
|
|
527
758
|
"cawg.publisher": "Publisher",
|
|
528
759
|
"cawg.sponsor": "Sponsor",
|
|
529
760
|
"cawg.translator": "Translator"
|
|
530
|
-
},
|
|
761
|
+
}, q = {
|
|
531
762
|
"cawg.document_verification": "ID Verified",
|
|
532
763
|
"cawg.web_site": "Website",
|
|
533
764
|
"cawg.affiliation": "Affiliation",
|
|
534
765
|
"cawg.social_media": "Social Media",
|
|
535
766
|
"cawg.crypto_wallet": "Crypto Wallet"
|
|
536
|
-
},
|
|
767
|
+
}, J = {
|
|
537
768
|
"cawg.data_mining": "Data Mining",
|
|
538
769
|
"cawg.ai_inference": "AI Inference",
|
|
539
770
|
"cawg.ai_training": "AI Training",
|
|
540
771
|
"cawg.ai_generative_training": "AI Generative Training"
|
|
541
|
-
},
|
|
772
|
+
}, Y = {
|
|
542
773
|
allowed: "cawg-use-badge cawg-use-allowed",
|
|
543
774
|
notAllowed: "cawg-use-badge cawg-use-not-allowed",
|
|
544
775
|
constrained: "cawg-use-badge cawg-use-constrained"
|
|
545
|
-
},
|
|
776
|
+
}, ie = {
|
|
546
777
|
allowed: "Allowed",
|
|
547
778
|
notAllowed: "Not Allowed",
|
|
548
779
|
constrained: "Constrained"
|
|
549
|
-
},
|
|
780
|
+
}, ae = {
|
|
550
781
|
"cawg.identity_claims_aggregation": "Identity Claims Aggregation",
|
|
551
782
|
"cawg.x509.cose": "X.509 Certificate",
|
|
552
783
|
"cawg.verifiable_credential_binding": "Verifiable Credential"
|
|
553
784
|
};
|
|
554
|
-
function
|
|
785
|
+
function oe(e) {
|
|
555
786
|
try {
|
|
556
787
|
return new Date(e).toLocaleDateString(void 0, {
|
|
557
788
|
year: "numeric",
|
|
@@ -562,11 +793,11 @@ function H(e) {
|
|
|
562
793
|
return e;
|
|
563
794
|
}
|
|
564
795
|
}
|
|
565
|
-
function
|
|
566
|
-
return e == null ? "" : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? e.map((e) =>
|
|
796
|
+
function X(e) {
|
|
797
|
+
return e == null ? "" : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? e.map((e) => X(e)).filter(Boolean).join(", ") : typeof e == "object" ? Object.entries(e).filter(([e]) => !e.startsWith("@")).map(([e, t]) => `${e}: ${X(t)}`).join("; ") : String(e);
|
|
567
798
|
}
|
|
568
|
-
function
|
|
569
|
-
let
|
|
799
|
+
function se({ className: e, manifest: t, moreInfo: n, showCredentials: o, onIssuerClick: c }) {
|
|
800
|
+
let l = t.title, f = t.claimGenerator ?? t.claimGeneratorInfo?.[0]?.name ?? "Unknown", p = u(t.assertions?.["cawg.identity"]?.verifiedIdentities, t.assertions?.["cawg.metadata"]), m = f.split(" ").filter(Boolean).map((e) => e[0].toUpperCase()).join("") || "?", h = t.assertions?.["cawg.identity"], g = d(h), _ = g?.role ?? [], v = h?.verifiedIdentities ?? [], y = g?.sig_type, b = h?.issuer, x = typeof b == "string" ? b : b && typeof b == "object" && typeof b.id == "string" ? typeof b.name == "string" ? `${b.name} (${b.id})` : b.id : void 0, S = g?.trust_registry ?? [], C = t.assertions?.["cawg.training-mining"]?.entries ?? {}, w = t.assertions?.["cawg.metadata"], T = w ? Object.entries(w).filter(([e]) => !e.startsWith("@")) : [];
|
|
570
801
|
return /* @__PURE__ */ a("div", {
|
|
571
802
|
className: `cawg-card ${e ?? ""}`,
|
|
572
803
|
children: [
|
|
@@ -581,7 +812,7 @@ function W({ className: e, manifest: t, moreInfo: n }) {
|
|
|
581
812
|
className: "cawg-square",
|
|
582
813
|
children: /* @__PURE__ */ i("span", {
|
|
583
814
|
className: "cawg-logo-text",
|
|
584
|
-
children:
|
|
815
|
+
children: m
|
|
585
816
|
})
|
|
586
817
|
}), /* @__PURE__ */ a("div", {
|
|
587
818
|
style: {
|
|
@@ -590,60 +821,60 @@ function W({ className: e, manifest: t, moreInfo: n }) {
|
|
|
590
821
|
},
|
|
591
822
|
children: [/* @__PURE__ */ i("span", {
|
|
592
823
|
className: "cawg-media-title",
|
|
593
|
-
children:
|
|
824
|
+
children: l
|
|
594
825
|
}), /* @__PURE__ */ i("span", {
|
|
595
826
|
className: "cawg-creators-name",
|
|
596
|
-
children:
|
|
827
|
+
children: p
|
|
597
828
|
})]
|
|
598
829
|
})]
|
|
599
830
|
}),
|
|
600
|
-
|
|
831
|
+
_.length > 0 && /* @__PURE__ */ i("div", {
|
|
601
832
|
className: "cawg-roles",
|
|
602
|
-
children:
|
|
833
|
+
children: _.map((e) => /* @__PURE__ */ i("span", {
|
|
603
834
|
className: "cawg-role-badge",
|
|
604
|
-
children:
|
|
835
|
+
children: K[e] ?? e
|
|
605
836
|
}, e))
|
|
606
837
|
}),
|
|
607
|
-
|
|
838
|
+
h && /* @__PURE__ */ a(r, { children: [
|
|
608
839
|
/* @__PURE__ */ i("div", { className: "cawg-divider" }),
|
|
609
840
|
/* @__PURE__ */ i("div", {
|
|
610
841
|
className: "cawg-section-title",
|
|
611
842
|
children: "Identity Assertion"
|
|
612
843
|
}),
|
|
613
|
-
|
|
844
|
+
y && /* @__PURE__ */ a("div", {
|
|
614
845
|
className: "cawg-key-value",
|
|
615
846
|
children: [/* @__PURE__ */ i("div", {
|
|
616
847
|
className: "cawg-key-value-label",
|
|
617
848
|
children: "Credential Type"
|
|
618
849
|
}), /* @__PURE__ */ i("div", {
|
|
619
850
|
className: "cawg-key-value-value",
|
|
620
|
-
children:
|
|
851
|
+
children: ae[y] ?? y
|
|
621
852
|
})]
|
|
622
853
|
}),
|
|
623
|
-
|
|
854
|
+
x && /* @__PURE__ */ a("div", {
|
|
624
855
|
className: "cawg-key-value",
|
|
625
856
|
children: [/* @__PURE__ */ i("div", {
|
|
626
857
|
className: "cawg-key-value-label",
|
|
627
858
|
children: "Issuer"
|
|
628
859
|
}), /* @__PURE__ */ i("div", {
|
|
629
860
|
className: "cawg-key-value-value",
|
|
630
|
-
children:
|
|
861
|
+
children: x
|
|
631
862
|
})]
|
|
632
863
|
}),
|
|
633
|
-
|
|
864
|
+
S.length > 0 && /* @__PURE__ */ a("div", {
|
|
634
865
|
className: "cawg-key-value",
|
|
635
866
|
children: [/* @__PURE__ */ i("div", {
|
|
636
867
|
className: "cawg-key-value-label",
|
|
637
868
|
children: "Trust Registry"
|
|
638
869
|
}), /* @__PURE__ */ i(D, {
|
|
639
|
-
entries:
|
|
870
|
+
entries: S,
|
|
640
871
|
variant: "full"
|
|
641
872
|
})]
|
|
642
873
|
}),
|
|
643
|
-
|
|
874
|
+
v.length > 0 && /* @__PURE__ */ i("div", {
|
|
644
875
|
className: "cawg-identity-list",
|
|
645
876
|
style: { marginTop: 12 },
|
|
646
|
-
children:
|
|
877
|
+
children: v.map((e, t) => {
|
|
647
878
|
let n = e.type, r = e.name ?? e.username ?? e.address, o = e.provider, s = e.uri, c = e.verifiedAt;
|
|
648
879
|
return /* @__PURE__ */ i("div", {
|
|
649
880
|
className: "cawg-identity-item",
|
|
@@ -652,7 +883,7 @@ function W({ className: e, manifest: t, moreInfo: n }) {
|
|
|
652
883
|
children: [
|
|
653
884
|
/* @__PURE__ */ i("div", {
|
|
654
885
|
className: "cawg-identity-type-label",
|
|
655
|
-
children:
|
|
886
|
+
children: q[n] ?? n
|
|
656
887
|
}),
|
|
657
888
|
r && /* @__PURE__ */ i("div", {
|
|
658
889
|
className: "cawg-identity-name",
|
|
@@ -671,27 +902,31 @@ function W({ className: e, manifest: t, moreInfo: n }) {
|
|
|
671
902
|
}),
|
|
672
903
|
c && /* @__PURE__ */ a("div", {
|
|
673
904
|
className: "cawg-identity-meta",
|
|
674
|
-
children: ["Verified ",
|
|
905
|
+
children: ["Verified ", oe(c)]
|
|
675
906
|
})
|
|
676
907
|
]
|
|
677
908
|
})
|
|
678
909
|
}, t);
|
|
679
910
|
})
|
|
680
911
|
}),
|
|
681
|
-
|
|
912
|
+
S.length > 0 && /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ i("div", {
|
|
682
913
|
className: "cawg-section-title",
|
|
683
914
|
style: { marginTop: 16 },
|
|
684
915
|
children: "Trust Registries"
|
|
685
916
|
}), /* @__PURE__ */ i("div", {
|
|
686
917
|
className: "cawg-identity-list",
|
|
687
|
-
children:
|
|
918
|
+
children: S.map((e, t) => /* @__PURE__ */ i(E, {
|
|
688
919
|
entry: e,
|
|
689
920
|
variant: "full",
|
|
690
921
|
showEntity: !0
|
|
691
922
|
}, t))
|
|
692
923
|
})] })
|
|
693
924
|
] }),
|
|
694
|
-
|
|
925
|
+
o && /* @__PURE__ */ i(V, {
|
|
926
|
+
manifest: t,
|
|
927
|
+
onIssuerClick: c
|
|
928
|
+
}),
|
|
929
|
+
Object.keys(C).length > 0 && /* @__PURE__ */ a(r, { children: [
|
|
695
930
|
/* @__PURE__ */ i("div", { className: "cawg-divider" }),
|
|
696
931
|
/* @__PURE__ */ i("div", {
|
|
697
932
|
className: "cawg-section-title",
|
|
@@ -699,7 +934,7 @@ function W({ className: e, manifest: t, moreInfo: n }) {
|
|
|
699
934
|
}),
|
|
700
935
|
/* @__PURE__ */ i("div", {
|
|
701
936
|
className: "cawg-training-list",
|
|
702
|
-
children: Object.entries(
|
|
937
|
+
children: Object.entries(C).map(([e, t]) => /* @__PURE__ */ a("div", {
|
|
703
938
|
className: "cawg-training-item",
|
|
704
939
|
style: {
|
|
705
940
|
flexDirection: "column",
|
|
@@ -713,10 +948,10 @@ function W({ className: e, manifest: t, moreInfo: n }) {
|
|
|
713
948
|
},
|
|
714
949
|
children: [/* @__PURE__ */ i("span", {
|
|
715
950
|
className: "cawg-training-label",
|
|
716
|
-
children:
|
|
951
|
+
children: J[e] ?? e
|
|
717
952
|
}), /* @__PURE__ */ i("span", {
|
|
718
|
-
className:
|
|
719
|
-
children:
|
|
953
|
+
className: Y[t.use] ?? "cawg-use-badge",
|
|
954
|
+
children: ie[t.use] ?? t.use
|
|
720
955
|
})]
|
|
721
956
|
}), t.constraint_info && /* @__PURE__ */ i("div", {
|
|
722
957
|
className: "cawg-constraint-info",
|
|
@@ -725,14 +960,14 @@ function W({ className: e, manifest: t, moreInfo: n }) {
|
|
|
725
960
|
}, e))
|
|
726
961
|
})
|
|
727
962
|
] }),
|
|
728
|
-
|
|
963
|
+
T.length > 0 && /* @__PURE__ */ a(r, { children: [
|
|
729
964
|
/* @__PURE__ */ i("div", { className: "cawg-divider" }),
|
|
730
965
|
/* @__PURE__ */ i("div", {
|
|
731
966
|
className: "cawg-section-title",
|
|
732
967
|
children: "Metadata"
|
|
733
968
|
}),
|
|
734
|
-
|
|
735
|
-
let n =
|
|
969
|
+
T.map(([e, t]) => {
|
|
970
|
+
let n = X(t);
|
|
736
971
|
return n ? /* @__PURE__ */ a("div", {
|
|
737
972
|
className: "cawg-key-value",
|
|
738
973
|
children: [/* @__PURE__ */ i("div", {
|
|
@@ -757,8 +992,64 @@ function W({ className: e, manifest: t, moreInfo: n }) {
|
|
|
757
992
|
});
|
|
758
993
|
}
|
|
759
994
|
//#endregion
|
|
995
|
+
//#region src/components/Cawg/helper/describeCawg.ts
|
|
996
|
+
var ce = {
|
|
997
|
+
"cawg.creator": "Created by",
|
|
998
|
+
"cawg.contributor": "Contributed by",
|
|
999
|
+
"cawg.editor": "Edited by",
|
|
1000
|
+
"cawg.producer": "Produced by",
|
|
1001
|
+
"cawg.publisher": "Published by",
|
|
1002
|
+
"cawg.sponsor": "Sponsored by",
|
|
1003
|
+
"cawg.translator": "Translated by"
|
|
1004
|
+
};
|
|
1005
|
+
function Z(e) {
|
|
1006
|
+
return e.length <= 1 ? e.join("") : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
|
|
1007
|
+
}
|
|
1008
|
+
function le(e) {
|
|
1009
|
+
return Array.isArray(e) ? e.filter((e) => typeof e == "string").join(", ") : typeof e == "string" ? e : "";
|
|
1010
|
+
}
|
|
1011
|
+
function ue(e) {
|
|
1012
|
+
let t = e.uri ?? e.provider?.id;
|
|
1013
|
+
if (!t) return "website";
|
|
1014
|
+
try {
|
|
1015
|
+
return new URL(t).host.replace(/^www\./, "");
|
|
1016
|
+
} catch {
|
|
1017
|
+
return t;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
function de(e) {
|
|
1021
|
+
let t = e.some((e) => e.type === "cawg.document_verification"), n = [];
|
|
1022
|
+
for (let t of e) {
|
|
1023
|
+
let e;
|
|
1024
|
+
t.type === "cawg.social_media" ? e = t.provider?.name : t.type === "cawg.web_site" ? e = ue(t) : t.type === "cawg.crypto_wallet" && (e = "crypto wallet"), e && !n.includes(e) && n.push(e);
|
|
1025
|
+
}
|
|
1026
|
+
let r = [];
|
|
1027
|
+
return t && r.push("ID verified"), n.length > 0 && r.push(`linked to ${Z(n)}`), r.length > 0 ? ` (${r.join(", ")})` : "";
|
|
1028
|
+
}
|
|
1029
|
+
function fe(e) {
|
|
1030
|
+
let t = [...new Set(e.filter((e) => e.type === "cawg.affiliation" && e.provider?.name).map((e) => e.provider.name))];
|
|
1031
|
+
return t.length > 0 ? `, affiliated with ${Z(t)}` : "";
|
|
1032
|
+
}
|
|
1033
|
+
function Q(e) {
|
|
1034
|
+
let t = /* @__PURE__ */ new Map();
|
|
1035
|
+
for (let n of e) {
|
|
1036
|
+
let e = n.assertions?.["cawg.identity"], r = n.assertions?.["cawg.metadata"];
|
|
1037
|
+
if (!e && !r) continue;
|
|
1038
|
+
let i = e?.verifiedIdentities, a = Array.isArray(i) ? i : i ? [i] : [], o = le(r?.["dc:creator"]), s = a.length > 0 ? u([...a], {}) : "Unknown";
|
|
1039
|
+
if (s === "Unknown" && (s = o), !s) continue;
|
|
1040
|
+
let c = d(e)?.role ?? [], l = c.length > 0 ? c.map((e) => ce[e] ?? `${e.replace(/^cawg\./, "")} by`) : [o ? "Created by" : "Signed by"], f = `${s}${de(a)}${fe(a)}`;
|
|
1041
|
+
for (let e of l) {
|
|
1042
|
+
let n = t.get(e) ?? [];
|
|
1043
|
+
n.includes(f) || n.push(f), t.set(e, n);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
if (t.size === 0) return;
|
|
1047
|
+
let n = [...t.entries()].map(([e, t], n) => `${n === 0 ? e : e.charAt(0).toLowerCase() + e.slice(1)} ${Z(t)}`).join("; ");
|
|
1048
|
+
return n.endsWith(".") ? n : `${n}.`;
|
|
1049
|
+
}
|
|
1050
|
+
//#endregion
|
|
760
1051
|
//#region src/components/Cawg/Cawg.tsx
|
|
761
|
-
function
|
|
1052
|
+
function pe(e) {
|
|
762
1053
|
return {
|
|
763
1054
|
id: e.id ?? "",
|
|
764
1055
|
title: e.title ?? "",
|
|
@@ -780,36 +1071,7 @@ function G(e) {
|
|
|
780
1071
|
ingredients: e.ingredients ?? []
|
|
781
1072
|
};
|
|
782
1073
|
}
|
|
783
|
-
var
|
|
784
|
-
let o = t.manifestStore?.activeManifest, s = n == null ? t.manifests.find((e) => e.id === o || e.instanceId === o) ?? (o ? t.manifestStore.manifests[o] : void 0) ?? t.manifests[0] : G(n);
|
|
785
|
-
if (!s || !(s.assertions?.["cawg.identity"] != null || s.assertions?.["cawg.training-mining"] != null || s.assertions?.["cawg.metadata"] != null)) return null;
|
|
786
|
-
let [c, l] = e.useState(r || 1);
|
|
787
|
-
switch (c) {
|
|
788
|
-
case 1: return /* @__PURE__ */ i(b, {
|
|
789
|
-
className: a,
|
|
790
|
-
manifest: s,
|
|
791
|
-
moreInfo: () => {
|
|
792
|
-
l(2);
|
|
793
|
-
}
|
|
794
|
-
});
|
|
795
|
-
case 2: return /* @__PURE__ */ i(F, {
|
|
796
|
-
className: a,
|
|
797
|
-
manifest: s,
|
|
798
|
-
moreInfo: () => {
|
|
799
|
-
l(3);
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
case 3: return /* @__PURE__ */ i(W, {
|
|
803
|
-
className: a,
|
|
804
|
-
manifest: s,
|
|
805
|
-
moreInfo: () => {
|
|
806
|
-
l(1);
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
return /* @__PURE__ */ i("div", { children: "Level Of Detail Not Selected" });
|
|
811
|
-
};
|
|
812
|
-
K.knownAssertions = [
|
|
1074
|
+
var me = [
|
|
813
1075
|
"cawg.identity",
|
|
814
1076
|
"cawg.training-mining",
|
|
815
1077
|
"cawg.metadata",
|
|
@@ -826,5 +1088,33 @@ K.knownAssertions = [
|
|
|
826
1088
|
"cawg.social_media",
|
|
827
1089
|
"cawg.crypto_wallet"
|
|
828
1090
|
];
|
|
1091
|
+
function $(t = {}) {
|
|
1092
|
+
let { showCredentials: n = !1, onIssuerClick: r } = t, a = ({ manifest: t, entry: a, level: o, className: s }) => {
|
|
1093
|
+
let [c, l] = e.useState(o || 1), u = t.manifestStore?.activeManifest, d = a == null ? t.manifests.find((e) => e.id === u || e.instanceId === u) ?? (u ? t.manifestStore.manifests[u] : void 0) ?? t.manifests[0] : pe(a);
|
|
1094
|
+
if (!d || !(d.assertions?.["cawg.identity"] != null || d.assertions?.["cawg.training-mining"] != null || d.assertions?.["cawg.metadata"] != null)) return null;
|
|
1095
|
+
switch (c) {
|
|
1096
|
+
case 1: return /* @__PURE__ */ i(b, {
|
|
1097
|
+
className: s,
|
|
1098
|
+
manifest: d,
|
|
1099
|
+
moreInfo: () => l(2)
|
|
1100
|
+
});
|
|
1101
|
+
case 2: return /* @__PURE__ */ i(M, {
|
|
1102
|
+
className: s,
|
|
1103
|
+
manifest: d,
|
|
1104
|
+
moreInfo: () => l(3)
|
|
1105
|
+
});
|
|
1106
|
+
case 3: return /* @__PURE__ */ i(se, {
|
|
1107
|
+
className: s,
|
|
1108
|
+
manifest: d,
|
|
1109
|
+
moreInfo: () => l(1),
|
|
1110
|
+
showCredentials: n,
|
|
1111
|
+
onIssuerClick: r
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
return /* @__PURE__ */ i("div", { children: "Level Of Detail Not Selected" });
|
|
1115
|
+
};
|
|
1116
|
+
return a.knownAssertions = me, a.describe = Q, a;
|
|
1117
|
+
}
|
|
1118
|
+
var he = $();
|
|
829
1119
|
//#endregion
|
|
830
|
-
export {
|
|
1120
|
+
export { he as CAWGManifest, N as CREDENTIAL_SIG_TYPES, T as TrustBadge, E as TrustRegistryRow, D as TrustRegistrySummaryBadge, $ as createCAWGManifest, Q as describeCawg, z as getCawgCredentials, h as getTrustRegistryQueryFn, f as queryTrustRegistry, m as setTrustRegistryQueryFn, B as shortenDid, g as useTrustRegistryQuery, _ as useTrustRegistrySummary };
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
<rect width="34" height="34" fill="black"/>
|
|
8
8
|
</clipPath>
|
|
9
9
|
</defs>
|
|
10
|
-
</svg>`,d=()=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`16px`},children:[(0,n.jsx)(`div`,{dangerouslySetInnerHTML:{__html:u},style:{width:`24px`,height:`24px`,display:`flex`,alignItems:`center`}}),(0,n.jsx)(`span`,{style:{fontSize:`14px`,fontWeight:600,color:`#333`,display:`flex`,alignItems:`center`},children:`Creator Assertions Working Group`})]}),f=e=>{switch(e){case`cawg.document_verification`:return 0;case`cawg.social_media`:return 10;case`cawg.web_site`:return 20;case`cawg.affiliation`:return 1e6;default:return 1e5}},p=[`cawg.affiliation`],m=e=>{if(typeof e==`object`&&!Array.isArray(e)&&(e=[e]),!e||e.length===0)return`Unknown`;let t=e.sort((e,t)=>f(e.type)-f(t.type))[0];return!t||p.includes(t.type)?`Unknown`:t.name},h=e=>{if(e)return e.signer_payload??e.c2paAsset};async function g(){throw Error("No trust registry query function configured. Call `setTrustRegistryQueryFn` (or pass a `queryFn` prop to TrustBadge) with a function that queries a real TRQP endpoint.")}var _=g;function v(e){_=e}function y(){return _}function b(e,n,r,i,a,o=y()){let[s,c]=(0,t.useState)(`idle`),[l,u]=(0,t.useState)(null),[d,f]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!e){c(`idle`),u(null),f(null);return}let t=!1;return c(`loading`),f(null),o({entityId:e,action:n,resource:r,authorityId:i,trqpAuthorizationUri:a}).then(e=>{t||(u(e),c(`done`))},e=>{t||(u(null),f(e instanceof Error?e:Error(String(e))),c(`error`))}),()=>{t=!0}},[e,n,r,i,a,o]),{status:s,result:l,error:d}}function x(e,n=y()){let[r,i]=(0,t.useState)(`idle`),[a,o]=(0,t.useState)([]),[s,c]=(0,t.useState)(null),l=e.filter(e=>!!e.entity_id);return(0,t.useEffect)(()=>{if(l.length===0){i(`idle`),o([]),c(null);return}let e=!1;return i(`loading`),c(null),Promise.all(l.map(e=>n({entityId:e.entity_id,action:e.action,resource:e.resource,authorityId:e.authority_id,trqpAuthorizationUri:e.trqp_authorization_uri}))).then(t=>{e||(o(t),i(`done`))},t=>{e||(o([]),c(t instanceof Error?t:Error(String(t))),i(`error`))}),()=>{e=!0}},[l.map(e=>`${e.entity_id}|${e.action??``}|${e.resource??``}|${e.authority_id??``}|${e.trqp_authorization_uri??``}`).join(`,`),n]),{status:r,results:a,error:s}}var S=`Identity Unable to be Verified by Trust Registry`,C={"cawg.creator":`Creator`,"cawg.contributor":`Contributor`,"cawg.editor":`Editor`,"cawg.producer":`Producer`,"cawg.publisher":`Publisher`,"cawg.sponsor":`Sponsor`,"cawg.translator":`Translator`};function w({className:e,manifest:t,moreInfo:r}){let i=t.title,a=t.claimGenerator??t.claimGeneratorInfo?.[0]?.name??`Unknown`,o=m(t.assertions?.[`cawg.identity`]?.verifiedIdentities),s=a.split(` `).filter(Boolean).map(e=>e[0].toUpperCase()).join(``)||`?`,c=t.assertions?.[`cawg.identity`],l=h(c),u=l?.role??[],{status:f,results:p}=x(l?.trust_registry??[]),g=p.filter(e=>!e.hide),_=f===`done`&&g.some(e=>!e.authorized);return(0,n.jsxs)(`div`,{className:`cawg-card ${e??``}`,children:[(0,n.jsx)(d,{}),(0,n.jsxs)(`div`,{className:`cawg-container`,children:[t.thumbnail?(0,n.jsx)(`img`,{src:t.thumbnail,alt:`Thumbnail`,className:`cawg-thumbnail`}):(0,n.jsx)(`div`,{className:`cawg-square`,children:(0,n.jsx)(`span`,{className:`cawg-logo-text`,children:s})}),(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,n.jsx)(`span`,{className:`cawg-media-title`,children:i}),(0,n.jsx)(`span`,{className:`cawg-creators-name`,children:o})]})]}),_&&(0,n.jsx)(`div`,{style:{marginTop:12},children:(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-unverified`,children:S})}),u.length>0&&(0,n.jsx)(`div`,{className:`cawg-roles`,children:u.map(e=>(0,n.jsx)(`span`,{className:`cawg-role-badge`,children:C[e]??e},e))}),r&&(0,n.jsx)(`div`,{style:{marginTop:16},children:(0,n.jsx)(`button`,{onClick:r,className:`cawg-button`,children:`More Info`})})]})}function T(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}catch{return e}}var E=`Identity Verified by Trust Registry`,D=`Identity Unable to be Verified by Trust Registry`;function O(e,t,r,i){if(e===`error`)return(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-unverified`,title:r?.message,children:`Unable to reach trust registry`});if(e!==`done`||!t)return(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-pending`,children:`Checking trust registry…`});let a=(0,n.jsx)(`span`,{className:t.authorized?`cawg-trust-badge cawg-trust-verified`:`cawg-trust-badge cawg-trust-unverified`,title:t.authorized?`Recognized by ${t.authority_id} · checked ${T(t.time_evaluated)}`:t.message,children:t.authorized?E:D});return i===`compact`?a:(0,n.jsxs)(`div`,{className:`cawg-trust-status`,children:[a,t.authorized?(0,n.jsxs)(`div`,{className:`cawg-trust-meta`,children:[t.authority_id,` · checked `,T(t.time_evaluated)]}):t.message&&(0,n.jsx)(`div`,{className:`cawg-trust-message`,children:t.message})]})}function k({entityId:e,action:t,resource:r,authorityId:i,trqpAuthorizationUri:a,variant:o=`full`,queryFn:s}){let{status:c,result:l,error:u}=b(e,t,r,i,a,s);return!e||c===`done`&&l?.hide?null:(0,n.jsxs)(n.Fragment,{children:[c===`done`&&l?.icon&&(0,n.jsx)(`img`,{src:l.icon,alt:``,className:`cawg-trust-icon`}),O(c,l,u,o)]})}function A({entry:e,variant:t=`full`,showEntity:r=!1,queryFn:i}){let{status:a,result:o,error:s}=b(e.entity_id,e.action,e.resource,e.authority_id,e.trqp_authorization_uri,i);return a===`done`&&o?.hide?null:(0,n.jsxs)(`div`,{className:`cawg-identity-item`,children:[a===`done`&&o?.icon&&(0,n.jsx)(`img`,{src:o.icon,alt:``,className:`cawg-trust-icon`}),(0,n.jsxs)(`div`,{style:{flex:1},children:[e.authority_id&&(0,n.jsxs)(`div`,{className:`cawg-identity-name`,children:[`Authority: `,e.authority_id]}),r&&e.entity_id&&(0,n.jsxs)(`div`,{className:`cawg-identity-provider`,children:[`Entity: `,e.entity_id]}),e.action&&(0,n.jsxs)(`div`,{className:`cawg-identity-meta`,children:[`Action: `,e.action]}),e.resource&&(0,n.jsxs)(`div`,{className:`cawg-identity-meta`,children:[`Resource: `,e.resource]}),e.trqp_authorization_uri&&(0,n.jsx)(`a`,{href:e.trqp_authorization_uri,target:`_blank`,rel:`noopener noreferrer`,className:`cawg-identity-link`,children:e.trqp_authorization_uri}),O(a,o,s,t)]})]})}function j({entries:e,variant:t=`compact`,queryFn:r}){let{status:i,results:a,error:o}=x(e,r);if(e.filter(e=>e.entity_id).length===0)return null;if(i===`error`)return(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-unverified`,title:o?.message,children:`Unable to reach trust registry`});if(i!==`done`)return(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-pending`,children:`Checking trust registry…`});let s=a.filter(e=>!e.hide);if(s.length===0)return null;let c=s.every(e=>e.authorized),l=s.filter(e=>!e.authorized),u=s.find(e=>e.icon)?.icon,d=c?`Recognized by ${Array.from(new Set(s.map(e=>e.authority_id))).join(`, `)}`:l.map(e=>e.message).filter(Boolean).join(` · `)||void 0,f=(0,n.jsx)(`span`,{className:c?`cawg-trust-badge cawg-trust-verified`:`cawg-trust-badge cawg-trust-unverified`,title:d,children:c?E:D});return t===`compact`?(0,n.jsxs)(n.Fragment,{children:[u&&(0,n.jsx)(`img`,{src:u,alt:``,className:`cawg-trust-icon`}),f]}):(0,n.jsxs)(`div`,{className:`cawg-trust-status`,children:[u&&(0,n.jsx)(`img`,{src:u,alt:``,className:`cawg-trust-icon`}),f,c?(0,n.jsxs)(`div`,{className:`cawg-trust-meta`,children:[Array.from(new Set(s.map(e=>e.authority_id))).join(`, `),` · checked`,` `,T(s[0].time_evaluated)]}):d&&(0,n.jsx)(`div`,{className:`cawg-trust-message`,children:d})]})}var M={"cawg.creator":`Creator`,"cawg.contributor":`Contributor`,"cawg.editor":`Editor`,"cawg.producer":`Producer`,"cawg.publisher":`Publisher`,"cawg.sponsor":`Sponsor`,"cawg.translator":`Translator`},N={"cawg.document_verification":`ID Verified`,"cawg.web_site":`Website`,"cawg.affiliation":`Affiliation`,"cawg.social_media":`Social Media`,"cawg.crypto_wallet":`Crypto Wallet`},P={"cawg.data_mining":`Data Mining`,"cawg.ai_inference":`AI Inference`,"cawg.ai_training":`AI Training`,"cawg.ai_generative_training":`AI Generative Training`},F={allowed:`cawg-use-badge cawg-use-allowed`,notAllowed:`cawg-use-badge cawg-use-not-allowed`,constrained:`cawg-use-badge cawg-use-constrained`},I={allowed:`Allowed`,notAllowed:`Not Allowed`,constrained:`Constrained`};function L(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}catch{return e}}function R(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`, `):typeof e==`string`?e:``}function z({className:e,manifest:t,moreInfo:r}){let i=t.title,a=(t.claimGenerator??t.claimGeneratorInfo?.[0]?.name??`Unknown`).split(` `).filter(Boolean).map(e=>e[0].toUpperCase()).join(``)||`?`,o=m(t.assertions?.[`cawg.identity`]?.verifiedIdentities),s=t.assertions?.[`cawg.identity`],c=h(s),l=c?.role??[],u=s?.verifiedIdentities??[],f=c?.trust_registry??[],p=t.assertions?.[`cawg.training-mining`]?.entries??{},g=t.assertions?.[`cawg.metadata`],_=R(g?.[`dc:creator`]),v=g?.[`xmp:CreateDate`];return(0,n.jsxs)(`div`,{className:`cawg-card ${e??``}`,children:[(0,n.jsx)(d,{}),(0,n.jsxs)(`div`,{className:`cawg-container`,children:[t.thumbnail?(0,n.jsx)(`img`,{src:t.thumbnail,alt:`Thumbnail`,className:`cawg-thumbnail`}):(0,n.jsx)(`div`,{className:`cawg-square`,children:(0,n.jsx)(`span`,{className:`cawg-logo-text`,children:a})}),(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,n.jsx)(`span`,{className:`cawg-media-title`,children:i}),(0,n.jsx)(`span`,{className:`cawg-creators-name`,children:o})]})]}),l.length>0&&(0,n.jsx)(`div`,{className:`cawg-roles`,children:l.map(e=>(0,n.jsx)(`span`,{className:`cawg-role-badge`,children:M[e]??e},e))}),u.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsxs)(`div`,{className:`cawg-section-title`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,n.jsx)(`span`,{children:`Identity`}),f.length>0&&(0,n.jsx)(j,{entries:f,variant:`compact`})]}),(0,n.jsx)(`div`,{className:`cawg-identity-list`,children:u.map((e,t)=>{let r=e.type,i=e.name??e.username,a=e.provider;return(0,n.jsx)(`div`,{className:`cawg-identity-item`,children:(0,n.jsxs)(`div`,{style:{flex:1},children:[(0,n.jsx)(`div`,{className:`cawg-identity-type-label`,children:N[r]??r}),i&&(0,n.jsx)(`div`,{className:`cawg-identity-name`,children:i}),a?.name&&(0,n.jsx)(`div`,{className:`cawg-identity-provider`,children:a.name})]})},t)})})]}),f.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Trust Registries`}),(0,n.jsx)(`div`,{className:`cawg-identity-list`,children:f.map((e,t)=>(0,n.jsx)(A,{entry:e,variant:`compact`},t))})]}),Object.keys(p).length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Training & Data Mining`}),(0,n.jsx)(`div`,{className:`cawg-training-list`,children:Object.entries(p).map(([e,t])=>(0,n.jsxs)(`div`,{className:`cawg-training-item`,children:[(0,n.jsx)(`span`,{className:`cawg-training-label`,children:P[e]??e}),(0,n.jsx)(`span`,{className:F[t.use]??`cawg-use-badge`,children:I[t.use]??t.use})]},e))})]}),(_||v)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Creator`}),_&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Name`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:_})]}),v&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Date Created`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:L(v)})]})]}),r&&(0,n.jsx)(`div`,{style:{marginTop:16},children:(0,n.jsx)(`button`,{onClick:r,className:`cawg-button`,children:`More Info`})})]})}var B={"cawg.creator":`Creator`,"cawg.contributor":`Contributor`,"cawg.editor":`Editor`,"cawg.producer":`Producer`,"cawg.publisher":`Publisher`,"cawg.sponsor":`Sponsor`,"cawg.translator":`Translator`},V={"cawg.document_verification":`ID Verified`,"cawg.web_site":`Website`,"cawg.affiliation":`Affiliation`,"cawg.social_media":`Social Media`,"cawg.crypto_wallet":`Crypto Wallet`},H={"cawg.data_mining":`Data Mining`,"cawg.ai_inference":`AI Inference`,"cawg.ai_training":`AI Training`,"cawg.ai_generative_training":`AI Generative Training`},U={allowed:`cawg-use-badge cawg-use-allowed`,notAllowed:`cawg-use-badge cawg-use-not-allowed`,constrained:`cawg-use-badge cawg-use-constrained`},W={allowed:`Allowed`,notAllowed:`Not Allowed`,constrained:`Constrained`},G={"cawg.identity_claims_aggregation":`Identity Claims Aggregation`,"cawg.x509.cose":`X.509 Certificate`,"cawg.verifiable_credential_binding":`Verifiable Credential`};function K(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}catch{return e}}function q(e){return e==null?``:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>q(e)).filter(Boolean).join(`, `):typeof e==`object`?Object.entries(e).filter(([e])=>!e.startsWith(`@`)).map(([e,t])=>`${e}: ${q(t)}`).join(`; `):String(e)}function J({className:e,manifest:t,moreInfo:r}){let i=t.title,a=t.claimGenerator??t.claimGeneratorInfo?.[0]?.name??`Unknown`,o=m(t.assertions?.[`cawg.identity`]?.verifiedIdentities),s=a.split(` `).filter(Boolean).map(e=>e[0].toUpperCase()).join(``)||`?`,c=t.assertions?.[`cawg.identity`],l=h(c),u=l?.role??[],f=c?.verifiedIdentities??[],p=l?.sig_type,g=c?.issuer,_=l?.trust_registry??[],v=t.assertions?.[`cawg.training-mining`]?.entries??{},y=t.assertions?.[`cawg.metadata`],b=y?Object.entries(y).filter(([e])=>!e.startsWith(`@`)):[];return(0,n.jsxs)(`div`,{className:`cawg-card ${e??``}`,children:[(0,n.jsx)(d,{}),(0,n.jsxs)(`div`,{className:`cawg-container`,children:[t.thumbnail?(0,n.jsx)(`img`,{src:t.thumbnail,alt:`Thumbnail`,className:`cawg-thumbnail`}):(0,n.jsx)(`div`,{className:`cawg-square`,children:(0,n.jsx)(`span`,{className:`cawg-logo-text`,children:s})}),(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,n.jsx)(`span`,{className:`cawg-media-title`,children:i}),(0,n.jsx)(`span`,{className:`cawg-creators-name`,children:o})]})]}),u.length>0&&(0,n.jsx)(`div`,{className:`cawg-roles`,children:u.map(e=>(0,n.jsx)(`span`,{className:`cawg-role-badge`,children:B[e]??e},e))}),c&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Identity Assertion`}),p&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Credential Type`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:G[p]??p})]}),g&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Issuer`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:g})]}),_.length>0&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Trust Registry`}),(0,n.jsx)(j,{entries:_,variant:`full`})]}),f.length>0&&(0,n.jsx)(`div`,{className:`cawg-identity-list`,style:{marginTop:12},children:f.map((e,t)=>{let r=e.type,i=e.name??e.username??e.address,a=e.provider,o=e.uri,s=e.verifiedAt;return(0,n.jsx)(`div`,{className:`cawg-identity-item`,children:(0,n.jsxs)(`div`,{style:{flex:1},children:[(0,n.jsx)(`div`,{className:`cawg-identity-type-label`,children:V[r]??r}),i&&(0,n.jsx)(`div`,{className:`cawg-identity-name`,children:i}),a?.name&&(0,n.jsxs)(`div`,{className:`cawg-identity-provider`,children:[`via `,a.name]}),o&&(0,n.jsx)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,className:`cawg-identity-link`,children:o}),s&&(0,n.jsxs)(`div`,{className:`cawg-identity-meta`,children:[`Verified `,K(s)]})]})},t)})}),_.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-section-title`,style:{marginTop:16},children:`Trust Registries`}),(0,n.jsx)(`div`,{className:`cawg-identity-list`,children:_.map((e,t)=>(0,n.jsx)(A,{entry:e,variant:`full`,showEntity:!0},t))})]})]}),Object.keys(v).length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Training & Data Mining`}),(0,n.jsx)(`div`,{className:`cawg-training-list`,children:Object.entries(v).map(([e,t])=>(0,n.jsxs)(`div`,{className:`cawg-training-item`,style:{flexDirection:`column`,alignItems:`flex-start`},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,width:`100%`},children:[(0,n.jsx)(`span`,{className:`cawg-training-label`,children:H[e]??e}),(0,n.jsx)(`span`,{className:U[t.use]??`cawg-use-badge`,children:W[t.use]??t.use})]}),t.constraint_info&&(0,n.jsx)(`div`,{className:`cawg-constraint-info`,children:t.constraint_info})]},e))})]}),b.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Metadata`}),b.map(([e,t])=>{let r=q(t);return r?(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:e}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:r})]},e):null})]}),r&&(0,n.jsx)(`div`,{style:{marginTop:16},children:(0,n.jsx)(`button`,{onClick:r,className:`cawg-button`,children:`Small View`})})]})}function Y(e){return{id:e.id??``,title:e.title??``,claimGenerator:e.claimGenerator??null,claimGeneratorInfo:(e.claimGeneratorInfo??[]).map(e=>({name:e.name,"org.contentauth.c2pa_rs":e[`org.contentauth.c2pa_rs`]??``})),instanceId:e.instanceId??``,signatureInfo:{alg:e.signatureInfo?.alg??``,issuer:e.signatureInfo?.issuer??``,common_name:e.signatureInfo?.common_name??``,cert_serial_number:e.signatureInfo?.cert_serial_number??``},assertions:e.assertions??{},credentials:e.credentials??[],thumbnail:typeof e.thumbnail==`string`?e.thumbnail:null,ingredients:e.ingredients??[]}}var X=({manifest:e,entry:r,level:i,className:a})=>{let o=e.manifestStore?.activeManifest,s=r==null?e.manifests.find(e=>e.id===o||e.instanceId===o)??(o?e.manifestStore.manifests[o]:void 0)??e.manifests[0]:Y(r);if(!s||!(s.assertions?.[`cawg.identity`]!=null||s.assertions?.[`cawg.training-mining`]!=null||s.assertions?.[`cawg.metadata`]!=null))return null;let[c,l]=t.default.useState(i||1);switch(c){case 1:return(0,n.jsx)(w,{className:a,manifest:s,moreInfo:()=>{l(2)}});case 2:return(0,n.jsx)(z,{className:a,manifest:s,moreInfo:()=>{l(3)}});case 3:return(0,n.jsx)(J,{className:a,manifest:s,moreInfo:()=>{l(1)}})}return(0,n.jsx)(`div`,{children:`Level Of Detail Not Selected`})};X.knownAssertions=[`cawg.identity`,`cawg.training-mining`,`cawg.metadata`,`cawg.creator`,`cawg.contributor`,`cawg.editor`,`cawg.producer`,`cawg.publisher`,`cawg.sponsor`,`cawg.translator`,`cawg.document_verification`,`cawg.web_site`,`cawg.affiliation`,`cawg.social_media`,`cawg.crypto_wallet`],e.CAWGManifest=X,e.TrustBadge=k,e.TrustRegistryRow=A,e.TrustRegistrySummaryBadge=j,e.getTrustRegistryQueryFn=y,e.queryTrustRegistry=g,e.setTrustRegistryQueryFn=v,e.useTrustRegistryQuery=b,e.useTrustRegistrySummary=x});
|
|
10
|
+
</svg>`,d=()=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`16px`},children:[(0,n.jsx)(`div`,{dangerouslySetInnerHTML:{__html:u},style:{width:`24px`,height:`24px`,display:`flex`,alignItems:`center`}}),(0,n.jsx)(`span`,{style:{fontSize:`14px`,fontWeight:600,color:`#333`,display:`flex`,alignItems:`center`},children:`Creator Assertions Working Group`})]}),f=e=>{switch(e){case`cawg.document_verification`:return 0;case`cawg.social_media`:return 10;case`cawg.web_site`:return 20;case`cawg.affiliation`:return 1e6;default:return 1e5}},p=[`cawg.affiliation`],m=(e,t)=>{if(e&&typeof e==`object`&&!Array.isArray(e)&&(e=[e]),!e||e.length===0)return t?.[`dc:creator`]?t[`dc:creator`]:`Unknown`;let n=e.sort((e,t)=>f(e.type)-f(t.type))[0];return!n||p.includes(n.type)?`Unknown`:n.name},h=e=>{if(e)return e.signer_payload??e.c2paAsset};async function g(){throw Error("No trust registry query function configured. Call `setTrustRegistryQueryFn` (or pass a `queryFn` prop to TrustBadge) with a function that queries a real TRQP endpoint.")}var _=g;function v(e){_=e}function y(){return _}function b(e,n,r,i,a,o=y()){let[s,c]=(0,t.useState)(`idle`),[l,u]=(0,t.useState)(null),[d,f]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!e){c(`idle`),u(null),f(null);return}let t=!1;return c(`loading`),f(null),o({entityId:e,action:n,resource:r,authorityId:i,trqpAuthorizationUri:a}).then(e=>{t||(u(e),c(`done`))},e=>{t||(u(null),f(e instanceof Error?e:Error(String(e))),c(`error`))}),()=>{t=!0}},[e,n,r,i,a,o]),{status:s,result:l,error:d}}function x(e,n=y()){let[r,i]=(0,t.useState)(`idle`),[a,o]=(0,t.useState)([]),[s,c]=(0,t.useState)(null),l=e.filter(e=>!!e.entity_id);return(0,t.useEffect)(()=>{if(l.length===0){i(`idle`),o([]),c(null);return}let e=!1;return i(`loading`),c(null),Promise.all(l.map(e=>n({entityId:e.entity_id,action:e.action,resource:e.resource,authorityId:e.authority_id,trqpAuthorizationUri:e.trqp_authorization_uri}))).then(t=>{e||(o(t),i(`done`))},t=>{e||(o([]),c(t instanceof Error?t:Error(String(t))),i(`error`))}),()=>{e=!0}},[l.map(e=>`${e.entity_id}|${e.action??``}|${e.resource??``}|${e.authority_id??``}|${e.trqp_authorization_uri??``}`).join(`,`),n]),{status:r,results:a,error:s}}var S=`Identity Unable to be Verified by Trust Registry`,C={"cawg.creator":`Creator`,"cawg.contributor":`Contributor`,"cawg.editor":`Editor`,"cawg.producer":`Producer`,"cawg.publisher":`Publisher`,"cawg.sponsor":`Sponsor`,"cawg.translator":`Translator`};function w({className:e,manifest:t,moreInfo:r}){let i=t.title,a=t.claimGenerator??t.claimGeneratorInfo?.[0]?.name??`Unknown`,o=m(t.assertions?.[`cawg.identity`]?.verifiedIdentities,t.assertions?.[`cawg.metadata`]),s=a.split(` `).filter(Boolean).map(e=>e[0].toUpperCase()).join(``)||`?`,c=t.assertions?.[`cawg.identity`],l=h(c),u=l?.role??[],{status:f,results:p}=x(l?.trust_registry??[]),g=p.filter(e=>!e.hide),_=f===`done`&&g.some(e=>!e.authorized);return(0,n.jsxs)(`div`,{className:`cawg-card ${e??``}`,children:[(0,n.jsx)(d,{}),(0,n.jsxs)(`div`,{className:`cawg-container`,children:[t.thumbnail?(0,n.jsx)(`img`,{src:t.thumbnail,alt:`Thumbnail`,className:`cawg-thumbnail`}):(0,n.jsx)(`div`,{className:`cawg-square`,children:(0,n.jsx)(`span`,{className:`cawg-logo-text`,children:s})}),(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,n.jsx)(`span`,{className:`cawg-media-title`,children:i}),(0,n.jsx)(`span`,{className:`cawg-creators-name`,children:o})]})]}),_&&(0,n.jsx)(`div`,{style:{marginTop:12},children:(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-unverified`,children:S})}),u.length>0&&(0,n.jsx)(`div`,{className:`cawg-roles`,children:u.map(e=>(0,n.jsx)(`span`,{className:`cawg-role-badge`,children:C[e]??e},e))}),r&&(0,n.jsx)(`div`,{style:{marginTop:16},children:(0,n.jsx)(`button`,{onClick:r,className:`cawg-button`,children:`More Info`})})]})}function T(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}catch{return e}}var E=`Identity Verified by Trust Registry`,D=`Identity Unable to be Verified by Trust Registry`;function O(e,t,r,i){if(e===`error`)return(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-unverified`,title:r?.message,children:`Unable to reach trust registry`});if(e!==`done`||!t)return(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-pending`,children:`Checking trust registry…`});let a=(0,n.jsx)(`span`,{className:t.authorized?`cawg-trust-badge cawg-trust-verified`:`cawg-trust-badge cawg-trust-unverified`,title:t.authorized?`Recognized by ${t.authority_id} · checked ${T(t.time_evaluated)}`:t.message,children:t.authorized?E:D});return i===`compact`?a:(0,n.jsxs)(`div`,{className:`cawg-trust-status`,children:[a,t.authorized?(0,n.jsxs)(`div`,{className:`cawg-trust-meta`,children:[t.authority_id,` · checked `,T(t.time_evaluated)]}):t.message&&(0,n.jsx)(`div`,{className:`cawg-trust-message`,children:t.message})]})}function k({entityId:e,action:t,resource:r,authorityId:i,trqpAuthorizationUri:a,variant:o=`full`,queryFn:s}){let{status:c,result:l,error:u}=b(e,t,r,i,a,s);return!e||c===`done`&&l?.hide?null:(0,n.jsxs)(n.Fragment,{children:[c===`done`&&l?.icon&&(0,n.jsx)(`img`,{src:l.icon,alt:``,className:`cawg-trust-icon`}),O(c,l,u,o)]})}function A({entry:e,variant:t=`full`,showEntity:r=!1,queryFn:i}){let{status:a,result:o,error:s}=b(e.entity_id,e.action,e.resource,e.authority_id,e.trqp_authorization_uri,i);return a===`done`&&o?.hide?null:(0,n.jsxs)(`div`,{className:`cawg-identity-item`,children:[a===`done`&&o?.icon&&(0,n.jsx)(`img`,{src:o.icon,alt:``,className:`cawg-trust-icon`}),(0,n.jsxs)(`div`,{style:{flex:1},children:[e.authority_id&&(0,n.jsxs)(`div`,{className:`cawg-identity-name`,children:[`Authority: `,e.authority_id]}),r&&e.entity_id&&(0,n.jsxs)(`div`,{className:`cawg-identity-provider`,children:[`Entity: `,e.entity_id]}),e.action&&(0,n.jsxs)(`div`,{className:`cawg-identity-meta`,children:[`Action: `,e.action]}),e.resource&&(0,n.jsxs)(`div`,{className:`cawg-identity-meta`,children:[`Resource: `,e.resource]}),e.trqp_authorization_uri&&(0,n.jsx)(`a`,{href:e.trqp_authorization_uri,target:`_blank`,rel:`noopener noreferrer`,className:`cawg-identity-link`,children:e.trqp_authorization_uri}),O(a,o,s,t)]})]})}function j({entries:e,variant:t=`compact`,queryFn:r}){let{status:i,results:a,error:o}=x(e,r);if(e.filter(e=>e.entity_id).length===0)return null;if(i===`error`)return(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-unverified`,title:o?.message,children:`Unable to reach trust registry`});if(i!==`done`)return(0,n.jsx)(`span`,{className:`cawg-trust-badge cawg-trust-pending`,children:`Checking trust registry…`});let s=a.filter(e=>!e.hide);if(s.length===0)return null;let c=s.every(e=>e.authorized),l=s.filter(e=>!e.authorized),u=s.find(e=>e.icon)?.icon,d=c?`Recognized by ${Array.from(new Set(s.map(e=>e.authority_id))).join(`, `)}`:l.map(e=>e.message).filter(Boolean).join(` · `)||void 0,f=(0,n.jsx)(`span`,{className:c?`cawg-trust-badge cawg-trust-verified`:`cawg-trust-badge cawg-trust-unverified`,title:d,children:c?E:D});return t===`compact`?(0,n.jsxs)(n.Fragment,{children:[u&&(0,n.jsx)(`img`,{src:u,alt:``,className:`cawg-trust-icon`}),f]}):(0,n.jsxs)(`div`,{className:`cawg-trust-status`,children:[u&&(0,n.jsx)(`img`,{src:u,alt:``,className:`cawg-trust-icon`}),f,c?(0,n.jsxs)(`div`,{className:`cawg-trust-meta`,children:[Array.from(new Set(s.map(e=>e.authority_id))).join(`, `),` · checked`,` `,T(s[0].time_evaluated)]}):d&&(0,n.jsx)(`div`,{className:`cawg-trust-message`,children:d})]})}var M={"cawg.creator":`Creator`,"cawg.contributor":`Contributor`,"cawg.editor":`Editor`,"cawg.producer":`Producer`,"cawg.publisher":`Publisher`,"cawg.sponsor":`Sponsor`,"cawg.translator":`Translator`},ee={"cawg.document_verification":`ID Verified`,"cawg.web_site":`Website`,"cawg.affiliation":`Affiliation`,"cawg.social_media":`Social Media`,"cawg.crypto_wallet":`Crypto Wallet`},te={"cawg.data_mining":`Data Mining`,"cawg.ai_inference":`AI Inference`,"cawg.ai_training":`AI Training`,"cawg.ai_generative_training":`AI Generative Training`},N={allowed:`cawg-use-badge cawg-use-allowed`,notAllowed:`cawg-use-badge cawg-use-not-allowed`,constrained:`cawg-use-badge cawg-use-constrained`},ne={allowed:`Allowed`,notAllowed:`Not Allowed`,constrained:`Constrained`};function P(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}catch{return e}}function F(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`, `):typeof e==`string`?e:``}function I({className:e,manifest:t,moreInfo:r}){let i=t.title,a=(t.claimGenerator??t.claimGeneratorInfo?.[0]?.name??`Unknown`).split(` `).filter(Boolean).map(e=>e[0].toUpperCase()).join(``)||`?`,o=m(t.assertions?.[`cawg.identity`]?.verifiedIdentities,t.assertions?.[`cawg.metadata`]),s=t.assertions?.[`cawg.identity`],c=h(s),l=c?.role??[],u=s?.verifiedIdentities??[],f=c?.trust_registry??[],p=t.assertions?.[`cawg.training-mining`]?.entries??{},g=t.assertions?.[`cawg.metadata`],_=F(g?.[`dc:creator`]),v=g?.[`xmp:CreateDate`];return(0,n.jsxs)(`div`,{className:`cawg-card ${e??``}`,children:[(0,n.jsx)(d,{}),(0,n.jsxs)(`div`,{className:`cawg-container`,children:[t.thumbnail?(0,n.jsx)(`img`,{src:t.thumbnail,alt:`Thumbnail`,className:`cawg-thumbnail`}):(0,n.jsx)(`div`,{className:`cawg-square`,children:(0,n.jsx)(`span`,{className:`cawg-logo-text`,children:a})}),(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,n.jsx)(`span`,{className:`cawg-media-title`,children:i}),(0,n.jsx)(`span`,{className:`cawg-creators-name`,children:o})]})]}),l.length>0&&(0,n.jsx)(`div`,{className:`cawg-roles`,children:l.map(e=>(0,n.jsx)(`span`,{className:`cawg-role-badge`,children:M[e]??e},e))}),u.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsxs)(`div`,{className:`cawg-section-title`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,n.jsx)(`span`,{children:`Identity`}),f.length>0&&(0,n.jsx)(j,{entries:f,variant:`compact`})]}),(0,n.jsx)(`div`,{className:`cawg-identity-list`,children:u.map((e,t)=>{let r=e.type,i=e.name??e.username,a=e.provider;return(0,n.jsx)(`div`,{className:`cawg-identity-item`,children:(0,n.jsxs)(`div`,{style:{flex:1},children:[(0,n.jsx)(`div`,{className:`cawg-identity-type-label`,children:ee[r]??r}),i&&(0,n.jsx)(`div`,{className:`cawg-identity-name`,children:i}),a?.name&&(0,n.jsx)(`div`,{className:`cawg-identity-provider`,children:a.name})]})},t)})})]}),f.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Trust Registries`}),(0,n.jsx)(`div`,{className:`cawg-identity-list`,children:f.map((e,t)=>(0,n.jsx)(A,{entry:e,variant:`compact`},t))})]}),Object.keys(p).length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Training & Data Mining`}),(0,n.jsx)(`div`,{className:`cawg-training-list`,children:Object.entries(p).map(([e,t])=>(0,n.jsxs)(`div`,{className:`cawg-training-item`,children:[(0,n.jsx)(`span`,{className:`cawg-training-label`,children:te[e]??e}),(0,n.jsx)(`span`,{className:N[t.use]??`cawg-use-badge`,children:ne[t.use]??t.use})]},e))})]}),(_||v)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Creator`}),_&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Name`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:_})]}),v&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Date Created`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:P(v)})]})]}),r&&(0,n.jsx)(`div`,{style:{marginTop:16},children:(0,n.jsx)(`button`,{onClick:r,className:`cawg-button`,children:`More Info`})})]})}var L={"cawg.identity_claims_aggregation":`Identity claims aggregation`,"cawg.verifiable_credential_binding":`Verifiable credential binding`},re=/^cawg\.identity(__\d+)?$/,R=e=>typeof e==`object`&&!!e&&!Array.isArray(e),z=e=>(Array.isArray(e)?e:e===void 0?[]:[e]).filter(R),B=e=>typeof e==`string`?e:void 0;function V(e){let t=B((R(e.signer_payload)?e.signer_payload:R(e.c2paAsset)?e.c2paAsset:void 0)?.sig_type);return t&&t in L?t:void 0}function H(e,t){let n=V(t);if(!n)return;let r=R(t.issuer)?{id:B(t.issuer.id)??``,name:B(t.issuer.name)}:{id:B(t.issuer)??``};if(!r.id)return;let i=n===`cawg.verifiable_credential_binding`;return{label:e,sigType:n,issuer:r,types:(Array.isArray(t.type)?t.type:[t.type]).filter(e=>typeof e==`string`),validFrom:B(t.validFrom)??B(t.issuanceDate),validUntil:B(t.validUntil)??B(t.expirationDate),subjects:z(i?t.credentialSubject:t.verifiedIdentities),bindings:i?z(t.termsOfUse).filter(e=>e.type===`C2PAAssetBinding`):z(t.c2paAsset),status:z(t.credentialStatus),schemas:z(t.credentialSchema).map(e=>({id:B(e.id)??``,type:B(e.type)})).filter(e=>e.id),raw:t}}function U(e){return Object.entries(e.assertions??{}).filter(([e,t])=>re.test(e)&&R(t)).sort(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0})).map(([e,t])=>H(e,t)).filter(e=>e!==void 0)}function W(e,t=48){return e.length>t?`${e.slice(0,t-15)}…${e.slice(-12)}`:e}function G({manifest:e,onIssuerClick:t}){let r=U(e);return r.length===0?null:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:r.length===1?`Credential`:`Credentials (${r.length})`}),(0,n.jsx)(`div`,{className:`cawg-credential-list`,children:r.map(e=>(0,n.jsx)(Y,{credential:e,onIssuerClick:t},e.label))})]})}function K(e){if(!e)return;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function q(e){let t=Date.now(),n=e.validFrom?Date.parse(e.validFrom):NaN,r=e.validUntil?Date.parse(e.validUntil):NaN;if(!Number.isNaN(n)&&t<n)return{label:`Not yet valid`,className:`cawg-credential-badge-warn`};if(!Number.isNaN(r)&&t>r)return{label:`Expired`,className:`cawg-credential-badge-warn`};if(!Number.isNaN(n))return{label:`In validity period`,className:`cawg-credential-badge-ok`}}function J(e){let t=t=>typeof e[t]==`string`?e[t]:void 0,n=t(`name`)??t(`username`)??t(`address`)??t(`uri`);return[t(`type`),n].filter(Boolean).join(` · `)||t(`id`)||`Subject`}function Y({credential:e,onIssuerClick:r}){let[i,a]=(0,t.useState)(!1),o=q(e),s=e.bindings.flatMap(e=>{let t=e.referencedAssertions??e.referenced_assertions;return Array.isArray(t)?t:[]}),c=e.bindings.flatMap(e=>Array.isArray(e.role)?e.role:[]),l=W(e.issuer.id),u=e.issuer.name?`${e.issuer.name} (${l})`:l;return(0,n.jsxs)(`details`,{className:`cawg-credential`,children:[(0,n.jsxs)(`summary`,{children:[(0,n.jsx)(`span`,{className:`cawg-credential-kind`,children:L[e.sigType]}),o&&(0,n.jsx)(`span`,{className:`cawg-credential-badge ${o.className}`,children:o.label})]}),(0,n.jsxs)(`div`,{className:`cawg-credential-tabs`,role:`tablist`,children:[(0,n.jsx)(`button`,{role:`tab`,"aria-selected":!i,className:`cawg-credential-tab`,onClick:()=>a(!1),children:`Summary`}),(0,n.jsx)(`button`,{role:`tab`,"aria-selected":i,className:`cawg-credential-tab`,onClick:()=>a(!0),children:`Raw JSON`})]}),i?(0,n.jsx)(`pre`,{className:`cawg-credential-raw`,children:JSON.stringify(e.raw,null,2)}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Issuer`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:r?(0,n.jsx)(`button`,{className:`cawg-credential-link`,onClick:()=>r(e.issuer.id),title:`Look up ${e.issuer.id}`,"aria-label":e.issuer.id,children:u}):(0,n.jsx)(`span`,{title:e.issuer.id,children:u})})]}),(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Type`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:e.types.join(`, `)})]}),(e.validFrom||e.validUntil)&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Validity`}),(0,n.jsxs)(`div`,{className:`cawg-key-value-value`,children:[e.validFrom&&(0,n.jsxs)(n.Fragment,{children:[`From `,K(e.validFrom)]}),e.validFrom&&e.validUntil&&(0,n.jsx)(`br`,{}),e.validUntil&&(0,n.jsxs)(n.Fragment,{children:[`Until `,K(e.validUntil)]})]})]}),e.subjects.length>0&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsxs)(`div`,{className:`cawg-key-value-label`,children:[e.sigType===`cawg.identity_claims_aggregation`?`Verified identities`:`Subjects`,` (`,e.subjects.length,`)`]}),(0,n.jsx)(`ul`,{className:`cawg-credential-subjects`,children:e.subjects.map((e,t)=>(0,n.jsx)(`li`,{children:J(e)},t))})]}),(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Asset binding`}),(0,n.jsxs)(`div`,{className:`cawg-key-value-value`,children:[s.length,` referenced assertion`,s.length===1?``:`s`,c.length>0&&(0,n.jsxs)(n.Fragment,{children:[` · role `,c.join(`, `)]})]})]}),(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Status`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:e.status.length?e.status.map(e=>[e.type,e.statusPurpose].filter(Boolean).join(` · `)).join(`; `):`No revocation status published`})]}),e.schemas.length>0&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Schema`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:e.schemas.map(e=>(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`a`,{href:e.id,target:`_blank`,rel:`noopener noreferrer`,className:`cawg-identity-link`,children:e.id}),e.type&&(0,n.jsxs)(n.Fragment,{children:[` (`,e.type,`)`]})]},e.id))})]})]})]})}var ie={"cawg.creator":`Creator`,"cawg.contributor":`Contributor`,"cawg.editor":`Editor`,"cawg.producer":`Producer`,"cawg.publisher":`Publisher`,"cawg.sponsor":`Sponsor`,"cawg.translator":`Translator`},ae={"cawg.document_verification":`ID Verified`,"cawg.web_site":`Website`,"cawg.affiliation":`Affiliation`,"cawg.social_media":`Social Media`,"cawg.crypto_wallet":`Crypto Wallet`},oe={"cawg.data_mining":`Data Mining`,"cawg.ai_inference":`AI Inference`,"cawg.ai_training":`AI Training`,"cawg.ai_generative_training":`AI Generative Training`},se={allowed:`cawg-use-badge cawg-use-allowed`,notAllowed:`cawg-use-badge cawg-use-not-allowed`,constrained:`cawg-use-badge cawg-use-constrained`},ce={allowed:`Allowed`,notAllowed:`Not Allowed`,constrained:`Constrained`},le={"cawg.identity_claims_aggregation":`Identity Claims Aggregation`,"cawg.x509.cose":`X.509 Certificate`,"cawg.verifiable_credential_binding":`Verifiable Credential`};function ue(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}catch{return e}}function X(e){return e==null?``:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>X(e)).filter(Boolean).join(`, `):typeof e==`object`?Object.entries(e).filter(([e])=>!e.startsWith(`@`)).map(([e,t])=>`${e}: ${X(t)}`).join(`; `):String(e)}function de({className:e,manifest:t,moreInfo:r,showCredentials:i,onIssuerClick:a}){let o=t.title,s=t.claimGenerator??t.claimGeneratorInfo?.[0]?.name??`Unknown`,c=m(t.assertions?.[`cawg.identity`]?.verifiedIdentities,t.assertions?.[`cawg.metadata`]),l=s.split(` `).filter(Boolean).map(e=>e[0].toUpperCase()).join(``)||`?`,u=t.assertions?.[`cawg.identity`],f=h(u),p=f?.role??[],g=u?.verifiedIdentities??[],_=f?.sig_type,v=u?.issuer,y=typeof v==`string`?v:v&&typeof v==`object`&&typeof v.id==`string`?typeof v.name==`string`?`${v.name} (${v.id})`:v.id:void 0,b=f?.trust_registry??[],x=t.assertions?.[`cawg.training-mining`]?.entries??{},S=t.assertions?.[`cawg.metadata`],C=S?Object.entries(S).filter(([e])=>!e.startsWith(`@`)):[];return(0,n.jsxs)(`div`,{className:`cawg-card ${e??``}`,children:[(0,n.jsx)(d,{}),(0,n.jsxs)(`div`,{className:`cawg-container`,children:[t.thumbnail?(0,n.jsx)(`img`,{src:t.thumbnail,alt:`Thumbnail`,className:`cawg-thumbnail`}):(0,n.jsx)(`div`,{className:`cawg-square`,children:(0,n.jsx)(`span`,{className:`cawg-logo-text`,children:l})}),(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`},children:[(0,n.jsx)(`span`,{className:`cawg-media-title`,children:o}),(0,n.jsx)(`span`,{className:`cawg-creators-name`,children:c})]})]}),p.length>0&&(0,n.jsx)(`div`,{className:`cawg-roles`,children:p.map(e=>(0,n.jsx)(`span`,{className:`cawg-role-badge`,children:ie[e]??e},e))}),u&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Identity Assertion`}),_&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Credential Type`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:le[_]??_})]}),y&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Issuer`}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:y})]}),b.length>0&&(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:`Trust Registry`}),(0,n.jsx)(j,{entries:b,variant:`full`})]}),g.length>0&&(0,n.jsx)(`div`,{className:`cawg-identity-list`,style:{marginTop:12},children:g.map((e,t)=>{let r=e.type,i=e.name??e.username??e.address,a=e.provider,o=e.uri,s=e.verifiedAt;return(0,n.jsx)(`div`,{className:`cawg-identity-item`,children:(0,n.jsxs)(`div`,{style:{flex:1},children:[(0,n.jsx)(`div`,{className:`cawg-identity-type-label`,children:ae[r]??r}),i&&(0,n.jsx)(`div`,{className:`cawg-identity-name`,children:i}),a?.name&&(0,n.jsxs)(`div`,{className:`cawg-identity-provider`,children:[`via `,a.name]}),o&&(0,n.jsx)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,className:`cawg-identity-link`,children:o}),s&&(0,n.jsxs)(`div`,{className:`cawg-identity-meta`,children:[`Verified `,ue(s)]})]})},t)})}),b.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-section-title`,style:{marginTop:16},children:`Trust Registries`}),(0,n.jsx)(`div`,{className:`cawg-identity-list`,children:b.map((e,t)=>(0,n.jsx)(A,{entry:e,variant:`full`,showEntity:!0},t))})]})]}),i&&(0,n.jsx)(G,{manifest:t,onIssuerClick:a}),Object.keys(x).length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Training & Data Mining`}),(0,n.jsx)(`div`,{className:`cawg-training-list`,children:Object.entries(x).map(([e,t])=>(0,n.jsxs)(`div`,{className:`cawg-training-item`,style:{flexDirection:`column`,alignItems:`flex-start`},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,width:`100%`},children:[(0,n.jsx)(`span`,{className:`cawg-training-label`,children:oe[e]??e}),(0,n.jsx)(`span`,{className:se[t.use]??`cawg-use-badge`,children:ce[t.use]??t.use})]}),t.constraint_info&&(0,n.jsx)(`div`,{className:`cawg-constraint-info`,children:t.constraint_info})]},e))})]}),C.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`cawg-divider`}),(0,n.jsx)(`div`,{className:`cawg-section-title`,children:`Metadata`}),C.map(([e,t])=>{let r=X(t);return r?(0,n.jsxs)(`div`,{className:`cawg-key-value`,children:[(0,n.jsx)(`div`,{className:`cawg-key-value-label`,children:e}),(0,n.jsx)(`div`,{className:`cawg-key-value-value`,children:r})]},e):null})]}),r&&(0,n.jsx)(`div`,{style:{marginTop:16},children:(0,n.jsx)(`button`,{onClick:r,className:`cawg-button`,children:`Small View`})})]})}var fe={"cawg.creator":`Created by`,"cawg.contributor":`Contributed by`,"cawg.editor":`Edited by`,"cawg.producer":`Produced by`,"cawg.publisher":`Published by`,"cawg.sponsor":`Sponsored by`,"cawg.translator":`Translated by`};function Z(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function pe(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`, `):typeof e==`string`?e:``}function me(e){let t=e.uri??e.provider?.id;if(!t)return`website`;try{return new URL(t).host.replace(/^www\./,``)}catch{return t}}function he(e){let t=e.some(e=>e.type===`cawg.document_verification`),n=[];for(let t of e){let e;t.type===`cawg.social_media`?e=t.provider?.name:t.type===`cawg.web_site`?e=me(t):t.type===`cawg.crypto_wallet`&&(e=`crypto wallet`),e&&!n.includes(e)&&n.push(e)}let r=[];return t&&r.push(`ID verified`),n.length>0&&r.push(`linked to ${Z(n)}`),r.length>0?` (${r.join(`, `)})`:``}function ge(e){let t=[...new Set(e.filter(e=>e.type===`cawg.affiliation`&&e.provider?.name).map(e=>e.provider.name))];return t.length>0?`, affiliated with ${Z(t)}`:``}function Q(e){let t=new Map;for(let n of e){let e=n.assertions?.[`cawg.identity`],r=n.assertions?.[`cawg.metadata`];if(!e&&!r)continue;let i=e?.verifiedIdentities,a=Array.isArray(i)?i:i?[i]:[],o=pe(r?.[`dc:creator`]),s=a.length>0?m([...a],{}):`Unknown`;if(s===`Unknown`&&(s=o),!s)continue;let c=h(e)?.role??[],l=c.length>0?c.map(e=>fe[e]??`${e.replace(/^cawg\./,``)} by`):[o?`Created by`:`Signed by`],u=`${s}${he(a)}${ge(a)}`;for(let e of l){let n=t.get(e)??[];n.includes(u)||n.push(u),t.set(e,n)}}if(t.size===0)return;let n=[...t.entries()].map(([e,t],n)=>`${n===0?e:e.charAt(0).toLowerCase()+e.slice(1)} ${Z(t)}`).join(`; `);return n.endsWith(`.`)?n:`${n}.`}function _e(e){return{id:e.id??``,title:e.title??``,claimGenerator:e.claimGenerator??null,claimGeneratorInfo:(e.claimGeneratorInfo??[]).map(e=>({name:e.name,"org.contentauth.c2pa_rs":e[`org.contentauth.c2pa_rs`]??``})),instanceId:e.instanceId??``,signatureInfo:{alg:e.signatureInfo?.alg??``,issuer:e.signatureInfo?.issuer??``,common_name:e.signatureInfo?.common_name??``,cert_serial_number:e.signatureInfo?.cert_serial_number??``},assertions:e.assertions??{},credentials:e.credentials??[],thumbnail:typeof e.thumbnail==`string`?e.thumbnail:null,ingredients:e.ingredients??[]}}var ve=[`cawg.identity`,`cawg.training-mining`,`cawg.metadata`,`cawg.creator`,`cawg.contributor`,`cawg.editor`,`cawg.producer`,`cawg.publisher`,`cawg.sponsor`,`cawg.translator`,`cawg.document_verification`,`cawg.web_site`,`cawg.affiliation`,`cawg.social_media`,`cawg.crypto_wallet`];function $(e={}){let{showCredentials:r=!1,onIssuerClick:i}=e,a=({manifest:e,entry:a,level:o,className:s})=>{let[c,l]=t.default.useState(o||1),u=e.manifestStore?.activeManifest,d=a==null?e.manifests.find(e=>e.id===u||e.instanceId===u)??(u?e.manifestStore.manifests[u]:void 0)??e.manifests[0]:_e(a);if(!d||!(d.assertions?.[`cawg.identity`]!=null||d.assertions?.[`cawg.training-mining`]!=null||d.assertions?.[`cawg.metadata`]!=null))return null;switch(c){case 1:return(0,n.jsx)(w,{className:s,manifest:d,moreInfo:()=>l(2)});case 2:return(0,n.jsx)(I,{className:s,manifest:d,moreInfo:()=>l(3)});case 3:return(0,n.jsx)(de,{className:s,manifest:d,moreInfo:()=>l(1),showCredentials:r,onIssuerClick:i})}return(0,n.jsx)(`div`,{children:`Level Of Detail Not Selected`})};return a.knownAssertions=ve,a.describe=Q,a}e.CAWGManifest=$(),e.CREDENTIAL_SIG_TYPES=L,e.TrustBadge=k,e.TrustRegistryRow=A,e.TrustRegistrySummaryBadge=j,e.createCAWGManifest=$,e.describeCawg=Q,e.getCawgCredentials=U,e.getTrustRegistryQueryFn=y,e.queryTrustRegistry=g,e.setTrustRegistryQueryFn=v,e.shortenDid=W,e.useTrustRegistryQuery=b,e.useTrustRegistrySummary=x});
|
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
import { PluginC2PA } from 'c2pa-react-component-types';
|
|
2
|
+
/** Options for {@link createCAWGManifest}. */
|
|
3
|
+
export interface CawgManifestOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Show the W3C verifiable credentials behind identity assertions (identity
|
|
6
|
+
* claims aggregation and verifiable credential binding) in the L3 view, as
|
|
7
|
+
* a summary with a raw JSON toggle. Off by default.
|
|
8
|
+
*/
|
|
9
|
+
showCredentials?: boolean;
|
|
10
|
+
/** Called with an issuer's DID when it's clicked in the credentials section. */
|
|
11
|
+
onIssuerClick?: (issuer: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a CAWG plugin for `C2paManifest` with the given options, e.g.
|
|
15
|
+
* `plugin={[createCAWGManifest({ showCredentials: true })]}`.
|
|
16
|
+
* `CAWGManifest` is `createCAWGManifest()`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createCAWGManifest(options?: CawgManifestOptions): PluginC2PA;
|
|
2
19
|
export declare const CAWGManifest: PluginC2PA;
|
|
3
20
|
export default CAWGManifest;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ManifestEntry } from 'c2pa-react-component-types';
|
|
2
|
+
/**
|
|
3
|
+
* Summarises who is behind the content across every manifest, e.g.
|
|
4
|
+
* "Created by Jordan Lee (ID verified), affiliated with Example Recording Studio."
|
|
5
|
+
* Entries are expected oldest ingredient first, active manifest last.
|
|
6
|
+
*/
|
|
7
|
+
export declare function describeCawg(entries: ManifestEntry[]): string | undefined;
|
|
@@ -7,4 +7,6 @@ export type VerifiedIdentitiesObject = {
|
|
|
7
7
|
};
|
|
8
8
|
"verifiedAt": string;
|
|
9
9
|
};
|
|
10
|
-
export declare const getBestUserName: (identityObjectArray: VerifiedIdentitiesObject[] | VerifiedIdentitiesObject
|
|
10
|
+
export declare const getBestUserName: (identityObjectArray: VerifiedIdentitiesObject[] | VerifiedIdentitiesObject | undefined, metaDataObject?: {
|
|
11
|
+
"dc:creator"?: string;
|
|
12
|
+
}) => string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Manifest } from 'c2pa-react-component-types';
|
|
2
|
+
/** The CAWG identity assertion signature types whose credential is a W3C verifiable credential. */
|
|
3
|
+
export declare const CREDENTIAL_SIG_TYPES: {
|
|
4
|
+
readonly 'cawg.identity_claims_aggregation': "Identity claims aggregation";
|
|
5
|
+
readonly 'cawg.verifiable_credential_binding': "Verifiable credential binding";
|
|
6
|
+
};
|
|
7
|
+
export type CredentialSigType = keyof typeof CREDENTIAL_SIG_TYPES;
|
|
8
|
+
/**
|
|
9
|
+
* A W3C verifiable credential carried by a CAWG identity assertion, as
|
|
10
|
+
* decoded by c2pa-rs (`core.decode_identity_assertions`).
|
|
11
|
+
*/
|
|
12
|
+
export interface CawgCredential {
|
|
13
|
+
/** Assertion label, e.g. `cawg.identity` or `cawg.identity__1`. */
|
|
14
|
+
label: string;
|
|
15
|
+
sigType: CredentialSigType;
|
|
16
|
+
issuer: {
|
|
17
|
+
id: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
};
|
|
20
|
+
types: string[];
|
|
21
|
+
validFrom?: string;
|
|
22
|
+
validUntil?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The credential subjects: `credentialSubject` for a verifiable credential
|
|
25
|
+
* binding, or the verified identities of an identity claims aggregation
|
|
26
|
+
* credential (which is what c2pa-rs keeps of its subject).
|
|
27
|
+
*/
|
|
28
|
+
subjects: Record<string, unknown>[];
|
|
29
|
+
/**
|
|
30
|
+
* What binds the credential to this asset: the `C2PAAssetBinding`
|
|
31
|
+
* `termsOfUse` entries of a binding, or an aggregation credential's
|
|
32
|
+
* `c2paAsset`.
|
|
33
|
+
*/
|
|
34
|
+
bindings: Record<string, unknown>[];
|
|
35
|
+
/** `credentialStatus` entries (revocation and similar). */
|
|
36
|
+
status: Record<string, unknown>[];
|
|
37
|
+
/** `credentialSchema` entries. */
|
|
38
|
+
schemas: {
|
|
39
|
+
id: string;
|
|
40
|
+
type?: string;
|
|
41
|
+
}[];
|
|
42
|
+
/** The decoded assertion, for raw display. */
|
|
43
|
+
raw: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/** The verifiable credentials in a manifest's CAWG identity assertions, in label order. */
|
|
46
|
+
export declare function getCawgCredentials(manifest: Manifest): CawgCredential[];
|
|
47
|
+
/** Long DIDs (a did:jwk carries the whole key) are shortened to their start and end. */
|
|
48
|
+
export declare function shortenDid(id: string, max?: number): string;
|
|
@@ -3,5 +3,9 @@ export interface CAWGL3Props {
|
|
|
3
3
|
manifest: Manifest;
|
|
4
4
|
moreInfo?: () => void;
|
|
5
5
|
className?: string;
|
|
6
|
+
/** Show the verifiable credentials behind the identity assertions. */
|
|
7
|
+
showCredentials?: boolean;
|
|
8
|
+
/** Called with an issuer DID when it's clicked in the credentials section. */
|
|
9
|
+
onIssuerClick?: (issuer: string) => void;
|
|
6
10
|
}
|
|
7
|
-
export default function CAWGL3({ className, manifest, moreInfo }: CAWGL3Props): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default function CAWGL3({ className, manifest, moreInfo, showCredentials, onIssuerClick }: CAWGL3Props): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Manifest } from 'c2pa-react-component-types';
|
|
2
|
+
export interface CredentialSectionProps {
|
|
3
|
+
manifest: Manifest;
|
|
4
|
+
/** Called with the issuer's DID when its name is clicked. Without it, the issuer is plain text. */
|
|
5
|
+
onIssuerClick?: (issuer: string) => void;
|
|
6
|
+
}
|
|
7
|
+
/** The W3C verifiable credentials behind a manifest's CAWG identity assertions. */
|
|
8
|
+
export declare function CredentialSection({ manifest, onIssuerClick }: CredentialSectionProps): import("react/jsx-runtime").JSX.Element | null;
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2pa-react-cawg-component",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "A React plugin for c2pa-react-component that renders Creator Assertions Working Group (CAWG) data — identity credentials, metadata, and training permissions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/c2pa-react-cawg-component.umd.cjs",
|
|
@@ -79,6 +79,6 @@
|
|
|
79
79
|
"vitest": "^4.1.5"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"c2pa-react-component-types": "
|
|
82
|
+
"c2pa-react-component-types": "file:.yalc/c2pa-react-component-types"
|
|
83
83
|
}
|
|
84
84
|
}
|