unoverse 0.1.1 → 0.1.2
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/lib/create.mjs +13 -2
- package/package.json +3 -3
package/lib/create.mjs
CHANGED
|
@@ -24,6 +24,18 @@ async function ask(rl, q) {
|
|
|
24
24
|
return (await rl.question(` ${q}`)).trim();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/** Operators hold the credential in two shapes: the raw dop_v1 API token, and the
|
|
28
|
+
* pre-encoded base64 `user:token` blob that docker config (and the starter's own
|
|
29
|
+
* `docr` setting) uses. Wrapping the second shape in base64 AGAIN is how a valid
|
|
30
|
+
* credential gets refused, so detect it and pass it through untouched. */
|
|
31
|
+
function registryAuth(token) {
|
|
32
|
+
if (/^[A-Za-z0-9+/]+=*$/.test(token)) {
|
|
33
|
+
const decoded = Buffer.from(token, "base64").toString("utf8");
|
|
34
|
+
if (/^[\x20-\x7e]+:[\x20-\x7e]+$/.test(decoded)) return token;
|
|
35
|
+
}
|
|
36
|
+
return Buffer.from(`${token}:${token}`).toString("base64");
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
/** The gate: prove the token opens the registry before handing over the kit.
|
|
28
40
|
* Docker registries use the bearer-realm flow: /v2/ answers 401 and names the
|
|
29
41
|
* auth realm; presenting the token there yields 200 (valid) or 401 (refused). */
|
|
@@ -34,10 +46,9 @@ async function validateRegistryToken(token) {
|
|
|
34
46
|
const realm = /realm="([^"]+)"/.exec(wa)?.[1];
|
|
35
47
|
const service = /service="([^"]+)"/.exec(wa)?.[1] ?? REGISTRY_HOST;
|
|
36
48
|
if (!realm) return probe.status === 200;
|
|
37
|
-
const auth = Buffer.from(`${token}:${token}`).toString("base64");
|
|
38
49
|
const res = await fetch(
|
|
39
50
|
`${realm}?service=${encodeURIComponent(service)}&scope=registry:catalog:*`,
|
|
40
|
-
{ headers: { Authorization: `Basic ${
|
|
51
|
+
{ headers: { Authorization: `Basic ${registryAuth(token)}` } },
|
|
41
52
|
);
|
|
42
53
|
return res.ok;
|
|
43
54
|
} catch {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unoverse",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "The Unoverse front door
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "The Unoverse front door — create a Studio project, a universe, or a client app, and launch Studio.",
|
|
5
5
|
"license": "SEE LICENSE IN README.md",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "git+https://github.com/unoverse-platform/unoverse.git"
|
|
22
22
|
}
|
|
23
|
-
}
|
|
23
|
+
}
|