@pod-os/elements 0.29.1-rc.e9091c9.0 → 0.30.1-rc.3f29969.0
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/dist/cjs/elements.cjs.js +1 -1
- package/dist/cjs/ion-icon_33.cjs.entry.js +68 -38
- package/dist/cjs/ion-icon_33.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/pos-tool-select/pos-tool-select.css +58 -10
- package/dist/collection/components/pos-tool-select/pos-tool-select.js +34 -2
- package/dist/collection/components/pos-tool-select/pos-tool-select.js.map +1 -1
- package/dist/collection/components/pos-type-router/pos-type-router.css +37 -2
- package/dist/collection/components/pos-type-router/pos-type-router.js +32 -8
- package/dist/collection/components/pos-type-router/pos-type-router.js.map +1 -1
- package/dist/collection/components/pos-type-router/selectToolsForTypes.js +28 -27
- package/dist/collection/components/pos-type-router/selectToolsForTypes.js.map +1 -1
- package/dist/components/pos-app2.js +7 -2
- package/dist/components/pos-app2.js.map +1 -1
- package/dist/components/pos-tool-select2.js +9 -2
- package/dist/components/pos-tool-select2.js.map +1 -1
- package/dist/components/pos-type-router2.js +58 -36
- package/dist/components/pos-type-router2.js.map +1 -1
- package/dist/elements/elements.esm.js +1 -1
- package/dist/elements/elements.esm.js.map +1 -1
- package/dist/elements/{p-7e194982.entry.js → p-e7498ab7.entry.js} +13 -13
- package/dist/elements/p-e7498ab7.entry.js.map +1 -0
- package/dist/esm/elements.js +1 -1
- package/dist/esm/ion-icon_33.entry.js +68 -38
- package/dist/esm/ion-icon_33.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/pos-tool-select/pos-tool-select.d.ts +10 -0
- package/dist/types/components/pos-type-router/pos-type-router.d.ts +10 -3
- package/dist/types/components/pos-type-router/selectToolsForTypes.d.ts +29 -4
- package/dist/types/components.d.ts +38 -0
- package/package.json +3 -3
- package/dist/elements/p-7e194982.entry.js.map +0 -1
|
@@ -1,72 +1,73 @@
|
|
|
1
1
|
export const AvailableTools = {
|
|
2
2
|
Generic: {
|
|
3
3
|
element: 'pos-app-generic',
|
|
4
|
-
label: '
|
|
4
|
+
label: 'Data',
|
|
5
5
|
icon: 'list-ul',
|
|
6
|
-
types: [],
|
|
6
|
+
types: [], // since this is included everywhere, it does not need to specify types
|
|
7
7
|
},
|
|
8
8
|
RdfDocument: {
|
|
9
9
|
element: 'pos-app-rdf-document',
|
|
10
|
-
label: '
|
|
11
|
-
icon: '
|
|
10
|
+
label: 'Things',
|
|
11
|
+
icon: 'diagram-2',
|
|
12
12
|
types: [
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
uri: 'http://www.w3.org/2007/ont/link#RDFDocument',
|
|
15
15
|
priority: 20,
|
|
16
16
|
},
|
|
17
17
|
],
|
|
18
18
|
},
|
|
19
19
|
DocumentViewer: {
|
|
20
20
|
element: 'pos-app-document-viewer',
|
|
21
|
-
label: '
|
|
21
|
+
label: 'Doc',
|
|
22
22
|
icon: 'file-text',
|
|
23
23
|
types: [
|
|
24
24
|
{
|
|
25
|
-
|
|
25
|
+
uri: mimeType('application/pdf'),
|
|
26
26
|
priority: 30,
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
|
|
29
|
+
uri: 'http://www.w3.org/2007/ont/link#Document',
|
|
30
30
|
priority: 10,
|
|
31
31
|
},
|
|
32
32
|
],
|
|
33
33
|
},
|
|
34
34
|
ImageViewer: {
|
|
35
35
|
element: 'pos-app-image-viewer',
|
|
36
|
-
label: '
|
|
36
|
+
label: 'Pic',
|
|
37
37
|
icon: 'file-image',
|
|
38
38
|
types: [
|
|
39
39
|
{
|
|
40
|
-
|
|
40
|
+
uri: 'http://purl.org/dc/terms/Image',
|
|
41
41
|
priority: 20,
|
|
42
42
|
},
|
|
43
43
|
],
|
|
44
44
|
},
|
|
45
45
|
LdpContainer: {
|
|
46
46
|
element: 'pos-app-ldp-container',
|
|
47
|
-
label: '
|
|
47
|
+
label: 'Content',
|
|
48
48
|
icon: 'folder',
|
|
49
|
-
types: [{
|
|
49
|
+
types: [{ uri: 'http://www.w3.org/ns/ldp#Container', priority: 30 }],
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
52
|
function mimeType(mimeType) {
|
|
53
53
|
return 'http://www.w3.org/ns/iana/media-types/' + mimeType + '#Resource';
|
|
54
54
|
}
|
|
55
55
|
export function selectToolsForTypes(types) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
})
|
|
66
|
-
.filter(Boolean),
|
|
67
|
-
{ tool: AvailableTools.Generic, priority: 0 },
|
|
68
|
-
]
|
|
69
|
-
.toSorted((a, b) => b.priority - a.priority)
|
|
70
|
-
.map(item => item.tool);
|
|
56
|
+
const typeUris = new Set(types.map(type => type.uri));
|
|
57
|
+
return Object.values(AvailableTools)
|
|
58
|
+
.map(maxPriorityFor(typeUris))
|
|
59
|
+
.filter(onlyRelevant)
|
|
60
|
+
.toSorted(byPriority)
|
|
61
|
+
.map(it => it.tool)
|
|
62
|
+
.concat(AvailableTools.Generic);
|
|
71
63
|
}
|
|
64
|
+
const maxPriorityFor = (typeUris) => tool => ({
|
|
65
|
+
tool,
|
|
66
|
+
priority: maxPriority(tool.types, typeUris),
|
|
67
|
+
});
|
|
68
|
+
function maxPriority(types, typeUris) {
|
|
69
|
+
return types.filter(type => typeUris.has(type.uri)).reduce((max, type) => Math.max(max, type.priority), 0);
|
|
70
|
+
}
|
|
71
|
+
const onlyRelevant = (it) => it.priority > 0;
|
|
72
|
+
const byPriority = (a, b) => b.priority - a.priority;
|
|
72
73
|
//# sourceMappingURL=selectToolsForTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectToolsForTypes.js","sourceRoot":"","sources":["../../../../src/components/pos-type-router/selectToolsForTypes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"selectToolsForTypes.js","sourceRoot":"","sources":["../../../../src/components/pos-type-router/selectToolsForTypes.ts"],"names":[],"mappings":"AAqDA,MAAM,CAAC,MAAM,cAAc,GAAkC;IAC3D,OAAO,EAAE;QACP,OAAO,EAAE,iBAAiB;QAC1B,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,EAAE,EAAE,uEAAuE;KACnF;IACD,WAAW,EAAE;QACX,OAAO,EAAE,sBAAsB;QAC/B,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE;YACL;gBACE,GAAG,EAAE,6CAA6C;gBAClD,QAAQ,EAAE,EAAE;aACb;SACF;KACF;IACD,cAAc,EAAE;QACd,OAAO,EAAE,yBAAyB;QAClC,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE;YACL;gBACE,GAAG,EAAE,QAAQ,CAAC,iBAAiB,CAAC;gBAChC,QAAQ,EAAE,EAAE;aACb;YACD;gBACE,GAAG,EAAE,0CAA0C;gBAC/C,QAAQ,EAAE,EAAE;aACb;SACF;KACF;IACD,WAAW,EAAE;QACX,OAAO,EAAE,sBAAsB;QAC/B,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE;YACL;gBACE,GAAG,EAAE,gCAAgC;gBACrC,QAAQ,EAAE,EAAE;aACb;SACF;KACF;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,uBAAuB;QAChC,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,oCAAoC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;KACrE;CACF,CAAC;AAEF,SAAS,QAAQ,CAAC,QAAgB;IAChC,OAAO,wCAAwC,GAAG,QAAQ,GAAG,WAAW,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAgB;IAClD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEtD,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;SACjC,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;SAC7B,MAAM,CAAC,YAAY,CAAC;SACpB,QAAQ,CAAC,UAAU,CAAC;SACpB,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;SAClB,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,cAAc,GAAG,CAAC,QAAqB,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CACvD,CAAC;IACC,IAAI;IACJ,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC;CAC5C,CAAiB,CAAC;AAErB,SAAS,WAAW,CAAC,KAAqB,EAAE,QAAqB;IAC/D,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7G,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,EAAgB,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC;AAE3D,MAAM,UAAU,GAAG,CAAC,CAAe,EAAE,CAAe,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC","sourcesContent":["import { RdfType } from '@pod-os/core';\n\n/**\n * Describes a tool that can be used\n */\nexport interface ToolConfig {\n /**\n * The HTML custom element that renders the tool\n */\n element: string;\n /**\n * A human-readable short label to identify the tool\n */\n label: string;\n /**\n * An icon to identify the tool\n * Available values see https://shoelace.style/components/icon/#default-icons\n */\n icon: string;\n /**\n * The types that can be handled by that tool\n */\n types: TypePriority[];\n}\n\n/**\n * Describes how well a given RDF type can be handled\n */\ninterface TypePriority {\n /**\n * URI identifying the RDF type\n */\n uri: string;\n /**\n * how well that type can be handled (higher values === better fit)\n */\n priority: number;\n}\n\n/**\n * Describes the priority (order) that applies to a tool\n */\ninterface ToolPriority {\n /**\n * The tool in question\n */\n tool: ToolConfig;\n /**\n * The priority given to the tool (higher values === better fit)\n */\n priority: number;\n}\n\nexport const AvailableTools: { [key: string]: ToolConfig } = {\n Generic: {\n element: 'pos-app-generic',\n label: 'Data',\n icon: 'list-ul',\n types: [], // since this is included everywhere, it does not need to specify types\n },\n RdfDocument: {\n element: 'pos-app-rdf-document',\n label: 'Things',\n icon: 'diagram-2',\n types: [\n {\n uri: 'http://www.w3.org/2007/ont/link#RDFDocument',\n priority: 20,\n },\n ],\n },\n DocumentViewer: {\n element: 'pos-app-document-viewer',\n label: 'Doc',\n icon: 'file-text',\n types: [\n {\n uri: mimeType('application/pdf'),\n priority: 30,\n },\n {\n uri: 'http://www.w3.org/2007/ont/link#Document',\n priority: 10,\n },\n ],\n },\n ImageViewer: {\n element: 'pos-app-image-viewer',\n label: 'Pic',\n icon: 'file-image',\n types: [\n {\n uri: 'http://purl.org/dc/terms/Image',\n priority: 20,\n },\n ],\n },\n LdpContainer: {\n element: 'pos-app-ldp-container',\n label: 'Content',\n icon: 'folder',\n types: [{ uri: 'http://www.w3.org/ns/ldp#Container', priority: 30 }],\n },\n};\n\nfunction mimeType(mimeType: string) {\n return 'http://www.w3.org/ns/iana/media-types/' + mimeType + '#Resource';\n}\n\nexport function selectToolsForTypes(types: RdfType[]) {\n const typeUris = new Set(types.map(type => type.uri));\n\n return Object.values(AvailableTools)\n .map(maxPriorityFor(typeUris))\n .filter(onlyRelevant)\n .toSorted(byPriority)\n .map(it => it.tool)\n .concat(AvailableTools.Generic);\n}\n\nconst maxPriorityFor = (typeUris: Set<string>) => tool =>\n ({\n tool,\n priority: maxPriority(tool.types, typeUris),\n }) as ToolPriority;\n\nfunction maxPriority(types: TypePriority[], typeUris: Set<string>): number {\n return types.filter(type => typeUris.has(type.uri)).reduce((max, type) => Math.max(max, type.priority), 0);\n}\n\nconst onlyRelevant = (it: ToolPriority) => it.priority > 0;\n\nconst byPriority = (a: ToolPriority, b: ToolPriority) => b.priority - a.priority;\n"]}
|
|
@@ -2514,8 +2514,6 @@ const redirectForLogin = async (idp, redirect_uri, client_details) => {
|
|
|
2514
2514
|
// RFC 6749 - Section 3.1.2 - sanitize redirect_uri
|
|
2515
2515
|
const redirect_uri_ = new URL(redirect_uri);
|
|
2516
2516
|
const redirect_uri_sane = redirect_uri_.origin + redirect_uri_.pathname + redirect_uri_.search;
|
|
2517
|
-
// RFC 9207 iss check: remember the identity provider (idp) / issuer (iss)
|
|
2518
|
-
sessionStorage.setItem("idp", idp);
|
|
2519
2517
|
// lookup openid configuration of idp
|
|
2520
2518
|
const idp_origin = new URL(idp).origin;
|
|
2521
2519
|
const openid_configuration = await fetch(`${idp_origin}/.well-known/openid-configuration`)
|
|
@@ -2525,6 +2523,13 @@ const redirectForLogin = async (idp, redirect_uri, client_details) => {
|
|
|
2525
2523
|
}
|
|
2526
2524
|
return response.json();
|
|
2527
2525
|
});
|
|
2526
|
+
// RFC 9207 iss check: remember the identity provider (idp) / issuer (iss) - relaxing for trailing slash
|
|
2527
|
+
const issuer = openid_configuration["issuer"];
|
|
2528
|
+
const trim_trailing_slash = (url) => (url.endsWith('/') ? url.slice(0, -1) : url);
|
|
2529
|
+
if (trim_trailing_slash(idp) !== trim_trailing_slash(issuer)) { // expected idp matches received issuer mod trailing slash?
|
|
2530
|
+
throw new Error("RFC 9207 - iss != idp - " + issuer + " != " + idp);
|
|
2531
|
+
}
|
|
2532
|
+
sessionStorage.setItem("idp", issuer);
|
|
2528
2533
|
// remember token endpoint
|
|
2529
2534
|
sessionStorage.setItem("token_endpoint", openid_configuration["token_endpoint"]);
|
|
2530
2535
|
// remember jwks_uri for later token verification
|