@partylayer/sdk 0.12.1 → 0.13.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/dist/index.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +51 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -340,6 +340,13 @@ declare class PartyLayerClient {
|
|
|
340
340
|
private readonly warmPlans;
|
|
341
341
|
private eventHandlers;
|
|
342
342
|
private activeSession;
|
|
343
|
+
/**
|
|
344
|
+
* True when `activeSession` was revived AS-IS (no live `status()` probe) because
|
|
345
|
+
* its adapter wasn't registered yet at restore time (the lazy configured-announce
|
|
346
|
+
* case). Cleared once a live probe validates it (or on fresh connect). When set,
|
|
347
|
+
* `aggregateAnnouncedWallets` re-probes the session the moment that adapter is born.
|
|
348
|
+
*/
|
|
349
|
+
private activeSessionNeedsProbe;
|
|
343
350
|
readonly registryClient: RegistryClient;
|
|
344
351
|
private logger;
|
|
345
352
|
private crypto;
|
|
@@ -643,6 +650,14 @@ interface AnnounceAdapterConfig {
|
|
|
643
650
|
ledgerApi?: boolean;
|
|
644
651
|
/** Populate the richer `session.metadata` on connect when the provider returns it. */
|
|
645
652
|
metadata?: boolean;
|
|
653
|
+
/**
|
|
654
|
+
* Declarative wallet-specific STATIC metadata (e.g. `{ signingMethod:
|
|
655
|
+
* 'webauthn-prf' }`) — the wagmi connector-property pattern (like rdns/iconUrl).
|
|
656
|
+
* Merged into `session.metadata` ONLY when `metadata` is enabled, and FILLS
|
|
657
|
+
* GAPS: runtime RPC values (from `status`/account) take precedence on a key
|
|
658
|
+
* collision (EIP-6963: the wallet's runtime announce is authoritative).
|
|
659
|
+
*/
|
|
660
|
+
staticMetadata?: Record<string, string>;
|
|
646
661
|
/**
|
|
647
662
|
* Optional error-translation hook. Given first crack at a thrown error: return
|
|
648
663
|
* an `Error` to surface it, or `undefined` to fall through to the SDK's
|
|
@@ -676,6 +691,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
676
691
|
readonly icon?: string;
|
|
677
692
|
private readonly provider;
|
|
678
693
|
private readonly metadataEnabled;
|
|
694
|
+
private readonly staticMetadata?;
|
|
679
695
|
private readonly mapError?;
|
|
680
696
|
restore?: WalletAdapter['restore'];
|
|
681
697
|
on?: WalletAdapter['on'];
|
package/dist/index.d.ts
CHANGED
|
@@ -340,6 +340,13 @@ declare class PartyLayerClient {
|
|
|
340
340
|
private readonly warmPlans;
|
|
341
341
|
private eventHandlers;
|
|
342
342
|
private activeSession;
|
|
343
|
+
/**
|
|
344
|
+
* True when `activeSession` was revived AS-IS (no live `status()` probe) because
|
|
345
|
+
* its adapter wasn't registered yet at restore time (the lazy configured-announce
|
|
346
|
+
* case). Cleared once a live probe validates it (or on fresh connect). When set,
|
|
347
|
+
* `aggregateAnnouncedWallets` re-probes the session the moment that adapter is born.
|
|
348
|
+
*/
|
|
349
|
+
private activeSessionNeedsProbe;
|
|
343
350
|
readonly registryClient: RegistryClient;
|
|
344
351
|
private logger;
|
|
345
352
|
private crypto;
|
|
@@ -643,6 +650,14 @@ interface AnnounceAdapterConfig {
|
|
|
643
650
|
ledgerApi?: boolean;
|
|
644
651
|
/** Populate the richer `session.metadata` on connect when the provider returns it. */
|
|
645
652
|
metadata?: boolean;
|
|
653
|
+
/**
|
|
654
|
+
* Declarative wallet-specific STATIC metadata (e.g. `{ signingMethod:
|
|
655
|
+
* 'webauthn-prf' }`) — the wagmi connector-property pattern (like rdns/iconUrl).
|
|
656
|
+
* Merged into `session.metadata` ONLY when `metadata` is enabled, and FILLS
|
|
657
|
+
* GAPS: runtime RPC values (from `status`/account) take precedence on a key
|
|
658
|
+
* collision (EIP-6963: the wallet's runtime announce is authoritative).
|
|
659
|
+
*/
|
|
660
|
+
staticMetadata?: Record<string, string>;
|
|
646
661
|
/**
|
|
647
662
|
* Optional error-translation hook. Given first crack at a thrown error: return
|
|
648
663
|
* an `Error` to surface it, or `undefined` to fall through to the SDK's
|
|
@@ -676,6 +691,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
676
691
|
readonly icon?: string;
|
|
677
692
|
private readonly provider;
|
|
678
693
|
private readonly metadataEnabled;
|
|
694
|
+
private readonly staticMetadata?;
|
|
679
695
|
private readonly mapError?;
|
|
680
696
|
restore?: WalletAdapter['restore'];
|
|
681
697
|
on?: WalletAdapter['on'];
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var GenericAnnounceAdapter = class {
|
|
|
35
35
|
icon;
|
|
36
36
|
provider;
|
|
37
37
|
metadataEnabled;
|
|
38
|
+
staticMetadata;
|
|
38
39
|
mapError;
|
|
39
40
|
// Optional WalletAdapter surface — assigned in the ctor ONLY when configured,
|
|
40
41
|
// so `getCapabilities()` and `'x' in adapter` feature-detection stay honest.
|
|
@@ -48,6 +49,7 @@ var GenericAnnounceAdapter = class {
|
|
|
48
49
|
this.provider = args.provider;
|
|
49
50
|
const config = args.config;
|
|
50
51
|
this.metadataEnabled = config?.metadata === true;
|
|
52
|
+
this.staticMetadata = config?.staticMetadata;
|
|
51
53
|
this.mapError = config?.mapError;
|
|
52
54
|
if (config?.events) this.on = this.makeOn();
|
|
53
55
|
if (config?.restore) this.restore = this.makeRestore();
|
|
@@ -90,7 +92,7 @@ var GenericAnnounceAdapter = class {
|
|
|
90
92
|
network: reportedNetwork ?? account.networkId ?? ctx.network
|
|
91
93
|
};
|
|
92
94
|
if (this.metadataEnabled) {
|
|
93
|
-
session.metadata = buildMetadata(status, account);
|
|
95
|
+
session.metadata = { ...this.staticMetadata ?? {}, ...buildMetadata(status, account) };
|
|
94
96
|
}
|
|
95
97
|
return { partyId, session, capabilities: this.getCapabilities() };
|
|
96
98
|
});
|
|
@@ -155,7 +157,12 @@ var GenericAnnounceAdapter = class {
|
|
|
155
157
|
return {
|
|
156
158
|
...persisted,
|
|
157
159
|
walletId: this.walletId,
|
|
158
|
-
|
|
160
|
+
// persisted (lowest) → static config → runtime RPC (wins).
|
|
161
|
+
metadata: {
|
|
162
|
+
...persisted.metadata ?? {},
|
|
163
|
+
...this.staticMetadata ?? {},
|
|
164
|
+
...buildMetadata(status, account)
|
|
165
|
+
}
|
|
159
166
|
};
|
|
160
167
|
});
|
|
161
168
|
}
|
|
@@ -709,12 +716,21 @@ var SESSION_STORAGE_KEY = "active_session";
|
|
|
709
716
|
var WALLETS_CHANGED_DEBOUNCE_MS = 50;
|
|
710
717
|
function deriveAnnounceConfig(entry) {
|
|
711
718
|
const cfg = entry.adapter?.config ?? {};
|
|
712
|
-
|
|
719
|
+
const config = {
|
|
713
720
|
events: entry.capabilities?.events === true,
|
|
714
721
|
restore: cfg.restore === true,
|
|
715
722
|
ledgerApi: cfg.ledgerApi === true,
|
|
716
723
|
metadata: cfg.metadata === true
|
|
717
724
|
};
|
|
725
|
+
const sm = cfg.staticMetadata;
|
|
726
|
+
if (sm && typeof sm === "object") {
|
|
727
|
+
const out = {};
|
|
728
|
+
for (const [k, v] of Object.entries(sm)) {
|
|
729
|
+
if (typeof v === "string") out[k] = v;
|
|
730
|
+
}
|
|
731
|
+
if (Object.keys(out).length > 0) config.staticMetadata = out;
|
|
732
|
+
}
|
|
733
|
+
return config;
|
|
718
734
|
}
|
|
719
735
|
var PartyLayerClient = class {
|
|
720
736
|
config;
|
|
@@ -728,6 +744,13 @@ var PartyLayerClient = class {
|
|
|
728
744
|
warmPlans = /* @__PURE__ */ new Map();
|
|
729
745
|
eventHandlers = /* @__PURE__ */ new Map();
|
|
730
746
|
activeSession = null;
|
|
747
|
+
/**
|
|
748
|
+
* True when `activeSession` was revived AS-IS (no live `status()` probe) because
|
|
749
|
+
* its adapter wasn't registered yet at restore time (the lazy configured-announce
|
|
750
|
+
* case). Cleared once a live probe validates it (or on fresh connect). When set,
|
|
751
|
+
* `aggregateAnnouncedWallets` re-probes the session the moment that adapter is born.
|
|
752
|
+
*/
|
|
753
|
+
activeSessionNeedsProbe = false;
|
|
731
754
|
registryClient;
|
|
732
755
|
// Expose for React hooks
|
|
733
756
|
logger;
|
|
@@ -1007,6 +1030,28 @@ var PartyLayerClient = class {
|
|
|
1007
1030
|
config: deriveAnnounceConfig(entry)
|
|
1008
1031
|
});
|
|
1009
1032
|
this.adapters.set(configured.walletId, configured);
|
|
1033
|
+
const active = this.activeSession;
|
|
1034
|
+
if (active && this.activeSessionNeedsProbe && active.walletId === configured.walletId && configured.restore) {
|
|
1035
|
+
try {
|
|
1036
|
+
const reprobed = await configured.restore(this.createAdapterContext(), {
|
|
1037
|
+
...active,
|
|
1038
|
+
encrypted: ""
|
|
1039
|
+
});
|
|
1040
|
+
if (reprobed) {
|
|
1041
|
+
this.activeSession = reprobed;
|
|
1042
|
+
this.activeSessionNeedsProbe = false;
|
|
1043
|
+
await this.persistSession(reprobed);
|
|
1044
|
+
this.emit("session:connected", { type: "session:connected", session: reprobed });
|
|
1045
|
+
} else {
|
|
1046
|
+
await this.removeSession(active.sessionId);
|
|
1047
|
+
this.activeSession = null;
|
|
1048
|
+
this.activeSessionNeedsProbe = false;
|
|
1049
|
+
this.emit("session:expired", { type: "session:expired", sessionId: active.sessionId });
|
|
1050
|
+
}
|
|
1051
|
+
} catch (err) {
|
|
1052
|
+
this.logger.warn("Restore re-probe failed; leaving session as-is", err);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1010
1055
|
}
|
|
1011
1056
|
} catch {
|
|
1012
1057
|
}
|
|
@@ -1233,6 +1278,7 @@ var PartyLayerClient = class {
|
|
|
1233
1278
|
}
|
|
1234
1279
|
await this.persistSession(session);
|
|
1235
1280
|
this.activeSession = session;
|
|
1281
|
+
this.activeSessionNeedsProbe = false;
|
|
1236
1282
|
this.updateRegistryStatus();
|
|
1237
1283
|
this.telemetry?.increment?.(core.METRICS.WALLET_CONNECT_SUCCESS);
|
|
1238
1284
|
this.telemetry?.increment?.(core.METRICS.SESSIONS_CREATED);
|
|
@@ -1623,6 +1669,7 @@ var PartyLayerClient = class {
|
|
|
1623
1669
|
});
|
|
1624
1670
|
if (restored) {
|
|
1625
1671
|
this.activeSession = restored;
|
|
1672
|
+
this.activeSessionNeedsProbe = false;
|
|
1626
1673
|
await this.persistSession(restored);
|
|
1627
1674
|
this.telemetry?.increment?.(core.METRICS.SESSIONS_RESTORED);
|
|
1628
1675
|
this.telemetry?.increment?.(core.METRICS.WALLET_CONNECT_SUCCESS);
|
|
@@ -1641,6 +1688,7 @@ var PartyLayerClient = class {
|
|
|
1641
1688
|
}
|
|
1642
1689
|
}
|
|
1643
1690
|
this.activeSession = session;
|
|
1691
|
+
this.activeSessionNeedsProbe = true;
|
|
1644
1692
|
return session;
|
|
1645
1693
|
} catch (err) {
|
|
1646
1694
|
this.logger.warn("Failed to restore session", err);
|