@dignetwork/dig-sdk 0.0.1-alpha.99 → 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 -31
- package/dist/DigNetwork/ContentServer.d.ts.map +0 -1
- package/dist/DigNetwork/ContentServer.js +0 -176
- 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 -81
- package/dist/DigNetwork/PropagationServer.d.ts.map +0 -1
- package/dist/DigNetwork/PropagationServer.js +0 -563
- 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 -324
- 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
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** The deploy-relevant subset of `dig.toml`, in the adapters' camelCase shape. */
|
|
2
|
+
interface DigTomlConfig {
|
|
3
|
+
storeId?: string;
|
|
4
|
+
outputDir?: string;
|
|
5
|
+
buildCommand?: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
network?: string;
|
|
8
|
+
remote?: string;
|
|
9
|
+
waitTimeout?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse the deploy-relevant keys out of a `dig.toml` string. Unknown keys, tables, and nested
|
|
13
|
+
* structures are ignored. Returns only the keys actually present (so it composes cleanly under the
|
|
14
|
+
* precedence rules in resolveDeployConfig).
|
|
15
|
+
*/
|
|
16
|
+
declare function parseDigToml(text: string): DigTomlConfig;
|
|
17
|
+
|
|
18
|
+
/** Per-call options a developer passes to the Vite plugin / Next adapter. */
|
|
19
|
+
interface AdapterOptions {
|
|
20
|
+
/** On-chain store id (64-hex) to advance. Usually set in dig.toml instead. */
|
|
21
|
+
storeId?: string;
|
|
22
|
+
/** Built-output directory to publish. Defaults to the framework's output (or "dist"). */
|
|
23
|
+
outputDir?: string;
|
|
24
|
+
/** Shell build command for `digstore` to run. Omit when the adapter builds itself. */
|
|
25
|
+
buildCommand?: string;
|
|
26
|
+
/** Commit message for the new capsule. */
|
|
27
|
+
message?: string;
|
|
28
|
+
/** Chain network. Defaults to "mainnet". */
|
|
29
|
+
network?: string;
|
|
30
|
+
/** The `origin` remote to publish to (e.g. `dig://<storeId>`). */
|
|
31
|
+
remote?: string;
|
|
32
|
+
/** Seconds to wait for on-chain confirmation. */
|
|
33
|
+
waitTimeout?: number;
|
|
34
|
+
}
|
|
35
|
+
/** The fully resolved config a deploy runs with. Secrets are present only if env supplied them. */
|
|
36
|
+
interface ResolvedDeployConfig {
|
|
37
|
+
storeId?: string;
|
|
38
|
+
outputDir: string;
|
|
39
|
+
buildCommand?: string;
|
|
40
|
+
message?: string;
|
|
41
|
+
network: string;
|
|
42
|
+
remote?: string;
|
|
43
|
+
waitTimeout?: number;
|
|
44
|
+
/** Publisher deploy key (64-hex). From env only. */
|
|
45
|
+
deployKey?: string;
|
|
46
|
+
/** Private-store secret salt (64-hex). From env only. */
|
|
47
|
+
salt?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Inputs to resolution — kept explicit so it is a pure function (no process.env read inside). */
|
|
50
|
+
interface ResolveInput {
|
|
51
|
+
options: AdapterOptions;
|
|
52
|
+
digToml: DigTomlConfig;
|
|
53
|
+
env: Record<string, string | undefined>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the final deploy config. Precedence per field: options > env (DIGSTORE_*) > dig.toml >
|
|
57
|
+
* default. Secrets (deployKey, salt) are taken from env ONLY.
|
|
58
|
+
*/
|
|
59
|
+
declare function resolveDeployConfig(input: ResolveInput): ResolvedDeployConfig;
|
|
60
|
+
|
|
61
|
+
/** Knobs for argv construction. */
|
|
62
|
+
interface DeployArgsOptions {
|
|
63
|
+
/**
|
|
64
|
+
* The adapter already ran the framework build, so don't hand `--build-command` to digstore (it
|
|
65
|
+
* would rebuild). The output dir is staged as-is.
|
|
66
|
+
*/
|
|
67
|
+
skipBuild?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Build the argv for `digstore <argv>` from a resolved config. Always `deploy --json`. Only flags
|
|
71
|
+
* whose values are set are emitted. SECRETS (deployKey, salt) are intentionally excluded — they go
|
|
72
|
+
* through the env (buildDeployEnv) so they never appear in the process table.
|
|
73
|
+
*/
|
|
74
|
+
declare function buildDeployArgs(cfg: ResolvedDeployConfig, opts?: DeployArgsOptions): string[];
|
|
75
|
+
/**
|
|
76
|
+
* The env overlay to merge onto the child process env: the SECRETS, passed out-of-band so they are
|
|
77
|
+
* never visible on the command line. Returns only the keys that have a value.
|
|
78
|
+
*/
|
|
79
|
+
declare function buildDeployEnv(cfg: ResolvedDeployConfig): Record<string, string>;
|
|
80
|
+
/** The friendly, parsed outcome of a deploy. */
|
|
81
|
+
interface DeployResult {
|
|
82
|
+
/** `storeId:rootHash` — the capsule identity (the ecosystem-vocabulary id the user shares). */
|
|
83
|
+
capsule: string;
|
|
84
|
+
/** Store identity (64-hex). */
|
|
85
|
+
storeId: string;
|
|
86
|
+
/** The new on-chain root (64-hex). */
|
|
87
|
+
root: string;
|
|
88
|
+
/** The dig:// URL naming this store (resolves through the network to the latest version). */
|
|
89
|
+
digUrl: string;
|
|
90
|
+
/** The human "view it" URL on DIGHub (the same one `digstore deploy` prints). */
|
|
91
|
+
hubUrl: string;
|
|
92
|
+
/** Whether the capsule was pushed to DIGHub (when the JSON reported it). */
|
|
93
|
+
pushed?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Parse `digstore deploy --json` stdout into a DeployResult. digstore emits a single JSON object
|
|
97
|
+
* (with at least `capsule` and `root`); we also tolerate extra JSON log lines by scanning lines
|
|
98
|
+
* bottom-up for the first object that carries a `capsule`. Throws a clear error if none is found or
|
|
99
|
+
* the output isn't JSON at all.
|
|
100
|
+
*/
|
|
101
|
+
declare function parseDeployResult(stdout: string): DeployResult;
|
|
102
|
+
|
|
103
|
+
/** A literal substring stamped into the shim so it is unmistakably a dev stub (asserted in tests). */
|
|
104
|
+
declare const DEV_SHIM_MARKER = "dig-sdk:dev-wallet-shim";
|
|
105
|
+
/** Options for the generated dev shim. */
|
|
106
|
+
interface DevShimOptions {
|
|
107
|
+
/** Mock receive address the shim returns from `getAddress`. A clearly-fake default is used. */
|
|
108
|
+
address?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Generate the dev-shim `<script>` body (no surrounding `<script>` tags). Inline it into the dev
|
|
112
|
+
* server's served HTML. It is an IIFE that installs `window.chia` ONLY if one is not already
|
|
113
|
+
* present, so the DIG Browser / a real extension always takes precedence. Eval-free and
|
|
114
|
+
* dependency-free — safe under a strict CSP.
|
|
115
|
+
*/
|
|
116
|
+
declare function devShimScript(options?: DevShimOptions): string;
|
|
117
|
+
|
|
118
|
+
export { type AdapterOptions as A, type DeployArgsOptions as D, type ResolveInput as R, type DeployResult as a, DEV_SHIM_MARKER as b, type DevShimOptions as c, type DigTomlConfig as d, type ResolvedDeployConfig as e, buildDeployArgs as f, buildDeployEnv as g, devShimScript as h, parseDigToml as i, parseDeployResult as p, resolveDeployConfig as r };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** The deploy-relevant subset of `dig.toml`, in the adapters' camelCase shape. */
|
|
2
|
+
interface DigTomlConfig {
|
|
3
|
+
storeId?: string;
|
|
4
|
+
outputDir?: string;
|
|
5
|
+
buildCommand?: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
network?: string;
|
|
8
|
+
remote?: string;
|
|
9
|
+
waitTimeout?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse the deploy-relevant keys out of a `dig.toml` string. Unknown keys, tables, and nested
|
|
13
|
+
* structures are ignored. Returns only the keys actually present (so it composes cleanly under the
|
|
14
|
+
* precedence rules in resolveDeployConfig).
|
|
15
|
+
*/
|
|
16
|
+
declare function parseDigToml(text: string): DigTomlConfig;
|
|
17
|
+
|
|
18
|
+
/** Per-call options a developer passes to the Vite plugin / Next adapter. */
|
|
19
|
+
interface AdapterOptions {
|
|
20
|
+
/** On-chain store id (64-hex) to advance. Usually set in dig.toml instead. */
|
|
21
|
+
storeId?: string;
|
|
22
|
+
/** Built-output directory to publish. Defaults to the framework's output (or "dist"). */
|
|
23
|
+
outputDir?: string;
|
|
24
|
+
/** Shell build command for `digstore` to run. Omit when the adapter builds itself. */
|
|
25
|
+
buildCommand?: string;
|
|
26
|
+
/** Commit message for the new capsule. */
|
|
27
|
+
message?: string;
|
|
28
|
+
/** Chain network. Defaults to "mainnet". */
|
|
29
|
+
network?: string;
|
|
30
|
+
/** The `origin` remote to publish to (e.g. `dig://<storeId>`). */
|
|
31
|
+
remote?: string;
|
|
32
|
+
/** Seconds to wait for on-chain confirmation. */
|
|
33
|
+
waitTimeout?: number;
|
|
34
|
+
}
|
|
35
|
+
/** The fully resolved config a deploy runs with. Secrets are present only if env supplied them. */
|
|
36
|
+
interface ResolvedDeployConfig {
|
|
37
|
+
storeId?: string;
|
|
38
|
+
outputDir: string;
|
|
39
|
+
buildCommand?: string;
|
|
40
|
+
message?: string;
|
|
41
|
+
network: string;
|
|
42
|
+
remote?: string;
|
|
43
|
+
waitTimeout?: number;
|
|
44
|
+
/** Publisher deploy key (64-hex). From env only. */
|
|
45
|
+
deployKey?: string;
|
|
46
|
+
/** Private-store secret salt (64-hex). From env only. */
|
|
47
|
+
salt?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Inputs to resolution — kept explicit so it is a pure function (no process.env read inside). */
|
|
50
|
+
interface ResolveInput {
|
|
51
|
+
options: AdapterOptions;
|
|
52
|
+
digToml: DigTomlConfig;
|
|
53
|
+
env: Record<string, string | undefined>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the final deploy config. Precedence per field: options > env (DIGSTORE_*) > dig.toml >
|
|
57
|
+
* default. Secrets (deployKey, salt) are taken from env ONLY.
|
|
58
|
+
*/
|
|
59
|
+
declare function resolveDeployConfig(input: ResolveInput): ResolvedDeployConfig;
|
|
60
|
+
|
|
61
|
+
/** Knobs for argv construction. */
|
|
62
|
+
interface DeployArgsOptions {
|
|
63
|
+
/**
|
|
64
|
+
* The adapter already ran the framework build, so don't hand `--build-command` to digstore (it
|
|
65
|
+
* would rebuild). The output dir is staged as-is.
|
|
66
|
+
*/
|
|
67
|
+
skipBuild?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Build the argv for `digstore <argv>` from a resolved config. Always `deploy --json`. Only flags
|
|
71
|
+
* whose values are set are emitted. SECRETS (deployKey, salt) are intentionally excluded — they go
|
|
72
|
+
* through the env (buildDeployEnv) so they never appear in the process table.
|
|
73
|
+
*/
|
|
74
|
+
declare function buildDeployArgs(cfg: ResolvedDeployConfig, opts?: DeployArgsOptions): string[];
|
|
75
|
+
/**
|
|
76
|
+
* The env overlay to merge onto the child process env: the SECRETS, passed out-of-band so they are
|
|
77
|
+
* never visible on the command line. Returns only the keys that have a value.
|
|
78
|
+
*/
|
|
79
|
+
declare function buildDeployEnv(cfg: ResolvedDeployConfig): Record<string, string>;
|
|
80
|
+
/** The friendly, parsed outcome of a deploy. */
|
|
81
|
+
interface DeployResult {
|
|
82
|
+
/** `storeId:rootHash` — the capsule identity (the ecosystem-vocabulary id the user shares). */
|
|
83
|
+
capsule: string;
|
|
84
|
+
/** Store identity (64-hex). */
|
|
85
|
+
storeId: string;
|
|
86
|
+
/** The new on-chain root (64-hex). */
|
|
87
|
+
root: string;
|
|
88
|
+
/** The dig:// URL naming this store (resolves through the network to the latest version). */
|
|
89
|
+
digUrl: string;
|
|
90
|
+
/** The human "view it" URL on DIGHub (the same one `digstore deploy` prints). */
|
|
91
|
+
hubUrl: string;
|
|
92
|
+
/** Whether the capsule was pushed to DIGHub (when the JSON reported it). */
|
|
93
|
+
pushed?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Parse `digstore deploy --json` stdout into a DeployResult. digstore emits a single JSON object
|
|
97
|
+
* (with at least `capsule` and `root`); we also tolerate extra JSON log lines by scanning lines
|
|
98
|
+
* bottom-up for the first object that carries a `capsule`. Throws a clear error if none is found or
|
|
99
|
+
* the output isn't JSON at all.
|
|
100
|
+
*/
|
|
101
|
+
declare function parseDeployResult(stdout: string): DeployResult;
|
|
102
|
+
|
|
103
|
+
/** A literal substring stamped into the shim so it is unmistakably a dev stub (asserted in tests). */
|
|
104
|
+
declare const DEV_SHIM_MARKER = "dig-sdk:dev-wallet-shim";
|
|
105
|
+
/** Options for the generated dev shim. */
|
|
106
|
+
interface DevShimOptions {
|
|
107
|
+
/** Mock receive address the shim returns from `getAddress`. A clearly-fake default is used. */
|
|
108
|
+
address?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Generate the dev-shim `<script>` body (no surrounding `<script>` tags). Inline it into the dev
|
|
112
|
+
* server's served HTML. It is an IIFE that installs `window.chia` ONLY if one is not already
|
|
113
|
+
* present, so the DIG Browser / a real extension always takes precedence. Eval-free and
|
|
114
|
+
* dependency-free — safe under a strict CSP.
|
|
115
|
+
*/
|
|
116
|
+
declare function devShimScript(options?: DevShimOptions): string;
|
|
117
|
+
|
|
118
|
+
export { type AdapterOptions as A, type DeployArgsOptions as D, type ResolveInput as R, type DeployResult as a, DEV_SHIM_MARKER as b, type DevShimOptions as c, type DigTomlConfig as d, type ResolvedDeployConfig as e, buildDeployArgs as f, buildDeployEnv as g, devShimScript as h, parseDigToml as i, parseDeployResult as p, resolveDeployConfig as r };
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/** The read-crypto functions the SDK uses from the dig_client WASM. */
|
|
2
|
+
interface DigClientWasm {
|
|
3
|
+
/** `retrieval_key = SHA-256(canonical rootless urn)`, lowercase hex. Empty key ⇒ index.html. */
|
|
4
|
+
retrievalKey(storeIdHex: string, resourceKey: string): string;
|
|
5
|
+
/** Derive the 32-byte AES-256 content key (lowercase hex). `saltHex` for a private store. */
|
|
6
|
+
deriveKey(storeIdHex: string, resourceKey: string, saltHex?: string | null): string;
|
|
7
|
+
/**
|
|
8
|
+
* Verify `ciphertext` is included under `trustedRootHex` via the base64 merkle `proofB64`.
|
|
9
|
+
* Returns true on success, false on ANY verification failure (a decoy returns false rather than
|
|
10
|
+
* throwing). Throws only on malformed inputs.
|
|
11
|
+
*/
|
|
12
|
+
verifyInclusion(ciphertext: Uint8Array, proofB64: string, trustedRootHex: string): boolean;
|
|
13
|
+
/** AES-256-GCM-SIV-open a single chunk under an explicit 32-byte `keyHex`. Throws on tag fail. */
|
|
14
|
+
decryptChunk(keyHex: string, ciphertext: Uint8Array): Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Full read pipeline: gate (inclusion) then decrypt (URN key, split by `chunkLens`), returning
|
|
17
|
+
* plaintext bytes. `chunkLens` may be null/empty for a single-chunk resource.
|
|
18
|
+
*/
|
|
19
|
+
decryptResource(storeIdHex: string, resourceKey: string, ciphertext: Uint8Array, proofB64: string, trustedRootHex: string, saltHex?: string | null, chunkLens?: Uint32Array | null): Uint8Array;
|
|
20
|
+
/** As `decryptResource`, returning UTF-8 text. */
|
|
21
|
+
decryptResourceToText(storeIdHex: string, resourceKey: string, ciphertext: Uint8Array, proofB64: string, trustedRootHex: string, saltHex?: string | null, chunkLens?: Uint32Array | null): string;
|
|
22
|
+
/** Seal a resource's plaintext as one GCM-SIV blob under its per-URN key (the encrypt inverse). */
|
|
23
|
+
encryptResource(storeIdHex: string, resourceKey: string, plaintext: Uint8Array, saltHex?: string | null): Uint8Array;
|
|
24
|
+
/** Reconstruct the canonical rootless URN string. */
|
|
25
|
+
reconstructUrn(storeIdHex: string, resourceKey: string): string;
|
|
26
|
+
/** Reconstruct a root-pinned display URN string. */
|
|
27
|
+
reconstructUrnWithRoot(storeIdHex: string, rootHex: string, resourceKey: string): string;
|
|
28
|
+
/** Library version (matches the crate version). */
|
|
29
|
+
version(): string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A normalized `{ publicKey, signature }` pair from a wallet sign, both as `0x`-prefixed hex. */
|
|
33
|
+
interface SignResult {
|
|
34
|
+
/** The signing public key (synthetic BLS key), `0x`-prefixed hex. */
|
|
35
|
+
publicKey: string | null;
|
|
36
|
+
/** The BLS signature, `0x`-prefixed hex (or the raw wallet string). */
|
|
37
|
+
signature: string | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The minimal injected-provider contract the SDK detects on `window.chia` (the DIG Browser's
|
|
41
|
+
* in-process wallet, or a compatible CHIP-0002 extension). Mirrors the DIG Browser provider:
|
|
42
|
+
* `request({ method, params })` returns the wallet's `data`; `connect(eager)` blocks on per-origin
|
|
43
|
+
* approval; `on`/`off` are EIP-1193-style event hooks.
|
|
44
|
+
*/
|
|
45
|
+
interface InjectedChiaProvider {
|
|
46
|
+
/** Unspoofable marker the DIG Browser provider sets; the SDK prefers a provider that has it. */
|
|
47
|
+
isDIG?: boolean;
|
|
48
|
+
/** Some providers expose a connected flag. */
|
|
49
|
+
isConnected?: boolean;
|
|
50
|
+
/** One CHIP-0002 RPC. Bare names auto-prefix to `chip0002_`; `chia_*` passes through. */
|
|
51
|
+
request(args: {
|
|
52
|
+
method: string;
|
|
53
|
+
params?: unknown;
|
|
54
|
+
}): Promise<unknown>;
|
|
55
|
+
/** Ask the wallet to approve this origin. Blocks until approved/rejected. */
|
|
56
|
+
connect?(eager?: boolean): Promise<unknown>;
|
|
57
|
+
on?(event: string, fn: (data: unknown) => void): void;
|
|
58
|
+
off?(event: string, fn: (data: unknown) => void): void;
|
|
59
|
+
}
|
|
60
|
+
declare global {
|
|
61
|
+
var chia: InjectedChiaProvider | undefined;
|
|
62
|
+
interface Window {
|
|
63
|
+
chia?: InjectedChiaProvider;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Which wallet transport is backing a `ChiaProvider`. */
|
|
67
|
+
type WalletBackend = "injected" | "walletconnect";
|
|
68
|
+
/** A connected wallet session, returned by `ChiaProvider.connect()`. */
|
|
69
|
+
interface WalletSession {
|
|
70
|
+
/** The transport backing this session. */
|
|
71
|
+
backend: WalletBackend;
|
|
72
|
+
/** The CAIP-2 chain id (e.g. "chia:mainnet"). */
|
|
73
|
+
chain: string;
|
|
74
|
+
/**
|
|
75
|
+
* The session topic. For WalletConnect this is the real relay topic; for the injected backend
|
|
76
|
+
* it is a stable sentinel ("injected") — callers do not need to inspect it.
|
|
77
|
+
*/
|
|
78
|
+
topic: string;
|
|
79
|
+
/** The wallet's receive address, when known at connect time. */
|
|
80
|
+
address?: string | null;
|
|
81
|
+
}
|
|
82
|
+
/** Options for `DigClient.read*` calls — chiefly which dig RPC endpoint to use. */
|
|
83
|
+
interface ReadOptions {
|
|
84
|
+
/** dig RPC endpoint. Defaults to the public `https://rpc.dig.net`. */
|
|
85
|
+
rpc?: string;
|
|
86
|
+
}
|
|
87
|
+
/** The result of reading a resource by URN. */
|
|
88
|
+
interface ReadResult {
|
|
89
|
+
/** Store identity (64-hex). */
|
|
90
|
+
storeId: string;
|
|
91
|
+
/** The on-chain generation root the content was verified against (or null if none supplied). */
|
|
92
|
+
root: string | null;
|
|
93
|
+
/** The resource path within the store. */
|
|
94
|
+
resourceKey: string;
|
|
95
|
+
/** Private-store salt used (or null). */
|
|
96
|
+
salt: string | null;
|
|
97
|
+
/**
|
|
98
|
+
* The resource bytes. When `decrypted` is true these are the authenticated plaintext; when
|
|
99
|
+
* false they are the RAW served ciphertext (a decoy / wrong-key / wrong-salt response is just
|
|
100
|
+
* opaque bytes — the model is oblivious, so this is never a "not found" verdict).
|
|
101
|
+
*/
|
|
102
|
+
bytes: Uint8Array;
|
|
103
|
+
/** Advisory: did the served bytes' inclusion proof verify against `root`? */
|
|
104
|
+
verified: boolean;
|
|
105
|
+
/** Did the bytes decrypt+authenticate under this URN's derived key? */
|
|
106
|
+
decrypted: boolean;
|
|
107
|
+
}
|
|
108
|
+
/** The two root-independent keys a URN maps to (derived client-side, nothing sent to the network). */
|
|
109
|
+
interface UrnKeys {
|
|
110
|
+
storeId: string;
|
|
111
|
+
root: string | null;
|
|
112
|
+
resourceKey: string;
|
|
113
|
+
salt: string | null;
|
|
114
|
+
/** `SHA-256(canonical rootless URN)`, lowercase hex — what the dig RPC is addressed by. */
|
|
115
|
+
retrievalKey: string;
|
|
116
|
+
/** The per-URN AES-256-GCM-SIV decryption key, lowercase hex. */
|
|
117
|
+
decryptionKey: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The default public dig RPC endpoint. */
|
|
121
|
+
declare const DEFAULT_RPC = "https://rpc.dig.net";
|
|
122
|
+
/** Options to construct a DigClient. */
|
|
123
|
+
interface DigClientOptions {
|
|
124
|
+
/** dig RPC endpoint. Defaults to the public `https://rpc.dig.net`. */
|
|
125
|
+
rpc?: string;
|
|
126
|
+
/** Override `fetch` (e.g. an instrumented one). Defaults to the global `fetch`. */
|
|
127
|
+
fetch?: typeof fetch;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The read-crypto client. Construct once and reuse — the wasm is loaded + SRI-verified lazily on
|
|
131
|
+
* the first read and memoized process/page-wide.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* const dig = new DigClient();
|
|
135
|
+
* const { bytes, decrypted } = await dig.read({
|
|
136
|
+
* urn: "urn:dig:chia:<storeId>/index.html",
|
|
137
|
+
* root: "<onchain-root-hex>",
|
|
138
|
+
* });
|
|
139
|
+
* if (decrypted) console.log(new TextDecoder().decode(bytes));
|
|
140
|
+
*/
|
|
141
|
+
declare class DigClient {
|
|
142
|
+
private readonly rpc;
|
|
143
|
+
private readonly fetchImpl;
|
|
144
|
+
constructor(options?: DigClientOptions);
|
|
145
|
+
/** Load (and SRI-verify) the read-crypto wasm. Exposed for callers that want the raw functions. */
|
|
146
|
+
wasm(): Promise<DigClientWasm>;
|
|
147
|
+
/** `retrieval_key = SHA-256(canonical rootless URN)`, lowercase hex. */
|
|
148
|
+
retrievalKey(storeId: string, resourceKey: string): Promise<string>;
|
|
149
|
+
/** Derive the per-URN AES-256-GCM-SIV key, lowercase hex. `salt` for a private store. */
|
|
150
|
+
deriveKey(storeId: string, resourceKey: string, salt?: string | null): Promise<string>;
|
|
151
|
+
/** Verify served `ciphertext` is included under `root` via the base64 merkle `proof`. */
|
|
152
|
+
verifyInclusion(ciphertext: Uint8Array, proof: string, root: string): Promise<boolean>;
|
|
153
|
+
/** Reconstruct the canonical rootless URN whose SHA-256 is the retrieval key. */
|
|
154
|
+
reconstructUrn(storeId: string, resourceKey: string): Promise<string>;
|
|
155
|
+
/**
|
|
156
|
+
* Derive, client-side, the two root-independent keys a URN maps to (retrieval + decryption).
|
|
157
|
+
* Nothing is sent to the network — pure local derivation via the wasm.
|
|
158
|
+
*/
|
|
159
|
+
deriveUrnKeys(input: {
|
|
160
|
+
urn: string;
|
|
161
|
+
salt?: string | null;
|
|
162
|
+
}): Promise<UrnKeys>;
|
|
163
|
+
/**
|
|
164
|
+
* Fetch + verify + decrypt one resource by URN. `root` is the on-chain generation root to verify
|
|
165
|
+
* against (resolved by the caller from the chain); when omitted, the root embedded in the URN is
|
|
166
|
+
* used. Returns the bytes plus advisory `verified`/`decrypted` flags. NEVER throws "not found"
|
|
167
|
+
* (presence is unknowable) — it throws only on a transport failure.
|
|
168
|
+
*/
|
|
169
|
+
read(input: {
|
|
170
|
+
urn: string;
|
|
171
|
+
root?: string | null;
|
|
172
|
+
salt?: string | null;
|
|
173
|
+
}, opts?: ReadOptions): Promise<ReadResult>;
|
|
174
|
+
/** As `read`, but decoding the plaintext to a UTF-8 string when it decrypts (else throws). */
|
|
175
|
+
readText(input: {
|
|
176
|
+
urn: string;
|
|
177
|
+
root?: string | null;
|
|
178
|
+
salt?: string | null;
|
|
179
|
+
}, opts?: ReadOptions): Promise<string>;
|
|
180
|
+
/**
|
|
181
|
+
* Read by explicit (storeId, resourceKey, root, salt) rather than a URN string. The oblivious
|
|
182
|
+
* download primitive the URN read is built on.
|
|
183
|
+
*/
|
|
184
|
+
readResource(input: {
|
|
185
|
+
storeId: string;
|
|
186
|
+
resourceKey: string;
|
|
187
|
+
root: string;
|
|
188
|
+
salt?: string | null;
|
|
189
|
+
}, opts?: ReadOptions): Promise<ReadResult>;
|
|
190
|
+
private fetchCiphertext;
|
|
191
|
+
private rpcCall;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** SHA-256 (lowercase hex) of vendor/dig_client_bg.wasm — the SRI digest. Fail closed on mismatch. */
|
|
195
|
+
declare const DIG_CLIENT_WASM_SHA256 = "ff486be806f908a2a90780e499a04dbd34e10e3b97be0470cb9ee841a1e49e77";
|
|
196
|
+
/** Optional explicit wasm inputs, for environments where auto-resolution can't find vendor/. */
|
|
197
|
+
interface WasmConfig {
|
|
198
|
+
/**
|
|
199
|
+
* The wasm bytes (already loaded). When provided, SRI is still enforced unless `skipIntegrity`.
|
|
200
|
+
* Pass this in CSP-strict browsers where you fetch + verify the bytes yourself.
|
|
201
|
+
*/
|
|
202
|
+
wasmBytes?: BufferSource;
|
|
203
|
+
/**
|
|
204
|
+
* URL to the wasm-bindgen glue module (vendor/dig_client.mjs) for browser dynamic import. When
|
|
205
|
+
* omitted in a browser, the loader tries to import the glue relative to this module.
|
|
206
|
+
*/
|
|
207
|
+
glueUrl?: string;
|
|
208
|
+
/**
|
|
209
|
+
* URL to fetch the wasm bytes from (browser) when `wasmBytes` is not supplied. The fetched bytes
|
|
210
|
+
* are SRI-verified before init.
|
|
211
|
+
*/
|
|
212
|
+
wasmUrl?: string;
|
|
213
|
+
/** Skip the SRI check. Only for tests / trusted custom builds — NOT recommended. */
|
|
214
|
+
skipIntegrity?: boolean;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Override how the read-crypto wasm is located/loaded. Call BEFORE the first `DigClient` read.
|
|
218
|
+
* Mainly for browsers without a bundler that resolves package files, or CSP-strict apps that fetch
|
|
219
|
+
* + verify the wasm bytes themselves and hand them in. Resets any cached instance.
|
|
220
|
+
*/
|
|
221
|
+
declare function configureWasm(config: WasmConfig): void;
|
|
222
|
+
/**
|
|
223
|
+
* Load, SRI-verify, and instantiate the read-crypto wasm, returning its functions. Memoized — at
|
|
224
|
+
* most one init per process/page. Fails closed on an integrity mismatch.
|
|
225
|
+
*/
|
|
226
|
+
declare function loadDigClientWasm(): Promise<DigClientWasm>;
|
|
227
|
+
|
|
228
|
+
/** The parts of a parsed DIG URN. `root`/`salt` are null when absent. */
|
|
229
|
+
interface ParsedUrn {
|
|
230
|
+
/** Store identity (64-hex launcher id), lowercased. */
|
|
231
|
+
readonly storeId: string;
|
|
232
|
+
/** Generation root (64-hex), lowercased — or null for the root-independent form. */
|
|
233
|
+
readonly root: string | null;
|
|
234
|
+
/** Resource path within the store (verbatim, not lowercased). */
|
|
235
|
+
readonly resourceKey: string;
|
|
236
|
+
/** Private-store secret salt (hex), lowercased — or null for a public store. */
|
|
237
|
+
readonly salt: string | null;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Parse a DIG URN into its parts. Throws on a malformed URN.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* parseUrn("urn:dig:chia:" + "ab".repeat(32) + "/index.html")
|
|
244
|
+
* // → { storeId: "abab…", root: null, resourceKey: "index.html", salt: null }
|
|
245
|
+
*/
|
|
246
|
+
declare function parseUrn(raw: string): ParsedUrn;
|
|
247
|
+
/** True iff `raw` is a syntactically valid DIG URN. Never throws. */
|
|
248
|
+
declare function isUrn(raw: string): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Reconstruct the canonical, root-INDEPENDENT URN string for a store + resource key:
|
|
251
|
+
* `urn:dig:chia:<store_id>/<resource_key>`. An empty resource key resolves to the default view
|
|
252
|
+
* `index.html`. This is the form whose SHA-256 is the retrieval key and whose bytes seed the AES
|
|
253
|
+
* key — matching the wasm's `reconstructUrn`.
|
|
254
|
+
*/
|
|
255
|
+
declare function reconstructUrn(storeId: string, resourceKey: string): string;
|
|
256
|
+
/**
|
|
257
|
+
* Reconstruct a root-PINNED display URN: `urn:dig:chia:<store_id>:<root>/<resource_key>`. Useful
|
|
258
|
+
* for sharing a URN bound to a specific generation; the retrieval/AES keys still use the rootless
|
|
259
|
+
* form (`reconstructUrn`).
|
|
260
|
+
*/
|
|
261
|
+
declare function reconstructUrnWithRoot(storeId: string, root: string, resourceKey: string): string;
|
|
262
|
+
|
|
263
|
+
export { DEFAULT_RPC as D, type InjectedChiaProvider as I, type ParsedUrn as P, type ReadOptions as R, type SignResult as S, type UrnKeys as U, type WalletBackend as W, type WalletSession as a, DIG_CLIENT_WASM_SHA256 as b, DigClient as c, type DigClientOptions as d, type DigClientWasm as e, type ReadResult as f, type WasmConfig as g, configureWasm as h, isUrn as i, reconstructUrnWithRoot as j, loadDigClientWasm as l, parseUrn as p, reconstructUrn as r };
|