@unicitylabs/sphere-sdk 0.8.0-dev.4 → 0.8.0-dev.5
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/dist/core/index.cjs +9 -9
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +4 -3
- package/dist/core/index.d.ts +4 -3
- package/dist/core/index.js +9 -9
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +32 -7
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +32 -7
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +30 -8
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +8 -2
- package/dist/impl/nodejs/index.d.ts +8 -2
- package/dist/impl/nodejs/index.js +30 -8
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1465,13 +1465,19 @@ declare abstract class BaseTrustBaseLoader implements TrustBaseLoader {
|
|
|
1465
1465
|
*/
|
|
1466
1466
|
declare class NodeTrustBaseLoader extends BaseTrustBaseLoader {
|
|
1467
1467
|
private filePath?;
|
|
1468
|
-
|
|
1468
|
+
/**
|
|
1469
|
+
* @param filePathOrNetwork - a NetworkType, or a file path to load the trust base from
|
|
1470
|
+
* @param fallbackNetwork - network used for the embedded fallback when a file path is
|
|
1471
|
+
* supplied (and the file is missing/unreadable). Required when filePathOrNetwork is a
|
|
1472
|
+
* path — we must never silently fall back to testnet on a different network.
|
|
1473
|
+
*/
|
|
1474
|
+
constructor(filePathOrNetwork?: string | NetworkType, fallbackNetwork?: NetworkType);
|
|
1469
1475
|
protected loadFromExternal(): Promise<unknown | null>;
|
|
1470
1476
|
}
|
|
1471
1477
|
/**
|
|
1472
1478
|
* Create Node.js TrustBase loader
|
|
1473
1479
|
*/
|
|
1474
|
-
declare function createNodeTrustBaseLoader(filePathOrNetwork?: string | NetworkType): TrustBaseLoader$1;
|
|
1480
|
+
declare function createNodeTrustBaseLoader(filePathOrNetwork?: string | NetworkType, fallbackNetwork?: NetworkType): TrustBaseLoader$1;
|
|
1475
1481
|
/**
|
|
1476
1482
|
* Create UnicityAggregatorProvider with Node.js TrustBase loader
|
|
1477
1483
|
*/
|
|
@@ -1465,13 +1465,19 @@ declare abstract class BaseTrustBaseLoader implements TrustBaseLoader {
|
|
|
1465
1465
|
*/
|
|
1466
1466
|
declare class NodeTrustBaseLoader extends BaseTrustBaseLoader {
|
|
1467
1467
|
private filePath?;
|
|
1468
|
-
|
|
1468
|
+
/**
|
|
1469
|
+
* @param filePathOrNetwork - a NetworkType, or a file path to load the trust base from
|
|
1470
|
+
* @param fallbackNetwork - network used for the embedded fallback when a file path is
|
|
1471
|
+
* supplied (and the file is missing/unreadable). Required when filePathOrNetwork is a
|
|
1472
|
+
* path — we must never silently fall back to testnet on a different network.
|
|
1473
|
+
*/
|
|
1474
|
+
constructor(filePathOrNetwork?: string | NetworkType, fallbackNetwork?: NetworkType);
|
|
1469
1475
|
protected loadFromExternal(): Promise<unknown | null>;
|
|
1470
1476
|
}
|
|
1471
1477
|
/**
|
|
1472
1478
|
* Create Node.js TrustBase loader
|
|
1473
1479
|
*/
|
|
1474
|
-
declare function createNodeTrustBaseLoader(filePathOrNetwork?: string | NetworkType): TrustBaseLoader$1;
|
|
1480
|
+
declare function createNodeTrustBaseLoader(filePathOrNetwork?: string | NetworkType, fallbackNetwork?: NetworkType): TrustBaseLoader$1;
|
|
1475
1481
|
/**
|
|
1476
1482
|
* Create UnicityAggregatorProvider with Node.js TrustBase loader
|
|
1477
1483
|
*/
|
|
@@ -26871,7 +26871,7 @@ function getEmbeddedTrustBase(network) {
|
|
|
26871
26871
|
case "dev":
|
|
26872
26872
|
return TRUSTBASE_DEV;
|
|
26873
26873
|
default:
|
|
26874
|
-
|
|
26874
|
+
throw new SphereError(`getEmbeddedTrustBase: unknown network "${network}"`, "INVALID_CONFIG");
|
|
26875
26875
|
}
|
|
26876
26876
|
}
|
|
26877
26877
|
var BaseTrustBaseLoader = class {
|
|
@@ -26891,11 +26891,23 @@ var BaseTrustBaseLoader = class {
|
|
|
26891
26891
|
// impl/nodejs/oracle/index.ts
|
|
26892
26892
|
var NodeTrustBaseLoader = class extends BaseTrustBaseLoader {
|
|
26893
26893
|
filePath;
|
|
26894
|
-
|
|
26894
|
+
/**
|
|
26895
|
+
* @param filePathOrNetwork - a NetworkType, or a file path to load the trust base from
|
|
26896
|
+
* @param fallbackNetwork - network used for the embedded fallback when a file path is
|
|
26897
|
+
* supplied (and the file is missing/unreadable). Required when filePathOrNetwork is a
|
|
26898
|
+
* path — we must never silently fall back to testnet on a different network.
|
|
26899
|
+
*/
|
|
26900
|
+
constructor(filePathOrNetwork, fallbackNetwork) {
|
|
26895
26901
|
if (!filePathOrNetwork) {
|
|
26896
|
-
|
|
26902
|
+
throw new SphereError("NodeTrustBaseLoader: network or trustBasePath is required.", "INVALID_CONFIG");
|
|
26897
26903
|
} else if (filePathOrNetwork.includes("/") || filePathOrNetwork.includes(".")) {
|
|
26898
|
-
|
|
26904
|
+
if (!fallbackNetwork) {
|
|
26905
|
+
throw new SphereError(
|
|
26906
|
+
"NodeTrustBaseLoader: fallbackNetwork is required when a trustBasePath is supplied.",
|
|
26907
|
+
"INVALID_CONFIG"
|
|
26908
|
+
);
|
|
26909
|
+
}
|
|
26910
|
+
super(fallbackNetwork);
|
|
26899
26911
|
this.filePath = filePathOrNetwork;
|
|
26900
26912
|
} else {
|
|
26901
26913
|
super(filePathOrNetwork);
|
|
@@ -26913,14 +26925,21 @@ var NodeTrustBaseLoader = class extends BaseTrustBaseLoader {
|
|
|
26913
26925
|
return null;
|
|
26914
26926
|
}
|
|
26915
26927
|
};
|
|
26916
|
-
function createNodeTrustBaseLoader(filePathOrNetwork) {
|
|
26917
|
-
return new NodeTrustBaseLoader(filePathOrNetwork);
|
|
26928
|
+
function createNodeTrustBaseLoader(filePathOrNetwork, fallbackNetwork) {
|
|
26929
|
+
return new NodeTrustBaseLoader(filePathOrNetwork, fallbackNetwork);
|
|
26918
26930
|
}
|
|
26919
26931
|
function createUnicityAggregatorProvider(config) {
|
|
26920
26932
|
const { trustBasePath, network, ...restConfig } = config;
|
|
26933
|
+
if (!trustBasePath && !network) {
|
|
26934
|
+
throw new SphereError(
|
|
26935
|
+
"createUnicityAggregatorProvider: network or trustBaseUrl required.",
|
|
26936
|
+
"INVALID_CONFIG"
|
|
26937
|
+
);
|
|
26938
|
+
}
|
|
26921
26939
|
return new UnicityAggregatorProvider({
|
|
26922
26940
|
...restConfig,
|
|
26923
|
-
|
|
26941
|
+
// When a path is supplied, `network` (if any) is the embedded-fallback network.
|
|
26942
|
+
trustBaseLoader: createNodeTrustBaseLoader(trustBasePath ?? network, network)
|
|
26924
26943
|
});
|
|
26925
26944
|
}
|
|
26926
26945
|
var createUnicityOracleProvider = createUnicityAggregatorProvider;
|
|
@@ -29687,7 +29706,10 @@ function createNodeProviders(config) {
|
|
|
29687
29706
|
);
|
|
29688
29707
|
}
|
|
29689
29708
|
}
|
|
29690
|
-
|
|
29709
|
+
if (!config?.network) {
|
|
29710
|
+
throw new SphereError("createNodeProviders: config.network is required.", "INVALID_CONFIG");
|
|
29711
|
+
}
|
|
29712
|
+
const network = config.network;
|
|
29691
29713
|
const globalDebug = config?.debug ?? false;
|
|
29692
29714
|
logger.configure({ debug: globalDebug });
|
|
29693
29715
|
if (config?.transport?.debug) logger.setTagDebug("Nostr", true);
|