@unicitylabs/sphere-sdk 0.7.2 → 0.8.0-dev.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/dist/core/index.cjs +1127 -767
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +3383 -3147
- package/dist/core/index.d.ts +3383 -3147
- package/dist/core/index.js +1115 -755
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +17 -19
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +17 -19
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +17 -19
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +10 -5
- package/dist/impl/nodejs/index.d.ts +10 -5
- package/dist/impl/nodejs/index.js +17 -19
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +1181 -1041
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3906 -3728
- package/dist/index.d.ts +3906 -3728
- package/dist/index.js +1159 -1019
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
|
@@ -200,7 +200,7 @@ interface TransportProvider extends BaseProvider {
|
|
|
200
200
|
resolveNametag?(nametag: string): Promise<string | null>;
|
|
201
201
|
/**
|
|
202
202
|
* Resolve nametag to full peer information
|
|
203
|
-
* Returns transportPubkey, chainPubkey, l1Address, directAddress
|
|
203
|
+
* Returns transportPubkey, chainPubkey, l1Address, directAddress
|
|
204
204
|
*/
|
|
205
205
|
resolveNametagInfo?(nametag: string): Promise<PeerInfo | null>;
|
|
206
206
|
/**
|
|
@@ -523,7 +523,7 @@ type TransportEventCallback = (event: TransportEvent) => void;
|
|
|
523
523
|
/**
|
|
524
524
|
* Resolved peer identity information.
|
|
525
525
|
* Returned by resolve methods — contains all public address formats for a peer.
|
|
526
|
-
*
|
|
526
|
+
* The nametag field is optional (only present if a nametag is registered).
|
|
527
527
|
*/
|
|
528
528
|
interface PeerInfo {
|
|
529
529
|
/** Nametag name (without @), if registered */
|
|
@@ -536,8 +536,6 @@ interface PeerInfo {
|
|
|
536
536
|
l1Address: string;
|
|
537
537
|
/** L3 DIRECT address (DIRECT://...) */
|
|
538
538
|
directAddress: string;
|
|
539
|
-
/** L3 PROXY address derived from nametag hash (PROXY:...), only if nametag registered */
|
|
540
|
-
proxyAddress?: string;
|
|
541
539
|
/** Event timestamp */
|
|
542
540
|
timestamp: number;
|
|
543
541
|
}
|
|
@@ -762,7 +760,6 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
762
760
|
resolveAddressInfo(address: string): Promise<PeerInfo | null>;
|
|
763
761
|
/**
|
|
764
762
|
* Convert a BindingInfo (from nostr-js-sdk) to PeerInfo (sphere-sdk type).
|
|
765
|
-
* Computes PROXY address from nametag if available.
|
|
766
763
|
*/
|
|
767
764
|
private bindingInfoToPeerInfo;
|
|
768
765
|
/**
|
|
@@ -905,8 +902,16 @@ declare class UnicityAggregatorProvider implements OracleProvider {
|
|
|
905
902
|
private aggregatorClient;
|
|
906
903
|
private stateTransitionClient;
|
|
907
904
|
private trustBase;
|
|
905
|
+
/** Raw trust-base JSON as loaded (kept so the v2 token engine can re-parse it). */
|
|
906
|
+
private trustBaseJson;
|
|
908
907
|
/** Get the current trust base */
|
|
909
908
|
getTrustBase(): RootTrustBase | null;
|
|
909
|
+
/** Raw trust-base JSON (for constructing the v2 token engine); null if loaded as an object. */
|
|
910
|
+
getTrustBaseJson(): unknown | null;
|
|
911
|
+
/** The aggregator URL this provider is configured against. */
|
|
912
|
+
getAggregatorUrl(): string;
|
|
913
|
+
/** The gateway API key (for the v2 token engine); undefined when none is configured. */
|
|
914
|
+
getApiKey(): string | undefined;
|
|
910
915
|
/** Get the state transition client */
|
|
911
916
|
getStateTransitionClient(): StateTransitionClient | null;
|
|
912
917
|
/** Get the aggregator client */
|
|
@@ -200,7 +200,7 @@ interface TransportProvider extends BaseProvider {
|
|
|
200
200
|
resolveNametag?(nametag: string): Promise<string | null>;
|
|
201
201
|
/**
|
|
202
202
|
* Resolve nametag to full peer information
|
|
203
|
-
* Returns transportPubkey, chainPubkey, l1Address, directAddress
|
|
203
|
+
* Returns transportPubkey, chainPubkey, l1Address, directAddress
|
|
204
204
|
*/
|
|
205
205
|
resolveNametagInfo?(nametag: string): Promise<PeerInfo | null>;
|
|
206
206
|
/**
|
|
@@ -523,7 +523,7 @@ type TransportEventCallback = (event: TransportEvent) => void;
|
|
|
523
523
|
/**
|
|
524
524
|
* Resolved peer identity information.
|
|
525
525
|
* Returned by resolve methods — contains all public address formats for a peer.
|
|
526
|
-
*
|
|
526
|
+
* The nametag field is optional (only present if a nametag is registered).
|
|
527
527
|
*/
|
|
528
528
|
interface PeerInfo {
|
|
529
529
|
/** Nametag name (without @), if registered */
|
|
@@ -536,8 +536,6 @@ interface PeerInfo {
|
|
|
536
536
|
l1Address: string;
|
|
537
537
|
/** L3 DIRECT address (DIRECT://...) */
|
|
538
538
|
directAddress: string;
|
|
539
|
-
/** L3 PROXY address derived from nametag hash (PROXY:...), only if nametag registered */
|
|
540
|
-
proxyAddress?: string;
|
|
541
539
|
/** Event timestamp */
|
|
542
540
|
timestamp: number;
|
|
543
541
|
}
|
|
@@ -762,7 +760,6 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
762
760
|
resolveAddressInfo(address: string): Promise<PeerInfo | null>;
|
|
763
761
|
/**
|
|
764
762
|
* Convert a BindingInfo (from nostr-js-sdk) to PeerInfo (sphere-sdk type).
|
|
765
|
-
* Computes PROXY address from nametag if available.
|
|
766
763
|
*/
|
|
767
764
|
private bindingInfoToPeerInfo;
|
|
768
765
|
/**
|
|
@@ -905,8 +902,16 @@ declare class UnicityAggregatorProvider implements OracleProvider {
|
|
|
905
902
|
private aggregatorClient;
|
|
906
903
|
private stateTransitionClient;
|
|
907
904
|
private trustBase;
|
|
905
|
+
/** Raw trust-base JSON as loaded (kept so the v2 token engine can re-parse it). */
|
|
906
|
+
private trustBaseJson;
|
|
908
907
|
/** Get the current trust base */
|
|
909
908
|
getTrustBase(): RootTrustBase | null;
|
|
909
|
+
/** Raw trust-base JSON (for constructing the v2 token engine); null if loaded as an object. */
|
|
910
|
+
getTrustBaseJson(): unknown | null;
|
|
911
|
+
/** The aggregator URL this provider is configured against. */
|
|
912
|
+
getAggregatorUrl(): string;
|
|
913
|
+
/** The gateway API key (for the v2 token engine); undefined when none is configured. */
|
|
914
|
+
getApiKey(): string | undefined;
|
|
910
915
|
/** Get the state transition client */
|
|
911
916
|
getStateTransitionClient(): StateTransitionClient | null;
|
|
912
917
|
/** Get the aggregator client */
|
|
@@ -25283,26 +25283,14 @@ var NostrTransportProvider = class _NostrTransportProvider {
|
|
|
25283
25283
|
}
|
|
25284
25284
|
/**
|
|
25285
25285
|
* Convert a BindingInfo (from nostr-js-sdk) to PeerInfo (sphere-sdk type).
|
|
25286
|
-
* Computes PROXY address from nametag if available.
|
|
25287
25286
|
*/
|
|
25288
25287
|
async bindingInfoToPeerInfo(binding, nametag) {
|
|
25289
|
-
const nametagValue = nametag || binding.nametag;
|
|
25290
|
-
let proxyAddress = binding.proxyAddress;
|
|
25291
|
-
if (nametagValue && !proxyAddress) {
|
|
25292
|
-
try {
|
|
25293
|
-
const { ProxyAddress } = await import("@unicitylabs/state-transition-sdk/lib/address/ProxyAddress");
|
|
25294
|
-
const proxyAddr = await ProxyAddress.fromNameTag(nametagValue);
|
|
25295
|
-
proxyAddress = proxyAddr.toString();
|
|
25296
|
-
} catch {
|
|
25297
|
-
}
|
|
25298
|
-
}
|
|
25299
25288
|
return {
|
|
25300
|
-
nametag:
|
|
25289
|
+
nametag: nametag || binding.nametag,
|
|
25301
25290
|
transportPubkey: binding.transportPubkey,
|
|
25302
25291
|
chainPubkey: binding.publicKey || "",
|
|
25303
25292
|
l1Address: binding.l1Address || "",
|
|
25304
25293
|
directAddress: binding.directAddress || "",
|
|
25305
|
-
proxyAddress,
|
|
25306
25294
|
timestamp: binding.timestamp
|
|
25307
25295
|
};
|
|
25308
25296
|
}
|
|
@@ -25328,7 +25316,6 @@ var NostrTransportProvider = class _NostrTransportProvider {
|
|
|
25328
25316
|
chainPubkey: content.public_key || "",
|
|
25329
25317
|
l1Address: content.l1_address || "",
|
|
25330
25318
|
directAddress: content.direct_address || "",
|
|
25331
|
-
proxyAddress: content.proxy_address || void 0,
|
|
25332
25319
|
timestamp: bindingEvent.created_at * 1e3
|
|
25333
25320
|
};
|
|
25334
25321
|
} catch {
|
|
@@ -25371,7 +25358,6 @@ var NostrTransportProvider = class _NostrTransportProvider {
|
|
|
25371
25358
|
chainPubkey: content.public_key || "",
|
|
25372
25359
|
l1Address: content.l1_address || "",
|
|
25373
25360
|
directAddress: content.direct_address || "",
|
|
25374
|
-
proxyAddress: content.proxy_address || void 0,
|
|
25375
25361
|
timestamp: event.created_at * 1e3
|
|
25376
25362
|
});
|
|
25377
25363
|
} catch {
|
|
@@ -25441,8 +25427,6 @@ var NostrTransportProvider = class _NostrTransportProvider {
|
|
|
25441
25427
|
}
|
|
25442
25428
|
const nostrPubkey = this.getNostrPubkey();
|
|
25443
25429
|
if (nametag) {
|
|
25444
|
-
const { ProxyAddress } = await import("@unicitylabs/state-transition-sdk/lib/address/ProxyAddress");
|
|
25445
|
-
const proxyAddr = await ProxyAddress.fromNameTag(nametag);
|
|
25446
25430
|
try {
|
|
25447
25431
|
const success2 = await this.nostrClient.publishNametagBinding(
|
|
25448
25432
|
nametag,
|
|
@@ -25450,8 +25434,7 @@ var NostrTransportProvider = class _NostrTransportProvider {
|
|
|
25450
25434
|
{
|
|
25451
25435
|
publicKey: chainPubkey,
|
|
25452
25436
|
l1Address,
|
|
25453
|
-
directAddress
|
|
25454
|
-
proxyAddress: proxyAddr.toString()
|
|
25437
|
+
directAddress
|
|
25455
25438
|
}
|
|
25456
25439
|
);
|
|
25457
25440
|
if (success2) {
|
|
@@ -26419,10 +26402,24 @@ var UnicityAggregatorProvider = class {
|
|
|
26419
26402
|
aggregatorClient = null;
|
|
26420
26403
|
stateTransitionClient = null;
|
|
26421
26404
|
trustBase = null;
|
|
26405
|
+
/** Raw trust-base JSON as loaded (kept so the v2 token engine can re-parse it). */
|
|
26406
|
+
trustBaseJson = null;
|
|
26422
26407
|
/** Get the current trust base */
|
|
26423
26408
|
getTrustBase() {
|
|
26424
26409
|
return this.trustBase;
|
|
26425
26410
|
}
|
|
26411
|
+
/** Raw trust-base JSON (for constructing the v2 token engine); null if loaded as an object. */
|
|
26412
|
+
getTrustBaseJson() {
|
|
26413
|
+
return this.trustBaseJson;
|
|
26414
|
+
}
|
|
26415
|
+
/** The aggregator URL this provider is configured against. */
|
|
26416
|
+
getAggregatorUrl() {
|
|
26417
|
+
return this.config.url;
|
|
26418
|
+
}
|
|
26419
|
+
/** The gateway API key (for the v2 token engine); undefined when none is configured. */
|
|
26420
|
+
getApiKey() {
|
|
26421
|
+
return this.config.apiKey || void 0;
|
|
26422
|
+
}
|
|
26426
26423
|
/** Get the state transition client */
|
|
26427
26424
|
getStateTransitionClient() {
|
|
26428
26425
|
return this.stateTransitionClient;
|
|
@@ -26479,6 +26476,7 @@ var UnicityAggregatorProvider = class {
|
|
|
26479
26476
|
try {
|
|
26480
26477
|
const trustBaseJson = await this.config.trustBaseLoader.load();
|
|
26481
26478
|
if (trustBaseJson) {
|
|
26479
|
+
this.trustBaseJson = trustBaseJson;
|
|
26482
26480
|
this.trustBase = RootTrustBase.fromJSON(trustBaseJson);
|
|
26483
26481
|
}
|
|
26484
26482
|
} catch (error) {
|