@dignetwork/dig-sdk 0.0.1-alpha.98 → 0.1.0
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/LICENSE +21 -7
- package/README.md +267 -0
- package/dist/adapters.cjs +315 -0
- package/dist/adapters.cjs.map +1 -0
- package/dist/adapters.d.cts +20 -0
- package/dist/adapters.d.ts +20 -0
- package/dist/adapters.js +306 -0
- package/dist/adapters.js.map +1 -0
- package/dist/dev-shim-Bgw8X2E9.d.cts +118 -0
- package/dist/dev-shim-Bgw8X2E9.d.ts +118 -0
- package/dist/dig-client-entry-BIzuZ7Rs.d.cts +263 -0
- package/dist/dig-client-entry-BIzuZ7Rs.d.ts +263 -0
- package/dist/dig-client.cjs +330 -0
- package/dist/dig-client.cjs.map +1 -0
- package/dist/dig-client.d.cts +1 -0
- package/dist/dig-client.d.ts +1 -0
- package/dist/dig-client.js +319 -0
- package/dist/dig-client.js.map +1 -0
- package/dist/index.cjs +754 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +192 -0
- package/dist/index.d.ts +192 -5
- package/dist/index.js +731 -19
- package/dist/index.js.map +1 -0
- package/dist/next.cjs +326 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +23 -0
- package/dist/next.d.ts +23 -0
- package/dist/next.js +319 -0
- package/dist/next.js.map +1 -0
- package/dist/spend.cjs +14 -0
- package/dist/spend.cjs.map +1 -0
- package/dist/spend.d.cts +1 -0
- package/dist/spend.d.ts +1 -0
- package/dist/spend.js +3 -0
- package/dist/spend.js.map +1 -0
- package/dist/vite.cjs +338 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +35 -0
- package/dist/vite.d.ts +35 -0
- package/dist/vite.js +332 -0
- package/dist/vite.js.map +1 -0
- package/package.json +87 -59
- package/vendor/PROVENANCE.md +102 -0
- package/vendor/dig_client.d.ts +150 -0
- package/vendor/dig_client.mjs +805 -0
- package/vendor/dig_client_bg.wasm +0 -0
- package/dist/DataIntegrityTree/DataIntegrityTree.d.ts +0 -163
- package/dist/DataIntegrityTree/DataIntegrityTree.d.ts.map +0 -1
- package/dist/DataIntegrityTree/DataIntegrityTree.js +0 -707
- package/dist/DataIntegrityTree/DataLayerError.d.ts +0 -6
- package/dist/DataIntegrityTree/DataLayerError.d.ts.map +0 -1
- package/dist/DataIntegrityTree/DataLayerError.js +0 -17
- package/dist/DataIntegrityTree/index.d.ts +0 -2
- package/dist/DataIntegrityTree/index.d.ts.map +0 -1
- package/dist/DataIntegrityTree/index.js +0 -17
- package/dist/DigNetwork/ContentServer.d.ts +0 -33
- package/dist/DigNetwork/ContentServer.d.ts.map +0 -1
- package/dist/DigNetwork/ContentServer.js +0 -308
- package/dist/DigNetwork/DigChallenge.d.ts +0 -82
- package/dist/DigNetwork/DigChallenge.d.ts.map +0 -1
- package/dist/DigNetwork/DigChallenge.js +0 -144
- package/dist/DigNetwork/DigNetwork.d.ts +0 -14
- package/dist/DigNetwork/DigNetwork.d.ts.map +0 -1
- package/dist/DigNetwork/DigNetwork.js +0 -169
- package/dist/DigNetwork/DigPeer.d.ts +0 -24
- package/dist/DigNetwork/DigPeer.d.ts.map +0 -1
- package/dist/DigNetwork/DigPeer.js +0 -118
- package/dist/DigNetwork/IncentiveServer.d.ts +0 -13
- package/dist/DigNetwork/IncentiveServer.d.ts.map +0 -1
- package/dist/DigNetwork/IncentiveServer.js +0 -76
- package/dist/DigNetwork/PropagationServer.d.ts +0 -75
- package/dist/DigNetwork/PropagationServer.d.ts.map +0 -1
- package/dist/DigNetwork/PropagationServer.js +0 -536
- package/dist/DigNetwork/index.d.ts +0 -4
- package/dist/DigNetwork/index.d.ts.map +0 -1
- package/dist/DigNetwork/index.js +0 -19
- package/dist/blockchain/DataStore.d.ts +0 -67
- package/dist/blockchain/DataStore.d.ts.map +0 -1
- package/dist/blockchain/DataStore.js +0 -413
- package/dist/blockchain/DataStoreSerializer.d.ts +0 -52
- package/dist/blockchain/DataStoreSerializer.d.ts.map +0 -1
- package/dist/blockchain/DataStoreSerializer.js +0 -109
- package/dist/blockchain/FullNodePeer.d.ts +0 -31
- package/dist/blockchain/FullNodePeer.d.ts.map +0 -1
- package/dist/blockchain/FullNodePeer.js +0 -295
- package/dist/blockchain/ServerCoin.d.ts +0 -29
- package/dist/blockchain/ServerCoin.d.ts.map +0 -1
- package/dist/blockchain/ServerCoin.js +0 -321
- package/dist/blockchain/Wallet.d.ts +0 -28
- package/dist/blockchain/Wallet.d.ts.map +0 -1
- package/dist/blockchain/Wallet.js +0 -253
- package/dist/blockchain/coins.d.ts +0 -6
- package/dist/blockchain/coins.d.ts.map +0 -1
- package/dist/blockchain/coins.js +0 -102
- package/dist/blockchain/index.d.ts +0 -8
- package/dist/blockchain/index.d.ts.map +0 -1
- package/dist/blockchain/index.js +0 -36
- package/dist/index.d.ts.map +0 -1
- package/dist/prompts.d.ts +0 -21
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js +0 -149
- package/dist/types.d.ts +0 -64
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/utils/ContentScanner.d.ts +0 -63
- package/dist/utils/ContentScanner.d.ts.map +0 -1
- package/dist/utils/ContentScanner.js +0 -175
- package/dist/utils/Environment.d.ts +0 -18
- package/dist/utils/Environment.d.ts.map +0 -1
- package/dist/utils/Environment.js +0 -85
- package/dist/utils/FileCache.d.ts +0 -11
- package/dist/utils/FileCache.d.ts.map +0 -1
- package/dist/utils/FileCache.js +0 -58
- package/dist/utils/FileTransfer.d.ts +0 -47
- package/dist/utils/FileTransfer.d.ts.map +0 -1
- package/dist/utils/FileTransfer.js +0 -209
- package/dist/utils/NconfManager.d.ts +0 -11
- package/dist/utils/NconfManager.d.ts.map +0 -1
- package/dist/utils/NconfManager.js +0 -56
- package/dist/utils/StoreArchiveManager.d.ts +0 -45
- package/dist/utils/StoreArchiveManager.d.ts.map +0 -1
- package/dist/utils/StoreArchiveManager.js +0 -153
- package/dist/utils/asyncPool.d.ts +0 -9
- package/dist/utils/asyncPool.d.ts.map +0 -1
- package/dist/utils/asyncPool.js +0 -23
- package/dist/utils/config.d.ts +0 -68
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -223
- package/dist/utils/connectionUtils.d.ts +0 -10
- package/dist/utils/connectionUtils.d.ts.map +0 -1
- package/dist/utils/connectionUtils.js +0 -18
- package/dist/utils/credentialsUtils.d.ts +0 -8
- package/dist/utils/credentialsUtils.d.ts.map +0 -1
- package/dist/utils/credentialsUtils.js +0 -122
- package/dist/utils/directoryUtils.d.ts +0 -9
- package/dist/utils/directoryUtils.d.ts.map +0 -1
- package/dist/utils/directoryUtils.js +0 -110
- package/dist/utils/encryption.d.ts +0 -8
- package/dist/utils/encryption.d.ts.map +0 -1
- package/dist/utils/encryption.js +0 -55
- package/dist/utils/hashUtils.d.ts +0 -8
- package/dist/utils/hashUtils.d.ts.map +0 -1
- package/dist/utils/hashUtils.js +0 -44
- package/dist/utils/index.d.ts +0 -14
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -29
- package/dist/utils/merkle.d.ts +0 -2
- package/dist/utils/merkle.d.ts.map +0 -1
- package/dist/utils/merkle.js +0 -28
- package/dist/utils/network.d.ts +0 -2
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js +0 -54
- package/dist/utils/spinnerUtils.d.ts +0 -2
- package/dist/utils/spinnerUtils.d.ts.map +0 -1
- package/dist/utils/spinnerUtils.js +0 -47
- package/dist/utils/ssl.d.ts +0 -5
- package/dist/utils/ssl.d.ts.map +0 -1
- package/dist/utils/ssl.js +0 -50
- package/dist/utils/validationUtils.d.ts +0 -9
- package/dist/utils/validationUtils.d.ts.map +0 -1
- package/dist/utils/validationUtils.js +0 -55
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// src/provider/injected.ts
|
|
6
|
+
var INJECTED_TOPIC = "injected";
|
|
7
|
+
|
|
8
|
+
// src/adapters/dev-shim.ts
|
|
9
|
+
var DEV_SHIM_MARKER = "dig-sdk:dev-wallet-shim";
|
|
10
|
+
var DEFAULT_DEV_ADDRESS = "xch1dev0000000000000000000000000000000000000000000000000000devshim";
|
|
11
|
+
function lit(s) {
|
|
12
|
+
return JSON.stringify(s);
|
|
13
|
+
}
|
|
14
|
+
function devShimScript(options = {}) {
|
|
15
|
+
const address = options.address ?? DEFAULT_DEV_ADDRESS;
|
|
16
|
+
return [
|
|
17
|
+
`/* ${DEV_SHIM_MARKER} \u2014 DEV ONLY. A stub wallet for local development; NOT a real wallet. */`,
|
|
18
|
+
`(function () {`,
|
|
19
|
+
` "use strict";`,
|
|
20
|
+
` if (typeof window === "undefined") return;`,
|
|
21
|
+
` // A real injected wallet (DIG Browser / extension) always wins \u2014 never clobber it.`,
|
|
22
|
+
` if (window.chia) return;`,
|
|
23
|
+
` var DEV_ADDRESS = ${lit(address)};`,
|
|
24
|
+
` var TOPIC = ${lit(INJECTED_TOPIC)};`,
|
|
25
|
+
` function ok(data) { return Promise.resolve({ data: data }); }`,
|
|
26
|
+
` function nope(method) {`,
|
|
27
|
+
` return Promise.reject(new Error(`,
|
|
28
|
+
` "[" + ${lit(DEV_SHIM_MARKER)} + "] '" + method + "' needs a real wallet; the dev shim does not sign. " +`,
|
|
29
|
+
` "Open in the DIG Browser or connect a wallet to sign for real."));`,
|
|
30
|
+
` }`,
|
|
31
|
+
` window.chia = {`,
|
|
32
|
+
` isDIG: true, // detected by the SDK's injected-provider check`,
|
|
33
|
+
` isDevShim: true, // so the app can tell it is the dev stub`,
|
|
34
|
+
` topic: TOPIC,`,
|
|
35
|
+
` connect: function () { return Promise.resolve(true); },`,
|
|
36
|
+
` request: function (args) {`,
|
|
37
|
+
` var method = args && args.method ? String(args.method) : "";`,
|
|
38
|
+
` switch (method) {`,
|
|
39
|
+
` case "chip0002_connect": return ok(true);`,
|
|
40
|
+
` case "chip0002_getPublicKeys": return ok([]);`,
|
|
41
|
+
` case "getAddress":`,
|
|
42
|
+
` case "chia_getAddress": return ok(DEV_ADDRESS);`,
|
|
43
|
+
` default:`,
|
|
44
|
+
` // Signing / spend methods must not be faked.`,
|
|
45
|
+
` return nope(method);`,
|
|
46
|
+
` }`,
|
|
47
|
+
` },`,
|
|
48
|
+
` on: function () {},`,
|
|
49
|
+
` off: function () {},`,
|
|
50
|
+
` };`,
|
|
51
|
+
` if (window.console && window.console.info) {`,
|
|
52
|
+
` window.console.info("[" + ${lit(DEV_SHIM_MARKER)} + "] installed a DEV window.chia (mock address " + DEV_ADDRESS + ").");`,
|
|
53
|
+
` }`,
|
|
54
|
+
`})();`
|
|
55
|
+
].join("\n");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/adapters/config.ts
|
|
59
|
+
function envVal(env, key) {
|
|
60
|
+
const v = env[key];
|
|
61
|
+
if (v == null) return void 0;
|
|
62
|
+
const t = v.trim();
|
|
63
|
+
return t === "" ? void 0 : t;
|
|
64
|
+
}
|
|
65
|
+
function pick(...candidates) {
|
|
66
|
+
for (const c of candidates) if (c !== void 0) return c;
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
function resolveDeployConfig(input) {
|
|
70
|
+
const { options, digToml, env } = input;
|
|
71
|
+
const storeId = pick(
|
|
72
|
+
options.storeId,
|
|
73
|
+
envVal(env, "DIGSTORE_STORE_ID"),
|
|
74
|
+
digToml.storeId
|
|
75
|
+
);
|
|
76
|
+
const outputDir = pick(options.outputDir, envVal(env, "DIGSTORE_OUTPUT_DIR"), digToml.outputDir) ?? "dist";
|
|
77
|
+
const buildCommand = pick(
|
|
78
|
+
options.buildCommand,
|
|
79
|
+
envVal(env, "DIGSTORE_BUILD_COMMAND"),
|
|
80
|
+
digToml.buildCommand
|
|
81
|
+
);
|
|
82
|
+
const message = pick(options.message, envVal(env, "DIGSTORE_MESSAGE"), digToml.message);
|
|
83
|
+
const network = pick(options.network, envVal(env, "DIGSTORE_NETWORK"), digToml.network) ?? "mainnet";
|
|
84
|
+
const remote = pick(options.remote, envVal(env, "DIGSTORE_REMOTE"), digToml.remote);
|
|
85
|
+
const waitFromEnv = envVal(env, "DIGSTORE_WAIT_TIMEOUT");
|
|
86
|
+
const waitTimeout = pick(
|
|
87
|
+
options.waitTimeout,
|
|
88
|
+
waitFromEnv != null ? Number.parseInt(waitFromEnv, 10) : void 0,
|
|
89
|
+
digToml.waitTimeout
|
|
90
|
+
);
|
|
91
|
+
return {
|
|
92
|
+
storeId,
|
|
93
|
+
outputDir,
|
|
94
|
+
buildCommand,
|
|
95
|
+
message,
|
|
96
|
+
network,
|
|
97
|
+
remote,
|
|
98
|
+
waitTimeout: Number.isFinite(waitTimeout) ? waitTimeout : void 0,
|
|
99
|
+
// SECRETS — env only.
|
|
100
|
+
deployKey: envVal(env, "DIGSTORE_DEPLOY_KEY"),
|
|
101
|
+
salt: envVal(env, "DIGSTORE_STORE_SALT")
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/adapters/dig-toml.ts
|
|
106
|
+
var KEY_MAP = {
|
|
107
|
+
store_id: "storeId",
|
|
108
|
+
"store-id": "storeId",
|
|
109
|
+
output_dir: "outputDir",
|
|
110
|
+
"output-dir": "outputDir",
|
|
111
|
+
build_command: "buildCommand",
|
|
112
|
+
"build-command": "buildCommand",
|
|
113
|
+
message: "message",
|
|
114
|
+
network: "network",
|
|
115
|
+
remote: "remote",
|
|
116
|
+
wait_timeout: "waitTimeout",
|
|
117
|
+
"wait-timeout": "waitTimeout"
|
|
118
|
+
};
|
|
119
|
+
var APPLY_ORDER = Object.keys(KEY_MAP).sort(
|
|
120
|
+
(a) => a.includes("-") ? 1 : -1
|
|
121
|
+
);
|
|
122
|
+
function stripComment(line) {
|
|
123
|
+
let inSingle = false;
|
|
124
|
+
let inDouble = false;
|
|
125
|
+
for (let i = 0; i < line.length; i++) {
|
|
126
|
+
const ch = line[i];
|
|
127
|
+
if (ch === "'" && !inDouble) inSingle = !inSingle;
|
|
128
|
+
else if (ch === '"' && !inSingle) inDouble = !inDouble;
|
|
129
|
+
else if (ch === "#" && !inSingle && !inDouble) return line.slice(0, i);
|
|
130
|
+
}
|
|
131
|
+
return line;
|
|
132
|
+
}
|
|
133
|
+
function unquote(raw) {
|
|
134
|
+
const v = raw.trim();
|
|
135
|
+
if (v.startsWith('"') && v.endsWith('"') && v.length >= 2 || v.startsWith("'") && v.endsWith("'") && v.length >= 2) {
|
|
136
|
+
return v.slice(1, -1);
|
|
137
|
+
}
|
|
138
|
+
return v;
|
|
139
|
+
}
|
|
140
|
+
function parseDigToml(text) {
|
|
141
|
+
const raw = {};
|
|
142
|
+
for (const lineRaw of text.split(/\r?\n/)) {
|
|
143
|
+
const line = stripComment(lineRaw).trim();
|
|
144
|
+
if (!line || line.startsWith("[")) continue;
|
|
145
|
+
const eq = line.indexOf("=");
|
|
146
|
+
if (eq <= 0) continue;
|
|
147
|
+
const key = line.slice(0, eq).trim();
|
|
148
|
+
if (!(key in KEY_MAP)) continue;
|
|
149
|
+
raw[key] = unquote(line.slice(eq + 1));
|
|
150
|
+
}
|
|
151
|
+
const out = {};
|
|
152
|
+
for (const key of APPLY_ORDER) {
|
|
153
|
+
const value = raw[key];
|
|
154
|
+
const field = KEY_MAP[key];
|
|
155
|
+
if (value === void 0 || field === void 0) continue;
|
|
156
|
+
if (field === "waitTimeout") {
|
|
157
|
+
const n = Number.parseInt(value, 10);
|
|
158
|
+
if (Number.isFinite(n)) out.waitTimeout = n;
|
|
159
|
+
} else {
|
|
160
|
+
out[field] = value;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return out;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// src/adapters/deploy.ts
|
|
167
|
+
function buildDeployArgs(cfg, opts = {}) {
|
|
168
|
+
const argv = ["deploy", "--json"];
|
|
169
|
+
if (cfg.storeId) argv.push("--store-id", cfg.storeId);
|
|
170
|
+
if (cfg.outputDir) argv.push("--output-dir", cfg.outputDir);
|
|
171
|
+
if (!opts.skipBuild && cfg.buildCommand) argv.push("--build-command", cfg.buildCommand);
|
|
172
|
+
if (cfg.message) argv.push("--message", cfg.message);
|
|
173
|
+
if (cfg.network) argv.push("--network", cfg.network);
|
|
174
|
+
if (cfg.remote) argv.push("--remote", cfg.remote);
|
|
175
|
+
if (cfg.waitTimeout != null) argv.push("--wait-timeout", String(cfg.waitTimeout));
|
|
176
|
+
return argv;
|
|
177
|
+
}
|
|
178
|
+
function buildDeployEnv(cfg) {
|
|
179
|
+
const env = {};
|
|
180
|
+
if (cfg.deployKey) env.DIGSTORE_DEPLOY_KEY = cfg.deployKey;
|
|
181
|
+
if (cfg.salt) env.DIGSTORE_STORE_SALT = cfg.salt;
|
|
182
|
+
return env;
|
|
183
|
+
}
|
|
184
|
+
var CAPSULE_RE = /^([0-9a-f]{64}):([0-9a-f]{64})$/i;
|
|
185
|
+
function parseDeployResult(stdout) {
|
|
186
|
+
const lines = stdout.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith("{") && l.endsWith("}"));
|
|
187
|
+
if (lines.length === 0) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
`could not parse digstore deploy output (no JSON object found). Output was:
|
|
190
|
+
${stdout.slice(0, 500)}`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
let obj;
|
|
194
|
+
let fallback;
|
|
195
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
196
|
+
const line = lines[i];
|
|
197
|
+
if (line === void 0) continue;
|
|
198
|
+
let parsed;
|
|
199
|
+
try {
|
|
200
|
+
parsed = JSON.parse(line);
|
|
201
|
+
} catch {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (typeof parsed.capsule === "string") {
|
|
205
|
+
obj = parsed;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
if (!fallback) fallback = parsed;
|
|
209
|
+
}
|
|
210
|
+
if (!obj) {
|
|
211
|
+
if (fallback) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
`digstore deploy did not report a capsule (deploy may have failed). Output:
|
|
214
|
+
${JSON.stringify(fallback)}`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
throw new Error(`could not parse digstore deploy output as JSON:
|
|
218
|
+
${stdout.slice(0, 500)}`);
|
|
219
|
+
}
|
|
220
|
+
const capsule = obj.capsule;
|
|
221
|
+
const m = CAPSULE_RE.exec(capsule);
|
|
222
|
+
if (!m || m[1] === void 0 || m[2] === void 0) {
|
|
223
|
+
throw new Error(`digstore deploy reported a malformed capsule "${capsule}" (expected storeId:root)`);
|
|
224
|
+
}
|
|
225
|
+
const storeId = m[1].toLowerCase();
|
|
226
|
+
const root = (typeof obj.root === "string" ? obj.root : m[2]).toLowerCase();
|
|
227
|
+
return {
|
|
228
|
+
capsule,
|
|
229
|
+
storeId,
|
|
230
|
+
root,
|
|
231
|
+
// dig:// names the store on the network (resolves to its latest published version).
|
|
232
|
+
digUrl: `dig://${storeId}`,
|
|
233
|
+
// Mirrors digstore deploy.rs::hub_url — the public DIGHub view of an owned store.
|
|
234
|
+
hubUrl: `https://hub.dig.net/stores/${storeId}`,
|
|
235
|
+
pushed: typeof obj.pushed === "boolean" ? obj.pushed : void 0
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// src/adapters/run.ts
|
|
240
|
+
async function readDigToml(cwd) {
|
|
241
|
+
const { readFile } = await import('fs/promises');
|
|
242
|
+
const path = await import('path');
|
|
243
|
+
try {
|
|
244
|
+
const text = await readFile(path.join(cwd, "dig.toml"), "utf8");
|
|
245
|
+
return parseDigToml(text);
|
|
246
|
+
} catch {
|
|
247
|
+
return {};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async function runDeploy(options = {}) {
|
|
251
|
+
const cwd = options.cwd ?? process.cwd();
|
|
252
|
+
const bin = options.digstoreBin ?? "digstore";
|
|
253
|
+
const log = options.logger ?? ((l) => console.log(l));
|
|
254
|
+
const digToml = await readDigToml(cwd);
|
|
255
|
+
const cfg = resolveDeployConfig({
|
|
256
|
+
options: {
|
|
257
|
+
storeId: options.storeId,
|
|
258
|
+
outputDir: options.outputDir,
|
|
259
|
+
buildCommand: options.buildCommand,
|
|
260
|
+
message: options.message,
|
|
261
|
+
network: options.network,
|
|
262
|
+
remote: options.remote,
|
|
263
|
+
waitTimeout: options.waitTimeout
|
|
264
|
+
},
|
|
265
|
+
digToml,
|
|
266
|
+
env: process.env
|
|
267
|
+
});
|
|
268
|
+
const argv = buildDeployArgs(cfg, { skipBuild: options.skipBuild });
|
|
269
|
+
const childEnv = { ...process.env, ...buildDeployEnv(cfg) };
|
|
270
|
+
log(`\u25B6 digstore ${argv.filter((a) => a !== cfg.deployKey && a !== cfg.salt).join(" ")}`);
|
|
271
|
+
const { spawn } = await import('child_process');
|
|
272
|
+
const stdout = await new Promise((resolve, reject) => {
|
|
273
|
+
const child = spawn(bin, argv, {
|
|
274
|
+
cwd,
|
|
275
|
+
env: childEnv,
|
|
276
|
+
// digstore reads no stdin here; capture stdout (the JSON) and stream stderr through.
|
|
277
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
278
|
+
shell: false
|
|
279
|
+
});
|
|
280
|
+
let out = "";
|
|
281
|
+
let err = "";
|
|
282
|
+
child.stdout.on("data", (d) => {
|
|
283
|
+
out += d.toString();
|
|
284
|
+
});
|
|
285
|
+
child.stderr.on("data", (d) => {
|
|
286
|
+
err += d.toString();
|
|
287
|
+
});
|
|
288
|
+
child.on("error", (e) => {
|
|
289
|
+
reject(
|
|
290
|
+
new Error(
|
|
291
|
+
`could not run "${bin}" \u2014 is digstore installed and on PATH? (${e.message})`
|
|
292
|
+
)
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
child.on("close", (code) => {
|
|
296
|
+
if (code === 0) resolve(out);
|
|
297
|
+
else reject(new Error(`digstore deploy failed (exit ${code}).
|
|
298
|
+
${err || out}`));
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
const result = parseDeployResult(stdout);
|
|
302
|
+
log(`\u2713 deployed capsule ${result.capsule}`);
|
|
303
|
+
log(` dig:// ${result.digUrl}`);
|
|
304
|
+
log(` view ${result.hubUrl}`);
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// src/vite.ts
|
|
309
|
+
function digVite(options = {}) {
|
|
310
|
+
const injectDev = options.devWallet !== false;
|
|
311
|
+
const shim = injectDev ? devShimScript(options.devWalletOptions) : "";
|
|
312
|
+
return {
|
|
313
|
+
name: "dignetwork:vite-plugin-dig",
|
|
314
|
+
// The dev shim is only meaningful for the dev server.
|
|
315
|
+
apply: "serve",
|
|
316
|
+
transformIndexHtml: {
|
|
317
|
+
order: "pre",
|
|
318
|
+
handler(html) {
|
|
319
|
+
if (!injectDev) return html;
|
|
320
|
+
const tag = `
|
|
321
|
+
<script>${shim}</script>
|
|
322
|
+
`;
|
|
323
|
+
if (html.includes("<head>")) return html.replace("<head>", `<head>${tag}`);
|
|
324
|
+
return tag + html;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function digDeploy(options = {}) {
|
|
330
|
+
return runDeploy({ ...options, skipBuild: true });
|
|
331
|
+
}
|
|
332
|
+
var vite_default = digVite;
|
|
333
|
+
|
|
334
|
+
exports.default = vite_default;
|
|
335
|
+
exports.digDeploy = digDeploy;
|
|
336
|
+
exports.digVite = digVite;
|
|
337
|
+
//# sourceMappingURL=vite.cjs.map
|
|
338
|
+
//# sourceMappingURL=vite.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/provider/injected.ts","../src/adapters/dev-shim.ts","../src/adapters/config.ts","../src/adapters/dig-toml.ts","../src/adapters/deploy.ts","../src/adapters/run.ts","../src/vite.ts"],"names":[],"mappings":";;;;;AAgCO,IAAM,cA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ite.cjs","sourcesContent":["// Injected-provider transport — the DIG Browser's in-process wallet (and compatible CHIP-0002\n// extensions), exposed on every page as `window.chia`. When present the SDK PREFERS it over\n// WalletConnect: no QR, no relay, no pairing. The native provider returns the SAME response shapes\n// Sage returns over WalletConnect, so the normalizers in provider/methods.ts are unchanged — only\n// the TRANSPORT differs. Genericized from hub.dig.net/apps/web/lib/injected-wallet.js.\n//\n// Detection: we key on the explicit, unspoofable `isDIG` marker the DIG Browser provider sets, not\n// merely the presence of `window.chia` (a different Chia provider could also define that).\n\nimport type { InjectedChiaProvider, WalletBackend } from \"../types.js\";\nimport { WALLET_METHODS, DEFAULT_CHAIN } from \"../methods.js\";\nimport type { WalletTransport } from \"./transport.js\";\n\n/** The injected provider on the current global, or undefined when not running in a DIG Browser. */\nexport function getInjectedProvider(): InjectedChiaProvider | undefined {\n const g = globalThis as { chia?: InjectedChiaProvider };\n return typeof g !== \"undefined\" ? g.chia : undefined;\n}\n\n/**\n * True iff an injected DIG wallet is available. Detects on the unspoofable `isDIG` marker. Pass\n * `{ anyChia: true }` to accept any `window.chia` that implements `request` (e.g. a non-DIG\n * CHIP-0002 extension).\n */\nexport function isInjectedAvailable(opts: { anyChia?: boolean } = {}): boolean {\n const p = getInjectedProvider();\n if (!p) return false;\n if (opts.anyChia) return typeof p.request === \"function\";\n return !!p.isDIG;\n}\n\n/** Sentinel topic for the injected backend (it has no per-session relay topic). */\nexport const INJECTED_TOPIC = \"injected\";\n\n/** A WalletTransport backed by the injected window.chia provider. */\nexport class InjectedTransport implements WalletTransport {\n readonly backend: WalletBackend = \"injected\";\n readonly topic = INJECTED_TOPIC;\n readonly chain: string;\n private readonly provider: InjectedChiaProvider;\n\n constructor(provider: InjectedChiaProvider, chain: string = DEFAULT_CHAIN) {\n this.provider = provider;\n this.chain = chain;\n }\n\n /** Connect: ask the native wallet to approve this origin. Blocks until approved/rejected. */\n async connect(eager = false): Promise<void> {\n if (typeof this.provider.connect === \"function\") {\n await this.provider.connect(eager);\n }\n // A provider without connect() (older build) is tolerated — request() will gate per-method.\n }\n\n // The native wallet implements the full canonical set (it returns Sage-shaped responses), so\n // support is a static allowlist — no per-session negotiation as with WalletConnect.\n supports(method: string): boolean {\n return (WALLET_METHODS as readonly string[]).includes(method);\n }\n\n async request(method: string, params: unknown): Promise<unknown> {\n if (!this.supports(method)) {\n throw new Error(`The DIG Browser wallet does not support \"${method}\".`);\n }\n return this.provider.request({ method, params });\n }\n\n async disconnect(): Promise<void> {\n // The injected wallet has no per-session teardown; per-origin consent is managed in the wallet.\n }\n}\n","// The `window.chia` DEV shim the adapters inject during `dev`.\n//\n// In production a dapp's wallet is the REAL injected provider — the DIG Browser's in-process wallet\n// (or a CHIP-0002 extension) — which the SDK's ChiaProvider detects on `window.chia` via the\n// `isDIG` marker (see src/provider/injected.ts). During local `vite dev` / `next dev` there is no\n// such wallet, so calling `ChiaProvider.connect({ mode: \"injected\" })` would fail and the developer\n// couldn't exercise the wallet path at all.\n//\n// This shim installs a MINIMAL, clearly-labelled stub that satisfies the SAME injected-provider\n// contract the SDK detects (`isDIG`, `request({method,params})`, `connect()`), so the wallet code\n// path runs end-to-end in dev. It is a STUB, not a wallet: it returns a configurable mock address\n// and otherwise throws on methods that would need real signing, so a developer is never misled into\n// thinking a signature is real. It is generated as a self-contained, eval-free `<script>` body\n// (CSP-safe) that GUARDS on an existing `window.chia`, so a real wallet always wins.\n//\n// The shim's method names + response envelope mirror src/provider/injected.ts and\n// src/provider/methods.ts (the native provider returns `{ data }`), so the SAME normalizers run in\n// dev as in production — only the values are mocked.\n\nimport { INJECTED_TOPIC } from \"../provider/injected.js\";\n\n/** A literal substring stamped into the shim so it is unmistakably a dev stub (asserted in tests). */\nexport const DEV_SHIM_MARKER = \"dig-sdk:dev-wallet-shim\";\n\n/** Options for the generated dev shim. */\nexport interface DevShimOptions {\n /** Mock receive address the shim returns from `getAddress`. A clearly-fake default is used. */\n address?: string;\n}\n\n/** A clearly-fake default dev address (so it is obvious in the UI this is not a real wallet). */\nconst DEFAULT_DEV_ADDRESS = \"xch1dev0000000000000000000000000000000000000000000000000000devshim\";\n\n/** JSON-encode a string for safe inlining into a script literal. */\nfunction lit(s: string): string {\n return JSON.stringify(s);\n}\n\n/**\n * Generate the dev-shim `<script>` body (no surrounding `<script>` tags). Inline it into the dev\n * server's served HTML. It is an IIFE that installs `window.chia` ONLY if one is not already\n * present, so the DIG Browser / a real extension always takes precedence. Eval-free and\n * dependency-free — safe under a strict CSP.\n */\nexport function devShimScript(options: DevShimOptions = {}): string {\n const address = options.address ?? DEFAULT_DEV_ADDRESS;\n // The shim mirrors the injected-provider contract the SDK detects. `request` resolves a small set\n // of read methods with mock data and rejects signing methods (a dev stub must not fake a\n // signature). Method names are the bare CHIP-0002 names the SDK normalizes.\n return [\n `/* ${DEV_SHIM_MARKER} — DEV ONLY. A stub wallet for local development; NOT a real wallet. */`,\n `(function () {`,\n ` \"use strict\";`,\n ` if (typeof window === \"undefined\") return;`,\n ` // A real injected wallet (DIG Browser / extension) always wins — never clobber it.`,\n ` if (window.chia) return;`,\n ` var DEV_ADDRESS = ${lit(address)};`,\n ` var TOPIC = ${lit(INJECTED_TOPIC)};`,\n ` function ok(data) { return Promise.resolve({ data: data }); }`,\n ` function nope(method) {`,\n ` return Promise.reject(new Error(`,\n ` \"[\" + ${lit(DEV_SHIM_MARKER)} + \"] '\" + method + \"' needs a real wallet; the dev shim does not sign. \" +`,\n ` \"Open in the DIG Browser or connect a wallet to sign for real.\"));`,\n ` }`,\n ` window.chia = {`,\n ` isDIG: true, // detected by the SDK's injected-provider check`,\n ` isDevShim: true, // so the app can tell it is the dev stub`,\n ` topic: TOPIC,`,\n ` connect: function () { return Promise.resolve(true); },`,\n ` request: function (args) {`,\n ` var method = args && args.method ? String(args.method) : \"\";`,\n ` switch (method) {`,\n ` case \"chip0002_connect\": return ok(true);`,\n ` case \"chip0002_getPublicKeys\": return ok([]);`,\n ` case \"getAddress\":`,\n ` case \"chia_getAddress\": return ok(DEV_ADDRESS);`,\n ` default:`,\n ` // Signing / spend methods must not be faked.`,\n ` return nope(method);`,\n ` }`,\n ` },`,\n ` on: function () {},`,\n ` off: function () {},`,\n ` };`,\n ` if (window.console && window.console.info) {`,\n ` window.console.info(\"[\" + ${lit(DEV_SHIM_MARKER)} + \"] installed a DEV window.chia (mock address \" + DEV_ADDRESS + \").\");`,\n ` }`,\n `})();`,\n ].join(\"\\n\");\n}\n","// Deploy-config resolution for the framework adapters.\n//\n// The final config a deploy runs with is composed from three layers, highest precedence first:\n// 1. plugin options — what the developer wrote in vite.config / the Next adapter call\n// 2. environment vars — what CI injects (DIGSTORE_*), incl. the SECRETS (deploy key, salt)\n// 3. dig.toml — the project's checked-in defaults\n// 4. built-in defaults — outputDir=\"dist\", network=\"mainnet\" (mirrors deploy.rs::resolve_config)\n//\n// This mirrors `digstore deploy`'s own resolution order (flag/env > dig.toml > default) so the\n// adapters never disagree with the CLI about what a project deploys. SECRETS are resolved ONLY from\n// env — never from options or dig.toml — so they can't end up checked into a repo or a config file.\n\nimport type { DigTomlConfig } from \"./dig-toml.js\";\n\n/** Per-call options a developer passes to the Vite plugin / Next adapter. */\nexport interface AdapterOptions {\n /** On-chain store id (64-hex) to advance. Usually set in dig.toml instead. */\n storeId?: string;\n /** Built-output directory to publish. Defaults to the framework's output (or \"dist\"). */\n outputDir?: string;\n /** Shell build command for `digstore` to run. Omit when the adapter builds itself. */\n buildCommand?: string;\n /** Commit message for the new capsule. */\n message?: string;\n /** Chain network. Defaults to \"mainnet\". */\n network?: string;\n /** The `origin` remote to publish to (e.g. `dig://<storeId>`). */\n remote?: string;\n /** Seconds to wait for on-chain confirmation. */\n waitTimeout?: number;\n}\n\n/** The fully resolved config a deploy runs with. Secrets are present only if env supplied them. */\nexport interface ResolvedDeployConfig {\n storeId?: string;\n outputDir: string;\n buildCommand?: string;\n message?: string;\n network: string;\n remote?: string;\n waitTimeout?: number;\n /** Publisher deploy key (64-hex). From env only. */\n deployKey?: string;\n /** Private-store secret salt (64-hex). From env only. */\n salt?: string;\n}\n\n/** Inputs to resolution — kept explicit so it is a pure function (no process.env read inside). */\nexport interface ResolveInput {\n options: AdapterOptions;\n digToml: DigTomlConfig;\n env: Record<string, string | undefined>;\n}\n\n/** A non-empty, trimmed env value, or undefined. Empty/whitespace env vars count as unset. */\nfunction envVal(env: Record<string, string | undefined>, key: string): string | undefined {\n const v = env[key];\n if (v == null) return undefined;\n const t = v.trim();\n return t === \"\" ? undefined : t;\n}\n\n/** First defined of the candidates (treating \"\" the caller already filtered as undefined). */\nfunction pick<T>(...candidates: (T | undefined)[]): T | undefined {\n for (const c of candidates) if (c !== undefined) return c;\n return undefined;\n}\n\n/**\n * Resolve the final deploy config. Precedence per field: options > env (DIGSTORE_*) > dig.toml >\n * default. Secrets (deployKey, salt) are taken from env ONLY.\n */\nexport function resolveDeployConfig(input: ResolveInput): ResolvedDeployConfig {\n const { options, digToml, env } = input;\n\n const storeId = pick(\n options.storeId,\n envVal(env, \"DIGSTORE_STORE_ID\"),\n digToml.storeId,\n );\n const outputDir =\n pick(options.outputDir, envVal(env, \"DIGSTORE_OUTPUT_DIR\"), digToml.outputDir) ?? \"dist\";\n const buildCommand = pick(\n options.buildCommand,\n envVal(env, \"DIGSTORE_BUILD_COMMAND\"),\n digToml.buildCommand,\n );\n const message = pick(options.message, envVal(env, \"DIGSTORE_MESSAGE\"), digToml.message);\n const network =\n pick(options.network, envVal(env, \"DIGSTORE_NETWORK\"), digToml.network) ?? \"mainnet\";\n const remote = pick(options.remote, envVal(env, \"DIGSTORE_REMOTE\"), digToml.remote);\n\n const waitFromEnv = envVal(env, \"DIGSTORE_WAIT_TIMEOUT\");\n const waitTimeout = pick(\n options.waitTimeout,\n waitFromEnv != null ? Number.parseInt(waitFromEnv, 10) : undefined,\n digToml.waitTimeout,\n );\n\n return {\n storeId,\n outputDir,\n buildCommand,\n message,\n network,\n remote,\n waitTimeout: Number.isFinite(waitTimeout) ? waitTimeout : undefined,\n // SECRETS — env only.\n deployKey: envVal(env, \"DIGSTORE_DEPLOY_KEY\"),\n salt: envVal(env, \"DIGSTORE_STORE_SALT\"),\n };\n}\n","// Minimal `dig.toml` reader for the framework adapters.\n//\n// `digstore deploy` reads its config from a project's `dig.toml` (digstore-cli/src/dig_toml.rs).\n// The adapters need the SAME few top-level keys so a project's `dig.toml` is the single source of\n// truth across the CLI and the plugins. Rather than pull in a TOML parser dependency for ~7 flat\n// `key = \"value\"` lines, we parse just those keys ourselves. We accept BOTH the canonical\n// kebab-case key and the snake_case alias, exactly like digstore's `#[serde(rename/alias)]`.\n//\n// Anything beyond these keys (tables, arrays, nested values) is intentionally ignored — the\n// adapters only forward the deploy-relevant scalars to `digstore deploy`, which re-reads the full\n// file authoritatively.\n\n/** The deploy-relevant subset of `dig.toml`, in the adapters' camelCase shape. */\nexport interface DigTomlConfig {\n storeId?: string;\n outputDir?: string;\n buildCommand?: string;\n message?: string;\n network?: string;\n remote?: string;\n waitTimeout?: number;\n}\n\n// Map each canonical/alias TOML key onto the camelCase field. kebab-case is canonical (it is what\n// `digstore new` writes); snake_case is the tolerated alias. When both appear, the canonical\n// kebab-case key wins (it is applied last).\nconst KEY_MAP: Record<string, keyof DigTomlConfig> = {\n store_id: \"storeId\",\n \"store-id\": \"storeId\",\n output_dir: \"outputDir\",\n \"output-dir\": \"outputDir\",\n build_command: \"buildCommand\",\n \"build-command\": \"buildCommand\",\n message: \"message\",\n network: \"network\",\n remote: \"remote\",\n wait_timeout: \"waitTimeout\",\n \"wait-timeout\": \"waitTimeout\",\n};\n\n// Apply snake_case first then kebab-case so the canonical kebab form overrides the alias.\nconst APPLY_ORDER = Object.keys(KEY_MAP).sort((a) =>\n a.includes(\"-\") ? 1 : -1,\n);\n\n/** Strip a `# comment` that is not inside a quoted value. */\nfunction stripComment(line: string): string {\n let inSingle = false;\n let inDouble = false;\n for (let i = 0; i < line.length; i++) {\n const ch = line[i];\n if (ch === \"'\" && !inDouble) inSingle = !inSingle;\n else if (ch === '\"' && !inSingle) inDouble = !inDouble;\n else if (ch === \"#\" && !inSingle && !inDouble) return line.slice(0, i);\n }\n return line;\n}\n\n/** Unquote a TOML scalar: `\"x\"` / `'x'` → `x`; a bare token is returned trimmed. */\nfunction unquote(raw: string): string {\n const v = raw.trim();\n if (\n (v.startsWith('\"') && v.endsWith('\"') && v.length >= 2) ||\n (v.startsWith(\"'\") && v.endsWith(\"'\") && v.length >= 2)\n ) {\n return v.slice(1, -1);\n }\n return v;\n}\n\n/**\n * Parse the deploy-relevant keys out of a `dig.toml` string. Unknown keys, tables, and nested\n * structures are ignored. Returns only the keys actually present (so it composes cleanly under the\n * precedence rules in resolveDeployConfig).\n */\nexport function parseDigToml(text: string): DigTomlConfig {\n // Collect raw (canonical-or-alias) string values keyed by the TOML key as written.\n const raw: Record<string, string> = {};\n for (const lineRaw of text.split(/\\r?\\n/)) {\n const line = stripComment(lineRaw).trim();\n if (!line || line.startsWith(\"[\")) continue; // skip blanks + table headers\n const eq = line.indexOf(\"=\");\n if (eq <= 0) continue;\n const key = line.slice(0, eq).trim();\n if (!(key in KEY_MAP)) continue;\n raw[key] = unquote(line.slice(eq + 1));\n }\n\n const out: DigTomlConfig = {};\n for (const key of APPLY_ORDER) {\n const value = raw[key];\n const field = KEY_MAP[key];\n if (value === undefined || field === undefined) continue;\n if (field === \"waitTimeout\") {\n const n = Number.parseInt(value, 10);\n if (Number.isFinite(n)) out.waitTimeout = n;\n } else {\n out[field] = value;\n }\n }\n return out;\n}\n","// The pure glue around `digstore deploy --json`: build the child argv + env, and parse the result.\n//\n// The adapters SHELL OUT to the installed `digstore` binary (the canonical deployer — it advances\n// the on-chain root, stages the build dir, and pushes the new capsule to DIGHub). They never\n// re-implement deploy. These helpers are the deterministic, side-effect-free pieces:\n//\n// • buildDeployArgs — resolved config → argv (always `deploy --json`, only set flags).\n// • buildDeployEnv — resolved config → the env overlay carrying the SECRETS to the child, so the\n// deploy key / salt are NEVER on the argv (process-table leak), matching\n// digstore-cli's own guidance (deploy.rs).\n// • parseDeployResult— `digstore deploy --json` stdout → { capsule, storeId, root, digUrl, hubUrl,\n// pushed }, deriving the URLs exactly as digstore does (capsule = storeId:root;\n// hub view = https://hub.dig.net/stores/<id>; dig:// names the store).\n\nimport type { ResolvedDeployConfig } from \"./config.js\";\n\n/** Knobs for argv construction. */\nexport interface DeployArgsOptions {\n /**\n * The adapter already ran the framework build, so don't hand `--build-command` to digstore (it\n * would rebuild). The output dir is staged as-is.\n */\n skipBuild?: boolean;\n}\n\n/**\n * Build the argv for `digstore <argv>` from a resolved config. Always `deploy --json`. Only flags\n * whose values are set are emitted. SECRETS (deployKey, salt) are intentionally excluded — they go\n * through the env (buildDeployEnv) so they never appear in the process table.\n */\nexport function buildDeployArgs(\n cfg: ResolvedDeployConfig,\n opts: DeployArgsOptions = {},\n): string[] {\n const argv: string[] = [\"deploy\", \"--json\"];\n if (cfg.storeId) argv.push(\"--store-id\", cfg.storeId);\n if (cfg.outputDir) argv.push(\"--output-dir\", cfg.outputDir);\n if (!opts.skipBuild && cfg.buildCommand) argv.push(\"--build-command\", cfg.buildCommand);\n if (cfg.message) argv.push(\"--message\", cfg.message);\n if (cfg.network) argv.push(\"--network\", cfg.network);\n if (cfg.remote) argv.push(\"--remote\", cfg.remote);\n if (cfg.waitTimeout != null) argv.push(\"--wait-timeout\", String(cfg.waitTimeout));\n return argv;\n}\n\n/**\n * The env overlay to merge onto the child process env: the SECRETS, passed out-of-band so they are\n * never visible on the command line. Returns only the keys that have a value.\n */\nexport function buildDeployEnv(cfg: ResolvedDeployConfig): Record<string, string> {\n const env: Record<string, string> = {};\n if (cfg.deployKey) env.DIGSTORE_DEPLOY_KEY = cfg.deployKey;\n if (cfg.salt) env.DIGSTORE_STORE_SALT = cfg.salt;\n return env;\n}\n\n/** The friendly, parsed outcome of a deploy. */\nexport interface DeployResult {\n /** `storeId:rootHash` — the capsule identity (the ecosystem-vocabulary id the user shares). */\n capsule: string;\n /** Store identity (64-hex). */\n storeId: string;\n /** The new on-chain root (64-hex). */\n root: string;\n /** The dig:// URL naming this store (resolves through the network to the latest version). */\n digUrl: string;\n /** The human \"view it\" URL on DIGHub (the same one `digstore deploy` prints). */\n hubUrl: string;\n /** Whether the capsule was pushed to DIGHub (when the JSON reported it). */\n pushed?: boolean;\n}\n\nconst CAPSULE_RE = /^([0-9a-f]{64}):([0-9a-f]{64})$/i;\n\n/**\n * Parse `digstore deploy --json` stdout into a DeployResult. digstore emits a single JSON object\n * (with at least `capsule` and `root`); we also tolerate extra JSON log lines by scanning lines\n * bottom-up for the first object that carries a `capsule`. Throws a clear error if none is found or\n * the output isn't JSON at all.\n */\nexport function parseDeployResult(stdout: string): DeployResult {\n const lines = stdout\n .split(/\\r?\\n/)\n .map((l) => l.trim())\n .filter((l) => l.startsWith(\"{\") && l.endsWith(\"}\"));\n\n if (lines.length === 0) {\n throw new Error(\n `could not parse digstore deploy output (no JSON object found). Output was:\\n${stdout.slice(0, 500)}`,\n );\n }\n\n // Prefer the LAST JSON object that has a capsule (deploy emits one final result object). Keep the\n // first parseable object as a fallback so the error message can show what digstore DID return.\n let obj: Record<string, unknown> | undefined;\n let fallback: Record<string, unknown> | undefined;\n for (let i = lines.length - 1; i >= 0; i--) {\n const line = lines[i];\n if (line === undefined) continue;\n let parsed: Record<string, unknown>;\n try {\n parsed = JSON.parse(line) as Record<string, unknown>;\n } catch {\n continue; // not JSON — skip this line\n }\n if (typeof parsed.capsule === \"string\") {\n obj = parsed;\n break;\n }\n if (!fallback) fallback = parsed;\n }\n\n if (!obj) {\n if (fallback) {\n throw new Error(\n `digstore deploy did not report a capsule (deploy may have failed). Output:\\n${JSON.stringify(fallback)}`,\n );\n }\n throw new Error(`could not parse digstore deploy output as JSON:\\n${stdout.slice(0, 500)}`);\n }\n\n const capsule = obj.capsule as string;\n const m = CAPSULE_RE.exec(capsule);\n if (!m || m[1] === undefined || m[2] === undefined) {\n throw new Error(`digstore deploy reported a malformed capsule \"${capsule}\" (expected storeId:root)`);\n }\n const storeId = m[1].toLowerCase();\n const root = (typeof obj.root === \"string\" ? obj.root : m[2]).toLowerCase();\n\n return {\n capsule,\n storeId,\n root,\n // dig:// names the store on the network (resolves to its latest published version).\n digUrl: `dig://${storeId}`,\n // Mirrors digstore deploy.rs::hub_url — the public DIGHub view of an owned store.\n hubUrl: `https://hub.dig.net/stores/${storeId}`,\n pushed: typeof obj.pushed === \"boolean\" ? obj.pushed : undefined,\n };\n}\n","// The shared, Node-only deploy runner both framework adapters call on their `publish` step.\n//\n// It composes the pure pieces (load dig.toml → resolve config → build argv + env), spawns the\n// installed `digstore` binary with `deploy --json`, and parses the result into a friendly\n// DeployResult ({ capsule, digUrl, hubUrl }). It is intentionally thin: ALL deploy logic lives in\n// `digstore deploy` (the canonical deployer — advances the on-chain root, stages, pushes the\n// capsule); this only marshals config in and the result out.\n//\n// Node-only: it uses node:child_process / node:fs. The framework entrypoints import it lazily on\n// the publish path so importing the plugin in a browser/config context never pulls Node APIs.\n\nimport { resolveDeployConfig, type AdapterOptions } from \"./config.js\";\nimport { parseDigToml, type DigTomlConfig } from \"./dig-toml.js\";\nimport {\n buildDeployArgs,\n buildDeployEnv,\n parseDeployResult,\n type DeployArgsOptions,\n type DeployResult,\n} from \"./deploy.js\";\n\n/** Options for {@link runDeploy}. */\nexport interface RunDeployOptions extends AdapterOptions, DeployArgsOptions {\n /** Project root that holds `dig.toml` and the build output. Defaults to `process.cwd()`. */\n cwd?: string;\n /** The `digstore` executable. Defaults to `\"digstore\"` (must be on PATH). */\n digstoreBin?: string;\n /** Sink for human-readable progress. Defaults to `console.log`. */\n logger?: (line: string) => void;\n}\n\n/** Read `dig.toml` from `cwd` (returns {} when absent). */\nasync function readDigToml(cwd: string): Promise<DigTomlConfig> {\n const { readFile } = await import(\"node:fs/promises\");\n const path = await import(\"node:path\");\n try {\n const text = await readFile(path.join(cwd, \"dig.toml\"), \"utf8\");\n return parseDigToml(text);\n } catch {\n return {}; // no dig.toml — rely on options + env\n }\n}\n\n/**\n * Resolve config, run `digstore deploy --json`, and parse the capsule. Spawns `digstore` with the\n * SECRETS injected through the child env (never the argv). Rejects with digstore's stderr on\n * non-zero exit. Returns the parsed {@link DeployResult}.\n */\nexport async function runDeploy(options: RunDeployOptions = {}): Promise<DeployResult> {\n const cwd = options.cwd ?? process.cwd();\n const bin = options.digstoreBin ?? \"digstore\";\n const log = options.logger ?? ((l: string) => console.log(l));\n\n const digToml = await readDigToml(cwd);\n const cfg = resolveDeployConfig({\n options: {\n storeId: options.storeId,\n outputDir: options.outputDir,\n buildCommand: options.buildCommand,\n message: options.message,\n network: options.network,\n remote: options.remote,\n waitTimeout: options.waitTimeout,\n },\n digToml,\n env: process.env,\n });\n\n const argv = buildDeployArgs(cfg, { skipBuild: options.skipBuild });\n const childEnv = { ...process.env, ...buildDeployEnv(cfg) };\n\n log(`▶ digstore ${argv.filter((a) => a !== cfg.deployKey && a !== cfg.salt).join(\" \")}`);\n\n const { spawn } = await import(\"node:child_process\");\n const stdout = await new Promise<string>((resolve, reject) => {\n const child = spawn(bin, argv, {\n cwd,\n env: childEnv,\n // digstore reads no stdin here; capture stdout (the JSON) and stream stderr through.\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n shell: false,\n });\n let out = \"\";\n let err = \"\";\n child.stdout.on(\"data\", (d: Buffer) => {\n out += d.toString();\n });\n child.stderr.on(\"data\", (d: Buffer) => {\n err += d.toString();\n });\n child.on(\"error\", (e: Error) => {\n reject(\n new Error(\n `could not run \"${bin}\" — is digstore installed and on PATH? (${e.message})`,\n ),\n );\n });\n child.on(\"close\", (code: number | null) => {\n if (code === 0) resolve(out);\n else reject(new Error(`digstore deploy failed (exit ${code}).\\n${err || out}`));\n });\n });\n\n const result = parseDeployResult(stdout);\n log(`✓ deployed capsule ${result.capsule}`);\n log(` dig:// ${result.digUrl}`);\n log(` view ${result.hubUrl}`);\n return result;\n}\n","// `@dignetwork/dig-sdk/vite` — a Vite plugin that makes DIG a first-class deploy target.\n//\n// Two jobs:\n// 1. DEV: during `vite dev` it injects the SDK's `window.chia` dev shim into the served HTML, so a\n// plain browser (no DIG Browser, no extension) still has an injected wallet to develop against\n// — the SAME injected-provider contract the SDK's ChiaProvider detects in production.\n// 2. PUBLISH: it exposes `digDeploy()` — call it from a `publish` script (after `vite build`) to\n// shell out to `digstore deploy --json`, shipping the build dir → a new capsule and printing\n// the dig:// + DIGHub URL. (Deploy is a deliberate, credentialed step — it spends DIG — so it\n// is NOT wired into the default `vite build`; you opt in via a `publish` script.)\n//\n// Vite is an OPTIONAL peer dependency: this module declares no hard import of \"vite\". The returned\n// object is a structurally-valid Vite Plugin (name + transformIndexHtml), typed loosely so the SDK\n// builds without vite installed.\n\nimport { devShimScript, type DevShimOptions } from \"./adapters/dev-shim.js\";\nimport type { AdapterOptions } from \"./adapters/config.js\";\nimport type { DeployResult } from \"./adapters/deploy.js\";\nimport { runDeploy } from \"./adapters/run.js\";\n\n/** Options for {@link digVite}. */\nexport interface DigVitePluginOptions {\n /**\n * Inject the dev `window.chia` shim during `vite dev`. Default: true. The shim never clobbers a\n * real injected wallet (it guards on an existing `window.chia`).\n */\n devWallet?: boolean;\n /** Dev-shim options (e.g. the mock address it returns). */\n devWalletOptions?: DevShimOptions;\n}\n\n// A minimal structural type for the Vite plugin shape we return, so we don't depend on \"vite\".\ninterface VitePluginLike {\n name: string;\n apply?: \"serve\" | \"build\";\n transformIndexHtml?: {\n order: \"pre\";\n handler: (html: string) => string;\n };\n}\n\n/**\n * The Vite plugin. Add to `vite.config` `plugins: [digVite()]`. Injects the dev wallet shim in\n * `vite dev`; deploys are run separately via {@link digDeploy} (or the `digDeploy` re-export) from a\n * `publish` script.\n */\nexport function digVite(options: DigVitePluginOptions = {}): VitePluginLike {\n const injectDev = options.devWallet !== false;\n const shim = injectDev ? devShimScript(options.devWalletOptions) : \"\";\n\n return {\n name: \"dignetwork:vite-plugin-dig\",\n // The dev shim is only meaningful for the dev server.\n apply: \"serve\",\n transformIndexHtml: {\n order: \"pre\",\n handler(html: string): string {\n if (!injectDev) return html;\n const tag = `\\n<script>${shim}</script>\\n`;\n // Inject as early as possible so window.chia exists before app code runs.\n if (html.includes(\"<head>\")) return html.replace(\"<head>\", `<head>${tag}`);\n return tag + html;\n },\n },\n };\n}\n\n/**\n * Deploy the built site to a DIG capsule. Call from a `publish` npm script AFTER `vite build`\n * (e.g. `\"publish:dig\": \"vite build && node -e \\\"import('@dignetwork/dig-sdk/vite').then(m=>m.digDeploy())\\\"\"`).\n * Reads `dig.toml` + env (DIGSTORE_*) for config + secrets. The adapter has already built, so it\n * tells digstore to stage the existing output dir rather than rebuild.\n */\nexport function digDeploy(options: AdapterOptions = {}): Promise<DeployResult> {\n return runDeploy({ ...options, skipBuild: true });\n}\n\nexport default digVite;\n"]}
|
package/dist/vite.d.cts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { c as DevShimOptions, A as AdapterOptions, a as DeployResult } from './dev-shim-Bgw8X2E9.cjs';
|
|
2
|
+
|
|
3
|
+
/** Options for {@link digVite}. */
|
|
4
|
+
interface DigVitePluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Inject the dev `window.chia` shim during `vite dev`. Default: true. The shim never clobbers a
|
|
7
|
+
* real injected wallet (it guards on an existing `window.chia`).
|
|
8
|
+
*/
|
|
9
|
+
devWallet?: boolean;
|
|
10
|
+
/** Dev-shim options (e.g. the mock address it returns). */
|
|
11
|
+
devWalletOptions?: DevShimOptions;
|
|
12
|
+
}
|
|
13
|
+
interface VitePluginLike {
|
|
14
|
+
name: string;
|
|
15
|
+
apply?: "serve" | "build";
|
|
16
|
+
transformIndexHtml?: {
|
|
17
|
+
order: "pre";
|
|
18
|
+
handler: (html: string) => string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The Vite plugin. Add to `vite.config` `plugins: [digVite()]`. Injects the dev wallet shim in
|
|
23
|
+
* `vite dev`; deploys are run separately via {@link digDeploy} (or the `digDeploy` re-export) from a
|
|
24
|
+
* `publish` script.
|
|
25
|
+
*/
|
|
26
|
+
declare function digVite(options?: DigVitePluginOptions): VitePluginLike;
|
|
27
|
+
/**
|
|
28
|
+
* Deploy the built site to a DIG capsule. Call from a `publish` npm script AFTER `vite build`
|
|
29
|
+
* (e.g. `"publish:dig": "vite build && node -e \"import('@dignetwork/dig-sdk/vite').then(m=>m.digDeploy())\""`).
|
|
30
|
+
* Reads `dig.toml` + env (DIGSTORE_*) for config + secrets. The adapter has already built, so it
|
|
31
|
+
* tells digstore to stage the existing output dir rather than rebuild.
|
|
32
|
+
*/
|
|
33
|
+
declare function digDeploy(options?: AdapterOptions): Promise<DeployResult>;
|
|
34
|
+
|
|
35
|
+
export { type DigVitePluginOptions, digVite as default, digDeploy, digVite };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { c as DevShimOptions, A as AdapterOptions, a as DeployResult } from './dev-shim-Bgw8X2E9.js';
|
|
2
|
+
|
|
3
|
+
/** Options for {@link digVite}. */
|
|
4
|
+
interface DigVitePluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Inject the dev `window.chia` shim during `vite dev`. Default: true. The shim never clobbers a
|
|
7
|
+
* real injected wallet (it guards on an existing `window.chia`).
|
|
8
|
+
*/
|
|
9
|
+
devWallet?: boolean;
|
|
10
|
+
/** Dev-shim options (e.g. the mock address it returns). */
|
|
11
|
+
devWalletOptions?: DevShimOptions;
|
|
12
|
+
}
|
|
13
|
+
interface VitePluginLike {
|
|
14
|
+
name: string;
|
|
15
|
+
apply?: "serve" | "build";
|
|
16
|
+
transformIndexHtml?: {
|
|
17
|
+
order: "pre";
|
|
18
|
+
handler: (html: string) => string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The Vite plugin. Add to `vite.config` `plugins: [digVite()]`. Injects the dev wallet shim in
|
|
23
|
+
* `vite dev`; deploys are run separately via {@link digDeploy} (or the `digDeploy` re-export) from a
|
|
24
|
+
* `publish` script.
|
|
25
|
+
*/
|
|
26
|
+
declare function digVite(options?: DigVitePluginOptions): VitePluginLike;
|
|
27
|
+
/**
|
|
28
|
+
* Deploy the built site to a DIG capsule. Call from a `publish` npm script AFTER `vite build`
|
|
29
|
+
* (e.g. `"publish:dig": "vite build && node -e \"import('@dignetwork/dig-sdk/vite').then(m=>m.digDeploy())\""`).
|
|
30
|
+
* Reads `dig.toml` + env (DIGSTORE_*) for config + secrets. The adapter has already built, so it
|
|
31
|
+
* tells digstore to stage the existing output dir rather than rebuild.
|
|
32
|
+
*/
|
|
33
|
+
declare function digDeploy(options?: AdapterOptions): Promise<DeployResult>;
|
|
34
|
+
|
|
35
|
+
export { type DigVitePluginOptions, digVite as default, digDeploy, digVite };
|