@artblocks/abx-storage 0.1.0-alpha.4 → 0.1.0-alpha.41
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/CHANGELOG.md +69 -0
- package/dist/arweave.d.ts +45 -44
- package/dist/arweave.d.ts.map +1 -1
- package/dist/arweave.js +98 -155
- package/dist/arweave.js.map +1 -1
- package/dist/backend.d.ts +1 -4
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +4 -33
- package/dist/backend.js.map +1 -1
- package/dist/content-index.d.ts.map +1 -1
- package/dist/content-index.js +3 -1
- package/dist/content-index.js.map +1 -1
- package/dist/content-plan.d.ts +78 -0
- package/dist/content-plan.d.ts.map +1 -0
- package/dist/content-plan.js +68 -0
- package/dist/content-plan.js.map +1 -0
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +3 -1
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/ipfs.d.ts +17 -1
- package/dist/ipfs.d.ts.map +1 -1
- package/dist/ipfs.js +60 -2
- package/dist/ipfs.js.map +1 -1
- package/dist/migrate.d.ts +37 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +55 -0
- package/dist/migrate.js.map +1 -0
- package/dist/probe.d.ts +66 -0
- package/dist/probe.d.ts.map +1 -0
- package/dist/probe.js +155 -0
- package/dist/probe.js.map +1 -0
- package/dist/readiness.d.ts +158 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +183 -0
- package/dist/readiness.js.map +1 -0
- package/dist/upload-readiness.d.ts +89 -0
- package/dist/upload-readiness.d.ts.map +1 -0
- package/dist/upload-readiness.js +85 -0
- package/dist/upload-readiness.js.map +1 -0
- package/dist/upload.d.ts +28 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +41 -0
- package/dist/upload.js.map +1 -0
- package/package.json +17 -9
package/dist/backend.js
CHANGED
|
@@ -3,37 +3,8 @@ import { keccak256 } from 'viem';
|
|
|
3
3
|
export function hashContent(bytes) {
|
|
4
4
|
return keccak256(bytes);
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
const ext = path.toLowerCase().slice(path.lastIndexOf('.') + 1);
|
|
11
|
-
const map = {
|
|
12
|
-
png: 'image/png',
|
|
13
|
-
jpg: 'image/jpeg',
|
|
14
|
-
jpeg: 'image/jpeg',
|
|
15
|
-
gif: 'image/gif',
|
|
16
|
-
webp: 'image/webp',
|
|
17
|
-
svg: 'image/svg+xml',
|
|
18
|
-
avif: 'image/avif',
|
|
19
|
-
tiff: 'image/tiff',
|
|
20
|
-
tif: 'image/tiff',
|
|
21
|
-
psd: 'image/vnd.adobe.photoshop',
|
|
22
|
-
mp4: 'video/mp4',
|
|
23
|
-
webm: 'video/webm',
|
|
24
|
-
html: 'text/html; charset=utf-8',
|
|
25
|
-
json: 'application/json',
|
|
26
|
-
glb: 'model/gltf-binary',
|
|
27
|
-
gltf: 'model/gltf+json',
|
|
28
|
-
mp3: 'audio/mpeg',
|
|
29
|
-
wav: 'audio/wav',
|
|
30
|
-
flac: 'audio/flac',
|
|
31
|
-
pdf: 'application/pdf',
|
|
32
|
-
txt: 'text/plain; charset=utf-8',
|
|
33
|
-
md: 'text/markdown; charset=utf-8',
|
|
34
|
-
csv: 'text/csv; charset=utf-8',
|
|
35
|
-
zip: 'application/zip',
|
|
36
|
-
};
|
|
37
|
-
return map[ext] ?? 'application/octet-stream';
|
|
38
|
-
}
|
|
6
|
+
// `contentTypeFromPath` lives in `@artblocks/abx-sdk` (src/mime.ts) and is re-exported from
|
|
7
|
+
// `./index.ts` unchanged, so this package's public API stays
|
|
8
|
+
// identical.
|
|
9
|
+
export { contentTypeFromPath } from '@artblocks/abx-sdk';
|
|
39
10
|
//# sourceMappingURL=backend.js.map
|
package/dist/backend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAW,MAAM,MAAM,CAAC;AAkFzC,yGAAyG;AACzG,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAW,MAAM,MAAM,CAAC;AAkFzC,yGAAyG;AACzG,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,4FAA4F;AAC5F,6DAA6D;AAC7D,aAAa;AACb,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-index.d.ts","sourceRoot":"","sources":["../src/content-index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"content-index.d.ts","sourceRoot":"","sources":["../src/content-index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,MAAM,CAAC;AAG9B;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,YAAY;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,IAAI,CAA6B;gBAE7B,OAAO,CAAC,EAAE,MAAM;IAQ5B,OAAO,CAAC,GAAG;IAIX,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,UAAU,GAAG,IAAI;IAIjC,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO;IAIvB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;CAIxC"}
|
package/dist/content-index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
+
import { resolveDataDir } from '@artblocks/abx-sdk/node';
|
|
3
4
|
export class ContentIndex {
|
|
4
5
|
path;
|
|
5
6
|
data;
|
|
6
7
|
constructor(dataDir) {
|
|
7
|
-
|
|
8
|
+
// Centralized in the SDK — see resolveDataDir's doc comment.
|
|
9
|
+
const base = dataDir ?? resolveDataDir().dir;
|
|
8
10
|
mkdirSync(base, { recursive: true });
|
|
9
11
|
this.path = resolve(base, 'content-index.json');
|
|
10
12
|
this.data = existsSync(this.path) ? JSON.parse(readFileSync(this.path, 'utf8')) : {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-index.js","sourceRoot":"","sources":["../src/content-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"content-index.js","sourceRoot":"","sources":["../src/content-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAcvD,MAAM,OAAO,YAAY;IACd,IAAI,CAAS;IACd,IAAI,CAA6B;IAEzC,YAAY,OAAgB;QAC1B,6DAA6D;QAC7D,MAAM,IAAI,GAAG,OAAO,IAAI,cAAc,EAAE,CAAC,GAAG,CAAC;QAC7C,SAAS,CAAC,IAAI,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAgC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvH,CAAC;IAEO,GAAG,CAAC,IAAS;QACnB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,IAAS;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC;IAC3C,CAAC;IAED,GAAG,CAAC,IAAS;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;IACrC,CAAC;IAED,GAAG,CAAC,IAAS,EAAE,KAAiB;QAC9B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;QAClC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deploy-time image content planning — the pure "which representation" decision behind
|
|
3
|
+
* `--onchain-uri`'s image handling (see reference/hosting.md): the bytes inline directly (SVG),
|
|
4
|
+
* a direct-URL backend hosts them and its URL rides on-chain, or they fall back to off-chain
|
|
5
|
+
* custody anchored by a keccak256 commitment. No I/O, no network — every input is a fact the
|
|
6
|
+
* caller already has in hand (the file's sniffed bytes, the resolved backend id).
|
|
7
|
+
*/
|
|
8
|
+
/** Backends that can hand back a PUBLIC direct URL for uploaded bytes — content-addressed and
|
|
9
|
+
* permanent (ipfs, arweave) or a mutable host with a configured public base (cloud/S3) — the set
|
|
10
|
+
* that makes "image off-chain, on-chain JSON pointing at it, no server" possible. `fs` custody
|
|
11
|
+
* (this machine only) is deliberately excluded: its bytes are never reachable off the machine
|
|
12
|
+
* that stored them. */
|
|
13
|
+
export declare const DIRECT_URL_BACKENDS: ReadonlySet<string>;
|
|
14
|
+
export type ImageContentLane = 'inline-svg' | 'onchain-url' | 'keccak-custody';
|
|
15
|
+
export interface ImageContentDecision {
|
|
16
|
+
lane: ImageContentLane;
|
|
17
|
+
/** True when `onChain` was requested but neither inline-SVG nor a direct-URL backend could
|
|
18
|
+
* honor it, so the on-chain image ends up a placeholder — the caller's cue to warn. */
|
|
19
|
+
onchainFallback: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Which representation an image's on-chain field takes — purely from local facts already in the
|
|
23
|
+
* caller's hand, in priority order: inline SVG > a direct-URL backend's hosted image > keccak
|
|
24
|
+
* custody. `isSvg` must come from sniffing the file's actual bytes (never inferred from the
|
|
25
|
+
* extension alone — a mislabeled raster must not be inlined as SVG, which is why every call site
|
|
26
|
+
* reads the file's head before deciding); `backendId` is the already-resolved storage backend.
|
|
27
|
+
*/
|
|
28
|
+
export declare function decideImageContentLane(input: {
|
|
29
|
+
onChain: boolean;
|
|
30
|
+
isSvg: boolean;
|
|
31
|
+
backendId: string;
|
|
32
|
+
}): ImageContentDecision;
|
|
33
|
+
export type RenderStorageResult = {
|
|
34
|
+
ok: true;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
reason: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Facts about a deploy/render configuration `validateRenderStorageCombo` decides from — every value
|
|
41
|
+
* a caller already has in hand (the raw `--image-base` URL, the resolved storage backend id,
|
|
42
|
+
* whether this operation publishes to a resolver it doesn't share a disk with). No I/O.
|
|
43
|
+
*/
|
|
44
|
+
export interface RenderStorageCombo {
|
|
45
|
+
/** The raw `--image-base <url>` value, if one was given — checked against ITS OWN shape (an
|
|
46
|
+
* ipfs/arweave gateway vs. anything else). This is deliberately unrelated to `backendId` below:
|
|
47
|
+
* `--image-base` names where the EFFECT RUNNER later overwrites a still (its own `ABX_S3_*`
|
|
48
|
+
* config), not where this deploy's own uploads go. */
|
|
49
|
+
imageBaseUrl?: string;
|
|
50
|
+
/** The resolved storage backend id (`fs` · `cloud`/`s3` · `ipfs` · `arweave` · …) — this deploy's
|
|
51
|
+
* OWN upload target, relevant only to {@link RenderStorageCombo.publishesToRemoteResolver} below.
|
|
52
|
+
* Omit when only checking the `imageBaseUrl` combo. */
|
|
53
|
+
backendId?: string;
|
|
54
|
+
/** Only meaningful when `backendId` is `cloud`/`s3`: whether a public read base is configured
|
|
55
|
+
* (`ABX_S3_PUBLIC_BASE` / `--public-base`). Without one, `cloud` can hold bytes but can't hand
|
|
56
|
+
* back a URL for them — same failure mode as a content-addressed backend, for a different reason. */
|
|
57
|
+
cloudHasPublicBase?: boolean;
|
|
58
|
+
/** This operation publishes rendered output to a resolver that may not share this machine's disk
|
|
59
|
+
* (`abx deploy-effects`, `abx render --remote`, `abx effects` against a remote token) — the ONLY
|
|
60
|
+
* case a backend needs to hand back a public URL at all. A co-located runner (`abx effects` on
|
|
61
|
+
* the same host as `abx serve`) never needs one, so omit/false there. */
|
|
62
|
+
publishesToRemoteResolver?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The one source of truth for "does this render × storage combination actually work" — encodes the
|
|
66
|
+
* known-bad combos so a deploy's real run can refuse them and its `--dry-run` can flag the same
|
|
67
|
+
* reason, from the SAME check (see `deploy-code`'s `--image-base` guard and the render/storage
|
|
68
|
+
* dry-run row, and `requirePublishableBackend`'s render/effects refusal, which all call this).
|
|
69
|
+
*
|
|
70
|
+
* Checked in order (a config can only be wrong for one reason at a time — the first match wins):
|
|
71
|
+
* 1. `--image-base` needs a MUTABLE, path-addressed URL (it names a key the effect runner
|
|
72
|
+
* overwrites in place) — a content-addressed gateway URL (ipfs/arweave) can't back a *fixed*
|
|
73
|
+
* per-token address, no matter what this deploy's OWN `--backend` happens to be.
|
|
74
|
+
* 2. Publishing to a resolver that doesn't share this disk needs a backend that can hand back a
|
|
75
|
+
* public URL for what it stores at all — `fs` (and `cloud` with no public base) can't.
|
|
76
|
+
*/
|
|
77
|
+
export declare function validateRenderStorageCombo(combo: RenderStorageCombo): RenderStorageResult;
|
|
78
|
+
//# sourceMappingURL=content-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-plan.d.ts","sourceRoot":"","sources":["../src/content-plan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;wBAIwB;AACxB,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAAyC,CAAC;AAE9F,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,aAAa,GACb,gBAAgB,CAAC;AAErB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,gBAAgB,CAAC;IACvB;4FACwF;IACxF,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,GAAG,oBAAoB,CAKzH;AAED,MAAM,MAAM,mBAAmB,GAAG;IAAC,EAAE,EAAE,IAAI,CAAA;CAAC,GAAG;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC;AAO3E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;2DAGuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;4DAEwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;0GAEsG;IACtG,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;8EAG0E;IAC1E,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,CAuBzF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deploy-time image content planning — the pure "which representation" decision behind
|
|
3
|
+
* `--onchain-uri`'s image handling (see reference/hosting.md): the bytes inline directly (SVG),
|
|
4
|
+
* a direct-URL backend hosts them and its URL rides on-chain, or they fall back to off-chain
|
|
5
|
+
* custody anchored by a keccak256 commitment. No I/O, no network — every input is a fact the
|
|
6
|
+
* caller already has in hand (the file's sniffed bytes, the resolved backend id).
|
|
7
|
+
*/
|
|
8
|
+
/** Backends that can hand back a PUBLIC direct URL for uploaded bytes — content-addressed and
|
|
9
|
+
* permanent (ipfs, arweave) or a mutable host with a configured public base (cloud/S3) — the set
|
|
10
|
+
* that makes "image off-chain, on-chain JSON pointing at it, no server" possible. `fs` custody
|
|
11
|
+
* (this machine only) is deliberately excluded: its bytes are never reachable off the machine
|
|
12
|
+
* that stored them. */
|
|
13
|
+
export const DIRECT_URL_BACKENDS = new Set(['ipfs', 'arweave', 'cloud']);
|
|
14
|
+
/**
|
|
15
|
+
* Which representation an image's on-chain field takes — purely from local facts already in the
|
|
16
|
+
* caller's hand, in priority order: inline SVG > a direct-URL backend's hosted image > keccak
|
|
17
|
+
* custody. `isSvg` must come from sniffing the file's actual bytes (never inferred from the
|
|
18
|
+
* extension alone — a mislabeled raster must not be inlined as SVG, which is why every call site
|
|
19
|
+
* reads the file's head before deciding); `backendId` is the already-resolved storage backend.
|
|
20
|
+
*/
|
|
21
|
+
export function decideImageContentLane(input) {
|
|
22
|
+
if (!input.onChain)
|
|
23
|
+
return { lane: 'keccak-custody', onchainFallback: false };
|
|
24
|
+
if (input.isSvg)
|
|
25
|
+
return { lane: 'inline-svg', onchainFallback: false };
|
|
26
|
+
if (DIRECT_URL_BACKENDS.has(input.backendId))
|
|
27
|
+
return { lane: 'onchain-url', onchainFallback: false };
|
|
28
|
+
return { lane: 'keccak-custody', onchainFallback: true };
|
|
29
|
+
}
|
|
30
|
+
/** Recognizable ipfs/arweave gateway shapes — the same hosts {@link parseLocator}
|
|
31
|
+
* (readiness.ts) treats as content-addressed networks, kept in sync deliberately: a locator this
|
|
32
|
+
* toolkit itself would classify as ipfs/arweave is exactly what `--image-base` can't use either. */
|
|
33
|
+
const CONTENT_ADDRESSED_URL_PATTERN = /ipfs:\/\/|ar:\/\/|\/ipfs\/|\.ipfs\.|ipfs\.io|dweb\.link|w3s\.link|arweave\.net|permagate\.io|vilenarios\.com|ar-io\.dev/i;
|
|
34
|
+
/**
|
|
35
|
+
* The one source of truth for "does this render × storage combination actually work" — encodes the
|
|
36
|
+
* known-bad combos so a deploy's real run can refuse them and its `--dry-run` can flag the same
|
|
37
|
+
* reason, from the SAME check (see `deploy-code`'s `--image-base` guard and the render/storage
|
|
38
|
+
* dry-run row, and `requirePublishableBackend`'s render/effects refusal, which all call this).
|
|
39
|
+
*
|
|
40
|
+
* Checked in order (a config can only be wrong for one reason at a time — the first match wins):
|
|
41
|
+
* 1. `--image-base` needs a MUTABLE, path-addressed URL (it names a key the effect runner
|
|
42
|
+
* overwrites in place) — a content-addressed gateway URL (ipfs/arweave) can't back a *fixed*
|
|
43
|
+
* per-token address, no matter what this deploy's OWN `--backend` happens to be.
|
|
44
|
+
* 2. Publishing to a resolver that doesn't share this disk needs a backend that can hand back a
|
|
45
|
+
* public URL for what it stores at all — `fs` (and `cloud` with no public base) can't.
|
|
46
|
+
*/
|
|
47
|
+
export function validateRenderStorageCombo(combo) {
|
|
48
|
+
if (combo.imageBaseUrl && CONTENT_ADDRESSED_URL_PATTERN.test(combo.imageBaseUrl)) {
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
reason: `--image-base '${combo.imageBaseUrl}' looks like a content-addressed (ipfs/arweave) gateway URL — a new upload there gets a NEW ` +
|
|
52
|
+
`address, so it can't back the SAME per-token URL the effect runner overwrites in place. Use a mutable bucket/CDN URL instead (S3/R2 — a --backend cloud upload target with ABX_S3_PUBLIC_BASE).`,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (combo.publishesToRemoteResolver) {
|
|
56
|
+
const hasLocator = !!combo.backendId && DIRECT_URL_BACKENDS.has(combo.backendId) && (combo.backendId !== 'cloud' || combo.cloudHasPublicBase);
|
|
57
|
+
if (!hasLocator) {
|
|
58
|
+
return {
|
|
59
|
+
ok: false,
|
|
60
|
+
reason: combo.backendId === 'cloud'
|
|
61
|
+
? `'cloud' has no public read base configured (ABX_S3_PUBLIC_BASE) — a resolver on another machine would have nothing to fetch.`
|
|
62
|
+
: `'${combo.backendId}' can't produce a URL for what it stores — a resolver on another machine would have nothing to serve. Use --backend cloud/ipfs/arweave, or render co-located with the resolver.`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { ok: true };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=content-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-plan.js","sourceRoot":"","sources":["../src/content-plan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;wBAIwB;AACxB,MAAM,CAAC,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AAc9F;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAA4D;IACjG,IAAI,CAAC,KAAK,CAAC,OAAO;QAAE,OAAO,EAAC,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,KAAK,EAAC,CAAC;IAC5E,IAAI,KAAK,CAAC,KAAK;QAAE,OAAO,E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.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,MAAM,CAAC;AAE9B,OAAO,KAAK,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAEhE;;;;;;GAMG;AACH,qBAAa,cAAe,YAAW,cAAc;IACnD,QAAQ,CAAC,EAAE,QAAQ;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAET,OAAO,CAAC,EAAE,MAAM;IAO5B,OAAO,CAAC,IAAI;IAIN,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrD,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAS7C,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhC,MAAM,IAAI,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;CAWxD"}
|
package/dist/fs.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
|
+
import { resolveDataDir } from '@artblocks/abx-sdk/node';
|
|
3
4
|
/**
|
|
4
5
|
* The reference backend: content-addressed files on the local disk — "store the
|
|
5
6
|
* bytes on your droplet and serve them." Zero dependencies, the natural floor for
|
|
@@ -11,7 +12,8 @@ export class LocalFsBackend {
|
|
|
11
12
|
id = 'fs';
|
|
12
13
|
dir;
|
|
13
14
|
constructor(dataDir) {
|
|
14
|
-
|
|
15
|
+
// Centralized in the SDK — see resolveDataDir's doc comment.
|
|
16
|
+
const base = dataDir ?? resolveDataDir().dir;
|
|
15
17
|
this.dir = resolve(base, 'content');
|
|
16
18
|
mkdirSync(this.dir, { recursive: true });
|
|
17
19
|
}
|
package/dist/fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AACnF,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AACnF,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAExC,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAGvD;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IAChB,EAAE,GAAG,IAAI,CAAC;IACV,GAAG,CAAS;IAErB,YAAY,OAAgB;QAC1B,6DAA6D;QAC7D,MAAM,IAAI,GAAG,OAAO,IAAI,cAAc,EAAE,CAAC,GAAG,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACpC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IACzC,CAAC;IAEO,IAAI,CAAC,IAAS;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;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rD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,EAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAG,CAAW,CAAC,OAAO,EAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,13 @@ export { LocalFsBackend } from './fs.js';
|
|
|
12
12
|
export { CloudStorageBackend, cloudConfigFromEnv, deriveSigningKey, sigv4Signature, type CloudStorageConfig, type SigV4Input, } from './cloud.js';
|
|
13
13
|
export { ContentIndex, type IndexEntry } from './content-index.js';
|
|
14
14
|
export { IpfsBackend, ipfsConfigFromEnv, type IpfsConfig } from './ipfs.js';
|
|
15
|
-
export { ArweaveBackend, HttpBundlerUploader,
|
|
15
|
+
export { ArweaveBackend, HttpBundlerUploader, arweaveConfigFromEnv, resolveArweaveJwk, arweaveKeyFilePath, arweaveFunding, arweaveProvider, turboIdentity, resolveTurboIdentity, turboIdentityAddress, isEthIdentity, ARWEAVE_FREE_UPLOAD_LIMIT, turboUploadCostUsd, turboUploadWinc, turboBalanceForAddress, type ArweaveConfig, type ArweaveProvider, type ArweaveUploader, type ArweaveFunding, type TurboIdentity, } from './arweave.js';
|
|
16
16
|
export { generateArweaveJwk, arweaveAddress, type ArweaveJwk } from './arweave-identity.js';
|
|
17
17
|
export { resolveBackend, type ResolveStorageOptions } from './resolve.js';
|
|
18
|
+
export { repinNodeCustody, type RepinResult } from './migrate.js';
|
|
19
|
+
export { uploadAndLocate, type UploadResult } from './upload.js';
|
|
20
|
+
export { DIRECT_URL_BACKENDS, decideImageContentLane, validateRenderStorageCombo, type ImageContentLane, type ImageContentDecision, type RenderStorageCombo, type RenderStorageResult, } from './content-plan.js';
|
|
21
|
+
export { isTurboArweave, planTurboUpload, assessStorageReadiness, assessTurboFunds, type TurboUploadPlan, type StorageReadinessReport, type TurboFundsCheck, } from './upload-readiness.js';
|
|
22
|
+
export { locatorStatus, awaitLocatorReady, parseLocator, probeGateway, gatewayUrlFor, resolveGatewayBase, type LocatorStatus, type LocatorStatusOptions, type LocatorNetwork, type GatewayProbe, type Readiness, type AwaitLocatorReadyOptions, type AwaitLocatorReadyEvent, type AwaitLocatorReadyResult, } from './readiness.js';
|
|
23
|
+
export { probeStorageBackend, checkCloudBackend, checkArweaveBackend, checkViaHealth, type StorageCheckResult, type StorageCheckOptions, } from './probe.js';
|
|
18
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,YAAY,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAChE,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,YAAY,EAAE,KAAK,UAAU,EAAC,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAC,WAAW,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAC,MAAM,WAAW,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,YAAY,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAChE,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,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Aa,EAClB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,13 @@ export { LocalFsBackend } from './fs.js';
|
|
|
3
3
|
export { CloudStorageBackend, cloudConfigFromEnv, deriveSigningKey, sigv4Signature, } from './cloud.js';
|
|
4
4
|
export { ContentIndex } from './content-index.js';
|
|
5
5
|
export { IpfsBackend, ipfsConfigFromEnv } from './ipfs.js';
|
|
6
|
-
export { ArweaveBackend, HttpBundlerUploader,
|
|
6
|
+
export { ArweaveBackend, HttpBundlerUploader, arweaveConfigFromEnv, resolveArweaveJwk, arweaveKeyFilePath, arweaveFunding, arweaveProvider, turboIdentity, resolveTurboIdentity, turboIdentityAddress, isEthIdentity, ARWEAVE_FREE_UPLOAD_LIMIT, turboUploadCostUsd, turboUploadWinc, turboBalanceForAddress, } from './arweave.js';
|
|
7
7
|
export { generateArweaveJwk, arweaveAddress } from './arweave-identity.js';
|
|
8
8
|
export { resolveBackend } from './resolve.js';
|
|
9
|
+
export { repinNodeCustody } from './migrate.js';
|
|
10
|
+
export { uploadAndLocate } from './upload.js';
|
|
11
|
+
export { DIRECT_URL_BACKENDS, decideImageContentLane, validateRenderStorageCombo, } from './content-plan.js';
|
|
12
|
+
export { isTurboArweave, planTurboUpload, assessStorageReadiness, assessTurboFunds, } from './upload-readiness.js';
|
|
13
|
+
export { locatorStatus, awaitLocatorReady, parseLocator, probeGateway, gatewayUrlFor, resolveGatewayBase, } from './readiness.js';
|
|
14
|
+
export { probeStorageBackend, checkCloudBackend, checkArweaveBackend, checkViaHealth, } from './probe.js';
|
|
9
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GAGf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,YAAY,EAAkB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAC,WAAW,EAAE,iBAAiB,EAAkB,MAAM,WAAW,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GAGf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,YAAY,EAAkB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAC,WAAW,EAAE,iBAAiB,EAAkB,MAAM,WAAW,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,GAMvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,kBAAkB,EAAE,cAAc,EAAkB,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAC,cAAc,EAA6B,MAAM,cAAc,CAAC;AACxE,OAAO,EAAC,gBAAgB,EAAmB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAC,eAAe,EAAoB,MAAM,aAAa,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,GAK3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,gBAAgB,GAIjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,kBAAkB,GASnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,GAGf,MAAM,YAAY,CAAC"}
|
package/dist/ipfs.d.ts
CHANGED
|
@@ -44,7 +44,8 @@ export declare class IpfsBackend implements StorageBackend {
|
|
|
44
44
|
/**
|
|
45
45
|
* Pin a directory of files as ONE IPFS object and return its gateway base
|
|
46
46
|
* (`<gateway>/ipfs/<dirCID>`), so `<base>/0.png` resolves. The CID is content-addressed →
|
|
47
|
-
* gateway-agnostic integrity for the whole set.
|
|
47
|
+
* gateway-agnostic integrity for the whole set. `kubo` recurses through a local node (below);
|
|
48
|
+
* `pinata` pins through the managed service.
|
|
48
49
|
*/
|
|
49
50
|
putDirectory(entries: DirEntry[]): Promise<{
|
|
50
51
|
base: string;
|
|
@@ -55,6 +56,21 @@ export declare class IpfsBackend implements StorageBackend {
|
|
|
55
56
|
}>;
|
|
56
57
|
private form;
|
|
57
58
|
private addKubo;
|
|
59
|
+
/**
|
|
60
|
+
* Recursive directory add through a local Kubo node's `/api/v0/add`. Each entry is appended as
|
|
61
|
+
* its own multipart part with a filename under a common `abx/` prefix — Kubo infers the
|
|
62
|
+
* directory tree from the slash-separated filenames (the same trick the Pinata path above uses),
|
|
63
|
+
* so `abx/index.html` lands at `index.html` under the returned root, not nested under a temp
|
|
64
|
+
* wrapper name. `recursive=true` tells Kubo to accept and pin that multi-file tree rather than
|
|
65
|
+
* erroring on more than one `file` part.
|
|
66
|
+
*
|
|
67
|
+
* Kubo streams one NDJSON object per added path, ending with the wrapping `abx` directory once
|
|
68
|
+
* everything beneath it has landed — so that final line is the "the whole tree is in and
|
|
69
|
+
* pinned" signal. A dropped connection, a killed node, or a mid-stream error object never
|
|
70
|
+
* produces it, so anything short of a clean, fully-parsed stream ending in that line throws
|
|
71
|
+
* rather than returning a CID for a partial upload.
|
|
72
|
+
*/
|
|
73
|
+
private addKuboDirectory;
|
|
58
74
|
private addPinata;
|
|
59
75
|
}
|
|
60
76
|
/** Build an IPFS config from the environment (non-secret values; PINATA_JWT is the secret). */
|
package/dist/ipfs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs.d.ts","sourceRoot":"","sources":["../src/ipfs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,EAAC,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAG1E;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,kGAAkG;IAClG,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,qBAAa,WAAY,YAAW,cAAc;IAIpC,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHhC,QAAQ,CAAC,EAAE,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;gBAER,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM;IAIxD,GAAG,CAAC,IAAI,EA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AAG,OAAO,CAAC,OAAO,CAAC;IAItC;;;;;;;OAOG;IACG,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKhD;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC;IAwB1D,MAAM,IAAI,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IAiBvD,OAAO,CAAC,IAAI;YAME,OAAO;IAUrB;;;;;;;;;;;;;OAaG;YACW,gBAAgB;YAsChB,SAAS;CAYxB;AAED,+FAA+F;AAC/F,wBAAgB,iBAAiB,IAAI,UAAU,CAS9C"}
|
package/dist/ipfs.js
CHANGED
|
@@ -42,11 +42,13 @@ export class IpfsBackend {
|
|
|
42
42
|
/**
|
|
43
43
|
* Pin a directory of files as ONE IPFS object and return its gateway base
|
|
44
44
|
* (`<gateway>/ipfs/<dirCID>`), so `<base>/0.png` resolves. The CID is content-addressed →
|
|
45
|
-
* gateway-agnostic integrity for the whole set.
|
|
45
|
+
* gateway-agnostic integrity for the whole set. `kubo` recurses through a local node (below);
|
|
46
|
+
* `pinata` pins through the managed service.
|
|
46
47
|
*/
|
|
47
48
|
async putDirectory(entries) {
|
|
48
49
|
if (this.cfg.mode !== 'pinata') {
|
|
49
|
-
|
|
50
|
+
const cid = await this.addKuboDirectory(entries);
|
|
51
|
+
return { base: `${trim(this.cfg.gateway)}/ipfs/${cid}` };
|
|
50
52
|
}
|
|
51
53
|
if (!this.cfg.pinataJwt)
|
|
52
54
|
throw new Error('IPFS pinata mode needs PINATA_JWT');
|
|
@@ -105,6 +107,62 @@ export class IpfsBackend {
|
|
|
105
107
|
throw new Error('IPFS add returned no CID');
|
|
106
108
|
return cid;
|
|
107
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Recursive directory add through a local Kubo node's `/api/v0/add`. Each entry is appended as
|
|
112
|
+
* its own multipart part with a filename under a common `abx/` prefix — Kubo infers the
|
|
113
|
+
* directory tree from the slash-separated filenames (the same trick the Pinata path above uses),
|
|
114
|
+
* so `abx/index.html` lands at `index.html` under the returned root, not nested under a temp
|
|
115
|
+
* wrapper name. `recursive=true` tells Kubo to accept and pin that multi-file tree rather than
|
|
116
|
+
* erroring on more than one `file` part.
|
|
117
|
+
*
|
|
118
|
+
* Kubo streams one NDJSON object per added path, ending with the wrapping `abx` directory once
|
|
119
|
+
* everything beneath it has landed — so that final line is the "the whole tree is in and
|
|
120
|
+
* pinned" signal. A dropped connection, a killed node, or a mid-stream error object never
|
|
121
|
+
* produces it, so anything short of a clean, fully-parsed stream ending in that line throws
|
|
122
|
+
* rather than returning a CID for a partial upload.
|
|
123
|
+
*/
|
|
124
|
+
async addKuboDirectory(entries) {
|
|
125
|
+
if (!this.cfg.apiUrl)
|
|
126
|
+
throw new Error('IPFS kubo mode needs an apiUrl (e.g. http://127.0.0.1:5001)');
|
|
127
|
+
const wrapName = 'abx';
|
|
128
|
+
const fd = new FormData();
|
|
129
|
+
for (const e of entries) {
|
|
130
|
+
fd.append('file', new Blob([e.bytes], { type: e.contentType }), `${wrapName}/${e.name}`);
|
|
131
|
+
}
|
|
132
|
+
const res = await fetch(`${trim(this.cfg.apiUrl)}/api/v0/add?recursive=true&pin=true&cid-version=1`, {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
body: fd,
|
|
135
|
+
});
|
|
136
|
+
const text = await res.text();
|
|
137
|
+
if (!res.ok)
|
|
138
|
+
throw new Error(`IPFS directory add failed (${res.status}): ${text}`);
|
|
139
|
+
const lines = text
|
|
140
|
+
.split('\n')
|
|
141
|
+
.map((l) => l.trim())
|
|
142
|
+
.filter(Boolean);
|
|
143
|
+
if (lines.length === 0)
|
|
144
|
+
throw new Error('IPFS directory add returned no output');
|
|
145
|
+
let root;
|
|
146
|
+
for (const line of lines) {
|
|
147
|
+
let obj;
|
|
148
|
+
try {
|
|
149
|
+
obj = JSON.parse(line);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// A cut-off connection lands mid-object — surface that as a truncation, not a JSON bug.
|
|
153
|
+
throw new Error(`IPFS directory add returned malformed output (truncated stream?): ${line}`);
|
|
154
|
+
}
|
|
155
|
+
// Kubo reports a failed file (e.g. it ran out of disk mid-add) as a JSON object on the same
|
|
156
|
+
// stream instead of a non-2xx status, so a per-line check is the only way to catch it.
|
|
157
|
+
if (obj.Type === 'error')
|
|
158
|
+
throw new Error(`IPFS directory add failed mid-stream: ${obj.Message ?? line}`);
|
|
159
|
+
if (obj.Name === wrapName && obj.Hash)
|
|
160
|
+
root = obj.Hash;
|
|
161
|
+
}
|
|
162
|
+
if (!root)
|
|
163
|
+
throw new Error('IPFS directory add stream ended without the wrapping directory CID (partial upload?)');
|
|
164
|
+
return root;
|
|
165
|
+
}
|
|
108
166
|
async addPinata(content) {
|
|
109
167
|
if (!this.cfg.pinataJwt)
|
|
110
168
|
throw new Error('IPFS pinata mode needs PINATA_JWT');
|
package/dist/ipfs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs.js","sourceRoot":"","sources":["../src/ipfs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AA2BhD,MAAM,IAAI,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAE1D,MAAM,OAAO,WAAW;IAIO;IAHpB,EAAE,GAAG,MAAM,CAAC;IACJ,KAAK,CAAe;IAErC,YAA6B,GAAe,EAAE,OAAgB;QAAjC,QAAG,GAAH,GAAG,CAAY;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,IAAS,EAAE,OAAsB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AG;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACxD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAED,+FAA+F;AAC/F,MAAM,UAAU,iBAAiB;IAC/B,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAsB,CAAC;IAC9G,OAAO;QACL,IAAI;QACJ,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,uBAAuB,CAAC;QACvH,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB;QAC/D,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,0BAA0B;QAC7E,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storage half of a resolver migration: re-pinning node-custody images to a durable backend.
|
|
3
|
+
*
|
|
4
|
+
* The rest of the migration — reconciling a destination resolver's off-chain state against a
|
|
5
|
+
* source resolver's served JSON (`buildMigrationPlan`/`verifyParity`) — is pure fetch-based
|
|
6
|
+
* reconciliation with no storage dependency, so it lives in `@artblocks/abx-sdk`'s `migrate.ts`.
|
|
7
|
+
* This module is the one piece that needs an actual byte-custody backend: turning a
|
|
8
|
+
* {@link NodeCustodyImage} (bytes that live only on the soon-to-be-decommissioned source host)
|
|
9
|
+
* into a portable, durable locator.
|
|
10
|
+
*/
|
|
11
|
+
import { type StorageBackend } from './backend.js';
|
|
12
|
+
import type { NodeCustodyImage } from '@artblocks/abx-sdk';
|
|
13
|
+
/**
|
|
14
|
+
* Re-pin node-custody images to a DURABLE backend so the destination never depends on the
|
|
15
|
+
* (soon-to-be-decommissioned) source host. For each image: fetch the bytes from the source,
|
|
16
|
+
* **verify** them against the on-chain hash (trustless — we trust the chain, not the old node),
|
|
17
|
+
* then `put` them to the destination operator's own backend and read back a portable locator.
|
|
18
|
+
*
|
|
19
|
+
* If the configured backend isn't durable (no `locator` — fs/cloud serve only through their own
|
|
20
|
+
* node, so re-pinning there just moves the single-host dependency), we re-pin NOTHING and report
|
|
21
|
+
* every image as `needsDurableBackend`: the right move is to configure IPFS/Arweave and re-run,
|
|
22
|
+
* never to bridge a URL that points back at the dying host.
|
|
23
|
+
*/
|
|
24
|
+
export interface RepinResult {
|
|
25
|
+
/** hash → new durable locator, ready to bridge to the destination. */
|
|
26
|
+
repinned: Record<string, string>;
|
|
27
|
+
/** Re-pinned token ids (for reporting). */
|
|
28
|
+
repinnedTokens: string[];
|
|
29
|
+
/** Bytes fetched but their hash didn't match the on-chain commitment — NOT trusted, NOT pinned. */
|
|
30
|
+
mismatched: NodeCustodyImage[];
|
|
31
|
+
/** Couldn't fetch the bytes from the source (host down, 404). */
|
|
32
|
+
unreachable: NodeCustodyImage[];
|
|
33
|
+
/** Skipped because no durable backend is configured — these need IPFS/Arweave + a re-run. */
|
|
34
|
+
needsDurableBackend: NodeCustodyImage[];
|
|
35
|
+
}
|
|
36
|
+
export declare function repinNodeCustody(images: NodeCustodyImage[], backend: StorageBackend): Promise<RepinResult>;
|
|
37
|
+
//# sourceMappingURL=migrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAc,KAAK,cAAc,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAGzD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,2CAA2C;IAC3C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,mGAAmG;IACnG,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,iEAAiE;IACjE,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,6FAA6F;IAC7F,mBAAmB,EAAE,gBAAgB,EAAE,CAAC;CACzC;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAyChH"}
|
package/dist/migrate.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storage half of a resolver migration: re-pinning node-custody images to a durable backend.
|
|
3
|
+
*
|
|
4
|
+
* The rest of the migration — reconciling a destination resolver's off-chain state against a
|
|
5
|
+
* source resolver's served JSON (`buildMigrationPlan`/`verifyParity`) — is pure fetch-based
|
|
6
|
+
* reconciliation with no storage dependency, so it lives in `@artblocks/abx-sdk`'s `migrate.ts`.
|
|
7
|
+
* This module is the one piece that needs an actual byte-custody backend: turning a
|
|
8
|
+
* {@link NodeCustodyImage} (bytes that live only on the soon-to-be-decommissioned source host)
|
|
9
|
+
* into a portable, durable locator.
|
|
10
|
+
*/
|
|
11
|
+
import { hashContent } from './backend.js';
|
|
12
|
+
export async function repinNodeCustody(images, backend) {
|
|
13
|
+
const result = { repinned: {}, repinnedTokens: [], mismatched: [], unreachable: [], needsDurableBackend: [] };
|
|
14
|
+
if (!images.length)
|
|
15
|
+
return result;
|
|
16
|
+
// A backend is "durable" for migration iff it can hand back a node-independent locator.
|
|
17
|
+
if (!backend.locator) {
|
|
18
|
+
result.needsDurableBackend = [...images];
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
for (const img of images) {
|
|
22
|
+
let bytes;
|
|
23
|
+
let contentType;
|
|
24
|
+
try {
|
|
25
|
+
const resp = await fetch(img.imageUrl);
|
|
26
|
+
if (!resp.ok) {
|
|
27
|
+
result.unreachable.push(img);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
bytes = new Uint8Array(await resp.arrayBuffer());
|
|
31
|
+
contentType = resp.headers.get('content-type') ?? 'application/octet-stream';
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
result.unreachable.push(img);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// Trustless: re-hash the fetched bytes and compare to the ON-CHAIN commitment.
|
|
38
|
+
if (hashContent(bytes).toLowerCase() !== img.hash.toLowerCase()) {
|
|
39
|
+
result.mismatched.push(img);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
await backend.put(img.hash, { bytes, contentType });
|
|
43
|
+
const loc = await backend.locator(img.hash);
|
|
44
|
+
if (loc) {
|
|
45
|
+
result.repinned[img.hash.toLowerCase()] = loc;
|
|
46
|
+
result.repinnedTokens.push(img.tokenId);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Stored, but the backend still can't produce a portable locator — treat as not durable.
|
|
50
|
+
result.needsDurableBackend.push(img);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAC,WAAW,EAAsB,MAAM,cAAc,CAAC;AA4B9D,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAA0B,EAAE,OAAuB;IACxF,MAAM,MAAM,GAAgB,EAAC,QAAQ,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAC,CAAC;IACzH,IAAI,CAAC,MA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