@tokenoftrust/cli 2.2.7 → 2.2.8
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.8",
|
|
4
4
|
"description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Token of Trust",
|
|
@@ -165,9 +165,22 @@ export async function mintOrCacheCredential({
|
|
|
165
165
|
/* fall through — tagFromRepoName degrades to "main" on a null repo name */
|
|
166
166
|
}
|
|
167
167
|
if (expectedHost && !hostMatches(originUrl, expectedHost)) return null;
|
|
168
|
-
const tag = tagFromRepoName(repoName, ctx.tenant);
|
|
169
168
|
|
|
170
|
-
|
|
169
|
+
// Prefer the tenant encoded in the git remote itself over `.tot/config.json`'s
|
|
170
|
+
// "tenant" field. The remote URL is the forge's OWN record of this checkout's repo
|
|
171
|
+
// (set once by `tenant_checkout`'s returned cloneUrl at clone time); the config file
|
|
172
|
+
// is tenant-owned, committed content a developer's own commit can set wrong at seed
|
|
173
|
+
// time or drift later — exactly what broke every client_switch/tenant_checkout call
|
|
174
|
+
// in fb-1790958790645-7j8gul / fb-1790969588649-zl3xa7. Every real tenant is
|
|
175
|
+
// provisioned with repo === owner (storefront's provisioning enforces this at every
|
|
176
|
+
// call site — buildStaffStoreIdentity, scripts/tenant/provision-gitea-repo.mjs), so
|
|
177
|
+
// the repo name IS the tenant id. Fall back to the config file only when the remote
|
|
178
|
+
// can't be read or parsed (no origin yet) — this never makes the mint MORE likely to
|
|
179
|
+
// fail than before, only less dependent on content the forge itself didn't set.
|
|
180
|
+
const tenant = repoName || ctx.tenant;
|
|
181
|
+
const tag = tagFromRepoName(repoName, tenant);
|
|
182
|
+
|
|
183
|
+
const cachePath = credentialCachePath(tenant, tag, env);
|
|
171
184
|
const cached = readCachedCredential(cachePath);
|
|
172
185
|
if (cached) return { username: cached.username, password: cached.password };
|
|
173
186
|
|
|
@@ -179,7 +192,7 @@ export async function mintOrCacheCredential({
|
|
|
179
192
|
return null; // not signed in (or session unrefreshable) — nothing this helper can do
|
|
180
193
|
}
|
|
181
194
|
try {
|
|
182
|
-
const res = await checkout(client, { tenant
|
|
195
|
+
const res = await checkout(client, { tenant, tag, cloneDir: null });
|
|
183
196
|
const cred = splitAuthedRemote(res.gitRemote || "");
|
|
184
197
|
if (!cred) return null;
|
|
185
198
|
const fresh = { username: cred.username, password: cred.token };
|
|
@@ -236,8 +249,12 @@ export function forgetCredential({ env = process.env, cwd = process.cwd(), expec
|
|
|
236
249
|
}).toString().trim();
|
|
237
250
|
} catch { /* no origin */ }
|
|
238
251
|
if (expectedHost && !hostMatches(originUrl, expectedHost)) return;
|
|
239
|
-
|
|
240
|
-
|
|
252
|
+
// Mirror `get`'s tenant resolution (remote-derived, falling back to the config
|
|
253
|
+
// file) so `erase` drops the SAME cache key `get` wrote, not a stale sibling.
|
|
254
|
+
const repoName = originUrl ? repoNameFromRemote(originUrl) : null;
|
|
255
|
+
const tenant = repoName || ctx.tenant;
|
|
256
|
+
const tag = tagFromRepoName(repoName, tenant);
|
|
257
|
+
dropCachedCredential(credentialCachePath(tenant, tag, env));
|
|
241
258
|
} catch {
|
|
242
259
|
/* erase is advisory — never fail git over it */
|
|
243
260
|
}
|