@dignetwork/dig-sdk 0.2.0 → 0.2.1
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/README.md +9 -6
- package/dist/adapters.cjs.map +1 -1
- package/dist/adapters.js.map +1 -1
- package/dist/{dig-client-entry-ChYxUvBn.d.cts → dig-client-entry-Bc95rd_t.d.cts} +10 -6
- package/dist/{dig-client-entry-ChYxUvBn.d.ts → dig-client-entry-Bc95rd_t.d.ts} +10 -6
- package/dist/dig-client.cjs +38 -31
- package/dist/dig-client.cjs.map +1 -1
- package/dist/dig-client.d.cts +1 -1
- package/dist/dig-client.d.ts +1 -1
- package/dist/dig-client.js +38 -31
- package/dist/dig-client.js.map +1 -1
- package/dist/index.cjs +40 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +40 -33
- package/dist/index.js.map +1 -1
- package/dist/next.cjs.map +1 -1
- package/dist/next.js.map +1 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js.map +1 -1
- package/package.json +5 -6
- package/vendor/PROVENANCE.md +0 -102
- package/vendor/dig_client.d.ts +0 -150
- package/vendor/dig_client.mjs +0 -805
- package/vendor/dig_client_bg.wasm +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WalletBackend, a as WalletSession, S as SignResult, I as InjectedChiaProvider } from './dig-client-entry-
|
|
2
|
-
export { C as CollectionItem, b as CollectionItemMetadata, c as CollectionItemsPage, d as CollectionMeta, D as DEFAULT_RPC, e as DIG_CLIENT_WASM_SHA256, f as DigClient, g as DigClientOptions, h as DigClientWasm, P as ParsedUrn, R as ReadOptions, i as ReadResult, U as UrnKeys, j as WasmConfig, k as configureWasm, l as isUrn, m as loadDigClientWasm, p as parseUrn, r as reconstructUrn, n as reconstructUrnWithRoot } from './dig-client-entry-
|
|
1
|
+
import { W as WalletBackend, a as WalletSession, S as SignResult, I as InjectedChiaProvider } from './dig-client-entry-Bc95rd_t.cjs';
|
|
2
|
+
export { C as CollectionItem, b as CollectionItemMetadata, c as CollectionItemsPage, d as CollectionMeta, D as DEFAULT_RPC, e as DIG_CLIENT_WASM_SHA256, f as DigClient, g as DigClientOptions, h as DigClientWasm, P as ParsedUrn, R as ReadOptions, i as ReadResult, U as UrnKeys, j as WasmConfig, k as configureWasm, l as isUrn, m as loadDigClientWasm, p as parseUrn, r as reconstructUrn, n as reconstructUrnWithRoot } from './dig-client-entry-Bc95rd_t.cjs';
|
|
3
3
|
|
|
4
4
|
/** A wallet transport: connect, then `request` CHIP-0002 methods through it. */
|
|
5
5
|
interface WalletTransport {
|
|
@@ -386,7 +386,7 @@ declare const DIG_SDK_ERROR_CODES: Readonly<{
|
|
|
386
386
|
readonly RPC_ERROR: "RPC_ERROR";
|
|
387
387
|
/** The dig RPC returned a malformed / inconsistent payload (e.g. chunk-length mismatch). */
|
|
388
388
|
readonly RPC_MALFORMED_RESPONSE: "RPC_MALFORMED_RESPONSE";
|
|
389
|
-
/** The
|
|
389
|
+
/** The read-crypto wasm failed its SRI integrity check — fail closed. */
|
|
390
390
|
readonly WASM_INTEGRITY: "WASM_INTEGRITY";
|
|
391
391
|
/** The read-crypto wasm could not be loaded (fetch/resolve failure). */
|
|
392
392
|
readonly WASM_LOAD_FAILED: "WASM_LOAD_FAILED";
|
|
@@ -478,7 +478,7 @@ interface SdkCapabilities {
|
|
|
478
478
|
readonly chains: readonly string[];
|
|
479
479
|
/** The default dig RPC endpoint `DigClient` reads from. */
|
|
480
480
|
readonly defaultRpc: string;
|
|
481
|
-
/** The SRI digest of the
|
|
481
|
+
/** The SRI digest of the read-crypto wasm from @dignetwork/dig-client (fail-closed on mismatch). */
|
|
482
482
|
readonly readCryptoWasmSha256: string;
|
|
483
483
|
/** The stable error-code catalogue (UPPER_SNAKE) consumers can branch on. */
|
|
484
484
|
readonly errorCodes: readonly DigSdkErrorCode[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WalletBackend, a as WalletSession, S as SignResult, I as InjectedChiaProvider } from './dig-client-entry-
|
|
2
|
-
export { C as CollectionItem, b as CollectionItemMetadata, c as CollectionItemsPage, d as CollectionMeta, D as DEFAULT_RPC, e as DIG_CLIENT_WASM_SHA256, f as DigClient, g as DigClientOptions, h as DigClientWasm, P as ParsedUrn, R as ReadOptions, i as ReadResult, U as UrnKeys, j as WasmConfig, k as configureWasm, l as isUrn, m as loadDigClientWasm, p as parseUrn, r as reconstructUrn, n as reconstructUrnWithRoot } from './dig-client-entry-
|
|
1
|
+
import { W as WalletBackend, a as WalletSession, S as SignResult, I as InjectedChiaProvider } from './dig-client-entry-Bc95rd_t.js';
|
|
2
|
+
export { C as CollectionItem, b as CollectionItemMetadata, c as CollectionItemsPage, d as CollectionMeta, D as DEFAULT_RPC, e as DIG_CLIENT_WASM_SHA256, f as DigClient, g as DigClientOptions, h as DigClientWasm, P as ParsedUrn, R as ReadOptions, i as ReadResult, U as UrnKeys, j as WasmConfig, k as configureWasm, l as isUrn, m as loadDigClientWasm, p as parseUrn, r as reconstructUrn, n as reconstructUrnWithRoot } from './dig-client-entry-Bc95rd_t.js';
|
|
3
3
|
|
|
4
4
|
/** A wallet transport: connect, then `request` CHIP-0002 methods through it. */
|
|
5
5
|
interface WalletTransport {
|
|
@@ -386,7 +386,7 @@ declare const DIG_SDK_ERROR_CODES: Readonly<{
|
|
|
386
386
|
readonly RPC_ERROR: "RPC_ERROR";
|
|
387
387
|
/** The dig RPC returned a malformed / inconsistent payload (e.g. chunk-length mismatch). */
|
|
388
388
|
readonly RPC_MALFORMED_RESPONSE: "RPC_MALFORMED_RESPONSE";
|
|
389
|
-
/** The
|
|
389
|
+
/** The read-crypto wasm failed its SRI integrity check — fail closed. */
|
|
390
390
|
readonly WASM_INTEGRITY: "WASM_INTEGRITY";
|
|
391
391
|
/** The read-crypto wasm could not be loaded (fetch/resolve failure). */
|
|
392
392
|
readonly WASM_LOAD_FAILED: "WASM_LOAD_FAILED";
|
|
@@ -478,7 +478,7 @@ interface SdkCapabilities {
|
|
|
478
478
|
readonly chains: readonly string[];
|
|
479
479
|
/** The default dig RPC endpoint `DigClient` reads from. */
|
|
480
480
|
readonly defaultRpc: string;
|
|
481
|
-
/** The SRI digest of the
|
|
481
|
+
/** The SRI digest of the read-crypto wasm from @dignetwork/dig-client (fail-closed on mismatch). */
|
|
482
482
|
readonly readCryptoWasmSha256: string;
|
|
483
483
|
/** The stable error-code catalogue (UPPER_SNAKE) consumers can branch on. */
|
|
484
484
|
readonly errorCodes: readonly DigSdkErrorCode[];
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var DIG_SDK_ERROR_CODES = Object.freeze({
|
|
|
43
43
|
RPC_ERROR: "RPC_ERROR",
|
|
44
44
|
/** The dig RPC returned a malformed / inconsistent payload (e.g. chunk-length mismatch). */
|
|
45
45
|
RPC_MALFORMED_RESPONSE: "RPC_MALFORMED_RESPONSE",
|
|
46
|
-
/** The
|
|
46
|
+
/** The read-crypto wasm failed its SRI integrity check — fail closed. */
|
|
47
47
|
WASM_INTEGRITY: "WASM_INTEGRITY",
|
|
48
48
|
/** The read-crypto wasm could not be loaded (fetch/resolve failure). */
|
|
49
49
|
WASM_LOAD_FAILED: "WASM_LOAD_FAILED",
|
|
@@ -699,7 +699,7 @@ var Paywall = class {
|
|
|
699
699
|
};
|
|
700
700
|
|
|
701
701
|
// src/loader.ts
|
|
702
|
-
var DIG_CLIENT_WASM_SHA256 = "
|
|
702
|
+
var DIG_CLIENT_WASM_SHA256 = "8c983561eabca34778abf698ca7c2fba36117f87282ca649079599ef7d1b1156";
|
|
703
703
|
var _config = {};
|
|
704
704
|
var _ready = null;
|
|
705
705
|
function configureWasm(config) {
|
|
@@ -731,47 +731,54 @@ function assertIntegrity(hex) {
|
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
async function loadNode() {
|
|
734
|
+
const { createRequire } = await import('module');
|
|
734
735
|
const { readFile } = await import('fs/promises');
|
|
735
|
-
const
|
|
736
|
-
const
|
|
737
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
738
|
-
const vendorDir = path.resolve(here, "..", "vendor");
|
|
739
|
-
const wasmPath = path.join(vendorDir, "dig_client_bg.wasm");
|
|
740
|
-
const gluePath = path.join(vendorDir, "dig_client.mjs");
|
|
736
|
+
const require2 = createRequire(import.meta.url);
|
|
737
|
+
const wasmPath = require2.resolve("@dignetwork/dig-client/dig_client_bg.wasm");
|
|
741
738
|
const buf = await readFile(wasmPath);
|
|
742
739
|
const bytes = new Uint8Array(buf.byteLength);
|
|
743
740
|
bytes.set(buf);
|
|
744
|
-
|
|
741
|
+
assertIntegrity(await sha256Hex(bytes));
|
|
742
|
+
const mod = await import('@dignetwork/dig-client/node');
|
|
743
|
+
return mod;
|
|
745
744
|
}
|
|
746
745
|
async function loadBrowser() {
|
|
747
|
-
const glueHref = _config.glueUrl ??
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
746
|
+
const glueHref = _config.glueUrl ?? "@dignetwork/dig-client/web";
|
|
747
|
+
const mod = await import(
|
|
748
|
+
/* @vite-ignore */
|
|
749
|
+
glueHref
|
|
750
|
+
);
|
|
751
|
+
if (typeof mod.default !== "function") {
|
|
752
|
+
throw new DigSdkError(
|
|
753
|
+
"WASM_LOAD_FAILED",
|
|
754
|
+
"dig-client web build exposed no init function (unexpected module shape)",
|
|
755
|
+
{}
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
if (_config.wasmBytes || _config.wasmUrl) {
|
|
759
|
+
let bytes;
|
|
760
|
+
if (_config.wasmBytes) {
|
|
761
|
+
bytes = _config.wasmBytes;
|
|
762
|
+
} else {
|
|
763
|
+
const wasmUrl = _config.wasmUrl;
|
|
764
|
+
const res = await fetch(wasmUrl);
|
|
765
|
+
if (!res.ok)
|
|
766
|
+
throw new DigSdkError("WASM_LOAD_FAILED", `dig-client wasm fetch failed (${res.status})`, {
|
|
767
|
+
httpStatus: res.status,
|
|
768
|
+
wasmUrl
|
|
769
|
+
});
|
|
770
|
+
bytes = await res.arrayBuffer();
|
|
771
|
+
}
|
|
772
|
+
assertIntegrity(await sha256Hex(bytes));
|
|
773
|
+
await mod.default({ module_or_path: bytes });
|
|
751
774
|
} else {
|
|
752
|
-
|
|
753
|
-
const res = await fetch(wasmUrl);
|
|
754
|
-
if (!res.ok)
|
|
755
|
-
throw new DigSdkError("WASM_LOAD_FAILED", `dig-client wasm fetch failed (${res.status})`, {
|
|
756
|
-
httpStatus: res.status,
|
|
757
|
-
wasmUrl
|
|
758
|
-
});
|
|
759
|
-
bytes = await res.arrayBuffer();
|
|
775
|
+
await mod.default();
|
|
760
776
|
}
|
|
761
|
-
return
|
|
777
|
+
return mod;
|
|
762
778
|
}
|
|
763
779
|
function loadDigClientWasm() {
|
|
764
780
|
if (_ready) return _ready;
|
|
765
|
-
_ready = (
|
|
766
|
-
const { glueHref, bytes } = isNode ? await loadNode() : await loadBrowser();
|
|
767
|
-
assertIntegrity(await sha256Hex(bytes));
|
|
768
|
-
const mod = await import(
|
|
769
|
-
/* @vite-ignore */
|
|
770
|
-
glueHref
|
|
771
|
-
);
|
|
772
|
-
await mod.default({ module_or_path: bytes });
|
|
773
|
-
return mod;
|
|
774
|
-
})().catch((e) => {
|
|
781
|
+
_ready = (isNode ? loadNode() : loadBrowser()).catch((e) => {
|
|
775
782
|
_ready = null;
|
|
776
783
|
throw e;
|
|
777
784
|
});
|
|
@@ -1108,7 +1115,7 @@ function undefinedFetch() {
|
|
|
1108
1115
|
}
|
|
1109
1116
|
|
|
1110
1117
|
// src/capabilities.ts
|
|
1111
|
-
var SDK_VERSION = "0.2.
|
|
1118
|
+
var SDK_VERSION = "0.2.1" ;
|
|
1112
1119
|
var MODULES = Object.freeze([
|
|
1113
1120
|
{
|
|
1114
1121
|
name: "ChiaProvider",
|