pinokiod 5.3.11 → 5.3.12
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 +27 -2
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -4892,27 +4892,51 @@ class Server {
|
|
|
4892
4892
|
}
|
|
4893
4893
|
const isLocalHost = (hostname) => ['localhost', '127.0.0.1', '0.0.0.0'].includes(String(hostname || '').toLowerCase())
|
|
4894
4894
|
const hostMatches = (a, b) => a && b && a.protocol === b.protocol && a.hostname === b.hostname
|
|
4895
|
+
const baseDomain = (hostname) => {
|
|
4896
|
+
const parts = String(hostname || '').toLowerCase().split('.').filter(Boolean)
|
|
4897
|
+
if (parts.length <= 2) return parts.join('.')
|
|
4898
|
+
return parts.slice(-2).join('.')
|
|
4899
|
+
}
|
|
4900
|
+
const sameBaseDomain = (a, b) => {
|
|
4901
|
+
const ha = String(a || '').toLowerCase()
|
|
4902
|
+
const hb = String(b || '').toLowerCase()
|
|
4903
|
+
if (!ha || !hb) return false
|
|
4904
|
+
if (isLocalHost(ha) && isLocalHost(hb)) return true
|
|
4905
|
+
return baseDomain(ha) === baseDomain(hb)
|
|
4906
|
+
}
|
|
4895
4907
|
|
|
4908
|
+
const registryRawPresent = !!registryRaw
|
|
4909
|
+
const connectRawPresent = !!connectRaw
|
|
4896
4910
|
let registryOverride = normalizeHttpUrl(registryRaw)
|
|
4897
4911
|
let connectOverride = normalizeHttpUrl(connectRaw)
|
|
4898
4912
|
if (returnUrl) {
|
|
4899
4913
|
try {
|
|
4900
4914
|
const returnHost = new URL(returnUrl)
|
|
4915
|
+
const returnOrigin = returnHost.origin
|
|
4901
4916
|
if (registryOverride) {
|
|
4902
4917
|
const regHost = new URL(registryOverride)
|
|
4903
|
-
const ok = hostMatches(regHost, returnHost)
|
|
4918
|
+
const ok = hostMatches(regHost, returnHost)
|
|
4919
|
+
|| sameBaseDomain(regHost.hostname, returnHost.hostname)
|
|
4904
4920
|
if (!ok) registryOverride = null
|
|
4905
4921
|
}
|
|
4906
4922
|
if (connectOverride) {
|
|
4907
4923
|
const conHost = new URL(connectOverride)
|
|
4908
|
-
const ok = hostMatches(conHost, returnHost)
|
|
4924
|
+
const ok = hostMatches(conHost, returnHost)
|
|
4925
|
+
|| sameBaseDomain(conHost.hostname, returnHost.hostname)
|
|
4909
4926
|
if (!ok) connectOverride = null
|
|
4910
4927
|
}
|
|
4928
|
+
if (!registryOverride && !registryRawPresent && returnOrigin) {
|
|
4929
|
+
registryOverride = returnOrigin
|
|
4930
|
+
}
|
|
4931
|
+
if (!connectOverride && !connectRawPresent && returnOrigin) {
|
|
4932
|
+
connectOverride = `${returnOrigin.replace(/\/$/, '')}/connect/pinokio`
|
|
4933
|
+
}
|
|
4911
4934
|
} catch (_) {}
|
|
4912
4935
|
} else {
|
|
4913
4936
|
registryOverride = null
|
|
4914
4937
|
connectOverride = null
|
|
4915
4938
|
}
|
|
4939
|
+
console.log("[registry/checkin] repo=%s return=%s registryRaw=%s connectRaw=%s registryOverride=%s connectOverride=%s", repoUrl || "", returnUrl || "", registryRaw || "", connectRaw || "", registryOverride || "", connectOverride || "")
|
|
4916
4940
|
|
|
4917
4941
|
let candidates = []
|
|
4918
4942
|
if (repoUrl && this.kernel && this.kernel.git) {
|
|
@@ -5227,6 +5251,7 @@ class Server {
|
|
|
5227
5251
|
connectUrl = await this.getRegistryConnectUrl().catch(() => null)
|
|
5228
5252
|
}
|
|
5229
5253
|
}
|
|
5254
|
+
console.log("[checkpoints/snapshot] publish=1 registryOverride=%s baseUrl=%s connectUrl=%s hasApiKey=%s", registryOverride || "", baseUrl || "", connectUrl || "", apiKey ? "yes" : "no")
|
|
5230
5255
|
if (!baseUrl || !apiKey) {
|
|
5231
5256
|
await this.kernel.git.setCheckpointSync(created.remoteKey, created.id, { status: "needs_link", at: Date.now() }).catch(() => {})
|
|
5232
5257
|
res.json({ ok: true, created: created || null, publish: { ok: false, code: "not_linked", connectUrl } })
|