create-dig-app 0.2.2 → 0.2.4

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/nft-cli.js CHANGED
@@ -237,7 +237,7 @@ export function validateProject(root) {
237
237
  throw new Error(`item "${item.name}": metadata_hash does not match any metadata/*.json`);
238
238
  }
239
239
  }
240
- // data_hash agrees with the real image bytes (resolve the image path from the dig:// URN tail).
240
+ // data_hash agrees with the real image bytes (resolve the image path from the URN's resource tail).
241
241
  const imgFile = resourceTail(media.data_uris?.[0]);
242
242
  if (imgFile && media.data_hash != null) {
243
243
  const imgPath = join(root, imgFile);
@@ -257,9 +257,14 @@ export function validateProject(root) {
257
257
  return { ok: true, checked };
258
258
  }
259
259
 
260
- /** Extract the resource path (everything after the first `/`) from a `dig://urn:…/<resource>` URI. */
260
+ /**
261
+ * Extract the resource path from a capsule URI — the canonical bare URN
262
+ * `urn:dig:chia:<storeId>:<root>/<resource>` or the `https://<host>/<resource>` gateway fallback.
263
+ * Strip an optional `scheme://authority` prefix, then the resource is everything after the first `/`.
264
+ */
261
265
  function resourceTail(uri) {
262
266
  if (!uri || typeof uri !== "string") return null;
263
- const i = uri.indexOf("/", uri.indexOf("://") + 3);
264
- return i >= 0 ? uri.slice(i + 1) : null;
267
+ const afterAuthority = uri.includes("://") ? uri.slice(uri.indexOf("://") + 3) : uri;
268
+ const i = afterAuthority.indexOf("/");
269
+ return i >= 0 ? afterAuthority.slice(i + 1) : null;
265
270
  }
@@ -364,14 +364,18 @@ export function itemsFromImages(fileNames) {
364
364
  });
365
365
  }
366
366
 
367
- // ── Capsule resource URIs (dig:// URN first, https gateway fallback) ───────────────────────────────
367
+ // ── Capsule resource URIs (canonical URN first, https gateway fallback) ─────────────────────────────
368
368
 
369
369
  /** The HTTPS gateway host for decrypted capsule resources (mirrors the hub's CAPSULE_HTTPS_GATEWAY). */
370
370
  export const CAPSULE_HTTPS_GATEWAY = "usercontent.dig.net";
371
371
 
372
372
  /**
373
- * Build the CHIP-0007 media URIs for a resource inside a capsule: the canonical `dig://` URN first,
373
+ * Build the CHIP-0007 media URIs for a resource inside a capsule: the canonical bare URN first,
374
374
  * then the https gateway fallback (the order the hub + digstore use).
375
+ *
376
+ * The URN is the bare, root-pinned `urn:dig:chia:<storeId>:<root>/<resource>` form — NEVER a
377
+ * `dig://`-prefixed URN (the `dig://urn:dig:chia:…` double-scheme is the #686 bug). `dig://` is not
378
+ * a content/resource scheme; the dig-urn-resolver consumes the bare URN and decides where to fetch.
375
379
  * @param {{storeId:string,root?:string,resource:string}} args
376
380
  * @returns {{urn:string,https:string,uris:string[]}}
377
381
  */
@@ -379,7 +383,7 @@ export function capsuleResourceUris({ storeId, root, resource }) {
379
383
  const sid = String(storeId ?? "").trim();
380
384
  const r = String(root ?? "").trim();
381
385
  const res = String(resource ?? "").trim().replace(/^\/+/, "");
382
- const urn = `dig://urn:dig:chia:${sid}${r ? `:${r}` : ""}/${res}`;
386
+ const urn = `urn:dig:chia:${sid}${r ? `:${r}` : ""}/${res}`;
383
387
  const https = `https://${sid}.${CAPSULE_HTTPS_GATEWAY}/${res}`;
384
388
  return { urn, https, uris: [urn, https] };
385
389
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-dig-app",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Scaffold a wallet-wired, deployable DIG Network app — free, no mint. The JS front door for building dapps, frontends, and NFT collections on Chia.",
5
5
  "license": "MIT",
6
6
  "author": "DIG Network",
@@ -215,7 +215,7 @@ function capsuleResourceUris({ storeId, root, resource }) {
215
215
  const sid = String(storeId ?? "").trim();
216
216
  const r = String(root ?? "").trim();
217
217
  const res = String(resource ?? "").trim().replace(/^\/+/, "");
218
- const urn = `dig://urn:dig:chia:${sid}${r ? `:${r}` : ""}/${res}`;
218
+ const urn = `urn:dig:chia:${sid}${r ? `:${r}` : ""}/${res}`;
219
219
  const https = `https://${sid}.${CAPSULE_HTTPS_GATEWAY}/${res}`;
220
220
  return { urn, https, uris: [urn, https] };
221
221
  }