@tokenoftrust/cli 2.0.4 → 2.0.5

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.0.4",
3
+ "version": "2.0.5",
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",
@@ -85,9 +85,23 @@ export async function resolveViewerTransport({
85
85
  const base = tenantBase(tenant, storefrontUrl);
86
86
  let res;
87
87
  try {
88
+ // `content-type: application/json` is REQUIRED, not decoration. Astro's origin
89
+ // check rejects any unsafe-method request that is cross-origin AND either
90
+ // form-like (`application/x-www-form-urlencoded`, `multipart/form-data`,
91
+ // `text/plain`) or carries no content-type at all. Node's `fetch` sends no
92
+ // `Origin`, so every request from here is "cross-origin" — declaring JSON is what
93
+ // takes it out of the form-POST class the check guards. It is an honest
94
+ // declaration, not a bypass: a browser cannot send `application/json`
95
+ // cross-origin without a CORS preflight this worker never answers, so the
96
+ // anti-CSRF property is preserved exactly. Spoofing an `Origin` header instead
97
+ // would assert a browser context that does not exist and protect nothing.
88
98
  res = await fetchImpl(`${base}/api/dev/cli-session`, {
89
99
  method: "POST",
90
- headers: { authorization: `Bearer ${dev.token}` },
100
+ headers: {
101
+ authorization: `Bearer ${dev.token}`,
102
+ "content-type": "application/json",
103
+ },
104
+ body: "{}",
91
105
  });
92
106
  } catch (e) {
93
107
  return {