@tekkare/romulus 0.1.312 → 0.1.313
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/module.json +1 -1
- package/layer/app/components/OipDocumentPreview.vue +15 -1
- package/layer/app/components/panels/OipPanelInbox.vue +46 -15
- package/layer/server/api/oip/inbox/files/[id]/content.get.ts +17 -0
- package/layer/server/api/oip/inbox/files/[id]/raw.get.ts +13 -0
- package/layer/server/utils/oipInbox.ts +50 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -46,7 +46,14 @@
|
|
|
46
46
|
</template>
|
|
47
47
|
|
|
48
48
|
<template v-if="src">
|
|
49
|
-
<iframe
|
|
49
|
+
<iframe
|
|
50
|
+
v-if="frame"
|
|
51
|
+
class="preview_frame"
|
|
52
|
+
:src="src"
|
|
53
|
+
:title="title"
|
|
54
|
+
sandbox="allow-scripts allow-same-origin allow-forms allow-popups"
|
|
55
|
+
/>
|
|
56
|
+
<iframe v-else-if="fallback" class="preview_frame" :src="fallbackSrc || src" :title="title" />
|
|
50
57
|
<RmDocumentViewer
|
|
51
58
|
v-else
|
|
52
59
|
:src="src"
|
|
@@ -86,6 +93,12 @@ const props = withDefaults(
|
|
|
86
93
|
* resolvent.
|
|
87
94
|
*/
|
|
88
95
|
fallbackSrc?: string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Encadre `src` tel quel, sans passer par le lecteur : pour un rapport
|
|
98
|
+
* HTML qui porte ses propres scripts (livrables share-platform), que le
|
|
99
|
+
* lecteur aplatirait.
|
|
100
|
+
*/
|
|
101
|
+
frame?: boolean;
|
|
89
102
|
}>(),
|
|
90
103
|
{
|
|
91
104
|
title: "",
|
|
@@ -95,6 +108,7 @@ const props = withDefaults(
|
|
|
95
108
|
query: null,
|
|
96
109
|
anchor: null,
|
|
97
110
|
fallbackSrc: null,
|
|
111
|
+
frame: false,
|
|
98
112
|
},
|
|
99
113
|
);
|
|
100
114
|
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
Reprend l'Inbox de l'accueil OIP Platform : les fichiers que Tekkare a
|
|
5
5
|
partages avec les workspaces du lecteur et les vues que des collegues lui
|
|
6
6
|
ont partagees, du plus recent au plus ancien. Une vue s'ouvre dans son app,
|
|
7
|
-
dans l'onglet courant si c'est celle-ci, sinon dans un nouvel onglet
|
|
8
|
-
fichier s'ouvre
|
|
7
|
+
dans l'onglet courant si c'est celle-ci, sinon dans un nouvel onglet. Un
|
|
8
|
+
fichier s'ouvre dans un apercu par-dessus l'ecran (OipDocumentPreview), sans
|
|
9
|
+
quitter l'app : ses octets passent par /api/oip/inbox/files.
|
|
9
10
|
|
|
10
11
|
Ouvrir le panneau marque l'Inbox lue (curseur unique, cf. useOipInbox). Les
|
|
11
12
|
lignes nouvelles le restent a l'ecran tant que le panneau est ouvert : on
|
|
@@ -20,7 +21,6 @@ defineProps<{ appKey?: string; superAdmin?: boolean }>();
|
|
|
20
21
|
const { locale } = useI18n();
|
|
21
22
|
const en = computed(() => locale.value === "en");
|
|
22
23
|
const { items, pending, unavailable, since, isNew, load, markSeen } = useOipInbox();
|
|
23
|
-
const PLATFORM_URL = useAppConfig().oip.platform.href;
|
|
24
24
|
|
|
25
25
|
/** Curseur fige a l'ouverture : la ligne garde son badge le temps de la lecture. */
|
|
26
26
|
const openedSince = ref(since.value);
|
|
@@ -46,14 +46,19 @@ function hostOf(url?: string): string {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function hrefOf(item: OipInboxItem): string {
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
return new URL(`/shared/${encodeURIComponent(item.id)}`, PLATFORM_URL).href;
|
|
52
|
-
} catch {
|
|
53
|
-
return PLATFORM_URL;
|
|
54
|
-
}
|
|
49
|
+
return item.url ?? "";
|
|
55
50
|
}
|
|
56
51
|
|
|
52
|
+
/** Fichier ouvert dans l'apercu, ou null. */
|
|
53
|
+
const previewed = ref<OipInboxItem | null>(null);
|
|
54
|
+
const previewOpen = computed({
|
|
55
|
+
get: () => !!previewed.value,
|
|
56
|
+
set: (value: boolean) => {
|
|
57
|
+
if (!value) previewed.value = null;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
const fileBase = (item: OipInboxItem) => `/api/oip/inbox/files/${encodeURIComponent(item.id)}`;
|
|
61
|
+
|
|
57
62
|
/** Une autre app (ou la plateforme) s'ouvre a cote : on ne quitte pas l'ecran en cours. */
|
|
58
63
|
const isExternal = (href: string) => !!origin.value && !href.startsWith(origin.value);
|
|
59
64
|
|
|
@@ -107,11 +112,19 @@ function subtitleOf(item: OipInboxItem): string {
|
|
|
107
112
|
|
|
108
113
|
<ul v-else-if="items.length" class="inbox_list">
|
|
109
114
|
<li v-for="item in items" :key="`${item.kind}:${item.id}`">
|
|
110
|
-
<
|
|
115
|
+
<component
|
|
116
|
+
:is="item.kind === 'view' ? 'a' : 'button'"
|
|
111
117
|
class="inbox_row"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
v-bind="
|
|
119
|
+
item.kind === 'view'
|
|
120
|
+
? {
|
|
121
|
+
href: hrefOf(item),
|
|
122
|
+
target: isExternal(hrefOf(item)) ? '_blank' : undefined,
|
|
123
|
+
rel: isExternal(hrefOf(item)) ? 'noopener noreferrer' : undefined,
|
|
124
|
+
}
|
|
125
|
+
: { type: 'button' }
|
|
126
|
+
"
|
|
127
|
+
@click="item.kind === 'file' && (previewed = item)"
|
|
115
128
|
>
|
|
116
129
|
<span class="inbox_icon"><i class="ph" :class="iconOf(item)" aria-hidden="true" /></span>
|
|
117
130
|
<span class="inbox_text">
|
|
@@ -125,16 +138,27 @@ function subtitleOf(item: OipInboxItem): string {
|
|
|
125
138
|
</span>
|
|
126
139
|
<i
|
|
127
140
|
class="ph inbox_go"
|
|
128
|
-
:class="
|
|
141
|
+
:class="
|
|
142
|
+
item.kind === 'file' ? 'ph-eye' : isExternal(hrefOf(item)) ? 'ph-arrow-square-out' : 'ph-arrow-right'
|
|
143
|
+
"
|
|
129
144
|
aria-hidden="true"
|
|
130
145
|
/>
|
|
131
|
-
</
|
|
146
|
+
</component>
|
|
132
147
|
</li>
|
|
133
148
|
</ul>
|
|
134
149
|
|
|
135
150
|
<p v-else class="inbox_note">
|
|
136
151
|
{{ en ? "Nothing shared with you yet." : "Rien ne vous a encore été partagé." }}
|
|
137
152
|
</p>
|
|
153
|
+
|
|
154
|
+
<OipDocumentPreview
|
|
155
|
+
v-model="previewOpen"
|
|
156
|
+
:src="previewed ? `${fileBase(previewed)}/content` : null"
|
|
157
|
+
:title="previewed?.title"
|
|
158
|
+
:download-src="previewed ? `${fileBase(previewed)}/raw?download=1` : null"
|
|
159
|
+
:external-src="previewed ? `${fileBase(previewed)}/raw` : null"
|
|
160
|
+
frame
|
|
161
|
+
/>
|
|
138
162
|
</div>
|
|
139
163
|
</template>
|
|
140
164
|
|
|
@@ -177,6 +201,13 @@ function subtitleOf(item: OipInboxItem): string {
|
|
|
177
201
|
transition: border-color 0.15s ease-out;
|
|
178
202
|
}
|
|
179
203
|
|
|
204
|
+
button.inbox_row {
|
|
205
|
+
width: 100%;
|
|
206
|
+
font: inherit;
|
|
207
|
+
text-align: left;
|
|
208
|
+
cursor: pointer;
|
|
209
|
+
}
|
|
210
|
+
|
|
180
211
|
.inbox_row:hover {
|
|
181
212
|
border-color: var(--color-secondary);
|
|
182
213
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam } from "h3";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GET /api/oip/inbox/files/:id/content : le livrable mis en page, pour
|
|
5
|
+
* l'apercu de l'Inbox du rail (iframe de meme origine). Meme route que la
|
|
6
|
+
* visionneuse /shared/:id d'oip7 : `allow-same-origin` reste dans le sandbox,
|
|
7
|
+
* sans lui les scripts du rapport tournent dans une origine nulle et son
|
|
8
|
+
* habillage casse ; le cookie de session est HttpOnly.
|
|
9
|
+
*/
|
|
10
|
+
export default defineEventHandler(async (event) => {
|
|
11
|
+
const id = getRouterParam(event, "id");
|
|
12
|
+
if (!id) throw createError({ status: 400, message: "id is required" });
|
|
13
|
+
const token = await oipAssertInboxFile(event, id);
|
|
14
|
+
return await oipSharingStream(event, token, `/a/${encodeURIComponent(id)}?content=1`, {
|
|
15
|
+
csp: "sandbox allow-scripts allow-same-origin allow-popups allow-forms",
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, getRouterParam } from "h3";
|
|
2
|
+
|
|
3
|
+
/** GET /api/oip/inbox/files/:id/raw[?download=1] : le fichier lui-meme (telecharger, nouvel onglet). */
|
|
4
|
+
export default defineEventHandler(async (event) => {
|
|
5
|
+
const id = getRouterParam(event, "id");
|
|
6
|
+
if (!id) throw createError({ status: 400, message: "id is required" });
|
|
7
|
+
const token = await oipAssertInboxFile(event, id);
|
|
8
|
+
const suffix = getQuery(event).download === "1" ? "?download=1" : "";
|
|
9
|
+
return await oipSharingStream(event, token, `/a/${encodeURIComponent(id)}/raw${suffix}`, {
|
|
10
|
+
csp: "sandbox",
|
|
11
|
+
forwardDisposition: true,
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -133,3 +133,53 @@ export async function oipInboxMarkSeen(event: H3Event, until?: string) {
|
|
|
133
133
|
throw createError({ status, message: "Could not update the inbox cursor" });
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Refuse sauf si le fichier est l'un de ceux partages avec les workspaces de
|
|
139
|
+
* l'appelant. La liste est elle-meme le controle d'appartenance : share-platform
|
|
140
|
+
* repond 403 a un non-membre. La route brute de share-platform precede ce
|
|
141
|
+
* controle et sert un blob prive a quiconque est identifie, d'ou ce passage.
|
|
142
|
+
*/
|
|
143
|
+
export async function oipAssertInboxFile(event: H3Event, artifactId: string): Promise<string> {
|
|
144
|
+
const token = await requireOipSession(event);
|
|
145
|
+
const files = await sharedFiles(token);
|
|
146
|
+
if (!files.some((file) => file.id === artifactId)) {
|
|
147
|
+
throw createError({ status: 404, message: "File not found" });
|
|
148
|
+
}
|
|
149
|
+
return token;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Relaie une reponse share-platform sous l'origine de l'app : le navigateur
|
|
154
|
+
* ne parle qu'a elle, et le jeton ne quitte pas le serveur.
|
|
155
|
+
*/
|
|
156
|
+
export async function oipSharingStream(
|
|
157
|
+
event: H3Event,
|
|
158
|
+
token: string,
|
|
159
|
+
path: string,
|
|
160
|
+
opts: { csp: string; forwardDisposition?: boolean },
|
|
161
|
+
) {
|
|
162
|
+
const sharing = String(useRuntimeConfig().oipSharingApiBase).replace(/\/$/, "");
|
|
163
|
+
let upstream: Response;
|
|
164
|
+
try {
|
|
165
|
+
upstream = await fetch(`${sharing}${path}`, {
|
|
166
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
167
|
+
redirect: "manual",
|
|
168
|
+
});
|
|
169
|
+
} catch {
|
|
170
|
+
throw createError({ status: 502, message: "Sharing service unreachable" });
|
|
171
|
+
}
|
|
172
|
+
if (!upstream.ok) {
|
|
173
|
+
const status = [401, 403, 404, 410].includes(upstream.status) ? upstream.status : 502;
|
|
174
|
+
throw createError({ status, message: "Shared file fetch failed" });
|
|
175
|
+
}
|
|
176
|
+
setResponseHeader(event, "content-type", upstream.headers.get("content-type") ?? "application/octet-stream");
|
|
177
|
+
if (opts.forwardDisposition) {
|
|
178
|
+
const disposition = upstream.headers.get("content-disposition");
|
|
179
|
+
if (disposition) setResponseHeader(event, "content-disposition", disposition);
|
|
180
|
+
}
|
|
181
|
+
setResponseHeader(event, "content-security-policy", opts.csp);
|
|
182
|
+
// Un livrable client ne regarde personne d'autre : jamais de cache partage.
|
|
183
|
+
setResponseHeader(event, "cache-control", "private, no-store");
|
|
184
|
+
return upstream.body;
|
|
185
|
+
}
|