pinokiod 5.3.8 → 5.3.10
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/package.json +1 -1
- package/server/index.js +22 -1
- package/server/views/registry_checkin.ejs +30 -0
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -4932,7 +4932,7 @@ class Server {
|
|
|
4932
4932
|
|
|
4933
4933
|
// Registry linking endpoint
|
|
4934
4934
|
this.app.get("/registry/link", ex(async (req, res) => {
|
|
4935
|
-
const { token, registry, app: appOrigin, next: nextRaw } = req.query
|
|
4935
|
+
const { token, registry, app: appOrigin, next: nextRaw, pinokioNext: pinokioNextRaw } = req.query
|
|
4936
4936
|
|
|
4937
4937
|
if (!token || !registry) {
|
|
4938
4938
|
res.status(400).render("registry_link", {
|
|
@@ -4972,6 +4972,27 @@ class Server {
|
|
|
4972
4972
|
if (candidate.origin === base.origin) redirectUrl = candidate.toString()
|
|
4973
4973
|
} catch (_) {}
|
|
4974
4974
|
}
|
|
4975
|
+
|
|
4976
|
+
if (pinokioNextRaw) {
|
|
4977
|
+
try {
|
|
4978
|
+
const nextVal = String(pinokioNextRaw)
|
|
4979
|
+
const protocol = (req.$source && req.$source.protocol) || req.get("X-Forwarded-Proto") || "http"
|
|
4980
|
+
const host = (req.$source && req.$source.host) || req.get("host")
|
|
4981
|
+
const base = new URL(`${protocol}://${host}`)
|
|
4982
|
+
let candidate = null
|
|
4983
|
+
if (nextVal.startsWith("/") && !nextVal.startsWith("//")) {
|
|
4984
|
+
if (nextVal.startsWith("/registry/checkin")) {
|
|
4985
|
+
candidate = new URL(nextVal, base.toString())
|
|
4986
|
+
}
|
|
4987
|
+
} else {
|
|
4988
|
+
const parsed = new URL(nextVal)
|
|
4989
|
+
if (parsed.origin === base.origin && parsed.pathname.startsWith("/registry/checkin")) {
|
|
4990
|
+
candidate = parsed
|
|
4991
|
+
}
|
|
4992
|
+
}
|
|
4993
|
+
if (candidate && candidate.origin === base.origin) redirectUrl = candidate.toString()
|
|
4994
|
+
} catch (_) {}
|
|
4995
|
+
}
|
|
4975
4996
|
|
|
4976
4997
|
try {
|
|
4977
4998
|
// Exchange token for API key at the specified registry
|
|
@@ -170,6 +170,31 @@
|
|
|
170
170
|
return null;
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
+
const buildConnectUrl = (rawUrl) => {
|
|
174
|
+
if (!rawUrl) return null;
|
|
175
|
+
try {
|
|
176
|
+
const u = new URL(rawUrl);
|
|
177
|
+
if (u.protocol !== 'http:' && u.protocol !== 'https:') return null;
|
|
178
|
+
const pinokioNext = `${window.location.pathname}${window.location.search}${window.location.hash || ''}`;
|
|
179
|
+
if (pinokioNext.startsWith('/') && !pinokioNext.startsWith('//')) {
|
|
180
|
+
u.searchParams.set('pinokioNext', pinokioNext);
|
|
181
|
+
}
|
|
182
|
+
if (data.returnUrl) {
|
|
183
|
+
try {
|
|
184
|
+
const ret = new URL(data.returnUrl);
|
|
185
|
+
const nextPath = `${ret.pathname}${ret.search}${ret.hash || ''}`;
|
|
186
|
+
if (nextPath.startsWith('/') && !nextPath.startsWith('//')) {
|
|
187
|
+
u.searchParams.set('next', nextPath);
|
|
188
|
+
}
|
|
189
|
+
} catch (err) {}
|
|
190
|
+
}
|
|
191
|
+
u.searchParams.set('pinokioUrl', window.location.origin);
|
|
192
|
+
return u.toString();
|
|
193
|
+
} catch (err) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
173
198
|
const candidates = Array.isArray(data.candidates) ? data.candidates : [];
|
|
174
199
|
const repoLabel = data.repoUrl ? `Repo: ${data.repoUrl}` : 'Missing repo URL';
|
|
175
200
|
if (repoEl) repoEl.textContent = repoLabel;
|
|
@@ -254,6 +279,11 @@
|
|
|
254
279
|
return;
|
|
255
280
|
}
|
|
256
281
|
if (publish && publish.code === 'not_linked') {
|
|
282
|
+
const connectUrl = buildConnectUrl(publish.connectUrl || '');
|
|
283
|
+
if (connectUrl) {
|
|
284
|
+
window.location.href = connectUrl;
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
257
287
|
redirectToReturn({ error: 'not_linked', connectUrl: publish.connectUrl || '' });
|
|
258
288
|
return;
|
|
259
289
|
}
|